From 4b581016757f32763b6dcdac4407e524b4debdd5 Mon Sep 17 00:00:00 2001 From: AlphaMode Date: Sun, 6 Nov 2022 22:49:37 -0600 Subject: [PATCH 001/156] 1.19 --- common/build.gradle | 5 +++ .../mod/mixin/client/MixinMinecraft.java | 6 +-- .../MixinClientPacketListener.java | 15 ++++--- .../mixin/client/world/MixinClientLevel.java | 13 +++--- .../mod/mixin/entity/MixinEntity.java | 4 +- .../feature/entity_collision/MixinEntity.java | 4 +- .../LavaFluidMixin.java | 4 +- .../client/MixinSimpleSoundInstance.java | 3 +- .../MixinLevelRendererVanilla.java | 9 +---- .../mod/mixin/server/MixinPlayerList.java | 12 +++--- .../mixin/server/command/MixinCommands.java | 5 ++- .../MixinServerGamePacketListenerImpl.java | 5 +-- .../network/MixinServerPlayerGameMode.java | 24 +++++------ .../world/MixinChunkMap$TrackedEntity.java | 9 ++--- .../mod/mixin/server/world/MixinChunkMap.java | 40 ++++++++++--------- .../client/audio/SimpleSoundInstanceOnShip.kt | 16 +++++--- .../mod/common/item/ShipAssemblerItem.kt | 7 ++-- .../mod/common/item/ShipCreatorItem.kt | 7 ++-- .../mod/compat/clothconfig/VSClothConfig.kt | 15 +++---- fabric/build.gradle | 4 +- .../mixin/world/level/block/FireMixin.java | 13 +++--- fabric/src/main/resources/fabric.mod.json | 4 +- .../mixin/world/level/block/FireMixin.java | 15 +++---- gradle.properties | 14 ++++--- quilt/build.gradle | 4 +- .../mixin/world/level/block/FireMixin.java | 13 +++--- quilt/src/main/resources/quilt.mod.json | 4 +- 27 files changed, 144 insertions(+), 130 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index ddd935ae2..c43a73967 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -28,6 +28,11 @@ loom { accessWidenerPath = file("src/main/resources/valkyrienskies-common.accesswidener") } +tasks.withType(JavaCompile).configureEach { + // Minecraft 1.18 (1.18-pre2) upwards uses Java 17. + it.options.release = 17 +} + jar { // Exclude dummy Optifine classes exclude "net/optifine/**" diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java index f6e09577e..bab7389e2 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java @@ -62,15 +62,15 @@ public abstract class MixinMinecraft @Redirect( at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;useItemOn(Lnet/minecraft/client/player/LocalPlayer;Lnet/minecraft/client/multiplayer/ClientLevel;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;" + target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;useItemOn(Lnet/minecraft/client/player/LocalPlayer;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;" ), method = "startUseItem" ) private InteractionResult useOriginalCrosshairForBlockPlacement(final MultiPlayerGameMode instance, - final LocalPlayer localPlayer, final ClientLevel clientLevel, final InteractionHand interactionHand, + final LocalPlayer localPlayer, final InteractionHand interactionHand, final BlockHitResult blockHitResult) { - return instance.useItemOn(localPlayer, clientLevel, interactionHand, + return instance.useItemOn(localPlayer, interactionHand, (BlockHitResult) this.originalCrosshairTarget); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java index 21b3249ca..920e336f9 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java @@ -4,7 +4,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientPacketListener; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.game.ClientboundAddEntityPacket; import net.minecraft.network.protocol.game.ClientboundLoginPacket; import net.minecraft.world.entity.Entity; @@ -25,10 +25,9 @@ public class MixinClientPacketListener { @Inject(method = "handleLogin", at = @At("TAIL")) public void afterLogin(final ClientboundLoginPacket packet, final CallbackInfo ci) { - Minecraft.getInstance().player.sendMessage( - new TextComponent("You are using an ALPHA version of Valkyrien Skies 2, use at your own risk!").withStyle( - ChatFormatting.RED, ChatFormatting.BOLD), - null); + Minecraft.getInstance().player.sendSystemMessage( + Component.literal("You are using an ALPHA version of Valkyrien Skies 2, use at your own risk!").withStyle( + ChatFormatting.RED, ChatFormatting.BOLD)); } @Inject( @@ -58,10 +57,10 @@ private void handleShipMountingEntity(final ClientboundAddEntityPacket packet, f final double f = packet.getZ(); final Entity entity = ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE.create(level); final int i = packet.getId(); - entity.setPacketCoordinates(d, e, f); + entity.syncPacketPositionCodec(d, e, f); entity.moveTo(d, e, f); - entity.setXRot((float) (packet.getxRot() * 360) / 256.0f); - entity.setYRot((float) (packet.getyRot() * 360) / 256.0f); + entity.setXRot((packet.getXRot() * 360) / 256.0f); + entity.setYRot((packet.getYRot() * 360) / 256.0f); entity.setId(i); entity.setUUID(packet.getUUID()); this.level.putNonPlayerEntity(i, entity); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientLevel.java index 8b50bad39..7893adf08 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientLevel.java @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.mixin.client.world; -import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.resources.sounds.SimpleSoundInstance; @@ -11,6 +10,7 @@ import net.minecraft.core.particles.ParticleTypes; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; +import net.minecraft.util.RandomSource; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Blocks; @@ -41,7 +41,7 @@ @Mixin(ClientLevel.class) public abstract class MixinClientLevel implements IShipObjectWorldClientProvider { @Unique - private final Random vsRandom = new Random(); + private final RandomSource vsRandom = RandomSource.create(); @Shadow @Final @@ -187,17 +187,18 @@ private void animateTickVS( value = "NEW", target = "net/minecraft/client/resources/sounds/SimpleSoundInstance" ), - method = "playLocalSound(DDDLnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FFZ)V" + method = "playSound(DDDLnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FFZJ)V" ) private SimpleSoundInstance redirectNewSoundInstance(final SoundEvent soundEvent, final SoundSource soundSource, - final float volume, final float pitch, final double x, final double y, final double z) { + final float volume, final float pitch, final RandomSource randomSource, final double x, final double y, + final double z) { final Ship ship = VSGameUtilsKt.getShipManagingPos(ClientLevel.class.cast(this), x, y, z); if (ship != null) { - return new SimpleSoundInstanceOnShip(soundEvent, soundSource, volume, pitch, x, y, z, + return new SimpleSoundInstanceOnShip(soundEvent, soundSource, volume, pitch, randomSource, x, y, z, ship); } - return new SimpleSoundInstance(soundEvent, soundSource, volume, pitch, x, y, z); + return new SimpleSoundInstance(soundEvent, soundSource, volume, pitch, randomSource, x, y, z); } } 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 a5e1d892a..7c8e4a11a 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 @@ -2,12 +2,12 @@ import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; -import java.util.Random; import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; import net.minecraft.ReportedException; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; +import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.level.ClipContext; @@ -212,7 +212,7 @@ public void positionRider(final Entity instance, final Entity passengerI, final @Shadow @Final - protected Random random; + protected RandomSource random; @Shadow public abstract float getEyeHeight(); 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 6eae3c0e0..cef4699ee 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 @@ -1,9 +1,9 @@ package org.valkyrienskies.mod.mixin.feature.entity_collision; -import java.util.Random; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.MoverType; @@ -245,7 +245,7 @@ private void preSpawnSprintParticle(final CallbackInfo ci) { @Shadow @Final - protected Random random; + protected RandomSource random; @Shadow private EntityDimensions dimensions; 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 b77ae5300..212503680 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 @@ -1,7 +1,7 @@ package org.valkyrienskies.mod.mixin.feature.fire_between_ship_and_world; -import java.util.Random; import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.FlowingFluid; import net.minecraft.world.level.material.FluidState; @@ -19,7 +19,7 @@ public abstract class LavaFluidMixin extends FlowingFluid { private boolean isModifyingFireTick = false; @Inject(method = "randomTick", at = @At("TAIL")) - public void fireTickMixin(final Level level, final BlockPos pos, final FluidState state, final Random random, + public void fireTickMixin(final Level level, final BlockPos pos, final FluidState state, final RandomSource random, final CallbackInfo ci) { if (isModifyingFireTick) { return; diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java index 39a276409..b109b72bc 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java @@ -27,7 +27,8 @@ private static void forRecord(final SoundEvent sound, final double x, final doub final Ship ship = VSGameUtilsKt.getShipManagingPos(Minecraft.getInstance().level, x, y, z); if (ship != null) { cir.setReturnValue(new SimpleSoundInstanceOnShip( - sound, SoundSource.RECORDS, 4.0F, 1.0F, false, 0, SoundInstance.Attenuation.LINEAR, x, y, z, ship)); + sound, SoundSource.RECORDS, 4.0F, 1.0F, SoundInstance.createUnseededRandom(), false, 0, + SoundInstance.Attenuation.LINEAR, x, y, z, ship)); } } 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 30c9775b2..7b0401e8c 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 @@ -244,7 +244,6 @@ private void renderChunkLayerVanilla( RenderSystem.setupShaderLights(shaderInstance); shaderInstance.apply(); final Uniform uniform = shaderInstance.CHUNK_OFFSET; - boolean bl2 = false; while (bl ? objectListIterator.hasNext() : objectListIterator.hasPrevious()) { final RenderChunkInfo renderChunkInfo2 = bl ? (RenderChunkInfo) objectListIterator.next() : (RenderChunkInfo) objectListIterator.previous(); @@ -262,18 +261,14 @@ private void renderChunkLayerVanilla( (float) ((double) blockPos.getZ() - center.z())); uniform.upload(); } - vertexBuffer.drawChunkLayer(); - bl2 = true; + vertexBuffer.bind(); + vertexBuffer.draw(); } if (uniform != null) { uniform.set(Vector3f.ZERO); } shaderInstance.clear(); - if (bl2) { - vertexFormat.clearBufferState(); - } VertexBuffer.unbind(); - VertexBuffer.unbindVertexArray(); this.minecraft.getProfiler().pop(); renderType.clearRenderState(); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinPlayerList.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinPlayerList.java index af59c186a..fe62e56ee 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinPlayerList.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinPlayerList.java @@ -3,7 +3,7 @@ import java.util.List; import net.minecraft.ChatFormatting; import net.minecraft.network.Connection; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; @@ -47,11 +47,11 @@ public abstract void broadcast(@Nullable Player player, double x, double y, doub private void afterPlayerJoin(final Connection netManager, final ServerPlayer player, final CallbackInfo ci) { VSCoreHooksKt.getCoreHooks().afterClientJoinServer(VSGameUtilsKt.getPlayerWrapper(player)); if (!KrunchSupport.INSTANCE.isKrunchSupported()) { - player.sendMessage( - new TextComponent( - "VS 2 physics are disabled on this server, because Krunch is not supported on this server! Currently only x86-64 Windows and Linux platforms are supported.").withStyle( - ChatFormatting.RED, ChatFormatting.BOLD), - null); + player.sendSystemMessage( + Component.literal( + "VS 2 physics are disabled on this server, because Krunch is not supported on this server! Currently only x86-64 Windows and Linux platforms are supported.") + .withStyle( + ChatFormatting.RED, ChatFormatting.BOLD)); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java index 167d70f97..720e37cb4 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java @@ -1,8 +1,10 @@ package org.valkyrienskies.mod.mixin.server.command; import com.mojang.brigadier.CommandDispatcher; +import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; +import net.minecraft.commands.Commands.CommandSelection; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -21,7 +23,8 @@ public class MixinCommands { at = @At("TAIL"), method = "" ) - public void onInit(final Commands.CommandSelection registrationEnvironment, final CallbackInfo ci) { + public void onInit( + final CommandSelection commandSelection, final CommandBuildContext commandBuildContext, final CallbackInfo ci) { } } 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 bcab5ad17..d4a772cd9 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 @@ -11,7 +11,6 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; import net.minecraft.server.network.ServerGamePacketListenerImpl; -import net.minecraft.world.level.ChunkPos; import net.minecraft.world.phys.Vec3; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Final; @@ -65,11 +64,11 @@ private Vec3 skipDistanceCheck2(final Vec3 instance, final Vec3 vec3) { @Redirect( at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/level/ChunkPos;getChessboardDistance(Lnet/minecraft/world/level/ChunkPos;)I" + target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" ), method = "handleUseItemOn" ) - private int skipDistanceCheck1(final ChunkPos instance, final ChunkPos chunkPos) { + private double skipDistanceCheck1(final Vec3 instance, final Vec3 vec3) { return 0; } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java index 1b8d1017b..6f350f158 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java @@ -1,16 +1,16 @@ package org.valkyrienskies.mod.mixin.server.network; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; +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.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.config.VSGameConfig; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @@ -18,29 +18,29 @@ @Mixin(ServerPlayerGameMode.class) public class MixinServerPlayerGameMode { + @Final @Shadow - public ServerPlayer player; + protected ServerPlayer player; @Shadow - public ServerLevel level; + protected ServerLevel level; /** * Includes ships in server-side distance check when player breaks a block. */ - @ModifyVariable( + @Redirect( method = "handleBlockBreakAction", - at = @At("STORE"), - index = 11 + at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D") ) - public double handleBlockBreakAction(final double g, final BlockPos pos, - final ServerboundPlayerActionPacket.Action action, - final Direction direction, final int worldHeight) { + public double handleBlockBreakAction(final Vec3 instance, final Vec3 vec3) { + final BlockPos pos = new BlockPos(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) .distanceSquared(player.getX(), player.getY() + 1.5, player.getZ()); } else { - return 0; + return instance.distanceToSqr(vec3); } } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java index 947ddeb42..dc0694f16 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java @@ -1,7 +1,6 @@ package org.valkyrienskies.mod.mixin.server.world; import net.minecraft.server.level.ChunkMap; -import net.minecraft.server.level.ServerEntity; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.phys.Vec3; @@ -28,15 +27,15 @@ public class MixinChunkMap$TrackedEntity { // Changes entity position for tracking into world space if needed @Redirect(method = "updatePlayer", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ServerEntity;sentPos()Lnet/minecraft/world/phys/Vec3;")) - Vec3 includeShips(final ServerEntity instance) { - final Vector3d pos = VectorConversionsMCKt.toJOML(instance.sentPos()); + target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;")) + Vec3 includeShips(final Entity instance) { + final Vector3d pos = VectorConversionsMCKt.toJOML(instance.position()); final Ship ship = inCallShip = VSGameUtilsKt.getShipObjectManagingPos(this.entity.level, pos); if (ship != null) { return VectorConversionsMCKt.toMinecraft(ship.getShipTransform() .getShipToWorldMatrix().transformPosition(pos)); } else { - return instance.sentPos(); + return instance.position(); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java index edc70fdaa..04b861587 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java @@ -7,7 +7,9 @@ import java.util.List; import java.util.Optional; import java.util.Set; +import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; +import net.minecraft.Util; import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ChunkMap; @@ -41,6 +43,9 @@ public abstract class MixinChunkMap { @Final private Supplier overworldDataStorage; + @Shadow + protected abstract CompoundTag upgradeChunkTag(CompoundTag compoundTag); + /** * Force the game to generate empty chunks in the shipyard. * @@ -50,26 +55,25 @@ public abstract class MixinChunkMap { * @author Tri0de */ @Inject(method = "readChunk", at = @At("HEAD"), cancellable = true) - private void preReadChunk(final ChunkPos chunkPos, final CallbackInfoReturnable cir) + private void preReadChunk(final ChunkPos chunkPos, + final CallbackInfoReturnable>> cir) throws IOException { final ChunkMap self = ChunkMap.class.cast(this); - final CompoundTag compoundTag = self.read(chunkPos); - final CompoundTag originalToReturn = compoundTag == null ? null : - self.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, compoundTag, Optional.empty()); - - if (originalToReturn == null) { - if (ChunkAllocator.isChunkInShipyard(chunkPos.x, chunkPos.z)) { - // The chunk doesn't yet exist and is in the shipyard. Make a new empty chunk - // Generate the chunk to be nothing - final LevelChunk generatedChunk = new LevelChunk(level, - new ProtoChunk(chunkPos, UpgradeData.EMPTY, level, - level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null), null); - // Its wasteful to serialize just for this to be deserialized, but it will work for now. - cir.setReturnValue(ChunkSerializer.write(level, generatedChunk)); + cir.setReturnValue(self.read(chunkPos).thenApplyAsync(compoundTag -> { + if (compoundTag.isEmpty()) { + if (ChunkAllocator.isChunkInShipyard(chunkPos.x, chunkPos.z)) { + // The chunk doesn't yet exist and is in the shipyard. Make a new empty chunk + // Generate the chunk to be nothing + final LevelChunk generatedChunk = new LevelChunk(level, + new ProtoChunk(chunkPos, UpgradeData.EMPTY, level, + level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null), null); + // Its wasteful to serialize just for this to be deserialized, but it will work for now. + return Optional.of(ChunkSerializer.write(level, generatedChunk)); + } } - } else { - cir.setReturnValue(originalToReturn); - } + return compoundTag.map(this::upgradeChunkTag); + }, Util.backgroundExecutor())); + } /** @@ -103,7 +107,7 @@ private void postGetPlayersWatchingChunk(final ChunkPos chunkPos, final boolean } } ); - + cir.setReturnValue(new ArrayList<>(watchingPlayers)); } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/client/audio/SimpleSoundInstanceOnShip.kt b/common/src/main/kotlin/org/valkyrienskies/mod/client/audio/SimpleSoundInstanceOnShip.kt index 0c1c2ac5a..10c69f46e 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/client/audio/SimpleSoundInstanceOnShip.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/client/audio/SimpleSoundInstanceOnShip.kt @@ -6,6 +6,7 @@ import net.minecraft.client.resources.sounds.SoundInstance.Attenuation.LINEAR import net.minecraft.resources.ResourceLocation import net.minecraft.sounds.SoundEvent import net.minecraft.sounds.SoundSource +import net.minecraft.util.RandomSource import org.joml.Vector3d import org.joml.Vector3dc import org.valkyrienskies.core.api.Ship @@ -19,6 +20,7 @@ class SimpleSoundInstanceOnShip : SimpleSoundInstance, VelocityTickableSoundInst soundSource: SoundSource, volume: Float, pitch: Float, + random: RandomSource, looping: Boolean, delay: Int, attenuation: Attenuation, @@ -27,19 +29,21 @@ class SimpleSoundInstanceOnShip : SimpleSoundInstance, VelocityTickableSoundInst z: Double, relative: Boolean, ship: Ship - ) : super(resourceLocation, soundSource, volume, pitch, looping, delay, attenuation, x, y, z, relative) { + ) : super(resourceLocation, soundSource, volume, pitch, random, looping, delay, attenuation, x, y, z, relative) { this.ship = ship } constructor( - soundEvent: SoundEvent, soundSource: SoundSource, f: Float, g: Float, bl: Boolean, i: Int, - attenuation: Attenuation, d: Double, e: Double, h: Double, ship: Ship - ) : this(soundEvent.location, soundSource, f, g, bl, i, attenuation, d, e, h, false, ship) + soundEvent: SoundEvent, soundSource: SoundSource, volume: Float, pitch: Float, random: RandomSource, + looping: Boolean, delay: Int, + attenuation: Attenuation, x: Double, y: Double, z: Double, ship: Ship + ) : this(soundEvent.location, soundSource, volume, pitch, random, looping, delay, attenuation, x, y, z, false, ship) constructor( - soundEvent: SoundEvent, soundSource: SoundSource, f: Float, g: Float, d: Double, e: Double, h: Double, + soundEvent: SoundEvent, soundSource: SoundSource, volume: Float, pitch: Float, random: RandomSource, x: Double, + y: Double, z: Double, ship: Ship - ) : this(soundEvent, soundSource, f, g, false, 0, LINEAR, d, e, h, ship) + ) : this(soundEvent, soundSource, volume, pitch, random, false, 0, LINEAR, x, y, z, ship) private val originalPos = Vector3d(x, y, z) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipAssemblerItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipAssemblerItem.kt index c1f3ceb18..90cc2968b 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipAssemblerItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipAssemblerItem.kt @@ -1,7 +1,6 @@ package org.valkyrienskies.mod.common.item -import net.minecraft.Util -import net.minecraft.network.chat.TextComponent +import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.InteractionResult import net.minecraft.world.item.Item @@ -21,7 +20,7 @@ class ShipAssemblerItem(properties: Properties) : Item(properties) { if (!level.isClientSide) { if (ChunkAllocator.isChunkInShipyard(pos.x shr 4, pos.z shr 4)) { - ctx.player?.sendMessage(TextComponent("That chunk is already part of a ship!"), Util.NIL_UUID) + ctx.player?.sendSystemMessage(Component.literal("That chunk is already part of a ship!")) } else if (!blockState.isAir) { // Make a ship val dimensionId = level.dimensionId @@ -34,7 +33,7 @@ class ShipAssemblerItem(properties: Properties) : Item(properties) { val shipData = createNewShipWithBlocks(pos, set, level) - ctx.player?.sendMessage(TextComponent("SHIPIFIED!"), Util.NIL_UUID) + ctx.player?.sendSystemMessage(Component.literal("SHIPIFIED!")) } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt index 787f6f4e5..46d87528f 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt @@ -1,8 +1,7 @@ package org.valkyrienskies.mod.common.item -import net.minecraft.Util import net.minecraft.core.Direction.NORTH -import net.minecraft.network.chat.TextComponent +import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.InteractionResult import net.minecraft.world.item.Item @@ -29,7 +28,7 @@ class ShipCreatorItem(properties: Properties, private val scale: Double) : Item( if (!level.isClientSide) { if (ChunkAllocator.isChunkInShipyard(blockPos.x shr 4, blockPos.z shr 4)) { - ctx.player?.sendMessage(TextComponent("That chunk is already part of a ship!"), Util.NIL_UUID) + ctx.player?.sendSystemMessage(Component.literal("That chunk is already part of a ship!")) } else if (!blockState.isAir) { // Make a ship val dimensionId = level.dimensionId @@ -40,7 +39,7 @@ class ShipCreatorItem(properties: Properties, private val scale: Double) : Item( // Move the block from the world to a ship level.relocateBlock(blockPos, centerPos, shipData, NORTH) - ctx.player?.sendMessage(TextComponent("SHIPIFIED!"), Util.NIL_UUID) + ctx.player?.sendSystemMessage(Component.literal("SHIPIFIED!")) } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt index 3287c777a..0ac8353de 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt @@ -14,7 +14,6 @@ import net.minecraft.ChatFormatting.GRAY import net.minecraft.ChatFormatting.ITALIC import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import net.minecraft.network.chat.TextComponent import org.valkyrienskies.core.config.SidedVSConfigClass import org.valkyrienskies.core.config.VSConfigClass import org.valkyrienskies.core.util.serialization.VSJacksonUtil @@ -31,7 +30,7 @@ object VSClothConfig { configClasses.forEach { configClass -> configClass.sides.forEach { side -> val name = if (configClasses.size == 1) side.sideName else "${configClass.name} - ${side.sideName}" - addEntriesForConfig(getOrCreateCategory(TextComponent(name)), ::entryBuilder, side) + addEntriesForConfig(getOrCreateCategory(Component.literal(name)), ::entryBuilder, side) } } savingRunnable = Runnable { @@ -83,12 +82,12 @@ object VSClothConfig { val description: String? = schema["description"]?.asText() val title: String = schema["title"]?.asText(null) ?: key.splitCamelCaseAndCapitalize() - val titleComponent = TextComponent(title) + val titleComponent = Component.literal(title) fun getValidationMessageComponent(value: JsonNode): Optional { val errors = validate(value) return if (errors.isNotEmpty()) { - Optional.of(TextComponent(errors.joinToString())) + Optional.of(Component.literal(errors.joinToString())) } else { Optional.empty() } @@ -105,7 +104,7 @@ object VSClothConfig { val enum: ArrayNode? = schema["enum"] as? ArrayNode val type = schema["type"].asText() - val tooltip: TextComponent? = null + val tooltip: Component? = null when { type == "integer" -> { @@ -237,7 +236,7 @@ object VSClothConfig { val newValue = try { mapper.readTree(str) } catch (ex: JsonProcessingException) { - return@setErrorSupplier Optional.of(TextComponent(ex.message)) + return@setErrorSupplier Optional.of(Component.literal(ex.message)) } getValidationMessageComponent(newValue) @@ -248,7 +247,9 @@ object VSClothConfig { } if (description != null) { - entries.add(entryBuilder().startTextDescription(TextComponent(description).withStyle(GRAY, ITALIC)).build()) + entries.add( + entryBuilder().startTextDescription(Component.literal(description).withStyle(GRAY, ITALIC)).build() + ) } return entries diff --git a/fabric/build.gradle b/fabric/build.gradle index c27929fb5..dd8a2c1c8 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -47,11 +47,11 @@ dependencies { // Depend on the fabric kotlin mod modImplementation("net.fabricmc:fabric-language-kotlin:1.8.5+kotlin.1.7.20") - modImplementation("com.terraformersmc:modmenu:3.2.3") + modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}") // Depend on the fabric API modImplementation("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}") - modImplementation("me.shedaniel.cloth:cloth-config-fabric:6.3.81") + modImplementation("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") implementation("org.valkyrienskies.core:vs-core:${rootProject.vs_core_version}") { 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 65750f0f0..60d5ca5ee 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 @@ -1,8 +1,8 @@ package org.valkyrienskies.mod.fabric.mixin.world.level.block; -import java.util.Random; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; @@ -32,7 +32,8 @@ public abstract class FireMixin { public static IntegerProperty AGE; @Inject(method = "tick", at = @At("TAIL")) - public void fireTickMixin(final BlockState state, final ServerLevel level, final BlockPos pos, final Random random, + public void fireTickMixin(final BlockState state, final ServerLevel level, final BlockPos pos, + final RandomSource random, final CallbackInfo ci) { if (isModifyingFireTick) { return; @@ -74,7 +75,7 @@ public void fireTickMixin(final BlockState state, final ServerLevel level, final } mutableBlockPos.setWithOffset(newPos, l, n, m); - final int p = this.getFireOdds(level, mutableBlockPos); + final int p = this.getIgniteOdds(level, mutableBlockPos); if (p > 0) { int q = (p + 40 + level.getDifficulty().getId() * 7) / (i + 30); if (bl2) { @@ -115,7 +116,7 @@ public void onPlaceMixin(final BlockState state, final Level level, final BlockP } @Shadow - private void checkBurnOut(final Level level, final BlockPos pos, final int chance, final Random random, + private void checkBurnOut(final Level level, final BlockPos pos, final int chance, final RandomSource random, final int age) { } @@ -125,8 +126,8 @@ protected boolean isNearRain(final Level level, final BlockPos pos) { } @Shadow - private int getFireOdds(final LevelReader level, final BlockPos pos) { - return getFireOdds(level, pos); + private int getIgniteOdds(final LevelReader level, final BlockPos pos) { + return getIgniteOdds(level, pos); } @Shadow diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 68d38d0fe..79cb3d4ed 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -29,8 +29,8 @@ ], "accessWidener": "valkyrienskies-common.accesswidener", "depends": { - "fabricloader": ">=0.7.4", - "minecraft": ">=1.16.5" + "fabricloader": ">=0.14.9", + "minecraft": ">=1.19.2" }, "breaks": { } 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 aa27daafd..9dab46c50 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 @@ -1,9 +1,9 @@ package org.valkyrienskies.mod.forge.mixin.world.level.block; -import java.util.Random; 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.LevelReader; @@ -29,7 +29,8 @@ public class FireMixin { public static IntegerProperty AGE; @Inject(method = "tick", at = @At("TAIL")) - public void fireTickMixin(final BlockState state, final ServerLevel level, final BlockPos pos, final Random random, + public void fireTickMixin(final BlockState state, final ServerLevel level, final BlockPos pos, + final RandomSource random, final CallbackInfo ci) { if (isModifyingFireTick) { return; @@ -71,7 +72,7 @@ public void fireTickMixin(final BlockState state, final ServerLevel level, final } mutableBlockPos.setWithOffset(newPos, l, n, m); - final int p = this.getFireOdds(level, mutableBlockPos); + final int p = this.getIgniteOdds(level, mutableBlockPos); if (p > 0) { int q = (p + 40 + level.getDifficulty().getId() * 7) / (i + 30); if (bl2) { @@ -110,9 +111,9 @@ public void onPlaceMixin(final BlockState state, final Level level, final BlockP } }); } - + @Shadow - private void tryCatchFire(final Level arg, final BlockPos arg2, final int k, final Random random, final int l, + private void tryCatchFire(final Level arg, final BlockPos arg2, final int k, final RandomSource random, final int l, final Direction face) { } @@ -122,8 +123,8 @@ protected boolean isNearRain(final Level level, final BlockPos pos) { } @Shadow - private int getFireOdds(final LevelReader level, final BlockPos pos) { - return getFireOdds(level, pos); + private int getIgniteOdds(final LevelReader level, final BlockPos pos) { + return getIgniteOdds(level, pos); } @Shadow diff --git a/gradle.properties b/gradle.properties index 41c32e8ca..dc0610465 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,17 @@ org.gradle.jvmargs=-Xmx4096M -minecraft_version=1.18.2 +minecraft_version=1.19.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 mod_version=2.0.0-alpha4 maven_group=org.valkyrienskies.mod -architectury_version=4.10.86 +architectury_version=6.3.49 fabric_loader_version=0.14.10 -fabric_api_version=0.59.0+1.18.2 -forge_version=1.18.2-40.1.84 -quilt_loader_version=0.17.2-beta.3 -quilt_fabric_api_version=1.0.0-beta.23+0.58.0-1.18.2 +fabric_api_version=0.64.0+1.19.2 +forge_version=1.19.2-43.1.47 +quilt_loader_version=0.17.6 +quilt_fabric_api_version=4.0.0-beta.19+0.64.0-1.19.2 +cloth_config_version=8.2.88 +modmenu_version=4.1.0 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually kotlin.stdlib.default.dependency=false diff --git a/quilt/build.gradle b/quilt/build.gradle index 7bcf255bd..9a87cf810 100644 --- a/quilt/build.gradle +++ b/quilt/build.gradle @@ -48,13 +48,13 @@ dependencies { common(project(path: ":common", configuration: "namedElements")) { transitive false } shadowCommon(project(path: ":common", configuration: "transformProductionQuilt")) { transitive false } - modImplementation("com.terraformersmc:modmenu:3.2.3") { + modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" } // Depend on the fabric API - modImplementation("me.shedaniel.cloth:cloth-config-fabric:6.3.81") { + modImplementation("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") { exclude group: "net.fabricmc" exclude group: "net.fabricmc.fabric-api" } diff --git a/quilt/src/main/java/org/valkyrienskies/mod/quilt/mixin/world/level/block/FireMixin.java b/quilt/src/main/java/org/valkyrienskies/mod/quilt/mixin/world/level/block/FireMixin.java index 363ca690f..cde5f6ec5 100644 --- a/quilt/src/main/java/org/valkyrienskies/mod/quilt/mixin/world/level/block/FireMixin.java +++ b/quilt/src/main/java/org/valkyrienskies/mod/quilt/mixin/world/level/block/FireMixin.java @@ -1,8 +1,8 @@ package org.valkyrienskies.mod.quilt.mixin.world.level.block; -import java.util.Random; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; @@ -32,7 +32,8 @@ public abstract class FireMixin { public static IntegerProperty AGE; @Inject(method = "tick", at = @At("TAIL")) - public void fireTickMixin(final BlockState state, final ServerLevel level, final BlockPos pos, final Random random, + public void fireTickMixin(final BlockState state, final ServerLevel level, final BlockPos pos, + final RandomSource random, final CallbackInfo ci) { if (isModifyingFireTick) { return; @@ -74,7 +75,7 @@ public void fireTickMixin(final BlockState state, final ServerLevel level, final } mutableBlockPos.setWithOffset(newPos, l, n, m); - final int p = this.getFireOdds(level, mutableBlockPos); + final int p = this.getIgniteOdds(level, mutableBlockPos); if (p > 0) { int q = (p + 40 + level.getDifficulty().getId() * 7) / (i + 30); if (bl2) { @@ -115,7 +116,7 @@ public void onPlaceMixin(final BlockState state, final Level level, final BlockP } @Shadow - private void checkBurnOut(final Level level, final BlockPos pos, final int chance, final Random random, + private void checkBurnOut(final Level level, final BlockPos pos, final int chance, final RandomSource random, final int age) { } @@ -125,8 +126,8 @@ protected boolean isNearRain(final Level level, final BlockPos pos) { } @Shadow - private int getFireOdds(final LevelReader level, final BlockPos pos) { - return getFireOdds(level, pos); + private int getIgniteOdds(final LevelReader level, final BlockPos pos) { + return getIgniteOdds(level, pos); } @Shadow diff --git a/quilt/src/main/resources/quilt.mod.json b/quilt/src/main/resources/quilt.mod.json index 98024a90f..2f42da189 100644 --- a/quilt/src/main/resources/quilt.mod.json +++ b/quilt/src/main/resources/quilt.mod.json @@ -30,11 +30,11 @@ }, { "id": "quilted_fabric_api", - "versions": ">=1.0.0-" + "versions": ">=4.0.0-" }, { "id": "minecraft", - "versions": ">=1.18.2" + "versions": ">=1.19.2" } ] }, From a925af56c7ed38244a10dc01f67bc795386d194a Mon Sep 17 00:00:00 2001 From: AlphaMode Date: Wed, 30 Nov 2022 00:49:55 -0600 Subject: [PATCH 002/156] update the 1.19.2 --- .../mod/mixin/server/command/MixinCommands.java | 2 ++ .../server/network/MixinServerGamePacketListenerImpl.java | 2 +- fabric/build.gradle | 6 +++--- .../mod/fabric/mixin/world/level/block/FireMixin.java | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java index 42abc9254..75c1170ca 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java @@ -1,6 +1,8 @@ package org.valkyrienskies.mod.mixin.server.command; +import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.Commands; +import net.minecraft.commands.Commands.CommandSelection; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; 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 21a9e068f..97c235682 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 @@ -68,7 +68,7 @@ private Vec3 skipDistanceCheck2(final Vec3 instance, final Vec3 vec3) { ), method = "handleUseItemOn" ) - private int skipDistanceCheck(final ChunkPos instance, final ChunkPos chunkPos) { + private double skipDistanceCheck1(final Vec3 instance, final Vec3 vec3) { return 0; } diff --git a/fabric/build.gradle b/fabric/build.gradle index df8dadbaf..b2ed75049 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -43,13 +43,13 @@ dependencies { // Depend on the fabric kotlin mod modImplementation("net.fabricmc:fabric-language-kotlin:1.8.5+kotlin.1.7.20") - modImplementation("curse.maven:sodium-394468:3669187") + modImplementation("curse.maven:sodium-394468:3957319") - modImplementation("com.terraformersmc:modmenu:${rootProject.modmenu_version}") + modImplementation("com.terraformersmc:modmenu:4.1.0") // Depend on the fabric API modImplementation("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}") - modImplementation("me.shedaniel.cloth:cloth-config-fabric:${rootProject.cloth_config_version}") + modImplementation("me.shedaniel.cloth:cloth-config-fabric:8.2.88") implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") { 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 43bd69fb4..7a8f961ce 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 @@ -2,6 +2,7 @@ import net.minecraft.core.BlockPos; 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.LevelReader; From 5246271eeffe94a0d8c991a19ded47c047469e97 Mon Sep 17 00:00:00 2001 From: AlphaMode Date: Fri, 6 Jan 2023 15:09:17 -0600 Subject: [PATCH 003/156] Upstream from 1.18.2 --- .../client/renderer/MixinGameRenderer.java | 2 +- .../MixinSoundPhysics.java | 2 +- .../MixinServerGamePacketListenerImpl.java | 4 ++-- .../world/MixinChunkMap$TrackedEntity.java | 2 +- .../mixin/world/level/block/FireMixin.java | 2 +- .../mod/forge/common/ValkyrienSkiesModForge.kt | 17 ++++++++--------- vs-core | 2 +- 7 files changed, 15 insertions(+), 16 deletions(-) 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 46f0bbaa6..04543da1a 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 @@ -292,7 +292,7 @@ private void setupCameraWithMountedShip(final LevelRenderer instance, final Pose // Use [camera.getPosition()] instead of [vec3] because mounting the player to the ship has changed the camera // position. prepareCullFrustum.call(instance, matrixStack, camera.getPosition(), - this.getProjectionMatrix(Math.max(fov, this.minecraft.options.fov))); + this.getProjectionMatrix(Math.max(fov, this.minecraft.options.fov().get()))); } // endregion } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sound_physics_remastered/MixinSoundPhysics.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sound_physics_remastered/MixinSoundPhysics.java index de87e5605..cd1ef96fa 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sound_physics_remastered/MixinSoundPhysics.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sound_physics_remastered/MixinSoundPhysics.java @@ -13,7 +13,7 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; @Pseudo -@Mixin(targets = "com.sonicether.soundphysics.SoundPhysics") +@Mixin(targets = "com.sonicether.soundphysics.SoundPhysics", remap = false) public abstract class MixinSoundPhysics { @Shadow 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 839a9f26a..410322d3b 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 @@ -69,8 +69,8 @@ private Vec3 skipDistanceCheck2(final Vec3 instance, final Vec3 vec3, final Oper ), method = "handleUseItemOn" ) - private int skipDistanceCheck(final ChunkPos instance, final ChunkPos chunkPos, - final Operation getChessboardDistance) { + private double skipDistanceCheck(final Vec3 instance, final Vec3 chunkPos, + final Operation getChessboardDistance) { return 0; } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java index 7080884f5..e8b7bc131 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java @@ -29,7 +29,7 @@ public class MixinChunkMap$TrackedEntity { // Changes entity position for tracking into world space if needed @ModifyExpressionValue(method = "updatePlayer", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ServerEntity;sentPos()Lnet/minecraft/world/phys/Vec3;")) + target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;")) Vec3 includeShips(final Vec3 original) { final Vector3d pos = VectorConversionsMCKt.toJOML(original); final Ship ship = inCallShip = VSGameUtilsKt.getShipObjectManagingPos(this.entity.level, pos); 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 6f9702762..f0cea23ef 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 @@ -124,5 +124,5 @@ private void tryCatchFire(final Level arg, final BlockPos arg2, final int k, fin protected abstract boolean isNearRain(Level level, BlockPos blockPos); @Shadow - protected abstract int getFireOdds(LevelReader levelReader, BlockPos blockPos); + protected abstract int getIgniteOdds(LevelReader levelReader, BlockPos blockPos); } 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 4d800dd3a..466361a45 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 @@ -8,14 +8,13 @@ import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.Item import net.minecraft.world.item.Item.Properties import net.minecraft.world.level.block.Block -import net.minecraftforge.client.ClientRegistry -import net.minecraftforge.client.ConfigGuiHandler.ConfigGuiFactory +import net.minecraftforge.client.ConfigScreenHandler import net.minecraftforge.client.event.EntityRenderersEvent +import net.minecraftforge.client.event.RegisterKeyMappingsEvent import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent import net.minecraftforge.fml.loading.FMLEnvironment import net.minecraftforge.registries.DeferredRegister @@ -40,7 +39,7 @@ import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig class ValkyrienSkiesModForge { private val BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ValkyrienSkiesMod.MOD_ID) private val ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ValkyrienSkiesMod.MOD_ID) - private val ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, ValkyrienSkiesMod.MOD_ID) + private val ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, ValkyrienSkiesMod.MOD_ID) private val TEST_CHAIR_REGISTRY: RegistryObject private val SHIP_CREATOR_ITEM_REGISTRY: RegistryObject private val SHIP_CREATOR_SMALLER_ITEM_REGISTRY: RegistryObject @@ -65,14 +64,14 @@ class ValkyrienSkiesModForge { BLOCKS.register(modBus) ITEMS.register(modBus) ENTITIES.register(modBus) - modBus.addListener(::clientSetup) + modBus.addListener(::registerKeyBindings) modBus.addListener(::entityRenderers) modBus.addListener(::loadComplete) forgeBus.addListener(::registerResourceManagers) - ModLoadingContext.get().registerExtensionPoint(ConfigGuiFactory::class.java) { - ConfigGuiFactory { _, parent -> + ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory::class.java) { + ConfigScreenHandler.ConfigScreenFactory { _, parent -> VSClothConfig.createConfigScreenFor( parent, VSConfigClass.getRegisteredConfig(VSCoreConfig::class.java), @@ -102,9 +101,9 @@ class ValkyrienSkiesModForge { event.addListener(VSEntityHandlerDataLoader) } - private fun clientSetup(event: FMLClientSetupEvent) { + private fun registerKeyBindings(event: RegisterKeyMappingsEvent) { VSKeyBindings.clientSetup { - ClientRegistry.registerKeyBinding(it) + event.register(it) } } diff --git a/vs-core b/vs-core index 18b1357e9..854f17248 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 18b1357e93d7cb5f1ef43d4a6e8ef67cd01fb7ef +Subproject commit 854f1724847e57dd115d1036f9e6ec3793adfbda From 8145558cd740924409264378f7fcc00568b8bc28 Mon Sep 17 00:00:00 2001 From: AlphaMode Date: Sat, 18 Feb 2023 20:40:14 -0600 Subject: [PATCH 004/156] Upstream from 1.18.2 --- common/build.gradle | 2 +- .../feature/world_border/MixinLevel.java | 8 +++++-- .../MixinLevelRendererVanilla.java | 4 ++-- .../mixin/server/world/MixinServerLevel.java | 11 +++++----- fabric/build.gradle | 8 +++---- fabric/gradle.properties | 21 ++++++++----------- forge/gradle.properties | 6 +++--- gradle.properties | 4 ++-- 8 files changed, 32 insertions(+), 32 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index 8e0bb7aa6..ac004efc6 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -23,7 +23,7 @@ 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.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.8-33") + modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.8.a-4") } architectury { 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 498e703de..eba9fbc57 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 @@ -3,8 +3,10 @@ import java.util.function.Supplier; import net.minecraft.core.Holder; 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; @@ -26,8 +28,10 @@ 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 CallbackInfo ci) { + 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) { ((OfLevel) this.worldBorder).setLevel(Level.class.cast(this)); } 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 6c9cf355c..409928b32 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 @@ -262,7 +262,8 @@ private void renderChunkLayer(final RenderType renderType, final PoseStack poseS (float) ((double) blockPos.getZ() - f)); uniform.upload(); } - vertexBuffer.drawChunkLayer(); + vertexBuffer.bind(); + vertexBuffer.draw(); bl2 = true; } if (uniform != null) { @@ -273,7 +274,6 @@ private void renderChunkLayer(final RenderType renderType, final PoseStack poseS vertexFormat.clearBufferState(); } VertexBuffer.unbind(); - VertexBuffer.unbindVertexArray(); this.minecraft.getProfiler().pop(); renderType.clearRenderState(); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java index 773f161fc..6d5d00ee1 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java @@ -15,7 +15,6 @@ import java.util.function.BooleanSupplier; import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos.MutableBlockPos; -import net.minecraft.core.Holder; import net.minecraft.core.Position; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; @@ -23,10 +22,12 @@ import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.progress.ChunkProgressListener; +import net.minecraft.world.level.CustomSpawner; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess; import net.minecraft.world.level.storage.ServerLevelData; import org.jetbrains.annotations.NotNull; @@ -73,9 +74,9 @@ public ServerShipWorldCore getShipObjectWorld() { @Inject(method = "", at = @At("RETURN")) void onInit(final MinecraftServer minecraftServer, final Executor executor, final LevelStorageAccess levelStorageAccess, - final ServerLevelData serverLevelData, final ResourceKey levelId, final Holder holder, - final ChunkProgressListener chunkProgressListener, final ChunkGenerator chunkGenerator, final boolean bl, - final long l, final List list, + final ServerLevelData serverLevelData, final ResourceKey levelId, final LevelStem levelStem, + final ChunkProgressListener chunkProgressListener, final boolean bl, + final long l, final List customSpawners, final boolean bl2, final CallbackInfo ci) { // This only happens when overworld gets loaded on startup, we have a mixin in MixinMinecraftServer for this specific case diff --git a/fabric/build.gradle b/fabric/build.gradle index 656c9ef1c..31b878ab7 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -40,7 +40,7 @@ dependencies { include(modImplementation("net.fabricmc:fabric-language-kotlin:1.8.5+kotlin.1.7.20")) include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:6.3.81")) - modImplementation("curse.maven:sodium-394468:3669187") + modImplementation("curse.maven:sodium-394468:3957319") modImplementation("com.terraformersmc:modmenu:4.1.0") // Depend on the fabric API @@ -60,17 +60,15 @@ dependencies { } // CC Restitched - modImplementation("curse.maven:cc-restitched-462672:3838648") + modImplementation("curse.maven:cc-restitched-462672:3908334") // Create compat modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_version}+${minecraft_version}") { transitive = false } modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version}") modImplementation("com.tterrag.registrate_fabric:Registrate:${registrate_version}") - modImplementation("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") - modImplementation("me.alphamode:ForgeTags:${forge_tags_version}") + modImplementation("io.github.fabricators_of_create.Porting-Lib:porting-lib:${port_lib_version}+${minecraft_version}") modImplementation("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") - modImplementation("dev.cafeteria:fake-player-api:${fake_player_api_version}") modImplementation("io.github.tropheusj:milk-lib:${milk_lib_version}") } diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 7973021b4..e90a472b3 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1,19 +1,16 @@ loader_platform=Fabric -create_version=0.5.0g-821 +create_version=0.5.0.i-961 # https://github.com/Fabricators-of-Create/Create/blob/mc1.18/fabric/dev/gradle.properties -config_api_id=3671141 -forge_config_api_port_version=3.2.4 -fake_player_api_version=0.3.0 +config_api_id=4143545 +forge_config_api_port_version=4.2.10 # https://maven.tterrag.com/com/jozufozu/flywheel/Flywheel-Fabric -flywheel_version=0.6.8-33 -reach_entity_attributes_version=2.1.1 -registrate_version=MC1.18.2-1.1.6 -forge_tags_version=2.1 -milk_lib_version=0.3.2 -port_lib_version=1.2.677-beta -port_lib_hash=cca931b +flywheel_version=0.6.8.a-4 +reach_entity_attributes_version=2.3.0 +registrate_version=1.1.50-MC1.19.2 +milk_lib_version=1.0.51 +port_lib_version=2.1.722 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.0.2+1.18.2 +no_indium_version=1.1.0+1.19 diff --git a/forge/gradle.properties b/forge/gradle.properties index d19154fc0..04e81539e 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -2,6 +2,6 @@ loader_platform=Forge loom.platform=forge kotlin.stdlib.default.dependency=false #Compat -create_version=0.5.0.g-233 -flywheel_version=0.6.8-98 -registrate_version=MC1.18.2-1.1.3 +create_version=0.5.0.i-23 +flywheel_version=0.6.8.a-14 +registrate_version=MC1.19-1.1.5 diff --git a/gradle.properties b/gradle.properties index 6aeee9d10..2405fca76 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,8 +5,8 @@ archives_base_name=valkyrienskies-118 mod_version=2.1.0-beta.10 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 -fabric_loader_version=0.14.10 -fabric_api_version=0.67.0+1.19.2 +fabric_loader_version=0.14.11 +fabric_api_version=0.73.2+1.19.2 forge_version=1.19.2-43.1.47 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually From 343e4baa83e80eec0642319b5786dedbfb68bb57 Mon Sep 17 00:00:00 2001 From: AlphaMode Date: Sat, 18 Feb 2023 20:49:53 -0600 Subject: [PATCH 005/156] Upstream from 1.18.2 --- .../mod/mixin/server/world/MixinChunkMap.java | 39 +++++++++---------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java index 3c6105a65..64cbbb6d8 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.mixin.server.world; -import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; @@ -9,7 +8,6 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; -import net.minecraft.Util; import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ChunkMap; @@ -57,28 +55,27 @@ public abstract class MixinChunkMap { */ @Inject(method = "readChunk", at = @At("HEAD"), cancellable = true) private void preReadChunk(final ChunkPos chunkPos, - final CallbackInfoReturnable>> cir) - throws IOException { + final CallbackInfoReturnable>> cir) { final ChunkMap self = ChunkMap.class.cast(this); - final CompoundTag compoundTag = self.read(chunkPos); - final CompoundTag originalToReturn = compoundTag == null ? null : - self.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, compoundTag, Optional.empty()); - cir.setReturnValue(originalToReturn); - if (originalToReturn == null) { - final ServerShip ship = VSGameUtilsKt.getShipManagingPos(level, chunkPos.x, chunkPos.z); - // If its in a ship and it shouldn't generate chunks OR if there is no ship but its happening in the shipyard - if ((ship == null && VSGameUtilsKt.isChunkInShipyard(level, chunkPos.x, chunkPos.z)) || - (ship != null && !ShipSettingsKt.getSettings(ship).getShouldGenerateChunks())) { - // The chunk doesn't yet exist and is in the shipyard. Make a new empty chunk - // Generate the chunk to be nothing - final LevelChunk generatedChunk = new LevelChunk(level, - new ProtoChunk(chunkPos, UpgradeData.EMPTY, level, - level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null), null); - // Its wasteful to serialize just for this to be deserialized, but it will work for now. - cir.setReturnValue(ChunkSerializer.write(level, generatedChunk)); + cir.setReturnValue(self.read(chunkPos).thenApplyAsync(compoundTag -> { + if (compoundTag.isEmpty()) { + final ServerShip ship = VSGameUtilsKt.getShipManagingPos(level, chunkPos.x, chunkPos.z); + // If its in a ship and it shouldn't generate chunks OR if there is no ship but its happening in the shipyard + if ((ship == null && VSGameUtilsKt.isChunkInShipyard(level, chunkPos.x, chunkPos.z)) || + (ship != null && !ShipSettingsKt.getSettings(ship).getShouldGenerateChunks())) { + // The chunk doesn't yet exist and is in the shipyard. Make a new empty chunk + // Generate the chunk to be nothing + final LevelChunk generatedChunk = new LevelChunk(level, + new ProtoChunk(chunkPos, UpgradeData.EMPTY, level, + level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null), null); + // Its wasteful to serialize just for this to be deserialized, but it will work for now. + return Optional.of(ChunkSerializer.write(level, generatedChunk)); + } } - } + return compoundTag.map(this::upgradeChunkTag); + })); + } /** From c25cc3b898d55be0ef328971f42d3fad7f9b3442 Mon Sep 17 00:00:00 2001 From: AlphaMode Date: Sat, 18 Feb 2023 21:00:32 -0600 Subject: [PATCH 006/156] Fix compile issues with forge --- .../valkyrienskies/mod/forge/common/ValkyrienSkiesModForge.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 fa547f07b..2c0424c63 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 @@ -48,7 +48,7 @@ class ValkyrienSkiesModForge { private val BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ValkyrienSkiesMod.MOD_ID) private val ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ValkyrienSkiesMod.MOD_ID) private val ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, ValkyrienSkiesMod.MOD_ID) - private val BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, ValkyrienSkiesMod.MOD_ID) + private val BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, ValkyrienSkiesMod.MOD_ID) private val TEST_CHAIR_REGISTRY: RegistryObject private val TEST_HINGE_REGISTRY: RegistryObject private val TEST_FLAP_REGISTRY: RegistryObject From ce123cc35ceadb68e3e13fe388c3dee27b778521 Mon Sep 17 00:00:00 2001 From: AlphaMode Date: Sat, 18 Feb 2023 21:13:09 -0600 Subject: [PATCH 007/156] Update base name to valkyrienskies-119 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 2405fca76..481fa9863 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,7 +1,7 @@ org.gradle.jvmargs=-Xmx4096M minecraft_version=1.19.2 enabled_platforms=quilt,fabric,forge -archives_base_name=valkyrienskies-118 +archives_base_name=valkyrienskies-119 mod_version=2.1.0-beta.10 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 From 6b810caba861b89fd14c868364aa226b6489bc65 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Wed, 1 Mar 2023 01:18:08 -0500 Subject: [PATCH 008/156] update version number, jvm args --- gradle.properties | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 481fa9863..353e13751 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,8 +1,8 @@ -org.gradle.jvmargs=-Xmx4096M +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.19.2 enabled_platforms=quilt,fabric,forge -archives_base_name=valkyrienskies-119 -mod_version=2.1.0-beta.10 +archives_base_name=valkyrienskies-1192 +mod_version=2.2.0-beta.1 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 fabric_loader_version=0.14.11 From b7ee622e99fdae0f85b8da88034d0989c02f892e Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Wed, 1 Mar 2023 02:15:48 -0500 Subject: [PATCH 009/156] ci: update playtest webhook --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 7ede9e82c..c3cb2f2b2 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_118_WEBHOOK} + webhook: ${VS2_1192_WEBHOOK} # Invoke jobs via workflows # See: https://circleci.com/docs/2.0/configuration-reference/#workflows From 08fd9389b0442a073d5907f7568a779b71ed19e4 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 4 Jun 2023 11:03:24 -0600 Subject: [PATCH 010/156] Got forge to launch (rendering is broken though) --- .../mixin/client/renderer/MixinLevelRenderer.java | 15 ++------------- .../MixinServerGamePacketListenerImpl.java | 2 ++ .../server/network/MixinServerPlayerGameMode.java | 10 ++-------- forge/build.gradle | 2 +- 4 files changed, 7 insertions(+), 22 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java index 8b10eb471..e8c4d0672 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java @@ -2,24 +2,13 @@ import static org.valkyrienskies.mod.common.VSClientGameUtils.transformRenderWithShip; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; 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; import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; import org.spongepowered.asm.mixin.Mixin; @@ -30,9 +19,7 @@ import org.spongepowered.asm.mixin.injection.ModifyConstant; 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.mixin.accessors.client.render.OverlayVertexConsumerAccessor; @Mixin(LevelRenderer.class) public abstract class MixinLevelRenderer { @@ -91,6 +78,7 @@ private void preRenderHitOutline(final PoseStack matrixStack, final VertexConsum /** * This mixin makes block damage render on ships. */ + /* @WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBreakingTexture(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;)V")) private void renderBlockDamage(final BlockRenderDispatcher blockRenderManager, final BlockState state, @@ -130,5 +118,6 @@ private void renderBlockDamage(final BlockRenderDispatcher blockRenderManager, f renderBreakingTexture.call(blockRenderManager, state, blockPos, blockRenderWorld, matrix, vertexConsumer); } } + */ } 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 58b1dd7e7..c1bb157fd 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 @@ -77,6 +77,7 @@ private Vec3 skipDistanceCheck2(final Vec3 instance, final Vec3 vec3, final Oper return VSGameUtilsKt.toWorldCoordinates(player.level, subtract.call(instance, vec3)); } + /* @WrapOperation( at = @At( value = "INVOKE", @@ -88,6 +89,7 @@ private double skipDistanceCheck(final Vec3 instance, final Vec3 chunkPos, final Operation getChessboardDistance) { return 0; } + */ @WrapOperation( method = "handleMovePlayer", diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java index 6f350f158..5c7156eba 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java @@ -1,19 +1,11 @@ package org.valkyrienskies.mod.mixin.server.network; -import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; -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.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.config.VSGameConfig; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @Mixin(ServerPlayerGameMode.class) public class MixinServerPlayerGameMode { @@ -28,6 +20,7 @@ public class MixinServerPlayerGameMode { /** * Includes ships in server-side distance check when player breaks a block. */ + /* @Redirect( method = "handleBlockBreakAction", at = @At(value = "INVOKE", @@ -43,4 +36,5 @@ public double handleBlockBreakAction(final Vec3 instance, final Vec3 vec3) { return instance.distanceToSqr(vec3); } } + */ } diff --git a/forge/build.gradle b/forge/build.gradle index 7ae7976cb..d368a4672 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -82,7 +82,7 @@ dependencies { forgeRuntimeLibrary('curse.maven:kotlinforforge-351264:3925887') // Cloth for config - include(modImplementation("me.shedaniel.cloth:cloth-config-forge:6.3.81")) + include(modImplementation("me.shedaniel.cloth:cloth-config-forge:8.2.88")) // Shade vs-core implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") From b06745bd59fca3a601dc49cd037207f5d8730efd Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 4 Jun 2023 12:25:18 -0600 Subject: [PATCH 011/156] Fixed ship blocks not rendering --- .../MixinRenderChunk.java | 13 ++++ .../MixinLevelRendererVanilla.java | 71 +++++++++++-------- 2 files changed, 55 insertions(+), 29 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fix_render_chunk_sorting/MixinRenderChunk.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fix_render_chunk_sorting/MixinRenderChunk.java index 209c90e91..ba901c22d 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fix_render_chunk_sorting/MixinRenderChunk.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fix_render_chunk_sorting/MixinRenderChunk.java @@ -51,4 +51,17 @@ private void preGetSquaredCameraDistance(final CallbackInfoReturnable ci cir.setReturnValue(relDistanceSq); } } + + // This fixes ship blocks not rendering for some reason... + @Inject(method = "hasAllNeighbors", at = @At("HEAD"), cancellable = true) + private void preHasAllNeighbors(final CallbackInfoReturnable cir) { + final ClientLevel world = Minecraft.getInstance().level; + if (world == null) { + return; + } + + if (VSGameUtilsKt.isBlockInShipyard(world, origin)) { + cir.setReturnValue(true); + } + } } 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 409928b32..711a71978 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 @@ -5,10 +5,8 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.blaze3d.shaders.Uniform; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.BufferUploader; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexBuffer; -import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.math.Matrix4f; import com.mojang.math.Vector3f; import it.unimi.dsi.fastutil.objects.ObjectArrayList; @@ -207,72 +205,87 @@ private void renderChunkLayer(final RenderType renderType, final PoseStack poseS RenderSystem.assertOnRenderThread(); renderType.setupRenderState(); this.minecraft.getProfiler().push("filterempty"); - this.minecraft.getProfiler().popPush(() -> "render_" + renderType); - final boolean bl = renderType != RenderType.translucent(); + this.minecraft.getProfiler().popPush(() -> { + return "render_" + renderType; + }); + boolean bl = renderType != RenderType.translucent(); final ListIterator objectListIterator = chunksToRender.listIterator(bl ? 0 : chunksToRender.size()); - final VertexFormat vertexFormat = renderType.format(); - final ShaderInstance shaderInstance = RenderSystem.getShader(); - BufferUploader.reset(); - for (int k = 0; k < 12; ++k) { - final int l = RenderSystem.getShaderTexture(k); + ShaderInstance shaderInstance = RenderSystem.getShader(); + + for(int k = 0; k < 12; ++k) { + int l = RenderSystem.getShaderTexture(k); shaderInstance.setSampler("Sampler" + k, l); } + if (shaderInstance.MODEL_VIEW_MATRIX != null) { shaderInstance.MODEL_VIEW_MATRIX.set(poseStack.last().pose()); } + if (shaderInstance.PROJECTION_MATRIX != null) { shaderInstance.PROJECTION_MATRIX.set(matrix4f); } + if (shaderInstance.COLOR_MODULATOR != null) { shaderInstance.COLOR_MODULATOR.set(RenderSystem.getShaderColor()); } + if (shaderInstance.FOG_START != null) { shaderInstance.FOG_START.set(RenderSystem.getShaderFogStart()); } + if (shaderInstance.FOG_END != null) { shaderInstance.FOG_END.set(RenderSystem.getShaderFogEnd()); } + if (shaderInstance.FOG_COLOR != null) { shaderInstance.FOG_COLOR.set(RenderSystem.getShaderFogColor()); } + if (shaderInstance.FOG_SHAPE != null) { shaderInstance.FOG_SHAPE.set(RenderSystem.getShaderFogShape().getIndex()); } + if (shaderInstance.TEXTURE_MATRIX != null) { shaderInstance.TEXTURE_MATRIX.set(RenderSystem.getTextureMatrix()); } + if (shaderInstance.GAME_TIME != null) { shaderInstance.GAME_TIME.set(RenderSystem.getShaderGameTime()); } + RenderSystem.setupShaderLights(shaderInstance); shaderInstance.apply(); - final Uniform uniform = shaderInstance.CHUNK_OFFSET; - boolean bl2 = false; - while (bl ? objectListIterator.hasNext() : objectListIterator.hasPrevious()) { - final RenderChunkInfo renderChunkInfo2 = - bl ? (RenderChunkInfo) objectListIterator.next() : (RenderChunkInfo) objectListIterator.previous(); - final ChunkRenderDispatcher.RenderChunk renderChunk = renderChunkInfo2.chunk; - if (renderChunk.getCompiledChunk().isEmpty(renderType)) { - continue; + Uniform uniform = shaderInstance.CHUNK_OFFSET; + + while(true) { + if (bl) { + if (!objectListIterator.hasNext()) { + break; + } + } else if (!objectListIterator.hasPrevious()) { + break; } - final VertexBuffer vertexBuffer = renderChunk.getBuffer(renderType); - final BlockPos blockPos = renderChunk.getOrigin(); - if (uniform != null) { - uniform.set((float) ((double) blockPos.getX() - d), (float) ((double) blockPos.getY() - e), - (float) ((double) blockPos.getZ() - f)); - uniform.upload(); + + RenderChunkInfo renderChunkInfo2 = bl ? (RenderChunkInfo)objectListIterator.next() : (RenderChunkInfo)objectListIterator.previous(); + ChunkRenderDispatcher.RenderChunk renderChunk = renderChunkInfo2.chunk; + if (!renderChunk.getCompiledChunk().isEmpty(renderType)) { + VertexBuffer vertexBuffer = renderChunk.getBuffer(renderType); + BlockPos blockPos = renderChunk.getOrigin(); + if (uniform != null) { + uniform.set((float)((double)blockPos.getX() - d), (float)((double)blockPos.getY() - e), (float)((double)blockPos.getZ() - f)); + uniform.upload(); + } + + vertexBuffer.bind(); + vertexBuffer.draw(); } - vertexBuffer.bind(); - vertexBuffer.draw(); - bl2 = true; } + if (uniform != null) { uniform.set(Vector3f.ZERO); } + shaderInstance.clear(); - if (bl2) { - vertexFormat.clearBufferState(); - } VertexBuffer.unbind(); this.minecraft.getProfiler().pop(); renderType.clearRenderState(); From a16a442faf6a559d00c6996e9237ff25e7769110 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 4 Jun 2023 13:14:17 -0600 Subject: [PATCH 012/156] Fixed ship block damage not rendering --- .../client/renderer/MixinLevelRenderer.java | 46 ----------- .../client/render/MixinLevelRenderer.java | 77 +++++++++++++++++++ .../valkyrienskies-fabric.mixins.json | 4 +- .../client/render/MixinLevelRenderer.java | 68 ++++++++++++++++ 4 files changed, 148 insertions(+), 47 deletions(-) create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/client/render/MixinLevelRenderer.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java index e8c4d0672..77773980b 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java @@ -74,50 +74,4 @@ private void preRenderHitOutline(final PoseStack matrixStack, final VertexConsum 0.0F, 0.0F, 0.0F, 0.4F); } } - - /** - * This mixin makes block damage render on ships. - */ - /* - @WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBreakingTexture(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;)V")) - private void renderBlockDamage(final BlockRenderDispatcher blockRenderManager, final BlockState state, - final BlockPos blockPos, final BlockAndTintGetter blockRenderWorld, final PoseStack matrix, - final VertexConsumer vertexConsumer, final Operation renderBreakingTexture, final PoseStack matrixStack, - final float methodTickDelta, final long methodLimitTime, final boolean methodRenderBlockOutline, - final Camera methodCamera, final GameRenderer methodGameRenderer, - final LightTexture methodLightmapTextureManager, final Matrix4f methodMatrix4f) { - - final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(level, blockPos); - if (ship != null) { - // Remove the vanilla render transform - matrixStack.popPose(); - - // Add the VS render transform - matrixStack.pushPose(); - - final ShipTransform renderTransform = ship.getRenderTransform(); - final Vec3 cameraPos = methodCamera.getPosition(); - - transformRenderWithShip(renderTransform, matrixStack, blockPos, cameraPos.x, cameraPos.y, cameraPos.z); - - final Matrix3f newNormalMatrix = matrixStack.last().normal().copy(); - final Matrix4f newModelMatrix = matrixStack.last().pose().copy(); - - // 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); - - // Finally, invoke the render damage function. - renderBreakingTexture.call(blockRenderManager, state, blockPos, blockRenderWorld, matrix, - newVertexConsumer); - } else { - // Vanilla behavior - renderBreakingTexture.call(blockRenderManager, state, blockPos, blockRenderWorld, matrix, vertexConsumer); - } - } - */ - } 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 new file mode 100644 index 000000000..8bb3bdc91 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/client/render/MixinLevelRenderer.java @@ -0,0 +1,77 @@ +package org.valkyrienskies.mod.fabric.mixin.client.render; + +import static org.valkyrienskies.mod.common.VSClientGameUtils.transformRenderWithShip; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +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; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.block.state.BlockState; +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.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.core.api.ships.properties.ShipTransform; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.mixin.accessors.client.render.OverlayVertexConsumerAccessor; + +@Mixin(LevelRenderer.class) +public abstract class MixinLevelRenderer { + @Shadow + private ClientLevel level; + + /** + * This mixin makes block damage render on ships. + */ + @WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBreakingTexture(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;)V")) + private void renderBlockDamage(final BlockRenderDispatcher blockRenderManager, final BlockState state, + final BlockPos blockPos, final BlockAndTintGetter blockRenderWorld, final PoseStack matrix, + final VertexConsumer vertexConsumer, final Operation renderBreakingTexture, final PoseStack matrixStack, + final float methodTickDelta, final long methodLimitTime, final boolean methodRenderBlockOutline, + final Camera methodCamera, final GameRenderer methodGameRenderer, + final LightTexture methodLightmapTextureManager, final Matrix4f methodMatrix4f) { + + final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(level, blockPos); + if (ship != null) { + // Remove the vanilla render transform + matrixStack.popPose(); + + // Add the VS render transform + matrixStack.pushPose(); + + final ShipTransform renderTransform = ship.getRenderTransform(); + final Vec3 cameraPos = methodCamera.getPosition(); + + transformRenderWithShip(renderTransform, matrixStack, blockPos, cameraPos.x, cameraPos.y, cameraPos.z); + + final Matrix3f newNormalMatrix = matrixStack.last().normal().copy(); + final Matrix4f newModelMatrix = matrixStack.last().pose().copy(); + + // 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); + + // Finally, invoke the render damage function. + renderBreakingTexture.call(blockRenderManager, state, blockPos, blockRenderWorld, matrix, + newVertexConsumer); + } else { + // Vanilla behavior + renderBreakingTexture.call(blockRenderManager, state, blockPos, blockRenderWorld, matrix, vertexConsumer); + } + } +} diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index dc75436f1..82561818b 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -14,7 +14,9 @@ "feature.explosions.ClipContextMixin", "world.level.block.FireMixin" ], - "client": [], + "client": [ + "client.render.MixinLevelRenderer" + ], "injectors": { "defaultRequire": 1 }, 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 304e0c108..d7f3579d3 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 @@ -1,14 +1,40 @@ package org.valkyrienskies.mod.forge.mixin.client.render; +import static org.valkyrienskies.mod.common.VSClientGameUtils.transformRenderWithShip; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +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; import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.LightTexture; +import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.BlockAndTintGetter; +import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.client.model.data.ModelData; 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.ClientShip; +import org.valkyrienskies.core.api.ships.properties.ShipTransform; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.mixin.accessors.client.render.OverlayVertexConsumerAccessor; @Mixin(LevelRenderer.class) public class MixinLevelRenderer { + @Shadow + private ClientLevel level; @Redirect(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/culling/Frustum;isVisible(Lnet/minecraft/world/phys/AABB;)Z")) @@ -16,4 +42,46 @@ public boolean dontClipTileEntities(final Frustum receiver, final AABB aabb) { return true; } + /** + * This mixin makes block damage render on ships. + */ + @WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBreakingTexture(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraftforge/client/model/data/ModelData;)V")) + private void renderBlockDamage(final BlockRenderDispatcher blockRenderManager, final BlockState state, + final BlockPos blockPos, final BlockAndTintGetter blockRenderWorld, final PoseStack matrix, + final VertexConsumer vertexConsumer, final ModelData modelData, final Operation renderBreakingTexture, final PoseStack matrixStack, + final float methodTickDelta, final long methodLimitTime, final boolean methodRenderBlockOutline, + final Camera methodCamera, final GameRenderer methodGameRenderer, + final LightTexture methodLightmapTextureManager, final Matrix4f methodMatrix4f) { + + final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(level, blockPos); + if (ship != null) { + // Remove the vanilla render transform + matrixStack.popPose(); + + // Add the VS render transform + matrixStack.pushPose(); + + final ShipTransform renderTransform = ship.getRenderTransform(); + final Vec3 cameraPos = methodCamera.getPosition(); + + transformRenderWithShip(renderTransform, matrixStack, blockPos, cameraPos.x, cameraPos.y, cameraPos.z); + + final Matrix3f newNormalMatrix = matrixStack.last().normal().copy(); + final Matrix4f newModelMatrix = matrixStack.last().pose().copy(); + + // 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); + + // Finally, invoke the render damage function. + renderBreakingTexture.call(blockRenderManager, state, blockPos, blockRenderWorld, matrix, + newVertexConsumer, modelData); + } else { + // Vanilla behavior + renderBreakingTexture.call(blockRenderManager, state, blockPos, blockRenderWorld, matrix, vertexConsumer, modelData); + } + } } From 1ec26606e49494f4da1a10d43ab6f3d25f6c0dc8 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 4 Jun 2023 14:07:04 -0600 Subject: [PATCH 013/156] Fixed block interactions in Fabric --- .../MixinServerGamePacketListenerImpl.java | 14 ------------ .../valkyrienskies-common.mixins.json | 1 - .../MixinServerGamePacketListenerImpl.java | 22 +++++++++++++++++++ .../network/MixinServerPlayerGameMode.java | 12 +++++++--- .../valkyrienskies-fabric.mixins.json | 2 ++ 5 files changed, 33 insertions(+), 18 deletions(-) create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerGamePacketListenerImpl.java rename {common/src/main/java/org/valkyrienskies/mod => fabric/src/main/java/org/valkyrienskies/mod/fabric}/mixin/server/network/MixinServerPlayerGameMode.java (75%) 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 c1bb157fd..580cc96aa 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 @@ -77,20 +77,6 @@ private Vec3 skipDistanceCheck2(final Vec3 instance, final Vec3 vec3, final Oper return VSGameUtilsKt.toWorldCoordinates(player.level, subtract.call(instance, vec3)); } - /* - @WrapOperation( - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" - ), - method = "handleUseItemOn" - ) - private double skipDistanceCheck(final Vec3 instance, final Vec3 chunkPos, - final Operation getChessboardDistance) { - return 0; - } - */ - @WrapOperation( method = "handleMovePlayer", at = @At( diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index fcb76e645..53f2e220c 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -52,7 +52,6 @@ "server.command.MixinCommands", "server.command.level.MixinServerPlayer", "server.network.MixinServerGamePacketListenerImpl", - "server.network.MixinServerPlayerGameMode", "server.world.MixinChunkMap", "server.world.MixinChunkMap$TrackedEntity", "server.world.MixinServerLevel", diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerGamePacketListenerImpl.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerGamePacketListenerImpl.java new file mode 100644 index 000000000..5fac1ed43 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerGamePacketListenerImpl.java @@ -0,0 +1,22 @@ +package org.valkyrienskies.mod.fabric.mixin.server.network; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ServerGamePacketListenerImpl.class) +public abstract class MixinServerGamePacketListenerImpl { + @WrapOperation( + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" + ), + method = "handleUseItemOn" + ) + private double skipDistanceCheck(final Vec3 instance, final Vec3 chunkPos, final Operation getChessboardDistance) { + return 0; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerPlayerGameMode.java similarity index 75% rename from common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java rename to fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerPlayerGameMode.java index 5c7156eba..44087ce6f 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerPlayerGameMode.java @@ -1,11 +1,19 @@ -package org.valkyrienskies.mod.mixin.server.network; +package org.valkyrienskies.mod.fabric.mixin.server.network; +import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; +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.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.config.VSGameConfig; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @Mixin(ServerPlayerGameMode.class) public class MixinServerPlayerGameMode { @@ -20,7 +28,6 @@ public class MixinServerPlayerGameMode { /** * Includes ships in server-side distance check when player breaks a block. */ - /* @Redirect( method = "handleBlockBreakAction", at = @At(value = "INVOKE", @@ -36,5 +43,4 @@ public double handleBlockBreakAction(final Vec3 instance, final Vec3 vec3) { return instance.distanceToSqr(vec3); } } - */ } diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 82561818b..492442ce9 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -12,6 +12,8 @@ "compat.create.MixinAbstractContraptionEntity", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", + "server.network.MixinServerGamePacketListenerImpl", + "server.network.MixinServerPlayerGameMode", "world.level.block.FireMixin" ], "client": [ From 2a13a74435433ae8f166405a8880810a4f5e0d13 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 4 Jun 2023 16:26:41 -0600 Subject: [PATCH 014/156] Fixed commands --- .../commands/MixinArgumentTypeInfos.java | 32 ++++++++++++++ .../mod/common/command/ShipArgumentInfo.kt | 42 +++++++++++++++++++ .../valkyrienskies-common.mixins.json | 1 + 3 files changed, 75 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypeInfos.java create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentInfo.kt diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypeInfos.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypeInfos.java new file mode 100644 index 000000000..88768fd63 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypeInfos.java @@ -0,0 +1,32 @@ +package org.valkyrienskies.mod.mixin.feature.commands; + +import com.mojang.brigadier.arguments.ArgumentType; +import net.minecraft.commands.synchronization.ArgumentTypeInfo; +import net.minecraft.commands.synchronization.ArgumentTypeInfos; +import net.minecraft.commands.synchronization.SingletonArgumentInfo; +import net.minecraft.core.Registry; +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.CallbackInfoReturnable; +import org.valkyrienskies.mod.common.command.RelativeVector3Argument; +import org.valkyrienskies.mod.common.command.ShipArgument; +import org.valkyrienskies.mod.common.command.ShipArgumentInfo; + +@Mixin(ArgumentTypeInfos.class) +public class MixinArgumentTypeInfos { + @Shadow + private static , T extends ArgumentTypeInfo.Template> ArgumentTypeInfo register( + Registry> arg, String string, Class class_, ArgumentTypeInfo arg2) { + throw new IllegalStateException(); + } + + @Inject(method = "bootstrap", at = @At("TAIL")) + private static void postBootstrap(final Registry> registry, + final CallbackInfoReturnable> ci) { + register(registry, "valkyrienskies:ship_argument", ShipArgument.class, new ShipArgumentInfo()); + register(registry, "valkyrienskies:relative_vector3_argument", RelativeVector3Argument.class, + SingletonArgumentInfo.contextFree(RelativeVector3Argument::new)); + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentInfo.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentInfo.kt new file mode 100644 index 000000000..eeedfb86e --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentInfo.kt @@ -0,0 +1,42 @@ +package org.valkyrienskies.mod.common.command + +import com.google.gson.JsonObject +import net.minecraft.commands.CommandBuildContext +import net.minecraft.commands.synchronization.ArgumentTypeInfo +import net.minecraft.network.FriendlyByteBuf +import org.valkyrienskies.mod.common.command.ShipArgument.Companion + +internal class ShipArgumentInfo : ArgumentTypeInfo { + override fun serializeToNetwork(template: ShipArgumentInfoTemplate, friendlyByteBuf: FriendlyByteBuf) { + friendlyByteBuf.writeBoolean(template.selectorOnly) + } + + override fun deserializeFromNetwork(friendlyByteBuf: FriendlyByteBuf): ShipArgumentInfoTemplate { + return ShipArgumentInfoTemplate( + this, friendlyByteBuf.readBoolean() + ) + } + + override fun unpack(argumentType: ShipArgument): ShipArgumentInfoTemplate { + return ShipArgumentInfoTemplate(this, argumentType.selectorOnly) + } + + override fun serializeToJson(template: ShipArgumentInfoTemplate, jsonObject: JsonObject) { + jsonObject.addProperty("selectorOnly", template.selectorOnly) + } +} + +internal class ShipArgumentInfoTemplate(private val info: ShipArgumentInfo, internal val selectorOnly: Boolean) : + ArgumentTypeInfo.Template { + override fun instantiate(commandBuildContext: CommandBuildContext): ShipArgument { + return if (selectorOnly) { + ShipArgument.selectorOnly() + } else { + Companion.ships() + } + } + + override fun type(): ArgumentTypeInfo { + return info + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 015fa73dc..c7146a373 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -18,6 +18,7 @@ "feature.block_placement_orientation.MixinBlockItem", "feature.block_placement_orientation.MixinBlockPlaceContext", "feature.clip_replace.MixinLevel", + "feature.commands.MixinArgumentTypeInfos", "feature.commands.MixinCommandSourceStack", "feature.conduit_fix.ConduitMixin", "feature.container_distance_check.MixinRandomizableContainerBlockEntity", From 325bafd29bfa8c318777edf349f5de3735a51de0 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 4 Jun 2023 16:27:35 -0600 Subject: [PATCH 015/156] Updated vs-core --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index b61972a84..ead972f38 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit b61972a84401fdd423b68be7483cfdfabfbda9bb +Subproject commit ead972f384499b1b7713e20dde3d0affe7fdc3f1 From beab12e15a43d1fc8193755a289d85152df09d6e Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 4 Jun 2023 16:30:25 -0600 Subject: [PATCH 016/156] Run test server job on 1.19.2 --- .github/workflows/{build-1.18.x.yml => build.yml} | 1 + 1 file changed, 1 insertion(+) rename .github/workflows/{build-1.18.x.yml => build.yml} (98%) diff --git a/.github/workflows/build-1.18.x.yml b/.github/workflows/build.yml similarity index 98% rename from .github/workflows/build-1.18.x.yml rename to .github/workflows/build.yml index 46464861e..d8520c9fe 100644 --- a/.github/workflows/build-1.18.x.yml +++ b/.github/workflows/build.yml @@ -3,6 +3,7 @@ on: push: branches: - '1.18.x/*' + - '1.19.2/*' pull_request: types: [ opened, synchronize, reopened ] jobs: From 82acff37d9debe4fc0ad39d2eb1a6ab3e356ce3d Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 4 Jun 2023 16:39:38 -0600 Subject: [PATCH 017/156] Fixed forge --- .../valkyrienskies/mod/forge/common/ValkyrienSkiesModForge.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 282ac8c49..0ea3b854c 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 @@ -156,7 +156,7 @@ class ValkyrienSkiesModForge { private fun registerCommands(event: RegisterCommandsEvent) { VSCommands.registerServerCommands(event.dispatcher) - if (event.environment == ALL || event.environment == INTEGRATED) { + if (event.commandSelection == ALL || event.commandSelection == INTEGRATED) { VSCommands.registerClientCommands(event.dispatcher) } } From 09efe8f3351edaf34f5b0fa0ecafd6e5c87beb0a Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 4 Jun 2023 19:07:47 -0600 Subject: [PATCH 018/156] Don't shade Guava --- common/build.gradle | 1 + fabric/build.gradle | 2 ++ forge/build.gradle | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/common/build.gradle b/common/build.gradle index c7f232f6a..575ed38f5 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -14,6 +14,7 @@ dependencies { implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") { exclude module: "netty-buffer" exclude module: "fastutil" + exclude group: "com.google.guava" } // FTB Stuffs diff --git a/fabric/build.gradle b/fabric/build.gradle index 31b878ab7..fca29a112 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -51,12 +51,14 @@ dependencies { exclude module: "netty-buffer" exclude module: "fastutil" exclude module: "kotlin-stdlib-jdk8" + exclude group: "com.google.guava" } // Shade vs-core shadowCommon("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") { exclude module: "netty-buffer" exclude module: "fastutil" exclude module: "kotlin-stdlib-jdk8" // Don't shade kotlin-stdlib-jdk8, even though vs-core depends on it + exclude group: "com.google.guava" } // CC Restitched diff --git a/forge/build.gradle b/forge/build.gradle index d368a4672..aedf61aec 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -88,24 +88,29 @@ dependencies { implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") forgeRuntimeLibrary shadowCommon("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") { transitive = false + exclude group: "com.google.guava" } // region Manually include every single dependency of vs-core (total meme) forgeRuntimeLibrary include("org.valkyrienskies.core:api:${rootProject.vs_core_version}") { transitive = false + exclude group: "com.google.guava" } forgeRuntimeLibrary shadowCommon("org.valkyrienskies.core:api-game:${rootProject.vs_core_version}") { transitive = false + exclude group: "com.google.guava" } forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+eb3ae45554") { transitive = false + exclude group: "com.google.guava" } forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+0b6f5db802") { transitive = false + exclude group: "com.google.guava" } forgeRuntimeLibrary include("javax.inject:javax.inject:1") { transitive = false } From 3558977b32d92481eca6c41039325a90ff56f718 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 4 Jun 2023 19:18:22 -0600 Subject: [PATCH 019/156] Empty commit to retry actions From d43a691e272c1f76f69c139e82cb6207b573f55e Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 5 Jun 2023 03:34:33 -0600 Subject: [PATCH 020/156] Fixed cruise control keybind not working on fabric --- .../mod/common/config/VSKeyBindings.kt | 4 + .../KeyMappingAccessor.java | 18 +++++ .../MixinKeyMapping.java | 80 +++++++++++++++++++ .../valkyrienskies-fabric.mixins.json | 4 +- 4 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/KeyMappingAccessor.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/MixinKeyMapping.java diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSKeyBindings.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSKeyBindings.kt index d68efb214..609fcbbfa 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSKeyBindings.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSKeyBindings.kt @@ -33,4 +33,8 @@ object VSKeyBindings { fun clientSetup(registerar: Consumer) { toBeRegistered.forEach { it.accept(registerar) } } + + fun isKeyMappingFromVS2(keyMapping: KeyMapping): Boolean { + return keyMapping.name.startsWith("key.valkyrienskies") + } } diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/KeyMappingAccessor.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/KeyMappingAccessor.java new file mode 100644 index 000000000..41b94b6a6 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/KeyMappingAccessor.java @@ -0,0 +1,18 @@ +package org.valkyrienskies.mod.fabric.mixin.feature.duplicate_keybindings; + +import com.mojang.blaze3d.platform.InputConstants; +import net.minecraft.client.KeyMapping; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(KeyMapping.class) +public interface KeyMappingAccessor { + @Accessor + InputConstants.Key getKey(); + + @Accessor + int getClickCount(); + + @Accessor + void setClickCount(int clickCount); +} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/MixinKeyMapping.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/MixinKeyMapping.java new file mode 100644 index 000000000..3a1401e85 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/MixinKeyMapping.java @@ -0,0 +1,80 @@ +package org.valkyrienskies.mod.fabric.mixin.feature.duplicate_keybindings; + +import com.google.common.collect.Maps; +import com.mojang.blaze3d.platform.InputConstants; +import com.mojang.blaze3d.platform.InputConstants.Key; +import java.util.Map; +import net.minecraft.client.KeyMapping; +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.mod.common.config.VSKeyBindings; + +/** + * This Mixin makes it so VS2 keybindings are pressed even when there exists another keybinding bound to the set same + * key. + */ +@Mixin(KeyMapping.class) +public class MixinKeyMapping { + @Unique + private static final Map VS2_KEYMAP = Maps.newHashMap(); + + @Shadow + @Final + private static Map MAP; + + @Shadow + @Final + private static Map ALL; + + @Shadow + private InputConstants.Key key; + + @Inject(method = "click", at = @At("HEAD")) + private static void preClick(final InputConstants.Key key, final CallbackInfo callbackInfo) { + final KeyMapping originalKeyMapping = MAP.get(key); + final KeyMapping vs2KeyMapping = VS2_KEYMAP.get(key); + if (vs2KeyMapping != null && originalKeyMapping != vs2KeyMapping) { + final KeyMappingAccessor keyMappingAccessor = (KeyMappingAccessor) vs2KeyMapping; + keyMappingAccessor.setClickCount(keyMappingAccessor.getClickCount() + 1); + } + } + + @Inject(method = "set", at = @At("HEAD")) + private static void preSet(final InputConstants.Key key, final boolean bl, final CallbackInfo callbackInfo) { + final KeyMapping originalKeyMapping = MAP.get(key); + final KeyMapping vs2KeyMapping = VS2_KEYMAP.get(key); + if (vs2KeyMapping != null && originalKeyMapping != vs2KeyMapping) { + vs2KeyMapping.setDown(bl); + } + } + + @Inject(method = "resetMapping", at = @At("HEAD")) + private static void preResetMapping(final CallbackInfo callbackInfo) { + VS2_KEYMAP.clear(); + for (final KeyMapping keyMapping : ALL.values()) { + if (VSKeyBindings.INSTANCE.isKeyMappingFromVS2(keyMapping)) { + final KeyMappingAccessor keyMappingAccessor = (KeyMappingAccessor) keyMapping; + VS2_KEYMAP.put(keyMappingAccessor.getKey(), keyMapping); + } + } + } + + @Inject(method = "(Ljava/lang/String;Lcom/mojang/blaze3d/platform/InputConstants$Type;ILjava/lang/String;)V", at = @At("RETURN"), remap = false) + private void postInit( + final String string, + final InputConstants.Type type, + final int i, + final String string2, + final CallbackInfo callbackInfo + ) { + final KeyMapping thisAsKeyMapping = KeyMapping.class.cast(this); + if (VSKeyBindings.INSTANCE.isKeyMappingFromVS2(thisAsKeyMapping)) { + VS2_KEYMAP.put(this.key, thisAsKeyMapping); + } + } +} diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 492442ce9..16591faa4 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -17,7 +17,9 @@ "world.level.block.FireMixin" ], "client": [ - "client.render.MixinLevelRenderer" + "client.render.MixinLevelRenderer", + "feature.duplicate_keybindings.KeyMappingAccessor", + "feature.duplicate_keybindings.MixinKeyMapping" ], "injectors": { "defaultRequire": 1 From e13b8ab8c35eae29e64cef29c6d8fcafde6921b1 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 5 Jun 2023 04:14:40 -0600 Subject: [PATCH 021/156] Fix forge server not launching --- .../mod/forge/common/ValkyrienSkiesModForge.kt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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 0ea3b854c..b94f8c8f8 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 @@ -82,8 +82,13 @@ class ValkyrienSkiesModForge { ITEMS.register(modBus) ENTITIES.register(modBus) BLOCK_ENTITIES.register(modBus) - modBus.addListener(::registerKeyBindings) - modBus.addListener(::entityRenderers) + + // Only run these on client to prevent loading client classes on server + if (isClient) { + modBus.addListener(::registerKeyBindings) + modBus.addListener(::entityRenderers) + } + modBus.addListener(::loadComplete) forgeBus.addListener(::registerCommands) From ceaa7cb2ca321827ebb835e13b7a3a91c9d707fc Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 5 Jun 2023 05:30:04 -0600 Subject: [PATCH 022/156] Fixed lava not working on forge --- .../valkyrienskies-common.mixins.json | 1 - .../water_in_ships_entity/MixinEntity.java | 2 +- .../valkyrienskies-fabric.mixins.json | 1 + .../water_in_ships_entity/MixinEntity.java | 181 ++++++++++++++++++ .../valkyrienskies-forge.mixins.json | 1 + 5 files changed, 184 insertions(+), 2 deletions(-) rename {common/src/main/java/org/valkyrienskies/mod => fabric/src/main/java/org/valkyrienskies/mod/fabric}/mixin/feature/water_in_ships_entity/MixinEntity.java (98%) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/water_in_ships_entity/MixinEntity.java diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index c7146a373..e3d3ea19b 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -41,7 +41,6 @@ "feature.shipyard_entities.MixinTransientEntitySectionManager", "feature.spawn_player_on_ship.MixinServerGamePacketListenerImpl", "feature.tick_ship_chunks.MixinChunkMap", - "feature.water_in_ships_entity.MixinEntity", "feature.world_border.MixinLevel", "feature.world_border.MixinWorldBorder", "mod_compat.create_big_cannons.MixinAbstractCannonProjectile", diff --git a/common/src/main/java/org/valkyrienskies/mod/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 similarity index 98% rename from common/src/main/java/org/valkyrienskies/mod/mixin/feature/water_in_ships_entity/MixinEntity.java rename to fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/water_in_ships_entity/MixinEntity.java index ecc3f5b40..a54f535e1 100644 --- a/common/src/main/java/org/valkyrienskies/mod/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 @@ -1,4 +1,4 @@ -package org.valkyrienskies.mod.mixin.feature.water_in_ships_entity; +package org.valkyrienskies.mod.fabric.mixin.feature.water_in_ships_entity; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 16591faa4..dab9070a3 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -12,6 +12,7 @@ "compat.create.MixinAbstractContraptionEntity", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", + "feature.water_in_ships_entity.MixinEntity", "server.network.MixinServerGamePacketListenerImpl", "server.network.MixinServerPlayerGameMode", "world.level.block.FireMixin" 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 new file mode 100644 index 000000000..70d1f439b --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/water_in_ships_entity/MixinEntity.java @@ -0,0 +1,181 @@ +package org.valkyrienskies.mod.forge.mixin.feature.water_in_ships_entity; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.material.FluidState; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.common.extensions.IForgeEntity; +import net.minecraftforge.fluids.FluidType; +import org.apache.commons.lang3.tuple.MutableTriple; +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.mod.common.VSGameUtilsKt; + +@Mixin(Entity.class) +public abstract class MixinEntity { + @Shadow + public Level level; + @Shadow + private AABB bb; + + @Shadow + public abstract double getEyeY(); + + @Shadow + public abstract double getX(); + + @Shadow + public abstract double getZ(); + + @Shadow + public abstract boolean touchingUnloadedChunk(); + + @Shadow + public abstract AABB getBoundingBox(); + + @Shadow + public abstract boolean isPushedByFluid(); + + @Shadow + public abstract Vec3 getDeltaMovement(); + + @Shadow + public abstract void setDeltaMovement(Vec3 vec3); + + @Unique + private boolean isShipWater = false; + + @Shadow + protected abstract void setFluidTypeHeight(FluidType type, double height); + + @Inject( + at = @At("HEAD"), + method = "updateFluidHeightAndDoFluidPushing()V", + remap = false + ) + // Overwrite the forge method, since it's written in a way that's really hard to precisely mixin into. + private void afterFluidStateUpdate(final CallbackInfo callbackInfo) { + if (this.touchingUnloadedChunk()) { + return; + } + VSGameUtilsKt.transformFromWorldToNearbyShipsAndWorld(level, this.getBoundingBox().deflate(0.001), aabb -> { + int i = Mth.floor(aabb.minX); + int j = Mth.ceil(aabb.maxX); + int k = Mth.floor(aabb.minY); + int l = Mth.ceil(aabb.maxY); + int i1 = Mth.floor(aabb.minZ); + int j1 = Mth.ceil(aabb.maxZ); + double d0 = 0.0; + boolean flag = this.isPushedByFluid(); + boolean flag1 = false; + Vec3 vec3 = Vec3.ZERO; + boolean k1 = false; + BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(); + Object2ObjectArrayMap + interimCalcs = new Object2ObjectArrayMap((Integer) FluidType.SIZE.get() - 1); + for (int l1 = i; l1 < j; ++l1) { + for (int i2 = k; i2 < l; ++i2) { + for (int j2 = i1; j2 < j1; ++j2) { + double d1; + blockpos$mutableblockpos.set(l1, i2, j2); + FluidState fluidstate = this.level.getFluidState(blockpos$mutableblockpos); + FluidType fluidType2 = fluidstate.getFluidType(); + if (fluidType2.isAir() || !((d1 = + (double) ((float) i2 + fluidstate.getHeight(this.level, blockpos$mutableblockpos))) >= + aabb.minY)) continue; + flag1 = true; + MutableTriple interim2 = + interimCalcs.computeIfAbsent(fluidType2, t -> MutableTriple.of(0.0, Vec3.ZERO, 0)); + interim2.setLeft(Math.max(d1 - aabb.minY, (Double) interim2.getLeft())); + if (!((IForgeEntity) this).isPushedByFluid(fluidType2)) continue; + Vec3 vec31 = fluidstate.getFlow(this.level, blockpos$mutableblockpos); + if ((Double) interim2.getLeft() < 0.4) { + vec31 = vec31.scale((Double) interim2.getLeft()); + } + interim2.setMiddle(((Vec3) interim2.getMiddle()).add(vec31)); + interim2.setRight((Integer) interim2.getRight() + 1); + } + } + } + interimCalcs.forEach((fluidType, interim) -> { + if (((Vec3) interim.getMiddle()).length() > 0.0) { + if ((Integer) interim.getRight() > 0) { + interim.setMiddle(((Vec3) interim.getMiddle()).scale( + 1.0 / (double) ((Integer) interim.getRight()).intValue())); + } + if (!Player.class.isInstance(this)) { + interim.setMiddle(((Vec3) interim.getMiddle()).normalize()); + } + Vec3 vec32 = this.getDeltaMovement(); + interim.setMiddle(((Vec3) interim.getMiddle()).scale( + ((IForgeEntity) this).getFluidMotionScale((FluidType) fluidType))); + double d2 = 0.003; + if (Math.abs(vec32.x) < 0.003 && Math.abs(vec32.z) < 0.003 && + ((Vec3) interim.getMiddle()).length() < 0.0045000000000000005) { + interim.setMiddle(((Vec3) interim.getMiddle()).normalize().scale(0.0045000000000000005)); + } + this.setDeltaMovement(this.getDeltaMovement().add((Vec3) interim.getMiddle())); + } + this.setFluidTypeHeight((FluidType) fluidType, (Double) interim.getLeft()); + }); + }); + } + + @WrapOperation( + at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/level/Level;getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"), + method = "updateFluidOnEyes" + ) + private FluidState getFluidStateRedirect(final Level level, final BlockPos blockPos, + final Operation getFluidState) { + final FluidState[] fluidState = {getFluidState.call(level, blockPos)}; + isShipWater = false; + if (fluidState[0].isEmpty()) { + + final double d = this.getEyeY() - 0.1111111119389534; + + final double origX = this.getX(); + final double origY = d; + final double origZ = this.getZ(); + + VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level, origX, origY, origZ, this.bb.getSize(), + (x, y, z) -> { + fluidState[0] = getFluidState.call(level, new BlockPos(x, y, z)); + }); + isShipWater = true; + } + return fluidState[0]; + } + + @WrapOperation( + at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/level/material/FluidState;getHeight(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;)F"), + method = "updateFluidOnEyes" + ) + private float fluidHeightOverride(final FluidState instance, final BlockGetter arg, final BlockPos arg2, + final Operation getHeight) { + if (!instance.isEmpty() && this.level instanceof Level) { + + if (isShipWater) { + if (instance.isSource()) { + return 1; + } + } + + } + return getHeight.call(instance, arg, arg2); + } + +} diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 96701e995..57ba7bb5e 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -16,6 +16,7 @@ "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", "feature.forge_interact.MixinIForgePlayer", + "feature.water_in_ships_entity.MixinEntity", "world.level.block.FireMixin" ], "client": [ From 8a7faf21853039993b07a33655e732a5db91e0fe Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 5 Jun 2023 06:49:30 -0600 Subject: [PATCH 023/156] Fixed compatibility with Cull Leaves mod --- .../sodium/MixinRegionChunkRenderer.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRegionChunkRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRegionChunkRenderer.java index a4dcc8298..18f2d1376 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRegionChunkRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRegionChunkRenderer.java @@ -18,7 +18,7 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.mixinducks.mod_compat.sodium.RegionChunkRendererDuck; -@Mixin(value = RegionChunkRenderer.class, remap = false) +@Mixin(value = RegionChunkRenderer.class, remap = false, priority = 1101) public class MixinRegionChunkRenderer implements RegionChunkRendererDuck { @Unique @@ -27,28 +27,29 @@ public class MixinRegionChunkRenderer implements RegionChunkRendererDuck { @Unique private final Vector3d camInShip = new Vector3d(); - @Redirect( + @WrapOperation( at = @At( value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSection;getBounds()Lme/jellysquid/mods/sodium/client/render/chunk/data/ChunkRenderBounds;" ), method = "buildDrawBatches" ) - private ChunkRenderBounds injectBuildDrawBatches(final RenderSection section, final List sections, - final BlockRenderPass pass, final ChunkCameraContext c) { - + private ChunkRenderBounds injectBuildDrawBatches( + final RenderSection section, final Operation getBounds, final List sections, + final BlockRenderPass pass, final ChunkCameraContext c + ) { final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, section.getChunkX(), section.getChunkZ()); if (ship != null) { ship.getRenderTransform().getWorldToShip().transformPosition(camInWorld, camInShip); - final ChunkRenderBounds originalBounds = section.getBounds(); + final ChunkRenderBounds originalBounds = getBounds.call(section); return new ChunkRenderBounds(originalBounds.x1 - 1.9f, originalBounds.y1 - 1.9f, originalBounds.z1 - 1.9f, originalBounds.x2 + 1.9f, originalBounds.y2 + 1.9f, originalBounds.z2 + 1.9f); } else { camInShip.set(camInWorld); - return section.getBounds(); + return getBounds.call(section); } } From cc3901ad137a31a0091dee8a1956467c042f4857 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 8 Jun 2023 19:05:50 -0600 Subject: [PATCH 024/156] Fixed fabric failing to launch --- .../feature/duplicate_keybindings/MixinKeyMapping.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/MixinKeyMapping.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/MixinKeyMapping.java index 3a1401e85..3e20fe9f9 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/MixinKeyMapping.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/duplicate_keybindings/MixinKeyMapping.java @@ -64,14 +64,8 @@ private static void preResetMapping(final CallbackInfo callbackInfo) { } } - @Inject(method = "(Ljava/lang/String;Lcom/mojang/blaze3d/platform/InputConstants$Type;ILjava/lang/String;)V", at = @At("RETURN"), remap = false) - private void postInit( - final String string, - final InputConstants.Type type, - final int i, - final String string2, - final CallbackInfo callbackInfo - ) { + @Inject(method = "", at = @At("RETURN"), remap = false) + private void postInit(final CallbackInfo callbackInfo) { final KeyMapping thisAsKeyMapping = KeyMapping.class.cast(this); if (VSKeyBindings.INSTANCE.isKeyMappingFromVS2(thisAsKeyMapping)) { VS2_KEYMAP.put(this.key, thisAsKeyMapping); From fb44adc8e8cf364daea125a385e3810b44efc32b Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 9 Jun 2023 02:54:34 -0400 Subject: [PATCH 025/156] require MC 1.19.2 --- fabric/src/main/resources/fabric.mod.json | 2 +- forge/src/main/resources/META-INF/mods.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 1b5e4680a..48ad3da8f 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.2", "fabric": "*" }, "breaks": { diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 58b0a0433..99510ab45 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.18.2,)" +versionRange = "[1.19.2]" ordering = "NONE" side = "BOTH" From de95b2cd2929637b66b1dfc3ef3318e250986dc8 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 9 Jun 2023 03:01:56 -0400 Subject: [PATCH 026/156] bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 840045741..ec1bcfb3c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.19.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-1192 -mod_version=2.2.0-beta.1 +mod_version=2.2.0-beta.2 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 fabric_loader_version=0.14.11 From af75aac04897e73b72332603ece303288a302f4c Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 9 Jun 2023 04:46:41 -0400 Subject: [PATCH 027/156] warn on broken big cannons mixin --- .../valkyrienskies/mod/mixin/ValkyrienMixinErrorHandler.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 52d011744..a5fa9a31d 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienMixinErrorHandler.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienMixinErrorHandler.java @@ -10,7 +10,9 @@ 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.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" )); @Override From 2ad8817bc50bfcf86bc7ee147b90ef22213b710a Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 9 Jun 2023 04:46:53 -0400 Subject: [PATCH 028/156] bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index ec1bcfb3c..82baba634 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.19.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-1192 -mod_version=2.2.0-beta.2 +mod_version=2.2.0-beta.3 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 fabric_loader_version=0.14.11 From 9175524ed6e81dce75150755fe922f78d4c2462a Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 12 Jun 2023 19:11:51 -0600 Subject: [PATCH 029/156] Initial work on 1.20 --- common/build.gradle | 14 +-- .../accessors/util/math/Matrix4fAccessor.java | 108 ------------------ .../mod/mixin/client/MixinGame.java | 26 ----- .../mod/mixin/client/MixinMinecraft.java | 8 ++ .../mod/common/BlockStateInfoProvider.kt | 2 +- .../common/DefaultBlockStateInfoProvider.kt | 16 ++- .../valkyrienskies/mod/common/PlayerUtil.kt | 2 +- .../mod/common/VSClientGameUtils.kt | 24 ---- .../valkyrienskies/mod/common/VSGameUtils.kt | 4 +- .../mod/common/block/TestChairBlock.kt | 6 +- .../mod/common/block/TestFlapBlock.kt | 4 +- .../mod/common/block/TestHingeBlock.kt | 6 +- .../mod/common/block/TestWingBlock.kt | 4 +- .../mod/common/command/VSCommands.kt | 2 +- .../config/VSEntityHandlerDataLoader.kt | 4 +- .../mod/common/config/VSMassDataLoader.kt | 17 +-- .../mod/common/entity/ShipMountingEntity.kt | 26 +++-- .../handling/AbstractShipyardEntityHandler.kt | 5 +- .../common/entity/handling/VSEntityManager.kt | 8 +- .../entity/handling/WorldEntityHandler.kt | 4 +- .../mod/common/hooks/VSGameEvents.kt | 2 +- .../mod/common/networking/VSGamePackets.kt | 5 +- .../mod/common/util/EntityDragger.kt | 4 +- .../common/util/EntityShipCollisionUtils.kt | 4 +- .../mod/common/util/MinecraftPlayer.kt | 2 +- .../mod/common/world/RaycastUtils.kt | 4 +- .../mod/util/VectorConversionsMC.kt | 103 +++-------------- .../valkyrienskies-common.mixins.json | 2 - fabric/build.gradle | 22 ++-- forge/build.gradle | 12 +- gradle.properties | 12 +- 31 files changed, 126 insertions(+), 336 deletions(-) delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/accessors/util/math/Matrix4fAccessor.java delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinGame.java diff --git a/common/build.gradle b/common/build.gradle index 575ed38f5..ec0240757 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -8,7 +8,7 @@ dependencies { modApi("me.shedaniel.cloth:cloth-config:4.14.64") - modCompileOnly("curse.maven:sodium-394468:3669187") + // modCompileOnly("curse.maven:sodium-394468:3669187") // vs-core implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") { @@ -18,15 +18,15 @@ dependencies { } // FTB Stuffs - modCompileOnly("curse.maven:ftb-util-404465:4210935") - modCompileOnly("curse.maven:ftb-teams-404468:4229138") - modCompileOnly("curse.maven:ftb-chunks-314906:4229120") + // modCompileOnly("curse.maven:ftb-util-404465:4210935") + // modCompileOnly("curse.maven:ftb-teams-404468:4229138") + // modCompileOnly("curse.maven:ftb-chunks-314906:4229120") //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.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.8.a-4") + // modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") + // { exclude group: 'com.github.AlphaMode', module: 'fakeconfigtoml' } + // modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.8.a-4") } architectury { 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/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/MixinMinecraft.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java index 56283a70b..89f80b05b 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java @@ -150,4 +150,12 @@ public void deleteShipObjectWorldClient() { shipObjectWorldCopy.destroyWorld(); shipObjectWorld = null; } + + @Inject( + method = "clearLevel", + at = @At("TAIL") + ) + private void postClearLevel(final CallbackInfo ci) { + deleteShipObjectWorldClient(); + } } 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 c3495e18f..8270fccf4 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -37,7 +37,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/DefaultBlockStateInfoProvider.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt index 476c17c2e..389c53940 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt @@ -1,7 +1,8 @@ package org.valkyrienskies.mod.common +import net.minecraft.world.level.block.Blocks +import net.minecraft.world.level.block.LiquidBlock import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.Material import org.valkyrienskies.core.apigame.world.chunks.BlockType object DefaultBlockStateInfoProvider : BlockStateInfoProvider { @@ -16,9 +17,14 @@ object DefaultBlockStateInfoProvider : BlockStateInfoProvider { override fun getBlockStateType(blockState: BlockState): BlockType { if (blockState.isAir) return vsCore.blockTypes.air - val blockMaterial = blockState.material - if (blockMaterial.isLiquid) - return if (blockMaterial == Material.LAVA) vsCore.blockTypes.lava else vsCore.blockTypes.water - return if (blockMaterial.isSolid) vsCore.blockTypes.solid else vsCore.blockTypes.air + val block = blockState.block + if (block is LiquidBlock) { + return if (block == Blocks.LAVA) { + vsCore.blockTypes.lava + } else { + vsCore.blockTypes.water + } + } + return if (blockState.isSolid) vsCore.blockTypes.solid else vsCore.blockTypes.air } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt index ce0890a0b..c1550aeca 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt @@ -25,7 +25,7 @@ object PlayerUtil { @JvmStatic fun transformPlayerTemporarily(player: Player, ship: LoadedShip?) { - if (player.level.isBlockInShipyard(player.x, player.y, player.z)) { + if (player.level().isBlockInShipyard(player.x, player.y, player.z)) { // player is already in shipyard return } 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 090da4119..29478af85 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 { @@ -61,29 +60,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 2bb4b6347..3bb5ae302 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -117,7 +117,7 @@ val Player.playerWrapper get() = (this as PlayerDuck).vs_getPlayer() * Like [Entity.squaredDistanceTo] except the destination is transformed into world coordinates if it is a ship */ fun Entity.squaredDistanceToInclShips(x: Double, y: Double, z: Double) = - level.squaredDistanceBetweenInclShips(x, y, z, this.x, this.y, this.z) + level().squaredDistanceBetweenInclShips(x, y, z, this.x, this.y, this.z) /** * Calculates the squared distance between to points. @@ -305,7 +305,7 @@ fun ClientLevel?.transformRenderAABBToWorld(pos: Position, aabb: AABB): AABB { return aabb } -fun Entity.getShipManaging(): Ship? = this.level.getShipManagingPos(this.position()) +fun Entity.getShipManaging(): Ship? = this.level().getShipManagingPos(this.position()) // Level fun Level?.getShipManagingPos(chunkX: Int, chunkZ: Int) = diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestChairBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestChairBlock.kt index 738fcfb1c..d351871ca 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestChairBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestChairBlock.kt @@ -14,7 +14,7 @@ import net.minecraft.world.level.block.HorizontalDirectionalBlock import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -28,7 +28,7 @@ import org.valkyrienskies.mod.common.util.toDoubles object TestChairBlock : HorizontalDirectionalBlock( - Properties.of(Material.WOOL).strength(1.0f, 120.0f).sound(SoundType.WOOL) + Properties.of().mapColor(MapColor.WOOL).strength(1.0f, 120.0f).sound(SoundType.WOOL).requiresCorrectToolForDrops() ) { private val SEAT_AABB: VoxelShape = box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0) @@ -47,7 +47,7 @@ object TestChairBlock : @Deprecated("Deprecated in Java") override fun getShape( - state: BlockState, level: BlockGetter?, pos: BlockPos?, context: CollisionContext? + state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext ): VoxelShape = SEAT_AABB @Deprecated("Deprecated in Java") diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestFlapBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestFlapBlock.kt index 60a505200..c3d3506af 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestFlapBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestFlapBlock.kt @@ -15,7 +15,7 @@ import net.minecraft.world.level.block.DirectionalBlock import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import org.valkyrienskies.core.api.ships.Wing @@ -23,7 +23,7 @@ import org.valkyrienskies.mod.common.util.toJOMLD object TestFlapBlock : DirectionalBlock( - Properties.of(Material.METAL).strength(10.0f, 1200.0f).sound(SoundType.METAL) + Properties.of().mapColor(MapColor.METAL).strength(10.0f, 1200.0f).sound(SoundType.METAL).requiresCorrectToolForDrops() ), WingBlock { private val EAST_AABB = box(4.0, 0.0, 0.0, 12.0, 16.0, 16.0) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestHingeBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestHingeBlock.kt index b22a496ec..0acece596 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestHingeBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestHingeBlock.kt @@ -24,7 +24,7 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -47,7 +47,7 @@ import kotlin.math.roundToInt object TestHingeBlock : DirectionalBlock( - Properties.of(Material.METAL).strength(10.0f, 1200.0f).sound(SoundType.METAL) + Properties.of().mapColor(MapColor.METAL).strength(10.0f, 1200.0f).sound(SoundType.WOOL).requiresCorrectToolForDrops() ), EntityBlock { private val EAST_AABB = box(0.0, 0.0, 0.0, 8.0, 16.0, 16.0) @@ -71,7 +71,7 @@ object TestHingeBlock : @Deprecated("Deprecated in Java") override fun getShape( - state: BlockState, level: BlockGetter?, pos: BlockPos?, context: CollisionContext? + state: BlockState, level: BlockGetter, pos: BlockPos, context: CollisionContext ): VoxelShape { when (state.getValue(FACING)) { DOWN -> { diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt index b7c9e808a..6b3fee44f 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt @@ -15,7 +15,7 @@ import net.minecraft.world.level.block.DirectionalBlock import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.material.Material +import net.minecraft.world.level.material.MapColor import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import org.valkyrienskies.core.api.ships.Wing @@ -23,7 +23,7 @@ import org.valkyrienskies.mod.common.util.toJOMLD object TestWingBlock : DirectionalBlock( - Properties.of(Material.METAL).strength(10.0f, 1200.0f).sound(SoundType.METAL) + Properties.of().mapColor(MapColor.METAL).strength(10.0f, 1200.0f).sound(SoundType.WOOL).requiresCorrectToolForDrops() ), WingBlock { private val EAST_AABB = box(4.0, 0.0, 0.0, 12.0, 16.0, 16.0) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt index 0a3f73197..07e692ef5 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt @@ -257,7 +257,7 @@ object VSCommands { if (sourceEntity != null) { val rayTrace = sourceEntity.pick(10.0, 1.0.toFloat(), false) if (rayTrace is BlockHitResult) { - val ship = sourceEntity.level.getShipManagingPos(rayTrace.blockPos) + val ship = sourceEntity.level().getShipManagingPos(rayTrace.blockPos) if (ship != null) { (it.source as VSCommandSource).sendVSMessage( Component.translatable(GET_SHIP_SUCCESS_MESSAGE, ship.slug) 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 06139f2e3..4ce7006f7 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 @@ -3,7 +3,8 @@ package org.valkyrienskies.mod.common.config import com.google.gson.Gson import com.google.gson.JsonElement 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 @@ -29,18 +30,18 @@ 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): VSBlockType? = - map[Registry.BLOCK.getKey(blockState.block)]?.type + map[BuiltInRegistries.BLOCK.getKey(blockState.block)]?.type class VSMassDataLoader : SimpleJsonResourceReloadListener(Gson(), "vs_mass") { private val tags = mutableListOf() override fun apply( - objects: MutableMap?, - resourceManager: ResourceManager?, - profiler: ProfilerFiller? + objects: MutableMap, + resourceManager: ResourceManager, + profiler: ProfilerFiller ) { map.clear() tags.clear() @@ -63,7 +64,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()) { @@ -74,7 +75,7 @@ object MassDatapackResolver : BlockStateInfoProvider { tag.get().forEach { add( VSBlockStateInfo( - Registry.BLOCK.getKey(it.value()), tagInfo.priority, tagInfo.mass, tagInfo.type + BuiltInRegistries.BLOCK.getKey(it.value()), tagInfo.priority, tagInfo.mass, tagInfo.type ) ) } 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 8f7577e38..1f778ff4a 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,9 +3,11 @@ 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 +import net.minecraft.world.entity.LivingEntity import net.minecraft.world.level.Level import org.joml.Vector3f import org.valkyrienskies.core.api.ships.LoadedServerShip @@ -31,34 +33,34 @@ open class ShipMountingEntity(type: EntityType, level: Level override fun tick() { super.tick() - if (!level.isClientSide && passengers.isEmpty()) { + if (!level().isClientSide && passengers.isEmpty()) { // Kill this entity if nothing is riding it kill() return } - if (level.getShipObjectManagingPos(blockPosition()!!) != null) + if (level().getShipObjectManagingPos(blockPosition()) != null) sendDrivingPacket() } - override fun readAdditionalSaveData(compound: CompoundTag?) { + override fun readAdditionalSaveData(compoundTag: CompoundTag) { } - override fun addAdditionalSaveData(compound: CompoundTag?) { + override fun addAdditionalSaveData(compoundTag: CompoundTag) { } override fun defineSynchedData() { } override fun remove(removalReason: RemovalReason) { - if (this.isController && !level.isClientSide) - (level.getShipObjectManagingPos(blockPosition()) as LoadedServerShip?) + if (this.isController && !level().isClientSide) + (level().getShipObjectManagingPos(blockPosition()) as LoadedServerShip?) ?.setAttachment(null) super.remove(removalReason) } private fun sendDrivingPacket() { - if (!level.isClientSide) return + if (!level().isClientSide) return // todo: custom keybinds for going up down and all around but for now lets just use the mc defaults val opts = Minecraft.getInstance().options val forward = opts.keyUp.isDown @@ -78,11 +80,15 @@ open class ShipMountingEntity(type: EntityType, level: Level PacketPlayerDriving(impulse, sprint, cruise).sendToServer() } - 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/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 8a45a3a62..c8dbdef39 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 @@ -72,7 +72,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 +91,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/entity/handling/WorldEntityHandler.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/WorldEntityHandler.kt index 11574a70d..bdd29d4bb 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/WorldEntityHandler.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/WorldEntityHandler.kt @@ -37,12 +37,12 @@ object WorldEntityHandler : VSEntityHandler { } override fun positionSetFromVehicle(self: Entity, vehicle: Entity, x: Double, y: Double, z: Double) { - val (wx, wy, wz) = self.level.toWorldCoordinates(x, y, z) + val (wx, wy, wz) = self.level().toWorldCoordinates(x, y, z) self.setPos(wx, wy, wz) } override fun getTeleportPos(self: Entity, pos: Vector3d): Vector3d { - return self.level.toWorldCoordinates(pos) + return self.level().toWorldCoordinates(pos) } override fun applyRenderOnMountedEntity( 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 fd3a1ccaf..65124d70f 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.impl.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 7c1efeb1b..4e245c9b6 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,7 @@ 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 @@ -30,7 +31,7 @@ object VSGamePackets { val seat = player.vehicle as? ShipMountingEntity ?: return@registerServerHandler if (seat.isController) { - val ship = seat.level.getShipObjectManagingPos(seat.blockPosition()) as? LoadedServerShip + val ship = seat.level().getShipObjectManagingPos(seat.blockPosition()) as? LoadedServerShip ?: return@registerServerHandler val attachment: SeatedControllingPlayer = ship.getAttachment() @@ -48,7 +49,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/EntityDragger.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDragger.kt index 64472ca35..4a2403548 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDragger.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDragger.kt @@ -20,7 +20,7 @@ object EntityDragger { */ fun dragEntitiesWithShips(entities: Iterable) { entities.forEach { entity -> - val shipMountedTo = entity.level.getShipObjectEntityMountedTo(entity) + val shipMountedTo = entity.level().getShipObjectEntityMountedTo(entity) // Don't drag entities that are already mounted to a ship if (shipMountedTo != null) return@forEach @@ -34,7 +34,7 @@ object EntityDragger { if (shipDraggingEntity != null) { if (entityDraggingInformation.isEntityBeingDraggedByAShip()) { // Compute how much we should drag the entity - val shipData = entity.level.shipObjectWorld.queryableShipData.getById(shipDraggingEntity) + val shipData = entity.level().shipObjectWorld.queryableShipData.getById(shipDraggingEntity) if (shipData != null) { dragTheEntity = true 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 974209d04..235dc6870 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 @@ -24,7 +24,7 @@ object EntityShipCollisionUtils { @JvmStatic fun isCollidingWithUnloadedShips(entity: Entity): Boolean { - val level = entity.level + val level = entity.level() if (level is ServerLevel || (level.isClientSide && level is ClientLevel)) { if (level.isClientSide && level is ClientLevel && !level.shipObjectWorld.isSyncedWithServer) { @@ -74,7 +74,7 @@ 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 // 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/util/MinecraftPlayer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/MinecraftPlayer.kt index 9aa72026b..b82f29afd 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/MinecraftPlayer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/MinecraftPlayer.kt @@ -28,7 +28,7 @@ class MinecraftPlayer(playerObject: Player) : IPlayer { get() = vsCore.hooks.isPhysicalClient || player.hasPermissions(4) override val dimension: DimensionId - get() = player.level.dimensionId + get() = player.level().dimensionId override fun getPosition(dest: Vector3d): Vector3d { return dest.set(player.x, player.y, player.z) 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 2b132b940..fe8ae339f 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 } @@ -270,6 +270,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/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 e3d3ea19b..57007a566 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -8,7 +8,6 @@ "accessors.network.protocol.game.ClientboundSectionBlocksUpdatePacketAccessor", "accessors.resource.ResourceKeyAccessor", "accessors.server.world.ChunkMapAccessor", - "accessors.util.math.Matrix4fAccessor", "accessors.world.level.pathfinder.PathAccessor", "entity.MixinEntity", "feature.ai.node_evaluator.PathNavigationRegionAccessor", @@ -71,7 +70,6 @@ "accessors.client.render.chunk.RenderChunkAccessor", "accessors.client.world.ClientChunkCacheStorageAccessor", "client.MixinCamera", - "client.MixinGame", "client.MixinMinecraft", "client.multiplayer.MixinClientPacketListener", "client.player.MixinLocalPlayer", diff --git a/fabric/build.gradle b/fabric/build.gradle index fca29a112..7be6bfe00 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -38,10 +38,10 @@ dependencies { // Depend on the fabric kotlin mod include(modImplementation("net.fabricmc:fabric-language-kotlin:1.8.5+kotlin.1.7.20")) - include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:6.3.81")) + // include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:6.3.81")) - modImplementation("curse.maven:sodium-394468:3957319") - modImplementation("com.terraformersmc:modmenu:4.1.0") + // modImplementation("curse.maven:sodium-394468:3957319") + // modImplementation("com.terraformersmc:modmenu:4.1.0") // Depend on the fabric API modImplementation("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}") @@ -62,16 +62,16 @@ dependencies { } // CC Restitched - modImplementation("curse.maven:cc-restitched-462672:3908334") + // modImplementation("curse.maven:cc-restitched-462672:3908334") // Create compat - modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_version}+${minecraft_version}") { transitive = false } - modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version}") - modImplementation("com.tterrag.registrate_fabric:Registrate:${registrate_version}") - modImplementation("io.github.fabricators_of_create.Porting-Lib:porting-lib:${port_lib_version}+${minecraft_version}") - modImplementation("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") - modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") - modImplementation("io.github.tropheusj:milk-lib:${milk_lib_version}") + // modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_version}+${minecraft_version}") { transitive = false } + // modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version}") + // modImplementation("com.tterrag.registrate_fabric:Registrate:${registrate_version}") + // modImplementation("io.github.fabricators_of_create.Porting-Lib:porting-lib:${port_lib_version}+${minecraft_version}") + // modImplementation("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") + // modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") + // modImplementation("io.github.tropheusj:milk-lib:${milk_lib_version}") } // Copy the VS common access widener to the generated resources folder diff --git a/forge/build.gradle b/forge/build.gradle index aedf61aec..ed604bdfb 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -66,20 +66,20 @@ dependencies { modCompileOnly("curse.maven:rubidium-574856:4024781") // 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}") // CC Tweaked - modCompileOnly("curse.maven:cc-tweaked-282001:4061947") + // modCompileOnly("curse.maven:cc-tweaked-282001:4061947") // TIS-3d - modCompileOnly("curse.maven:tis3d-238603:3738437") + // modCompileOnly("curse.maven:tis3d-238603:3738437") //modImplementation("curse.maven:tis3d-238603:3738437") //modImplementation("curse.maven:markdownmanual-502485:3738124") // Add Kotlin for Forge. - forgeRuntimeLibrary('curse.maven:kotlinforforge-351264:3925887') + forgeRuntimeLibrary('curse.maven:kotlinforforge-351264:4578885') // Cloth for config include(modImplementation("me.shedaniel.cloth:cloth-config-forge:8.2.88")) diff --git a/gradle.properties b/gradle.properties index 82baba634..8986bff12 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,13 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G -minecraft_version=1.19.2 +minecraft_version=1.20 enabled_platforms=quilt,fabric,forge -archives_base_name=valkyrienskies-1192 -mod_version=2.2.0-beta.3 +archives_base_name=valkyrienskies-1200 +mod_version=2.3.0-beta.1 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 -fabric_loader_version=0.14.11 -fabric_api_version=0.73.2+1.19.2 -forge_version=1.19.2-43.1.47 +fabric_loader_version=0.14.21 +fabric_api_version=0.83.0+1.20 +forge_version=1.20-46.0.14 create_fabric_version=0.5.0.i-1017+1.19.2 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually From 431dbf01adfb128147ee241543289b85de5ae928 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 12 Jun 2023 21:25:49 -0600 Subject: [PATCH 030/156] Well it compiles --- common/build.gradle | 2 +- .../resource/ResourceKeyAccessor.java | 5 ++-- .../mod/mixin/client/MixinCamera.java | 15 ++++++----- .../MixinClientPacketListener.java | 2 +- .../client/renderer/MixinGameRenderer.java | 22 ++++++++-------- .../client/world/MixinClientChunkCache.java | 2 +- .../mod/mixin/entity/MixinEntity.java | 5 ++-- .../SwimNodeEvaluatorMixin.java | 8 +++--- .../WalkNodeEvaluatorMixin.java | 2 +- .../feature/bed_fix/MixinServerPlayer.java | 2 +- .../feature/clip_replace/MixinLevel.java | 2 +- .../feature/entity_collision/MixinEntity.java | 4 +-- .../feature/explosions/MixinExplosion.java | 2 +- .../LavaFluidMixin.java | 2 +- .../feature/fluid_camera_fix/MixinCamera.java | 2 +- .../feature/ladders/MixinLivingEntity.java | 2 +- .../render_leashes/MixinMobRenderer.java | 2 +- .../shipyard_entities/MixinEntity.java | 2 +- .../MixinEntityRenderDispatcher.java | 6 ++--- .../shipyard_entities/MixinServerLevel.java | 2 +- .../tick_ship_chunks/MixinChunkMap.java | 2 +- .../mixin/feature/vs2_alpha_hud/MixinGui.java | 14 +++-------- .../MixinAbstractCannonProjectile.java | 3 +++ .../MixinPitchOrientedContraptionEntity.java | 2 ++ .../flywheel/InstancingEngineAccessor.java | 2 ++ .../MixinBlockEntityInstanceManager.java | 2 ++ .../flywheel/MixinInstanceManager.java | 2 ++ .../flywheel/MixinInstanceWorld.java | 2 ++ .../flywheel/MixinInstancingEngine.java | 2 ++ .../ftb_chunks/MixinClaimedChunkManager.java | 2 ++ .../optifine/MixinViewAreaOptifine.java | 6 ++--- .../optifine_vanilla/MixinLevelRenderer.java | 2 +- .../MixinLevelRendererVanilla.java | 6 ++--- .../MixinViewAreaVanilla.java | 6 ++--- .../mixin/server/MixinMinecraftServer.java | 6 ++--- .../MixinServerGamePacketListenerImpl.java | 11 ++++---- .../world/MixinChunkMap$TrackedEntity.java | 2 +- .../mod/mixin/server/world/MixinChunkMap.java | 4 +-- .../mixin/server/world/MixinServerLevel.java | 2 +- .../projectile/ProjectileUtilMixin.java | 4 +-- .../mod/mixin/world/level/MixinLevel.java | 9 +++---- .../MixinBlockEntityInstanceManagerDuck.java | 2 ++ .../mixinducks/MixinInstancingEngineDuck.java | 2 ++ .../valkyrienskies/mod/common/VSGameUtils.kt | 11 +++----- .../valkyrienskies-common.accesswidener | 2 ++ .../valkyrienskies-common.mixins.json | 8 ------ fabric/build.gradle | 2 +- .../client/render/MixinLevelRenderer.java | 10 ++++---- .../cc_restitched/MixinSpeakerPosition.java | 2 ++ .../cc_restitched/MixinTurtleBrain.java | 2 ++ .../cc_restitched/MixinTurtleMoveCommand.java | 2 ++ .../cc_restitched/MixinWirelessNetwork.java | 2 ++ .../mixin/compat/create/Matrix3dAccessor.java | 2 ++ .../MixinAbstractContraptionEntity.java | 2 ++ .../water_in_ships_entity/MixinEntity.java | 2 +- .../network/MixinServerPlayerGameMode.java | 2 +- .../mixin/world/level/block/FireMixin.java | 7 +++--- .../ContraptionShipyardEntityHandlerFabric.kt | 2 ++ .../mod/fabric/common/CreateConversions.kt | 2 ++ .../fabric/common/ValkyrienSkiesModFabric.kt | 25 ++++++++++--------- .../fabric/compat/modmenu/ValkyrienModMenu.kt | 2 ++ .../valkyrienskies-fabric.mixins.json | 6 ----- .../ContraptionShipyardEntityHandlerForge.kt | 2 ++ 63 files changed, 148 insertions(+), 133 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index ec0240757..0ce69d5b4 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -8,7 +8,7 @@ dependencies { modApi("me.shedaniel.cloth:cloth-config:4.14.64") - // modCompileOnly("curse.maven:sodium-394468:3669187") + modCompileOnly("maven.modrinth:sodium:mc1.20-0.4.10") // vs-core implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") { 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..eb9ea74c4 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,7 +1,8 @@ package org.valkyrienskies.mod.mixin.accessors.resource; -import java.util.Map; +import java.util.concurrent.ConcurrentMap; import net.minecraft.resources.ResourceKey; +import net.minecraft.resources.ResourceKey.InternKey; import net.minecraft.resources.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @@ -11,7 +12,7 @@ public interface ResourceKeyAccessor { @Accessor("VALUES") - static Map> getValues() { + static ConcurrentMap> getValues() { throw new AssertionError(); } 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/multiplayer/MixinClientPacketListener.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java index 2f75949b9..6f99f33b8 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java @@ -71,7 +71,7 @@ private void teleportingWithNoStep(final Entity instance, final double x, final double y, final double z, final float yRot, final float xRot, final int lerpSteps, final boolean teleport, final Operation lerpTo) { - if (VSGameUtilsKt.getShipObjectManagingPos(instance.level, instance.getX(), instance.getY(), instance.getZ()) != + if (VSGameUtilsKt.getShipObjectManagingPos(instance.level(), instance.getX(), instance.getY(), instance.getZ()) != null) { instance.setPos(x, y, z); lerpTo.call(instance, x, y, z, yRot, xRot, 1, teleport); 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 04543da1a..88de221ca 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; @@ -33,7 +33,6 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; 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; @@ -64,7 +63,7 @@ private static HitResult entityRaycastNoTransform( final Vec3 vec3d2 = entity.getViewVector(tickDelta); final Vec3 vec3d3 = vec3d.add(vec3d2.x * maxDistance, vec3d2.y * maxDistance, vec3d2.z * maxDistance); return RaycastUtilsKt.clipIncludeShips( - entity.level, + entity.level(), new ClipContext( vec3d, vec3d3, @@ -273,16 +272,15 @@ private void setupCameraWithMountedShip(final LevelRenderer instance, final Pose ); // Apply the ship render transform to [matrixStack] - final Quaternion invShipRenderRotation = VectorConversionsMCKt.toMinecraft( - playerShipMountedTo.getRenderTransform().getShipToWorldRotation().conjugate(new Quaterniond())); - matrixStack.mulPose(invShipRenderRotation); + final Quaterniond invShipRenderRotation = + playerShipMountedTo.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/client/world/MixinClientChunkCache.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientChunkCache.java index 1f3a2cdfc..5138bd6df 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientChunkCache.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientChunkCache.java @@ -66,7 +66,7 @@ private void preLoadChunkFromPacket(final int x, final int z, final LevelChunkSection[] chunkSections = worldChunk.getSections(); final LevelLightEngine lightingProvider = this.getLightEngine(); - lightingProvider.enableLightSources(new ChunkPos(x, z), true); + lightingProvider.setLightEnabled(new ChunkPos(x, z), true); for (int j = 0; j < chunkSections.length; ++j) { final LevelChunkSection chunkSection = chunkSections[j]; 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 d22a6a363..59d5db09d 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 @@ -7,7 +7,6 @@ import net.minecraft.ReportedException; import net.minecraft.core.BlockPos; import net.minecraft.util.Mth; -import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.ClipContext; @@ -73,8 +72,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/bed_fix/MixinServerPlayer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/bed_fix/MixinServerPlayer.java index 25298a479..f4a97bb84 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/bed_fix/MixinServerPlayer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/bed_fix/MixinServerPlayer.java @@ -32,7 +32,7 @@ private void isReachableBedBlock(final BlockPos blockPos, final CallbackInfoRetu final double origY = vec3.y; final double origZ = vec3.z; - VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level, origX, origY, origZ, 1, (x, y, z) -> { + VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level(), origX, origY, origZ, 1, (x, y, z) -> { cir.setReturnValue(Math.abs(this.getX() - x) <= 3.0 && Math.abs(this.getY() - y) <= 2.0 && Math.abs(this.getZ() - z) <= 3.0); }); 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 9701d9e7c..bc6dc59d1 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 @@ -135,7 +135,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); @@ -146,7 +146,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..1ff482f5b 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 @@ -51,7 +51,7 @@ private void onClimbableMixin(final CallbackInfoReturnable cir) { final EntityAccessor thisAsAccessor = (EntityAccessor) this; final BlockPos originalBlockPosition = thisAsAccessor.getBlockPosition(); - VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level, origX, origY, origZ, 1, (x, y, z) -> { + VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level(), origX, origY, origZ, 1, (x, y, z) -> { // Only run this if we haven't modified cir yet if (cir.getReturnValue() != Boolean.TRUE) { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_leashes/MixinMobRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_leashes/MixinMobRenderer.java index 06387edec..99cc8b1db 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_leashes/MixinMobRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_leashes/MixinMobRenderer.java @@ -23,7 +23,7 @@ public Vec3 getRopeHoldPosition(final Entity instance, final float partialTicks, final Vec3 origVec = getRopeHoldPosition.call(instance, partialTicks); final Vector3d vec = VectorConversionsMCKt.toJOML(origVec); - final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(instance.level, vec); + final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(instance.level(), vec); if (ship != null) { ship.getShipToWorld().transformPosition(vec); return VectorConversionsMCKt.toMinecraft(vec); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java index 474bda757..12f479eea 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java @@ -129,7 +129,7 @@ private Entity preventSavingVehiclePosAsOurPos(final Entity originalVehicle) { @Inject(method = "setRemoved", at = @At("HEAD")) private void preSetRemoved(final RemovalReason removalReason, final CallbackInfo ci) { final Entity thisAsEntity = Entity.class.cast(this); - final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(thisAsEntity.level, + final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(thisAsEntity.level(), VectorConversionsMCKt.toJOML(thisAsEntity.position())); if (ship != null) { VSEntityManager.INSTANCE.getHandler(thisAsEntity).entityRemovedFromShipyard(thisAsEntity, ship); 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 c04a1fe09..18d24607e 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 @@ -35,7 +35,7 @@ void render( final EntityRenderer entityRenderer) { final ClientShip ship = - (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level, entity.blockPosition()); + (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level(), entity.blockPosition()); if (ship != null) { // Remove the earlier applied translation matrixStack.popPose(); @@ -47,7 +47,7 @@ void render( buffer, packedLight); } else if (entity.isPassenger()) { final ClientShip vehicleShip = - (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level, + (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level(), entity.getVehicle().blockPosition()); // If the entity is a passenger and that vehicle is in ship space if (vehicleShip != null) { @@ -66,7 +66,7 @@ boolean shouldRender(final boolean returns, final Entity entity, final Frustum f if (!returns) { final ClientShip ship = - (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level, entity.blockPosition()); + (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level(), entity.blockPosition()); if (ship != null) { AABB aABB = entity.getBoundingBoxForCulling().inflate(0.5); if (aABB.hasNaN() || aABB.getSize() == 0.0) { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinServerLevel.java index cbfe081fb..2a0c91f21 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinServerLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinServerLevel.java @@ -36,7 +36,7 @@ void configureEntitySections(final CallbackInfo ci) { ) ) void preAddEntity(final Entity entity, final CallbackInfoReturnable cir) { - final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(entity.level, VectorConversionsMCKt.toJOML(entity.position())); + final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(entity.level(), VectorConversionsMCKt.toJOML(entity.position())); if (ship != null) { VSEntityManager.INSTANCE.getHandler(entity).freshEntityInShipyard(entity, ship); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/tick_ship_chunks/MixinChunkMap.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/tick_ship_chunks/MixinChunkMap.java index 4c11213ee..199934aa2 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/tick_ship_chunks/MixinChunkMap.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/tick_ship_chunks/MixinChunkMap.java @@ -29,7 +29,7 @@ private static void preDistanceToSqr(final ChunkPos chunkPos, final Entity entit final double d = chunkPos.x * 16 + 8; final double e = chunkPos.z * 16 + 8; final double retValue = - VSGameUtilsKt.squaredDistanceBetweenInclShips(entity.level, entity.getX(), 0, entity.getZ(), d, + VSGameUtilsKt.squaredDistanceBetweenInclShips(entity.level(), entity.getX(), 0, entity.getZ(), d, 0, e); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/vs2_alpha_hud/MixinGui.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/vs2_alpha_hud/MixinGui.java index 358b27d09..f6e51d83d 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/vs2_alpha_hud/MixinGui.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/vs2_alpha_hud/MixinGui.java @@ -1,14 +1,12 @@ package org.valkyrienskies.mod.mixin.feature.vs2_alpha_hud; -import static net.minecraft.client.gui.GuiComponent.fill; - import com.google.common.base.Strings; -import com.mojang.blaze3d.vertex.PoseStack; import java.util.ArrayList; import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.server.IntegratedServer; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -31,13 +29,11 @@ public class MixinGui { * Render the "VS 2 Alpha" text */ @Inject(method = "renderEffects", at = @At("HEAD")) - private void preRenderStatusEffectOverlay(final PoseStack matrices, final CallbackInfo ci) { + private void preRenderStatusEffectOverlay(final GuiGraphics guiGraphics, final CallbackInfo ci) { if (!VSGameConfig.CLIENT.getRenderDebugText()) { return; } - matrices.pushPose(); - final Font fontRenderer = minecraft.font; final List debugText = new ArrayList<>(); debugText.add("VS 2 Beta Build"); @@ -67,11 +63,9 @@ private void preRenderStatusEffectOverlay(final PoseStack matrices, final Callba final int posX = 1; - fill(matrices, posX, posY - 1, 2 + textLength + posX, posY + textHeight - 1, -1873784752); - fontRenderer.draw(matrices, string, 2.0F, (float) posY, 14737632); + guiGraphics.fill(posX, posY - 1, 2 + textLength + posX, posY + textHeight - 1, -1873784752); + guiGraphics.drawString(fontRenderer, string, 2, posY, 14737632); } } - - matrices.popPose(); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinAbstractCannonProjectile.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinAbstractCannonProjectile.java index 96439c2b4..3100dcd9d 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinAbstractCannonProjectile.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinAbstractCannonProjectile.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.mixin.mod_compat.create_big_cannons; +/* import net.minecraft.world.entity.projectile.Projectile; import net.minecraft.world.phys.Vec3; import org.joml.primitives.AABBd; @@ -18,6 +19,7 @@ /** * Make this pseudo so that we don't need CBC as a compile-dependency */ +/* @Pseudo @Mixin(targets = "rbasamoyai.createbigcannons.munitions.AbstractCannonProjectile") public abstract class MixinAbstractCannonProjectile { @@ -45,3 +47,4 @@ protected void vsClipAndDamage(final Vec3 start, final Vec3 end, final CallbackI shipClipAndDamage(start, end, Projectile.class.cast(this)); } } +*/ 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 index 31d32a8b0..6aea9cb99 100644 --- 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 @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.mixin.mod_compat.create_big_cannons; +/* import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; @@ -50,3 +51,4 @@ protected void vsProcesssRiderPositionHook( } } } +*/ 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 index dc644a299..64c3f3c14 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -13,3 +14,4 @@ public interface InstancingEngineAccessor { 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 index 6a252f0b2..5506090df 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -79,3 +80,4 @@ private MaterialManager createMaterialManager() { } } } +*/ 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 index 1418ee7ce..0ebcea96b 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -50,3 +51,4 @@ private BlockPos redirectGetWorldPos2(final TickableInstance receiver) { } } +*/ 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 index 0e08afb31..9d26566eb 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -93,3 +94,4 @@ void render(final ClientShip ship, final MaterialManager manager, final RenderLa } } } +*/ 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 index 213ba443a..8b7fca15b 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -32,3 +33,4 @@ public void render(final Matrix4f viewProjection, final double camX, final doubl }); } } +*/ 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..3090ef55c 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 @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.mixin.mod_compat.ftb_chunks; +/* import dev.ftb.mods.ftbchunks.data.ClaimedChunkManager; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; @@ -60,3 +61,4 @@ public abstract class MixinClaimedChunkManager { return newPos; } } +*/ 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 139766c24..9f727d691 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/vanilla_renderer/MixinLevelRendererVanilla.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/vanilla_renderer/MixinLevelRendererVanilla.java index 711a71978..020d419b8 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; @@ -26,7 +24,9 @@ import net.minecraft.core.Vec3i; import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.Nullable; +import org.joml.Matrix4f; import org.joml.Vector3dc; +import org.joml.Vector3f; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -282,7 +282,7 @@ private void renderChunkLayer(final RenderType renderType, final PoseStack poseS } if (uniform != null) { - uniform.set(Vector3f.ZERO); + uniform.set(new Vector3f()); } 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 847509901..8048ed2e5 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 @@ -47,7 +47,7 @@ public abstract class MixinMinecraftServer implements IShipObjectWorldServerProv @Unique private VSPipeline vsPipeline; - private Set loadedLevels = new HashSet<>(); + private Set loadedLevels = new HashSet<>(); @Inject( at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;initServer()Z"), @@ -131,7 +131,7 @@ private void postCreateLevels(final CallbackInfo ci) { ) private void preTick(final CallbackInfo ci) { // region Tell the VS world to load new levels, and unload deleted ones - final Map newLoadedLevels = new HashMap<>(); + final Map newLoadedLevels = new HashMap<>(); for (final ServerLevel level : getAllLevels()) { newLoadedLevels.put(VSGameUtilsKt.getDimensionId(level), level); } @@ -144,7 +144,7 @@ private void preTick(final CallbackInfo ci) { } */ - for (final String oldLoadedLevelId : loadedLevels) { + for (final Object oldLoadedLevelId : loadedLevels) { if (!newLoadedLevels.containsKey(oldLoadedLevelId)) { shipWorld.removeDimension(oldLoadedLevelId); } 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 580cc96aa..0036e4536 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; @@ -74,7 +75,7 @@ private int noFlyKick(final int original) { method = "handleUseItemOn" ) private Vec3 skipDistanceCheck2(final Vec3 instance, final Vec3 vec3, final Operation subtract) { - return VSGameUtilsKt.toWorldCoordinates(player.level, subtract.call(instance, vec3)); + return VSGameUtilsKt.toWorldCoordinates(player.level(), subtract.call(instance, vec3)); } @WrapOperation( @@ -125,14 +126,14 @@ 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 ServerShip ship = VSGameUtilsKt.getShipManagingPos((ServerLevel) player.level, blockPos); + 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 if (ship != null) { @@ -148,7 +149,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/server/world/MixinChunkMap$TrackedEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java index e8b7bc131..7ea390797 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java @@ -32,7 +32,7 @@ public class MixinChunkMap$TrackedEntity { target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;")) Vec3 includeShips(final Vec3 original) { final Vector3d pos = VectorConversionsMCKt.toJOML(original); - final Ship ship = inCallShip = VSGameUtilsKt.getShipObjectManagingPos(this.entity.level, pos); + final Ship ship = inCallShip = VSGameUtilsKt.getShipObjectManagingPos(this.entity.level(), pos); if (ship != null) { return VectorConversionsMCKt.toMinecraft(ship.getShipToWorld().transformPosition(pos)); } else { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java index 64cbbb6d8..70646bddc 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java @@ -8,7 +8,7 @@ import java.util.Set; import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; -import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; @@ -68,7 +68,7 @@ private void preReadChunk(final ChunkPos chunkPos, // Generate the chunk to be nothing final LevelChunk generatedChunk = new LevelChunk(level, new ProtoChunk(chunkPos, UpgradeData.EMPTY, level, - level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), null), null); + level.registryAccess().registryOrThrow(Registries.BIOME), null), null); // Its wasteful to serialize just for this to be deserialized, but it will work for now. return Optional.of(ChunkSerializer.write(level, generatedChunk)); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java index db6e4ee72..838a3a6be 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java @@ -166,7 +166,7 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf for (int z = 0; z < 16; z++) { final BlockState blockState = chunkSection.getBlockState(x, y, z); final int posX = (chunkX << 4) + x; - final int posY = chunkSection.bottomBlockY() + y; + final int posY = (sectionY << 4) + worldChunk.getMinBuildHeight() + y; final int posZ = (chunkZ << 4) + z; if (blockState.getBlock() instanceof WingBlock) { mutableBlockPos.set(posX, posY, posZ); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/world/entity/projectile/ProjectileUtilMixin.java b/common/src/main/java/org/valkyrienskies/mod/mixin/world/entity/projectile/ProjectileUtilMixin.java index 1e5205e8a..26c233439 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/world/entity/projectile/ProjectileUtilMixin.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/entity/projectile/ProjectileUtilMixin.java @@ -26,11 +26,11 @@ private static void beforeGetEntityHitResult( final Entity entity, final Vec3 vec3, final Vec3 vec32, final AABB aABB, final Predicate predicate, final double d, final CallbackInfoReturnable<@Nullable EntityHitResult> cir) { - if (!VSGameUtilsKt.getShipsIntersecting(entity.level, aABB).iterator().hasNext()) { + if (!VSGameUtilsKt.getShipsIntersecting(entity.level(), aABB).iterator().hasNext()) { return; } - cir.setReturnValue(RaycastUtilsKt.raytraceEntities(entity.level, entity, vec3, vec32, aABB, predicate, d)); + cir.setReturnValue(RaycastUtilsKt.raytraceEntities(entity.level(), entity, vec3, vec32, aABB, predicate, d)); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinLevel.java index 36f337955..56cbd4d18 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinLevel.java @@ -7,7 +7,6 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.valkyrienskies.mod.common.util.DimensionIdProvider; -import org.valkyrienskies.mod.mixin.accessors.resource.ResourceKeyAccessor; /** * This mixin isn't entirely necessary, but it optimizes [Level.dimensionId] in [VSGameUtils.kt] by caching this value @@ -16,15 +15,13 @@ @Mixin(Level.class) public abstract class MixinLevel implements DimensionIdProvider { @Unique - private String vsDimensionIdCached = null; + private Object vsDimensionIdCached = null; @NotNull @Override - public String getDimensionId() { + public Object getDimensionId() { if (vsDimensionIdCached == null) { - final ResourceKey dim = dimension(); - vsDimensionIdCached = - ((ResourceKeyAccessor) dim).getRegistryName().toString() + ":" + dim.location().toString(); + vsDimensionIdCached = dimension(); } return vsDimensionIdCached; } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java index 9e9a3aea5..03df30043 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.mixinducks; +/* import com.jozufozu.flywheel.api.MaterialManager; import java.util.WeakHashMap; import org.valkyrienskies.core.api.ships.ClientShip; @@ -9,3 +10,4 @@ public interface MixinBlockEntityInstanceManagerDuck { WeakHashMap getShipMaterialManagers(); } +*/ diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java index 2b9eeba86..227587868 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java @@ -1,8 +1,10 @@ package org.valkyrienskies.mod.mixinducks; +/* import com.jozufozu.flywheel.backend.RenderLayer; import com.mojang.math.Matrix4f; public interface MixinInstancingEngineDuck { void render(Matrix4f viewProjection, double camX, double camY, double camZ, RenderLayer layer); } +*/ 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 3bb5ae302..aeffff60e 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -6,6 +6,7 @@ import net.minecraft.core.BlockPos import net.minecraft.core.Position import net.minecraft.core.Vec3i import net.minecraft.resources.ResourceKey +import net.minecraft.resources.ResourceKey.InternKey import net.minecraft.resources.ResourceLocation import net.minecraft.server.MinecraftServer import net.minecraft.server.level.ServerChunkCache @@ -76,14 +77,8 @@ val Level.dimensionId: DimensionId } fun getResourceKey(dimensionId: DimensionId): ResourceKey { - @Suppress("UNCHECKED_CAST") val cached = ResourceKeyAccessor.getValues()[dimensionId] as ResourceKey? - if (cached == null) { - val (registryNamespace, registryName, namespace, name) = dimensionId.split(":") - return ResourceKeyAccessor.callCreate( - ResourceLocation(registryNamespace, registryName), ResourceLocation(namespace, name) - ) - } - return cached + @Suppress("UNCHECKED_CAST") val cached = ResourceKeyAccessor.getValues()[dimensionId as InternKey] as ResourceKey? + return cached!! } fun MinecraftServer.executeIf(condition: () -> Boolean, toExecute: Runnable) { diff --git a/common/src/main/resources/valkyrienskies-common.accesswidener b/common/src/main/resources/valkyrienskies-common.accesswidener index 2f5276228..01edad75f 100644 --- a/common/src/main/resources/valkyrienskies-common.accesswidener +++ b/common/src/main/resources/valkyrienskies-common.accesswidener @@ -24,3 +24,5 @@ accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo mutable field net/minecraft/world/phys/HitResult location Lnet/minecraft/world/phys/Vec3; # Make the field public accessible field net/minecraft/world/phys/HitResult location Lnet/minecraft/world/phys/Vec3; + +accessible class net/minecraft/resources/ResourceKey$InternKey diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 57007a566..4e787a805 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -42,9 +42,6 @@ "feature.tick_ship_chunks.MixinChunkMap", "feature.world_border.MixinLevel", "feature.world_border.MixinWorldBorder", - "mod_compat.create_big_cannons.MixinAbstractCannonProjectile", - "mod_compat.create_big_cannons.MixinPitchOrientedContraptionEntity", - "mod_compat.ftb_chunks.MixinClaimedChunkManager", "mod_compat.sodium.MixinChunkTracker", "mod_compat.sodium.MixinRegionChunkRenderer", "mod_compat.sodium.MixinRenderSectionManager", @@ -95,11 +92,6 @@ "feature.transform_particles.MixinLevelRenderer", "feature.transform_particles.MixinParticle", "feature.vs2_alpha_hud.MixinGui", - "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 7be6bfe00..2722d9998 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -40,7 +40,7 @@ dependencies { include(modImplementation("net.fabricmc:fabric-language-kotlin:1.8.5+kotlin.1.7.20")) // include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:6.3.81")) - // modImplementation("curse.maven:sodium-394468:3957319") + modCompileOnly("maven.modrinth:sodium:mc1.20-0.4.10") // modImplementation("com.terraformersmc:modmenu:4.1.0") // Depend on the fabric API 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..3b5a32454 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.0f); // 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/MixinSpeakerPosition.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java index f58bb2ae4..22202c555 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; +/* import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; @@ -46,3 +47,4 @@ public abstract class MixinSpeakerPosition { return instance.distanceToSqr(d); } } +*/ 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..201b87997 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 @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; +/* import dan200.computercraft.shared.turtle.blocks.TileTurtle; import dan200.computercraft.shared.turtle.core.TurtleBrain; import net.minecraft.core.BlockPos; @@ -113,3 +114,4 @@ private static BlockPos getWorldPosFromShipPos(final Ship ship, final BlockPos p return newPos; } } +*/ diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java index 7e44efd49..c9350f27b 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; +/* import dan200.computercraft.api.turtle.TurtleCommandResult; import dan200.computercraft.shared.turtle.core.TurtleMoveCommand; import dan200.computercraft.shared.turtle.core.TurtlePlayer; @@ -55,3 +56,4 @@ private static Vector3d getShipPosFromWorldPos(final Level world, final BlockPos return new Vector3d(position.getX(), position.getY(), position.getZ()); } } +*/ diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java index 62dbb0c1c..163030682 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; +/* import dan200.computercraft.api.network.IPacketReceiver; import dan200.computercraft.api.network.IPacketSender; import dan200.computercraft.api.network.Packet; @@ -44,3 +45,4 @@ public class MixinWirelessNetwork { shipSender = packet.sender(); } } +*/ diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/Matrix3dAccessor.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/Matrix3dAccessor.java index 8a6192c90..d9068f096 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/Matrix3dAccessor.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/Matrix3dAccessor.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.fabric.mixin.compat.create; +/* import com.simibubi.create.foundation.collision.Matrix3d; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; @@ -35,3 +36,4 @@ public interface Matrix3dAccessor { @Accessor("m22") double getM22(); } +*/ diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinAbstractContraptionEntity.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinAbstractContraptionEntity.java index 4c8a02439..0eef2152c 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinAbstractContraptionEntity.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinAbstractContraptionEntity.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.fabric.mixin.compat.create; +/* import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; @@ -62,3 +63,4 @@ public Matrix4dc computeContraptionWingTransform() { return new Matrix4d(rotationMatrix).setTranslation(pos); } } +*/ 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 7a8f961ce..638a8ad42 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 @@ -2,6 +2,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.BiomeTags; import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; @@ -44,7 +45,7 @@ public void fireTickMixin(final BlockState state, final ServerLevel level, final 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); @@ -52,7 +53,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.getBiome(newPos).is(BiomeTags.INCREASED_FIRE_BURNOUT); final int k = bl2 ? -50 : 0; this.checkBurnOut(level, newPos.east(), 300 + k, random, i); this.checkBurnOut(level, newPos.west(), 300 + k, random, i); @@ -105,7 +106,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 index 688ea6998..303d23d44 100644 --- a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ContraptionShipyardEntityHandlerFabric.kt +++ b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ContraptionShipyardEntityHandlerFabric.kt @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.fabric.common +/* import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity import net.minecraft.core.BlockPos import net.minecraft.world.entity.Entity @@ -38,3 +39,4 @@ object ContraptionShipyardEntityHandlerFabric: AbstractShipyardEntityHandler() { } } } + */ diff --git a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/CreateConversions.kt b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/CreateConversions.kt index 1f65afc9a..da12d1706 100644 --- a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/CreateConversions.kt +++ b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/CreateConversions.kt @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.fabric.common +/* import org.joml.Matrix3d import org.valkyrienskies.mod.fabric.mixin.compat.create.Matrix3dAccessor @@ -11,3 +12,4 @@ fun com.simibubi.create.foundation.collision.Matrix3d.toJOML(): Matrix3d { accessor.m20, accessor.m21, accessor.m22 ) } +*/ 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 543650e5e..048f2c187 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 @@ -59,13 +60,13 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_FLAP = TestFlapBlock ValkyrienSkiesMod.TEST_WING = TestWingBlock 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.SHIP_CREATOR_ITEM_SMALLER = ShipCreatorItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), { VSGameConfig.SERVER.miniShipSize }, { VSGameConfig.SERVER.minScaling } ) @@ -92,30 +93,30 @@ class ValkyrienSkiesModFabric : ModInitializer { if (isClient) onInitializeClient() ValkyrienSkiesMod.init(vsCore) - VSEntityManager.registerContraptionHandler(ContraptionShipyardEntityHandlerFabric) + // VSEntityManager.registerContraptionHandler(ContraptionShipyardEntityHandlerFabric) registerBlockAndItem("test_chair", ValkyrienSkiesMod.TEST_CHAIR) registerBlockAndItem("test_hinge", ValkyrienSkiesMod.TEST_HINGE) registerBlockAndItem("test_flap", ValkyrienSkiesMod.TEST_FLAP) registerBlockAndItem("test_wing", ValkyrienSkiesMod.TEST_WING) 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.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.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 ) @@ -176,12 +177,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/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt index bdd81fbdf..88870c090 100644 --- a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt +++ b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.fabric.compat.modmenu +/* import com.terraformersmc.modmenu.api.ConfigScreenFactory import com.terraformersmc.modmenu.api.ModMenuApi import org.valkyrienskies.core.impl.config.VSConfigClass.Companion.getRegisteredConfig @@ -18,3 +19,4 @@ class ValkyrienModMenu : ModMenuApi { } } } +*/ diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index dab9070a3..d88663706 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -4,12 +4,6 @@ "compatibilityLevel": "JAVA_8", "plugin": "org.valkyrienskies.mod.fabric.mixin.ValkyrienFabricMixinConfigPlugin", "mixins": [ - "compat.cc_restitched.MixinSpeakerPosition", - "compat.cc_restitched.MixinTurtleBrain", - "compat.cc_restitched.MixinTurtleMoveCommand", - "compat.cc_restitched.MixinWirelessNetwork", - "compat.create.Matrix3dAccessor", - "compat.create.MixinAbstractContraptionEntity", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", "feature.water_in_ships_entity.MixinEntity", 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 index 531be51eb..f565ebf70 100644 --- a/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ContraptionShipyardEntityHandlerForge.kt +++ b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ContraptionShipyardEntityHandlerForge.kt @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.forge.common +/* import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity import net.minecraft.core.BlockPos import net.minecraft.world.entity.Entity @@ -38,3 +39,4 @@ object ContraptionShipyardEntityHandlerForge: AbstractShipyardEntityHandler() { } } } +*/ From 9a1927b58cbcc6b0781784bc1013c7d1981ae8d3 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 13 Jun 2023 00:22:32 -0600 Subject: [PATCH 031/156] Got Fabric working (mostly) --- .../mod/mixin/client/MixinMinecraft.java | 11 +------ .../gui/screens/MixinConnectScreen.java | 16 ++++++++++ .../client/renderer/MixinGameRenderer.java | 2 +- ...erBlockEntity.java => MixinContainer.java} | 12 +++---- .../MixinClientPacketListener.java | 4 +-- .../shipyard_entities/MixinEntity.java | 31 +++++++++++++++++-- .../MixinEntitySectionStorage.java | 8 ++--- .../client/MixinSimpleSoundInstance.java | 7 +++-- .../feature/world_border/MixinLevel.java | 13 +------- .../MixinLevelRendererVanilla.java | 2 +- .../mod/mixin/realms/MixinRealmsConnect.java | 16 ++++++++++ .../mixin/server/MixinMinecraftServer.java | 6 ++-- .../command/level/MixinServerPlayer.java | 10 ++---- .../mixin/server/world/MixinServerLevel.java | 16 +--------- .../mod/mixin/world/level/MixinLevel.java | 9 ++++-- .../valkyrienskies/mod/common/VSGameUtils.kt | 15 +++++++-- .../valkyrienskies-common.mixins.json | 6 ++-- fabric/build.gradle | 2 +- fabric/src/main/resources/fabric.mod.json | 2 +- forge/src/main/resources/META-INF/mods.toml | 2 +- 20 files changed, 112 insertions(+), 78 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/client/gui/screens/MixinConnectScreen.java rename common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/{MixinRandomizableContainerBlockEntity.java => MixinContainer.java} (69%) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/realms/MixinRealmsConnect.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java index 89f80b05b..ffca7228a 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java @@ -6,7 +6,6 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.multiplayer.MultiPlayerGameMode; -import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.server.IntegratedServer; import net.minecraft.world.InteractionHand; @@ -123,14 +122,6 @@ public void setGamePause(final boolean pauseOnly, final CallbackInfo ci) { } } - @Inject( - method = "setCurrentServer", - at = @At("HEAD") - ) - public void preSetCurrentServer(final ServerData serverData, final CallbackInfo ci) { - ValkyrienSkiesMod.getVsCore().setClientUsesUDP(false); - } - @Override public void createShipObjectWorldClient() { if (shipObjectWorld != null) { @@ -145,7 +136,7 @@ public void createShipObjectWorldClient() { public void deleteShipObjectWorldClient() { final ClientShipWorldCore shipObjectWorldCopy = shipObjectWorld; if (shipObjectWorldCopy == null) { - throw new IllegalStateException("shipObjectWorld was null when it should be not null?"); + return; // throw new IllegalStateException("shipObjectWorld was null when it should be not null?"); } shipObjectWorldCopy.destroyWorld(); shipObjectWorld = null; diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/gui/screens/MixinConnectScreen.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/gui/screens/MixinConnectScreen.java new file mode 100644 index 000000000..76251c41d --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/gui/screens/MixinConnectScreen.java @@ -0,0 +1,16 @@ +package org.valkyrienskies.mod.mixin.client.gui.screens; + +import net.minecraft.client.gui.screens.ConnectScreen; +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.common.ValkyrienSkiesMod; + +@Mixin(ConnectScreen.class) +public class MixinConnectScreen { + @Inject(method = "startConnecting", at = @At("HEAD")) + private static void preStartConnecting(final CallbackInfo ci) { + ValkyrienSkiesMod.getVsCore().setClientUsesUDP(false); + } +} 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 88de221ca..52a4e6772 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 @@ -226,7 +226,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, diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinRandomizableContainerBlockEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java similarity index 69% rename from common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinRandomizableContainerBlockEntity.java rename to common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java index c1c55313d..5a284edf4 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinRandomizableContainerBlockEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java @@ -1,25 +1,23 @@ package org.valkyrienskies.mod.mixin.feature.container_distance_check; +import net.minecraft.world.Container; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; 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(RandomizableContainerBlockEntity.class) -public class MixinRandomizableContainerBlockEntity { - +@Mixin(Container.class) +public interface MixinContainer { @Redirect( - method = "stillValid", + method = "stillValidBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/entity/player/Player;I)Z", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;distanceToSqr(DDD)D" ) ) - private double includeShipsInDistanceCheck( + private static double includeShipsInDistanceCheck( final Player receiver, final double x, final double y, final double z) { return VSGameUtilsKt.squaredDistanceToInclShips(receiver, x, y, z); } - } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java index 8ac35350d..e065d72a6 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java @@ -47,9 +47,9 @@ public class MixinClientPacketListener implements SeamlessCopyClientPacketListen @Inject( at = @At("HEAD"), - method = "cleanup" + method = "close" ) - private void beforeCleanup(final CallbackInfo ci) { + private void beforeClose(final CallbackInfo ci) { chunks.cleanup(); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java index 12f479eea..62226d393 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java @@ -3,9 +3,12 @@ import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import java.util.Set; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity.RemovalReason; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.RelativeMovement; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import org.joml.Vector3d; @@ -15,6 +18,7 @@ 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.core.api.ships.LoadedShip; import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; @@ -26,7 +30,7 @@ public abstract class MixinEntity { @Shadow - public abstract Level getLevel(); + public abstract Level level(); @Shadow public abstract void setPosRaw(double d, double e, double f); @@ -37,6 +41,9 @@ public abstract class MixinEntity { @Shadow public abstract void teleportTo(double d, double e, double f); + @Shadow + public abstract boolean teleportTo(ServerLevel serverLevel, double d, double e, double f, Set set, float g, float h); + @Shadow public abstract EntityType getType(); @@ -62,7 +69,7 @@ private void positionRider(final Entity instance, final Entity passengerI, final */ @Inject(method = "setPosRaw", at = @At(value = "HEAD"), cancellable = true) private void handlePosSet(final double x, final double y, final double z, final CallbackInfo ci) { - final Level level = getLevel(); + final Level level = level(); //noinspection ConstantValue if (!Player.class.isInstance(this) || level == null || isModifyingSetPos || !VSGameUtilsKt.isBlockInShipyard(level, x, y, z)) { @@ -83,7 +90,7 @@ private void handlePosSet(final double x, final double y, final double z, final @Inject( at = @At("HEAD"), - method = "teleportTo", + method = "teleportTo(DDD)V", cancellable = true ) private void beforeTeleportTo(final double d, final double e, final double f, final CallbackInfo ci) { @@ -99,6 +106,24 @@ private void beforeTeleportTo(final double d, final double e, final double f, fi isModifyingTeleport = false; } + @Inject( + at = @At("HEAD"), + method = "teleportTo(Lnet/minecraft/server/level/ServerLevel;DDDLjava/util/Set;FF)Z", + cancellable = true + ) + private void beforeTeleportTo(ServerLevel serverLevel, double d, double e, double f, Set set, float g, float h, final CallbackInfoReturnable ci) { + if (isModifyingTeleport) { + return; + } + + ci.cancel(); + isModifyingTeleport = true; + final Vector3d pos = VSEntityManager.INSTANCE.getHandler(Entity.class.cast(this)) + .getTeleportPos(Entity.class.cast(this), new Vector3d(d, e, f)); + teleportTo(serverLevel, pos.x, pos.y, pos.z, set, g, h); + isModifyingTeleport = false; + } + /** * Prevent [saveWithoutId] from saving the vehicle's position as passenger's position when that vehicle is in the * shipyard. diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySectionStorage.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySectionStorage.java index 4aa6a15df..16c025c04 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySectionStorage.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySectionStorage.java @@ -1,7 +1,7 @@ package org.valkyrienskies.mod.mixin.feature.shipyard_entities; -import java.util.function.Consumer; import net.minecraft.core.SectionPos; +import net.minecraft.util.AbortableIterationConsumer; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.level.entity.EntitySection; @@ -23,7 +23,7 @@ public abstract class MixinEntitySectionStorage implements OfLevel { @Shadow - public abstract void forEachAccessibleNonEmptySection(AABB aABB, Consumer> consumer); + public abstract void forEachAccessibleNonEmptySection(AABB aABB, AbortableIterationConsumer> abortableIterationConsumer); @Unique private Level level; @@ -49,7 +49,7 @@ void onSectionCreate(final long l, final CallbackInfoReturnable> consumer, + void shipSections(final AABB aABB, final AbortableIterationConsumer> abortableIterationConsumer, final CallbackInfo ci) { if (level != null && !loopingShips) { @@ -63,7 +63,7 @@ void shipSections(final AABB aABB, final Consumer> consume // java.lang.IllegalArgumentException: Start element (9223367638808264704) is larger than end element (-9223372036854775808) try { - this.forEachAccessibleNonEmptySection(transformedAABB, consumer); + this.forEachAccessibleNonEmptySection(transformedAABB, abortableIterationConsumer); } catch (final IllegalArgumentException ex) { ex.printStackTrace(); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java index 5419aa484..1797b4e21 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java @@ -5,6 +5,7 @@ import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; +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; @@ -21,14 +22,14 @@ public class MixinSimpleSoundInstance { method = "forRecord", cancellable = true ) - private static void forRecord(final SoundEvent sound, final double x, final double y, final double z, + private static void forRecord(final SoundEvent sound, final Vec3 pos, final CallbackInfoReturnable cir) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(Minecraft.getInstance().level, x, y, z); + final Ship ship = VSGameUtilsKt.getShipManagingPos(Minecraft.getInstance().level, pos.x(), pos.y(), pos.z()); if (ship != null) { cir.setReturnValue(new SimpleSoundInstanceOnShip( sound, SoundSource.RECORDS, 4.0F, 1.0F, SoundInstance.createUnseededRandom(), false, 0, - SoundInstance.Attenuation.LINEAR, x, y, z, ship)); + SoundInstance.Attenuation.LINEAR, pos.x(), pos.y(), pos.z(), ship)); } } 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..4f903f876 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 @@ -1,13 +1,7 @@ package org.valkyrienskies.mod.mixin.feature.world_border; -import java.util.function.Supplier; -import net.minecraft.core.Holder; -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; import org.spongepowered.asm.mixin.Shadow; @@ -27,12 +21,7 @@ public class MixinLevel { at = @At("RETURN"), 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) { - + private void setWorldBorderLevel(final CallbackInfo ci) { ((OfLevel) this.worldBorder).setLevel(Level.class.cast(this)); } 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 020d419b8..3d6c40e78 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 @@ -155,7 +155,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 = "*" ) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/realms/MixinRealmsConnect.java b/common/src/main/java/org/valkyrienskies/mod/mixin/realms/MixinRealmsConnect.java new file mode 100644 index 000000000..916115439 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/realms/MixinRealmsConnect.java @@ -0,0 +1,16 @@ +package org.valkyrienskies.mod.mixin.realms; + +import net.minecraft.realms.RealmsConnect; +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.common.ValkyrienSkiesMod; + +@Mixin(RealmsConnect.class) +public class MixinRealmsConnect { + @Inject(method = "connect", at = @At("HEAD")) + private void preConnect(final CallbackInfo ci) { + ValkyrienSkiesMod.getVsCore().setClientUsesUDP(false); + } +} 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 8048ed2e5..847509901 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 @@ -47,7 +47,7 @@ public abstract class MixinMinecraftServer implements IShipObjectWorldServerProv @Unique private VSPipeline vsPipeline; - private Set loadedLevels = new HashSet<>(); + private Set loadedLevels = new HashSet<>(); @Inject( at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;initServer()Z"), @@ -131,7 +131,7 @@ private void postCreateLevels(final CallbackInfo ci) { ) private void preTick(final CallbackInfo ci) { // region Tell the VS world to load new levels, and unload deleted ones - final Map newLoadedLevels = new HashMap<>(); + final Map newLoadedLevels = new HashMap<>(); for (final ServerLevel level : getAllLevels()) { newLoadedLevels.put(VSGameUtilsKt.getDimensionId(level), level); } @@ -144,7 +144,7 @@ private void preTick(final CallbackInfo ci) { } */ - for (final Object oldLoadedLevelId : loadedLevels) { + for (final String oldLoadedLevelId : loadedLevels) { if (!newLoadedLevels.containsKey(oldLoadedLevelId)) { shipWorld.removeDimension(oldLoadedLevelId); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/level/MixinServerPlayer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/level/MixinServerPlayer.java index f3ecca12d..4a95a677f 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/level/MixinServerPlayer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/level/MixinServerPlayer.java @@ -1,7 +1,7 @@ package org.valkyrienskies.mod.mixin.server.command.level; -import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.Entity; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -13,10 +13,6 @@ @Mixin(ServerPlayer.class) public abstract class MixinServerPlayer { - - @Shadow - public abstract ServerLevel getLevel(); - @Shadow public abstract void teleportTo(double d, double e, double f); @@ -26,7 +22,7 @@ public abstract class MixinServerPlayer { cancellable = true ) private void beforeTeleportTo(final double x, final double y, final double z, final CallbackInfo ci) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(getLevel(), x, y, z); + final Ship ship = VSGameUtilsKt.getShipManagingPos(Entity.class.cast(this).level(), x, y, z); if (ship != null) { ci.cancel(); final Vector3d inWorld = VSGameUtilsKt.toWorldCoordinates(ship, x, y, z); @@ -40,7 +36,7 @@ private void beforeTeleportTo(final double x, final double y, final double z, fi cancellable = true ) private void beforeDismountTo(final double x, final double y, final double z, final CallbackInfo ci) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(getLevel(), x, y, z); + final Ship ship = VSGameUtilsKt.getShipManagingPos(Entity.class.cast(this).level(), x, y, z); if (ship != null) { ci.cancel(); final Vector3d inWorld = VSGameUtilsKt.toWorldCoordinates(ship, x, y, z); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java index 838a3a6be..5696e1570 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java @@ -11,26 +11,18 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Optional; -import java.util.concurrent.Executor; import java.util.function.BooleanSupplier; import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.Position; -import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.CustomSpawner; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; -import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess; -import net.minecraft.world.level.storage.ServerLevelData; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.joml.Vector3d; @@ -74,13 +66,7 @@ public ServerShipWorldCore getShipObjectWorld() { } @Inject(method = "", at = @At("RETURN")) - void onInit(final MinecraftServer minecraftServer, final Executor executor, - final LevelStorageAccess levelStorageAccess, - final ServerLevelData serverLevelData, final ResourceKey levelId, final LevelStem levelStem, - final ChunkProgressListener chunkProgressListener, final boolean bl, - final long l, final List customSpawners, - final boolean bl2, final CallbackInfo ci) { - + void onInit(final CallbackInfo ci) { // This only happens when overworld gets loaded on startup, we have a mixin in MixinMinecraftServer for this specific case if (getShipObjectWorld() != null) { getShipObjectWorld().addDimension(VSGameUtilsKt.getDimensionId((ServerLevel) (Object) this), diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinLevel.java index 56cbd4d18..18d2938eb 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinLevel.java @@ -7,6 +7,7 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.valkyrienskies.mod.common.util.DimensionIdProvider; +import org.valkyrienskies.mod.mixin.accessors.resource.ResourceKeyAccessor; /** * This mixin isn't entirely necessary, but it optimizes [Level.dimensionId] in [VSGameUtils.kt] by caching this value @@ -15,13 +16,15 @@ @Mixin(Level.class) public abstract class MixinLevel implements DimensionIdProvider { @Unique - private Object vsDimensionIdCached = null; + private String vsDimensionIdCached = null; @NotNull @Override - public Object getDimensionId() { + public String getDimensionId() { if (vsDimensionIdCached == null) { - vsDimensionIdCached = dimension(); + final ResourceKey dim = dimension(); + vsDimensionIdCached = + ((ResourceKeyAccessor) dim).getRegistryName().toString() + ":" + dim.location(); } return vsDimensionIdCached; } 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 aeffff60e..3aaa74ff1 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -5,6 +5,7 @@ import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.core.BlockPos import net.minecraft.core.Position import net.minecraft.core.Vec3i +import net.minecraft.core.registries.Registries import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceKey.InternKey import net.minecraft.resources.ResourceLocation @@ -76,9 +77,19 @@ 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 InternKey] as ResourceKey? - return cached!! + val cached =levelResourceKeyMap[dimensionId] + if (cached == null) { + val (registryNamespace, registryName, namespace, name) = dimensionId.split(":") + val toReturn: ResourceKey = ResourceKeyAccessor.callCreate( + ResourceLocation(registryNamespace, registryName), ResourceLocation(namespace, name) + ) + levelResourceKeyMap[dimensionId] = toReturn + return toReturn + } + return cached } fun MinecraftServer.executeIf(condition: () -> Boolean, toExecute: Runnable) { diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 4e787a805..6a0e3f476 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -20,7 +20,7 @@ "feature.commands.MixinArgumentTypeInfos", "feature.commands.MixinCommandSourceStack", "feature.conduit_fix.ConduitMixin", - "feature.container_distance_check.MixinRandomizableContainerBlockEntity", + "feature.container_distance_check.MixinContainer", "feature.dispensers.MixinDefaultDispenseItemBehavior", "feature.distance_replace.MixinEntity", "feature.entity_collision.MixinEntity", @@ -66,6 +66,7 @@ "accessors.client.render.ViewAreaAccessor", "accessors.client.render.chunk.RenderChunkAccessor", "accessors.client.world.ClientChunkCacheStorageAccessor", + "client.gui.screens.MixinConnectScreen", "client.MixinCamera", "client.MixinMinecraft", "client.multiplayer.MixinClientPacketListener", @@ -98,7 +99,8 @@ "mod_compat.sound_physics_remastered.MixinSoundPhysics", "mod_compat.vanilla_renderer.MixinLevelRendererVanilla", "mod_compat.vanilla_renderer.MixinViewAreaVanilla", - "mod_compat.vanilla_renderer.RenderChunkInfoAccessor" + "mod_compat.vanilla_renderer.RenderChunkInfoAccessor", + "realms.MixinRealmsConnect" ], "injectors": { "defaultRequire": 1 diff --git a/fabric/build.gradle b/fabric/build.gradle index 2722d9998..2c342ddb7 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -38,7 +38,7 @@ dependencies { // Depend on the fabric kotlin mod include(modImplementation("net.fabricmc:fabric-language-kotlin:1.8.5+kotlin.1.7.20")) - // include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:6.3.81")) + include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:11.0.99")) modCompileOnly("maven.modrinth:sodium:mc1.20-0.4.10") // modImplementation("com.terraformersmc:modmenu:4.1.0") diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 48ad3da8f..f433c9fc7 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.20", "fabric": "*" }, "breaks": { diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 99510ab45..997022bc0 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.20]" ordering = "NONE" side = "BOTH" From d9bfc0e73572d9e0414a12e23cc80147351c7854 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 13 Jun 2023 00:36:45 -0600 Subject: [PATCH 032/156] Got Forge working (mostly) --- .../MixinContainer.java | 2 +- .../mixin/client/render/MixinLevelRenderer.java | 10 +++++----- .../compat/cc_tweaked/MixinSpeakerPosition.java | 2 ++ .../compat/cc_tweaked/MixinTurtleBrain.java | 2 ++ .../cc_tweaked/MixinTurtleMoveCommand.java | 2 ++ .../compat/cc_tweaked/MixinWirelessNetwork.java | 2 ++ .../mixin/compat/create/Matrix3dAccessor.java | 2 ++ .../create/MixinAbstractContraptionEntity.java | 2 ++ .../MixinBlockBreakingKineticTileEntity.java | 3 ++- .../forge/mixin/compat/create/MixinBlocks.java | 2 ++ .../client/MixinContraptionRenderInfo.java | 3 ++- .../create/client/MixinFlwContraption.java | 2 ++ .../client/MixinScrollValueBehaviour.java | 2 ++ .../compat/create/client/MixinValueBox.java | 2 ++ .../MixinEnvironmentalTemperatureProvider.java | 6 +++--- .../tis3d/MixinCasingTileEntityRender.java | 3 ++- .../compat/tis3d/MixinInfraredPacketEntity.java | 2 ++ .../compat/tis3d/MixinRenderContextImpl.java | 2 ++ .../forge_interact/MixinIForgePlayer.java | 8 ++++---- .../water_in_ships_entity/MixinEntity.java | 2 +- .../mixin/world/level/block/FireMixin.java | 6 +++--- .../mod/forge/common/CreateConversions.kt | 2 ++ .../mod/forge/common/ValkyrienSkiesModForge.kt | 11 +++++------ .../resources/valkyrienskies-forge.mixins.json | 17 +---------------- 24 files changed, 55 insertions(+), 42 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java index 5a284edf4..c11b95d4d 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java @@ -16,7 +16,7 @@ public interface MixinContainer { target = "Lnet/minecraft/world/entity/player/Player;distanceToSqr(DDD)D" ) ) - private static double includeShipsInDistanceCheck( + static double includeShipsInDistanceCheck( final Player receiver, final double x, final double y, final double z) { return VSGameUtilsKt.squaredDistanceToInclShips(receiver, x, y, z); } 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..57bd32eac 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.0f); // 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/MixinSpeakerPosition.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java index fa6304a8a..abb0e5e16 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.cc_tweaked; +/* import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; @@ -45,3 +46,4 @@ public abstract class MixinSpeakerPosition { return instance.distanceToSqr(d); } } +*/ 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 index a5ca0bd71..9e19fae7a 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -114,3 +115,4 @@ private static BlockPos getWorldPosFromShipPos(final Ship ship, final BlockPos p 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 index 4798d7249..d2f7d8d3f 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -55,3 +56,4 @@ private static Vector3d getShipPosFromWorldPos(final Level world, final BlockPos 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 index f623cc254..f406eae1e 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -39,3 +40,4 @@ public class MixinWirelessNetwork { shipSender = packet.sender(); } } +*/ diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/Matrix3dAccessor.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/Matrix3dAccessor.java index 442fa71a3..e6f6a41ab 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/Matrix3dAccessor.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/Matrix3dAccessor.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create; +/* import com.simibubi.create.foundation.collision.Matrix3d; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @@ -33,3 +34,4 @@ public interface Matrix3dAccessor { @Accessor("m22") double getM22(); } +*/ diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinAbstractContraptionEntity.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinAbstractContraptionEntity.java index 28876cf44..aacce9751 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinAbstractContraptionEntity.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinAbstractContraptionEntity.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create; +/* import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; @@ -57,3 +58,4 @@ public Matrix4dc computeContraptionWingTransform() { return new Matrix4d(rotationMatrix).setTranslation(pos); } } +*/ 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 index 7ff605744..7aec0dc69 100644 --- 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 @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create; +/* import com.simibubi.create.content.contraptions.components.actors.BlockBreakingKineticTileEntity; import net.minecraft.core.BlockPos; import net.minecraft.world.level.ClipContext; @@ -63,4 +64,4 @@ private BlockPos getBreakingBlockPos(final BlockBreakingKineticTileEntity self) } } - +*/ 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 index a9277bb6f..52b7b1e79 100644 --- 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 @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create; +/* import com.simibubi.create.content.contraptions.components.millstone.MillstoneBlock; import com.simibubi.create.content.contraptions.processing.BasinBlock; import com.simibubi.create.content.logistics.block.chute.AbstractChuteBlock; @@ -62,3 +63,4 @@ Vec3 redirectPosition(final Entity entity) { } } +*/ 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 index ad14eb65e..f6da6c505 100644 --- 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 @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create.client; +/* import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderInfo; import net.minecraft.client.multiplayer.ClientLevel; @@ -24,4 +25,4 @@ private AABB redirectGetAABBForCulling(final AbstractContraptionEntity receiver) 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 index 18705b756..9b4fd1575 100644 --- 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 @@ -1,5 +1,6 @@ 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.components.structureMovement.AbstractContraptionEntity; @@ -59,3 +60,4 @@ private AABB transformLightboxToWorld(final AABB aabb, final double negCamX, fin 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/MixinScrollValueBehaviour.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinScrollValueBehaviour.java index 41783ea2f..aec0210d3 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinScrollValueBehaviour.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinScrollValueBehaviour.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create.client; +/* import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour; import net.minecraft.client.Minecraft; import net.minecraft.world.phys.Vec3; @@ -24,3 +25,4 @@ private Vec3 transformHitToShip(final Vec3 hitPos, final Vec3 blockPos) { } } +*/ diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java index 8d6cc8395..a2a07dba1 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create.client; +/* import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox; import org.spongepowered.asm.mixin.Mixin; @@ -23,3 +24,4 @@ public void redirectTranslate(final PoseStack instance, final double x, final do } } +*/ diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfcambiental/MixinEnvironmentalTemperatureProvider.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfcambiental/MixinEnvironmentalTemperatureProvider.java index f6a8523cb..1d99feed4 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfcambiental/MixinEnvironmentalTemperatureProvider.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfcambiental/MixinEnvironmentalTemperatureProvider.java @@ -23,15 +23,15 @@ public interface MixinEnvironmentalTemperatureProvider { static boolean calculateEnclosure(final Player player, final int radius) { // VS: Use player.blockPosition() instead of getOnPos() if getOnPos() is in a ship. BlockPos pos = player.getOnPos(); - if (VSGameUtilsKt.isBlockInShipyard(player.level, pos)) { + if (VSGameUtilsKt.isBlockInShipyard(player.level(), pos)) { pos = player.blockPosition(); } // Original method final PathNavigationRegion - region = new PathNavigationRegion(player.level, pos.above().offset(-radius, -radius, -radius), + region = new PathNavigationRegion(player.level(), pos.above().offset(-radius, -radius, -radius), pos.above().offset(radius, 400, radius)); - final Bee guineaPig = new Bee(EntityType.BEE, player.level); + final Bee guineaPig = new Bee(EntityType.BEE, player.level()); guineaPig.setPos(player.getPosition(0.0F)); guineaPig.setBaby(true); final FlyNodeEvaluator evaluator = new FlyNodeEvaluator(); 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 index 2b06a8e75..fd3eb77ec 100644 --- 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 @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.tis3d; +/* import li.cil.tis3d.client.renderer.tileentity.CasingTileEntityRenderer; import net.minecraft.client.Minecraft; import net.minecraft.core.BlockPos; @@ -28,4 +29,4 @@ public abstract class MixinCasingTileEntityRender { } } } - +*/ 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 index dc7e88889..61f2958ec 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -31,3 +32,4 @@ public class MixinInfraredPacketEntity { 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 index 864e2edec..024c53f5b 100644 --- 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 @@ -1,5 +1,6 @@ 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; @@ -39,3 +40,4 @@ public abstract class MixinRenderContextImpl { } } } +*/ diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java index 2c712438a..aae6afa18 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java @@ -22,11 +22,11 @@ public interface MixinIForgePlayer { * Include ships in server-side distance check when player interacts with a block. */ @Overwrite(remap = false) - default boolean canInteractWith(final BlockPos pos, final double padding) { + default boolean canReach(final BlockPos pos, final double padding) { if (VSGameConfig.SERVER.getEnableInteractDistanceChecks()) { - final double reach = this.self().getReachDistance() + padding; + final double reach = this.self().getEntityReach() + padding; final Vec3 eyes = this.self().getEyePosition(); - return VSGameUtilsKt.squaredDistanceBetweenInclShips(this.self().level, + return VSGameUtilsKt.squaredDistanceBetweenInclShips(this.self().level(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, @@ -44,7 +44,7 @@ default boolean isCloseEnough(final Entity entity, final double distance) { final Vec3 targetCenter = entity.getPosition(1.0F).add(0.0, (double) (entity.getBbHeight() / 2.0F), 0.0); final Optional hit = entity.getBoundingBox().clip(eye, targetCenter); return (hit.isPresent() ? - VSGameUtilsKt.squaredDistanceBetweenInclShips(this.self().level, + VSGameUtilsKt.squaredDistanceBetweenInclShips(this.self().level(), hit.get().x, hit.get().y, hit.get().z, eye.x, eye.y, eye.z) : this.self().distanceToSqr(entity)) < distance * distance; } else { 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 f0cea23ef..5877ad190 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 @@ -44,7 +44,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); @@ -52,7 +52,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); @@ -105,7 +105,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/CreateConversions.kt b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/CreateConversions.kt index 68f3319a4..1bd63dbc1 100644 --- a/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/CreateConversions.kt +++ b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/CreateConversions.kt @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.forge.common +/* import org.joml.Matrix3d import org.valkyrienskies.mod.forge.mixin.compat.create.Matrix3dAccessor @@ -11,3 +12,4 @@ fun com.simibubi.create.foundation.collision.Matrix3d.toJOML(): Matrix3d { accessor.m20, accessor.m21, accessor.m22 ) } +*/ 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 b94f8c8f8..c99a6ceca 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 @@ -5,7 +5,6 @@ import net.minecraft.resources.ResourceLocation 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 import net.minecraft.world.item.Item.Properties import net.minecraft.world.level.block.Block @@ -73,7 +72,7 @@ class ValkyrienSkiesModForge { VSForgeNetworking.registerPacketHandlers(vsCore.hooks) ValkyrienSkiesMod.init(vsCore) - VSEntityManager.registerContraptionHandler(ContraptionShipyardEntityHandlerForge) + // VSEntityManager.registerContraptionHandler(ContraptionShipyardEntityHandlerForge) val modBus = Bus.MOD.bus().get() val forgeBus = Bus.FORGE.bus().get() @@ -111,14 +110,14 @@ class ValkyrienSkiesModForge { TEST_WING_REGISTRY = registerBlockAndItem("test_wing") { TestWingBlock } SHIP_CREATOR_ITEM_REGISTRY = ITEMS.register("ship_creator") { - ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), + ShipCreatorItem(Properties(), { 1.0 }, { VSGameConfig.SERVER.minScaling }) } SHIP_CREATOR_SMALLER_ITEM_REGISTRY = ITEMS.register("ship_creator_smaller") { ShipCreatorItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), { VSGameConfig.SERVER.miniShipSize }, { VSGameConfig.SERVER.minScaling } ) @@ -131,7 +130,7 @@ class ValkyrienSkiesModForge { .build(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_mounting_entity").toString()) } 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) } @@ -154,7 +153,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/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 57ba7bb5e..4e4304464 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -4,30 +4,15 @@ "compatibilityLevel": "JAVA_17", "plugin": "org.valkyrienskies.mod.forge.mixin.ValkyrienForgeMixinConfigPlugin", "mixins": [ - "compat.cc_tweaked.MixinSpeakerPosition", - "compat.cc_tweaked.MixinTurtleBrain", - "compat.cc_tweaked.MixinTurtleMoveCommand", - "compat.cc_tweaked.MixinWirelessNetwork", - "compat.create.Matrix3dAccessor", - "compat.create.MixinAbstractContraptionEntity", - "compat.create.MixinBlockBreakingKineticTileEntity", - "compat.create.MixinBlocks", "compat.immersivengineering.MixinBlockEntityInventory", "compat.thermalexpansion.MixinTileCoFH", - "compat.tis3d.MixinInfraredPacketEntity", "feature.forge_interact.MixinIForgePlayer", "feature.water_in_ships_entity.MixinEntity", "world.level.block.FireMixin" ], "client": [ "client.render.MixinLevelRenderer", - "compat.create.client.MixinContraptionRenderInfo", - "compat.create.client.MixinFlwContraption", - "compat.create.client.MixinScrollValueBehaviour", - "compat.create.client.MixinValueBox", - "compat.sodium.MixinRenderSectionManager", - "compat.tis3d.MixinCasingTileEntityRender", - "compat.tis3d.MixinRenderContextImpl" + "compat.sodium.MixinRenderSectionManager" ], "injectors": { "defaultRequire": 1 From 80c8e1ffd0a036f23b8df29258da197d34da52d5 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 13 Jun 2023 01:00:05 -0600 Subject: [PATCH 033/156] Fixed ship bounding boxes not rendering correctly --- .../feature/container_distance_check/MixinContainer.java | 2 +- .../feature/render_ship_debug_bb/MixinDebugRenderer.java | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java index c11b95d4d..5a284edf4 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java @@ -16,7 +16,7 @@ public interface MixinContainer { target = "Lnet/minecraft/world/entity/player/Player;distanceToSqr(DDD)D" ) ) - static double includeShipsInDistanceCheck( + private static double includeShipsInDistanceCheck( final Player receiver, final double x, final double y, final double z) { return VSGameUtilsKt.squaredDistanceToInclShips(receiver, x, y, z); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_ship_debug_bb/MixinDebugRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_ship_debug_bb/MixinDebugRenderer.java index 1f6d5573c..88289b925 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_ship_debug_bb/MixinDebugRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_ship_debug_bb/MixinDebugRenderer.java @@ -33,10 +33,8 @@ public class MixinDebugRenderer { *

They get rendered in the same pass as entities. */ @Inject(method = "render", at = @At("HEAD")) - private void postRender(final PoseStack matricesIgnore, final MultiBufferSource.BufferSource vertexConsumersIgnore, + private void postRender(final PoseStack matrices, final MultiBufferSource.BufferSource vertexConsumersIgnore, final double cameraX, final double cameraY, final double cameraZ, final CallbackInfo ci) { - // Ignore the matrix/buffer inputs to this, we're really just using this mixin as a place to run our render code - final PoseStack matrices = new PoseStack(); final MultiBufferSource.BufferSource bufferSource = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder()); final ClientLevel world = Minecraft.getInstance().level; From 564812f67e6fb04c0ea9dd4f7158fdd6687259c5 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 13 Jun 2023 01:36:27 -0600 Subject: [PATCH 034/156] Removed dead code --- .../mod/mixin/accessors/resource/ResourceKeyAccessor.java | 8 -------- .../kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 2 -- .../main/resources/valkyrienskies-common.accesswidener | 2 -- 3 files changed, 12 deletions(-) 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 eb9ea74c4..50c1a4719 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,8 +1,6 @@ package org.valkyrienskies.mod.mixin.accessors.resource; -import java.util.concurrent.ConcurrentMap; import net.minecraft.resources.ResourceKey; -import net.minecraft.resources.ResourceKey.InternKey; import net.minecraft.resources.ResourceLocation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @@ -10,12 +8,6 @@ @Mixin(ResourceKey.class) public interface ResourceKeyAccessor { - - @Accessor("VALUES") - static ConcurrentMap> getValues() { - throw new AssertionError(); - } - @Accessor ResourceLocation getRegistryName(); 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 3aaa74ff1..5dca273dc 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -5,9 +5,7 @@ import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.core.BlockPos import net.minecraft.core.Position import net.minecraft.core.Vec3i -import net.minecraft.core.registries.Registries import net.minecraft.resources.ResourceKey -import net.minecraft.resources.ResourceKey.InternKey import net.minecraft.resources.ResourceLocation import net.minecraft.server.MinecraftServer import net.minecraft.server.level.ServerChunkCache diff --git a/common/src/main/resources/valkyrienskies-common.accesswidener b/common/src/main/resources/valkyrienskies-common.accesswidener index 01edad75f..2f5276228 100644 --- a/common/src/main/resources/valkyrienskies-common.accesswidener +++ b/common/src/main/resources/valkyrienskies-common.accesswidener @@ -24,5 +24,3 @@ accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo mutable field net/minecraft/world/phys/HitResult location Lnet/minecraft/world/phys/Vec3; # Make the field public accessible field net/minecraft/world/phys/HitResult location Lnet/minecraft/world/phys/Vec3; - -accessible class net/minecraft/resources/ResourceKey$InternKey From 555b6f27d3a4d547f8eb0407976a82bfabf15a8c Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 13 Jun 2023 01:42:46 -0600 Subject: [PATCH 035/156] Run GH on 1.20/main branch --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d8520c9fe..20542cba2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,6 +4,7 @@ on: branches: - '1.18.x/*' - '1.19.2/*' + - '1.20/*' pull_request: types: [ opened, synchronize, reopened ] jobs: From baf2e176a0e4e3a80cf1071c37cb81d7a910410c Mon Sep 17 00:00:00 2001 From: StewStrong Date: Wed, 14 Jun 2023 23:26:29 -0600 Subject: [PATCH 036/156] Added VS Creative Tab --- .../mod/common/ValkyrienSkiesMod.kt | 35 ++++++++++++++++++ .../assets/valkyrienskies/lang/en_us.json | 1 + .../fabric/common/ValkyrienSkiesModFabric.kt | 22 +++++------ .../forge/common/ValkyrienSkiesModForge.kt | 37 +++++++++++++++---- 4 files changed, 76 insertions(+), 19 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt index bbc5f5d30..96909fddf 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -1,9 +1,18 @@ package org.valkyrienskies.mod.common +import net.minecraft.core.Registry +import net.minecraft.core.registries.BuiltInRegistries +import net.minecraft.core.registries.Registries +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceKey +import net.minecraft.resources.ResourceLocation import net.minecraft.server.MinecraftServer import net.minecraft.world.entity.EntityType +import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.entity.BlockEntityType import org.valkyrienskies.core.api.ships.setAttachment import org.valkyrienskies.core.apigame.VSCore @@ -21,15 +30,21 @@ object ValkyrienSkiesMod { const val MOD_ID = "valkyrienskies" lateinit var TEST_CHAIR: Block + lateinit var TEST_CHAIR_ITEM: Item lateinit var TEST_HINGE: Block + lateinit var TEST_HINGE_ITEM: Item lateinit var TEST_FLAP: Block + lateinit var TEST_FLAP_ITEM: Item lateinit var TEST_WING: Block + lateinit var TEST_WING_ITEM: Item lateinit var SHIP_CREATOR_ITEM: Item lateinit var SHIP_ASSEMBLER_ITEM: Item lateinit var SHIP_CREATOR_ITEM_SMALLER: Item lateinit var SHIP_MOUNTING_ENTITY_TYPE: EntityType lateinit var TEST_HINGE_BLOCK_ENTITY_TYPE: BlockEntityType + val VS_CREATIVE_TAB = ResourceKey.create(Registries.CREATIVE_MODE_TAB, ResourceLocation("valkyrienskies")) + @JvmStatic var currentServer: MinecraftServer? = null @@ -52,4 +67,24 @@ object ValkyrienSkiesMod { event.ship.setAttachment(GameTickForceApplier()) } } + + fun registerCreativeTab() { + Registry.register( + BuiltInRegistries.CREATIVE_MODE_TAB, + VS_CREATIVE_TAB, + CreativeModeTab.builder(CreativeModeTab.Row.TOP, 0) + .title(Component.translatable("itemGroup.valkyrienSkies")) + .icon { ItemStack(SHIP_CREATOR_ITEM) } + .displayItems { _, output -> + output.accept(TEST_CHAIR_ITEM) + output.accept(TEST_HINGE_ITEM) + output.accept(TEST_FLAP_ITEM) + output.accept(TEST_WING_ITEM) + output.accept(SHIP_CREATOR_ITEM) + output.accept(SHIP_ASSEMBLER_ITEM) + output.accept(SHIP_CREATOR_ITEM_SMALLER) + } + .build() + ) + } } diff --git a/common/src/main/resources/assets/valkyrienskies/lang/en_us.json b/common/src/main/resources/assets/valkyrienskies/lang/en_us.json index 9851fd5b8..59929874e 100644 --- a/common/src/main/resources/assets/valkyrienskies/lang/en_us.json +++ b/common/src/main/resources/assets/valkyrienskies/lang/en_us.json @@ -7,6 +7,7 @@ "block.valkyrienskies.test_wing": "Debug Wing", "item.valkyrienskies.ship_creator": "Ship Creator", "item.valkyrienskies.ship_creator_smaller": "Mini Ship Creator", + "itemGroup.valkyrienSkies": "Valkyrien Skies", "argument.valkyrienskies.ship.no_found": "Ship not found", "argument.valkyrienskies.ship.multiple_found": "Multiple ships found", "command.valkyrienskies.delete.success": "Deleted %d ships!", 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 048f2c187..a0c80e419 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 @@ -21,7 +21,7 @@ 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 import net.minecraft.world.item.Item.Properties import net.minecraft.world.level.block.Block import org.valkyrienskies.core.apigame.VSCoreFactory @@ -38,7 +38,6 @@ import org.valkyrienskies.mod.common.config.VSEntityHandlerDataLoader 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.handling.VSEntityManager import org.valkyrienskies.mod.common.hooks.VSGameEvents import org.valkyrienskies.mod.common.item.ShipAssemblerItem import org.valkyrienskies.mod.common.item.ShipCreatorItem @@ -95,10 +94,10 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.init(vsCore) // VSEntityManager.registerContraptionHandler(ContraptionShipyardEntityHandlerFabric) - registerBlockAndItem("test_chair", ValkyrienSkiesMod.TEST_CHAIR) - registerBlockAndItem("test_hinge", ValkyrienSkiesMod.TEST_HINGE) - registerBlockAndItem("test_flap", ValkyrienSkiesMod.TEST_FLAP) - registerBlockAndItem("test_wing", ValkyrienSkiesMod.TEST_WING) + ValkyrienSkiesMod.TEST_CHAIR_ITEM = registerBlockAndItem("test_chair", ValkyrienSkiesMod.TEST_CHAIR) + ValkyrienSkiesMod.TEST_HINGE_ITEM =registerBlockAndItem("test_hinge", ValkyrienSkiesMod.TEST_HINGE) + ValkyrienSkiesMod.TEST_FLAP_ITEM = registerBlockAndItem("test_flap", ValkyrienSkiesMod.TEST_FLAP) + ValkyrienSkiesMod.TEST_WING_ITEM = registerBlockAndItem("test_wing", ValkyrienSkiesMod.TEST_WING) Registry.register( BuiltInRegistries.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_assembler"), ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM @@ -120,6 +119,8 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE ) + ValkyrienSkiesMod.registerCreativeTab() + CommandRegistrationCallback.EVENT.register { dispatcher, _, _ -> VSCommands.registerServerCommands(dispatcher) } @@ -175,14 +176,13 @@ class ValkyrienSkiesModFabric : ModInitializer { } } - private fun registerBlockAndItem(registryName: String, block: Block) { + private fun registerBlockAndItem(registryName: String, block: Block): Item { Registry.register( BuiltInRegistries.BLOCK, ResourceLocation(ValkyrienSkiesMod.MOD_ID, registryName), block ) - Registry.register( - BuiltInRegistries.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, registryName), - BlockItem(block, Properties()) - ) + val item = BlockItem(block, Properties()) + Registry.register(BuiltInRegistries.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, registryName), item) + return item } } 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 c99a6ceca..2dda79fb1 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 @@ -39,7 +39,6 @@ import org.valkyrienskies.mod.common.config.VSEntityHandlerDataLoader 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.handling.VSEntityManager import org.valkyrienskies.mod.common.hooks.VSGameEvents import org.valkyrienskies.mod.common.item.ShipAssemblerItem import org.valkyrienskies.mod.common.item.ShipCreatorItem @@ -52,9 +51,13 @@ class ValkyrienSkiesModForge { private val ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, ValkyrienSkiesMod.MOD_ID) private val BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, ValkyrienSkiesMod.MOD_ID) private val TEST_CHAIR_REGISTRY: RegistryObject + private val TEST_CHAIR_REGISTRY_ITEM: RegistryObject private val TEST_HINGE_REGISTRY: RegistryObject + private val TEST_HINGE_REGISTRY_ITEM: RegistryObject private val TEST_FLAP_REGISTRY: RegistryObject + private val TEST_FLAP_REGISTRY_ITEM: RegistryObject private val TEST_WING_REGISTRY: RegistryObject + private val TEST_WING_REGISTRY_ITEM: RegistryObject private val SHIP_CREATOR_ITEM_REGISTRY: RegistryObject private val SHIP_CREATOR_SMALLER_ITEM_REGISTRY: RegistryObject private val SHIP_MOUNTING_ENTITY_REGISTRY: RegistryObject> @@ -104,10 +107,22 @@ class ValkyrienSkiesModForge { } } - TEST_CHAIR_REGISTRY = registerBlockAndItem("test_chair") { TestChairBlock } - TEST_HINGE_REGISTRY = registerBlockAndItem("test_hinge") { TestHingeBlock } - TEST_FLAP_REGISTRY = registerBlockAndItem("test_flap") { TestFlapBlock } - TEST_WING_REGISTRY = registerBlockAndItem("test_wing") { TestWingBlock } + val testChairPair = registerBlockAndItem("test_chair") { TestChairBlock } + TEST_CHAIR_REGISTRY = testChairPair.first + TEST_CHAIR_REGISTRY_ITEM = testChairPair.second + + val testHingePair = registerBlockAndItem("test_hinge") { TestHingeBlock } + TEST_HINGE_REGISTRY = testHingePair.first + TEST_HINGE_REGISTRY_ITEM = testHingePair.second + + val testFlapPair = registerBlockAndItem("test_flap") { TestFlapBlock } + TEST_FLAP_REGISTRY = testFlapPair.first + TEST_FLAP_REGISTRY_ITEM = testFlapPair.second + + val testWingPair = registerBlockAndItem("test_wing") { TestWingBlock } + TEST_WING_REGISTRY = testWingPair.first + TEST_WING_REGISTRY_ITEM = testWingPair.second + SHIP_CREATOR_ITEM_REGISTRY = ITEMS.register("ship_creator") { ShipCreatorItem(Properties(), @@ -151,10 +166,10 @@ class ValkyrienSkiesModForge { event.registerEntityRenderer(SHIP_MOUNTING_ENTITY_REGISTRY.get(), ::EmptyRenderer) } - private fun registerBlockAndItem(registryName: String, blockSupplier: () -> Block): RegistryObject { + private fun registerBlockAndItem(registryName: String, blockSupplier: () -> Block): Pair, RegistryObject> { val blockRegistry = BLOCKS.register(registryName, blockSupplier) - ITEMS.register(registryName) { BlockItem(blockRegistry.get(), Properties()) } - return blockRegistry + val itemRegister = ITEMS.register(registryName) { BlockItem(blockRegistry.get(), Properties()) } + return Pair(blockRegistry, itemRegister) } private fun registerCommands(event: RegisterCommandsEvent) { @@ -171,13 +186,19 @@ class ValkyrienSkiesModForge { private fun loadComplete(event: FMLLoadCompleteEvent) { ValkyrienSkiesMod.TEST_CHAIR = TEST_CHAIR_REGISTRY.get() + ValkyrienSkiesMod.TEST_CHAIR_ITEM = TEST_CHAIR_REGISTRY_ITEM.get() ValkyrienSkiesMod.TEST_HINGE = TEST_HINGE_REGISTRY.get() + ValkyrienSkiesMod.TEST_HINGE_ITEM = TEST_HINGE_REGISTRY_ITEM.get() ValkyrienSkiesMod.TEST_FLAP = TEST_FLAP_REGISTRY.get() + ValkyrienSkiesMod.TEST_FLAP_ITEM = TEST_FLAP_REGISTRY_ITEM.get() ValkyrienSkiesMod.TEST_WING = TEST_WING_REGISTRY.get() + ValkyrienSkiesMod.TEST_WING_ITEM = TEST_WING_REGISTRY_ITEM.get() ValkyrienSkiesMod.SHIP_CREATOR_ITEM = SHIP_CREATOR_ITEM_REGISTRY.get() ValkyrienSkiesMod.SHIP_CREATOR_ITEM_SMALLER = SHIP_CREATOR_SMALLER_ITEM_REGISTRY.get() ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE = SHIP_MOUNTING_ENTITY_REGISTRY.get() ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM = SHIP_ASSEMBLER_ITEM_REGISTRY.get() ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE = TEST_HINGE_BLOCK_ENTITY_TYPE_REGISTRY.get() + + ValkyrienSkiesMod.registerCreativeTab() } } From a8664578d934ce6b809068f44bea0b57a0f12801 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 22 Jun 2023 18:35:51 -0600 Subject: [PATCH 037/156] Updated to 1.20.1 --- .github/workflows/build.yml | 1 + fabric/src/main/resources/fabric.mod.json | 2 +- forge/src/main/resources/META-INF/mods.toml | 2 +- gradle.properties | 8 ++++---- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 20542cba2..e62babf96 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,7 @@ on: - '1.18.x/*' - '1.19.2/*' - '1.20/*' + - '1.20.1/*' pull_request: types: [ opened, synchronize, reopened ] jobs: diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index f433c9fc7..9a4892d6a 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.20", + "minecraft": "1.20.1", "fabric": "*" }, "breaks": { diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 997022bc0..cbcf33fb1 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.20]" +versionRange = "[1.20.1]" ordering = "NONE" side = "BOTH" diff --git a/gradle.properties b/gradle.properties index 8986bff12..054c69f16 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,13 +1,13 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G -minecraft_version=1.20 +minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge -archives_base_name=valkyrienskies-1200 +archives_base_name=valkyrienskies-1201 mod_version=2.3.0-beta.1 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 fabric_loader_version=0.14.21 -fabric_api_version=0.83.0+1.20 -forge_version=1.20-46.0.14 +fabric_api_version=0.84.0+1.20.1 +forge_version=1.20.1-47.0.18 create_fabric_version=0.5.0.i-1017+1.19.2 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually From 414eee9897a452f0b7602dcbd495442494c90842 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 22 Jun 2023 18:50:20 -0600 Subject: [PATCH 038/156] Empty commit to retrigger actions From 709204c44e8de1374d3dd4df56239d6d55f64af1 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 22 Jun 2023 20:33:45 -0600 Subject: [PATCH 039/156] Re-enabled ModMenu support --- fabric/build.gradle | 2 +- .../mod/fabric/compat/modmenu/ValkyrienModMenu.kt | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 2c342ddb7..a1f1afb80 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -41,7 +41,7 @@ dependencies { include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:11.0.99")) modCompileOnly("maven.modrinth:sodium:mc1.20-0.4.10") - // modImplementation("com.terraformersmc:modmenu:4.1.0") + modImplementation("maven.modrinth:modmenu:7.1.0") // Depend on the fabric API modImplementation("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}") diff --git a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt index 88870c090..bdd81fbdf 100644 --- a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt +++ b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.fabric.compat.modmenu -/* import com.terraformersmc.modmenu.api.ConfigScreenFactory import com.terraformersmc.modmenu.api.ModMenuApi import org.valkyrienskies.core.impl.config.VSConfigClass.Companion.getRegisteredConfig @@ -19,4 +18,3 @@ class ValkyrienModMenu : ModMenuApi { } } } -*/ From 0027f43b320c0305774ced831e251fa7a2701b66 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 22 Jun 2023 20:44:49 -0600 Subject: [PATCH 040/156] Updated cloth-config to 11.0.99 --- common/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/build.gradle b/common/build.gradle index 0ce69d5b4..a67905ffd 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -6,7 +6,7 @@ dependencies { // Do NOT use other classes from fabric loader modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modApi("me.shedaniel.cloth:cloth-config:4.14.64") + modApi("me.shedaniel.cloth:cloth-config:11.0.99") modCompileOnly("maven.modrinth:sodium:mc1.20-0.4.10") From c9e7ee4d7f24ba20d2f576b296fbcab52bf518b6 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 22 Jun 2023 20:51:11 -0600 Subject: [PATCH 041/156] Fixed vs2 mod menu not working in Forge --- forge/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge/build.gradle b/forge/build.gradle index ed604bdfb..2eba63114 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -82,7 +82,7 @@ dependencies { forgeRuntimeLibrary('curse.maven:kotlinforforge-351264:4578885') // Cloth for config - include(modImplementation("me.shedaniel.cloth:cloth-config-forge:8.2.88")) + include(modImplementation("me.shedaniel.cloth:cloth-config-forge:11.0.99")) // Shade vs-core implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") From 5d00b7ee45b9d0da6fa31b58208e21f66fbc070d Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 23 Jun 2023 04:03:59 -0600 Subject: [PATCH 042/156] Don't export joml module with forge --- forge/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/forge/build.gradle b/forge/build.gradle index 2eba63114..ec357e439 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -116,7 +116,6 @@ dependencies { forgeRuntimeLibrary include("javax.inject:javax.inject:1") { transitive = false } // JOML for Math - forgeRuntimeLibrary include("org.joml:joml:1.10.4") { transitive = false } forgeRuntimeLibrary include("org.joml:joml-primitives:1.10.0") { transitive = false } // Apache Commons Math for Linear Programming From 476bc3d1fc142666ee04fdfbf2c68dcfbb94d351 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 23 Jun 2023 04:14:17 -0600 Subject: [PATCH 043/156] Fixed shipyard_entities.MixinEntitySection --- .../mixin/feature/shipyard_entities/MixinEntitySection.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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..96f0bfedd 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;Lnet/minecraft/util/AbortableIterationConsumer;)Lnet/minecraft/util/AbortableIterationConsumer$Continuation;", at = @At("HEAD"), ordinal = 0, argsOnly = true) @@ -41,7 +41,7 @@ AABB modifyAABB1(final AABB aabb) { } @ModifyVariable( - method = "getEntities(Lnet/minecraft/world/level/entity/EntityTypeTest;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Consumer;)V", + method = "getEntities(Lnet/minecraft/world/level/entity/EntityTypeTest;Lnet/minecraft/world/phys/AABB;Lnet/minecraft/util/AbortableIterationConsumer;)Lnet/minecraft/util/AbortableIterationConsumer$Continuation;", at = @At("HEAD"), ordinal = 0, argsOnly = true) From 6b345ea0b088e42f73c36c5b034f5049e7fa528d Mon Sep 17 00:00:00 2001 From: StewStrong Date: Wed, 28 Jun 2023 22:15:54 -0600 Subject: [PATCH 044/156] Bump version to 2.3.0-beta.2 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 054c69f16..1dba59c42 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-1201 -mod_version=2.3.0-beta.1 +mod_version=2.3.0-beta.2 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 fabric_loader_version=0.14.21 From 5fc9af445f24b1270ca1bfc7cdc39eb7f15b2845 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 29 Jun 2023 00:41:43 -0600 Subject: [PATCH 045/156] Disabled SwimNodeEvaluatorMixin --- .../feature/ai/node_evaluator/SwimNodeEvaluatorMixin.java | 8 ++++---- .../src/main/resources/valkyrienskies-common.mixins.json | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) 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 a30fcbb8e..845101b18 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 @@ -23,7 +23,7 @@ public abstract class SwimNodeEvaluatorMixin extends NodeEvaluator { @WrapOperation( at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/BlockGetter;getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"), - method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;IIIZZ)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" + method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" ) private FluidState getFluidStateRedirectPathType(final BlockGetter instance, final BlockPos blockPos, final Operation getFluidState) { @@ -58,7 +58,7 @@ private FluidState getFluidStateRedirectPathType(final BlockGetter instance, fin @WrapOperation( at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/BlockGetter;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), - method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;IIIZZ)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" + method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" ) private BlockState getBlockStateRedirectPathType(final BlockGetter instance, final BlockPos blockPos, final Operation getBlockState) { @@ -85,7 +85,7 @@ private BlockState getBlockStateRedirectPathType(final BlockGetter instance, fin @WrapOperation( at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;isPathfindable(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/pathfinder/PathComputationType;)Z"), - method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;IIIZZ)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" + method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" ) private boolean isPathFindableRedirectPathType(final BlockState instance, final BlockGetter blockGetter, final BlockPos blockPos, final PathComputationType pathComputationType, @@ -122,7 +122,7 @@ private boolean isPathFindableRedirectPathType(final BlockState instance, final @WrapOperation( at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/PathNavigationRegion;getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"), - method = "getNode" + method = "findAcceptedNode" ) private FluidState getFluidStateRedirectGetNode(final PathNavigationRegion instance, final BlockPos blockPos, final Operation getFluidState) { diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 6a0e3f476..3e18fb56a 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -11,7 +11,6 @@ "accessors.world.level.pathfinder.PathAccessor", "entity.MixinEntity", "feature.ai.node_evaluator.PathNavigationRegionAccessor", - "feature.ai.node_evaluator.SwimNodeEvaluatorMixin", "feature.ai.node_evaluator.WalkNodeEvaluatorMixin", "feature.bed_fix.MixinServerPlayer", "feature.block_placement_orientation.MixinBlockItem", From 0dd02e1f03d7f098f36a5afa7de3ce9ab7f82c1d Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 29 Jun 2023 01:25:00 -0600 Subject: [PATCH 046/156] Fixed MixinFlowingFluid --- .../fluid_escaping_ship_config/MixinFlowingFluid.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fluid_escaping_ship_config/MixinFlowingFluid.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fluid_escaping_ship_config/MixinFlowingFluid.java index 9f06d2cf7..41cb60c8f 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fluid_escaping_ship_config/MixinFlowingFluid.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/fluid_escaping_ship_config/MixinFlowingFluid.java @@ -27,13 +27,13 @@ private void beforeCanSpreadTo(final BlockGetter level, final BlockPos fromPos, if (VSGameConfig.SERVER.getPreventFluidEscapingShip() && level instanceof Level) { final Ship ship = VSGameUtilsKt.getShipManagingPos((Level) level, toPos); - if (ship != null && ship.getShipVoxelAABB() != null) { - final AABBic a = ship.getShipVoxelAABB(); + if (ship != null && ship.getShipAABB() != null) { + final AABBic a = ship.getShipAABB(); final int x = toPos.getX(); final int y = toPos.getY(); final int z = toPos.getZ(); - if (x <= a.minX() || y < a.minY() || z <= a.minZ() || x >= a.maxX() || y >= a.maxY() || z >= a.maxZ()) { + if (x < a.minX() || y < a.minY() || z < a.minZ() || x >= a.maxX() || y >= a.maxY() || z >= a.maxZ()) { cir.setReturnValue(false); } } From 6d82054f16ba04e0bdb2dc9434ea32005636145f Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 29 Jun 2023 01:44:12 -0600 Subject: [PATCH 047/156] Bump version to 2.3.0-beta.3 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 1dba59c42..ff2944737 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-1201 -mod_version=2.3.0-beta.2 +mod_version=2.3.0-beta.3 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 fabric_loader_version=0.14.21 From 754bc4f9ec2038964df1bef6af11e2f9f8f2d591 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 14 Jul 2023 01:22:14 -0600 Subject: [PATCH 048/156] Fixed rubidium not working --- forge/build.gradle | 2 +- .../forge/mixin/compat/sodium/MixinRenderSectionManager.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index ec357e439..8bd88f4ea 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -63,7 +63,7 @@ dependencies { transitive = false } - modCompileOnly("curse.maven:rubidium-574856:4024781") + modImplementation("curse.maven:rubidium-574856:4573226") // Create compat // modImplementation("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false } 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 index b62c9af72..bed0d55cf 100644 --- 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 @@ -7,6 +7,8 @@ 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.Matrix4d; +import org.joml.Matrix4f; import org.joml.Vector3dc; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -15,8 +17,6 @@ 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 { From 0c2b0e67809cfa6fa2533bcdc5318480b49e93af Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 14 Jul 2023 01:41:04 -0600 Subject: [PATCH 049/156] Empty commit to rerun actions From ab3fa08423feed03fba4a9778b8681bb4254f1f5 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 14 Jul 2023 02:06:01 -0600 Subject: [PATCH 050/156] Empty commit to rerun actions again From 50c98481bce1572ae15ae13d0c7b3701d9a3c827 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 14 Jul 2023 02:45:36 -0600 Subject: [PATCH 051/156] Empty commit to rerun actions again again From 6fe9b1613cd76520325a4626f2707651245e99be Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 14 Jul 2023 03:03:44 -0600 Subject: [PATCH 052/156] Empty commit to rerun actions again again again From 3392afcb473c8c152e61bfb75543e21a89f721c5 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 14 Jul 2023 03:11:49 -0600 Subject: [PATCH 053/156] Empty commit to rerun actions again again again again From afbc25315480be5391b64c0c719d05b7d65eae17 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 14 Jul 2023 23:12:23 -0600 Subject: [PATCH 054/156] Empty commit to rerun actions again again again again again From c865b62415737bf0b5a79ad544f5c415fd644781 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sat, 15 Jul 2023 02:34:47 -0600 Subject: [PATCH 055/156] Fixed ship bounding boxes flickering on client --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index ead972f38..9c5b345b1 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit ead972f384499b1b7713e20dde3d0affe7fdc3f1 +Subproject commit 9c5b345b16b72c9c2dcf34678f24ec0d9a0efdee From 9480a7cf6b966b6bd1b6d8abdc130ec732fb19d0 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sat, 15 Jul 2023 02:35:18 -0600 Subject: [PATCH 056/156] Removed redundant function --- .../kotlin/org/valkyrienskies/mod/util/VectorConversionsMC.kt | 1 - 1 file changed, 1 deletion(-) 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 a5253c42e..7a7aeed7b 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/util/VectorConversionsMC.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/util/VectorConversionsMC.kt @@ -66,7 +66,6 @@ fun Vector3ic.toBlockPos() = BlockPos(x(), y(), z()) fun Vector3dc.toMinecraft() = Vec3(x(), y(), z()) 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) From 0ecc997af5d366629e3808c687ed0b8d657297a2 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sat, 15 Jul 2023 05:48:57 -0600 Subject: [PATCH 057/156] Bumped version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index ff2944737..f6c3a6a7f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-1201 -mod_version=2.3.0-beta.3 +mod_version=2.3.0-beta.4 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 fabric_loader_version=0.14.21 From 7787492bb6612cdbe15e2d8e178de3ef087f1f6f Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sat, 15 Jul 2023 16:43:09 -0600 Subject: [PATCH 058/156] Updated architectury plugin and loom to latest --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index a271cfecd..2598e178c 100644 --- a/build.gradle +++ b/build.gradle @@ -7,8 +7,8 @@ buildscript { plugins { // Needed for Forge+Fabric - id "architectury-plugin" version "3.4.143" - id "dev.architectury.loom" version "1.0.306" apply false + id "architectury-plugin" version "3.4.146" + id "dev.architectury.loom" version "1.1.346" apply false id 'io.github.juuxel.loom-quiltflower' version '1.8.0' apply false // Kotlin id "org.jetbrains.kotlin.jvm" version "1.7.10" apply false From 9b64fd48b451941622181dbecb91045f10f9665e Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 18 Jul 2023 00:39:07 -0600 Subject: [PATCH 059/156] Added create to workspace --- forge/build.gradle | 6 +++--- forge/gradle.properties | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index 8bd88f4ea..2b5184ba1 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -66,9 +66,9 @@ dependencies { modImplementation("curse.maven:rubidium-574856:4573226") // 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}:all") { transitive = false } + modImplementation("com.jozufozu.flywheel:flywheel-forge-1.20:${flywheel_version}") + modImplementation("com.tterrag.registrate:Registrate:${registrate_version}") // CC Tweaked // modCompileOnly("curse.maven:cc-tweaked-282001:4061947") diff --git a/forge/gradle.properties b/forge/gradle.properties index 04e81539e..b858e6dd0 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -2,6 +2,6 @@ loader_platform=Forge loom.platform=forge kotlin.stdlib.default.dependency=false #Compat -create_version=0.5.0.i-23 -flywheel_version=0.6.8.a-14 -registrate_version=MC1.19-1.1.5 +create_version=0.5.1.d-9 +flywheel_version=0.6.9-4 +registrate_version=MC1.20-1.3.3 From 74841fa870ca000742e012c8135b40e4b8f854c7 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 18 Jul 2023 02:39:43 -0600 Subject: [PATCH 060/156] Got create rendering working in Fabric and Forge --- build.gradle | 5 +++++ common/build.gradle | 8 ++++---- .../flywheel/InstancingEngineAccessor.java | 2 -- .../flywheel/MixinBlockEntityInstanceManager.java | 2 -- .../mod_compat/flywheel/MixinInstanceManager.java | 6 ++---- .../mod_compat/flywheel/MixinInstanceWorld.java | 8 +++----- .../mod_compat/flywheel/MixinInstancingEngine.java | 4 +--- .../MixinBlockEntityInstanceManagerDuck.java | 2 -- .../mod/mixinducks/MixinInstancingEngineDuck.java | 4 +--- .../main/resources/valkyrienskies-common.mixins.json | 5 +++++ fabric/build.gradle | 8 ++++---- fabric/gradle.properties | 12 ++++++------ gradle.properties | 2 +- 13 files changed, 32 insertions(+), 36 deletions(-) diff --git a/build.gradle b/build.gradle index 2598e178c..fee094bd7 100644 --- a/build.gradle +++ b/build.gradle @@ -89,6 +89,11 @@ subprojects { maven { url = "https://maven.tterrag.com/" } // Registrate, Forge Create and Flywheel maven { url = "https://maven.cafeteria.dev/releases" } // Fake Player API maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes + maven { url = "https://mvn.devos.one/#/snapshots/" } // Create Fabric + maven { + url = "https://jitpack.io" + content { includeGroup("com.github.llamalad7.mixinextras") } + } // MixinExtras smh my head } } diff --git a/common/build.gradle b/common/build.gradle index a67905ffd..fba938c95 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,5 +1,5 @@ dependencies { - annotationProcessor(implementation("com.github.LlamaLad7:MixinExtras:0.1.1")) + annotationProcessor(implementation("com.github.llamalad7.mixinextras:mixinextras-common:0.2.0-beta.8")) compileOnly 'com.google.code.findbugs:jsr305:3.0.2' // We depend on fabric loader here to use the fabric @Environment annotations @@ -24,9 +24,9 @@ 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.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.8.a-4") + modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") + { exclude group: 'com.github.AlphaMode', module: 'fakeconfigtoml' } + modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.9-4") } architectury { 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 index 64c3f3c14..dc644a299 100644 --- 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 @@ -1,6 +1,5 @@ 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; @@ -14,4 +13,3 @@ public interface InstancingEngineAccessor { 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 index 5506090df..6a252f0b2 100644 --- 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 @@ -1,6 +1,5 @@ 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; @@ -80,4 +79,3 @@ private MaterialManager createMaterialManager() { } } } -*/ 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 index 0ebcea96b..8f1e8eb66 100644 --- 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 @@ -1,6 +1,5 @@ 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; @@ -32,7 +31,7 @@ private BlockPos redirectGetWorldPos1(final DynamicInstance receiver) { VectorConversionsMCKt.toJOMLD(receiver.getWorldPosition()) ); - return new BlockPos(v.x, v.y, v.z); + return BlockPos.containing(v.x, v.y, v.z); } @Redirect( @@ -47,8 +46,7 @@ private BlockPos redirectGetWorldPos2(final TickableInstance receiver) { receiver.getWorldPosition(), VectorConversionsMCKt.toJOMLD(receiver.getWorldPosition())); - return new BlockPos(v.x, v.y, v.z); + return BlockPos.containing(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 index 9d26566eb..52116092d 100644 --- 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 @@ -1,6 +1,5 @@ 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; @@ -9,9 +8,9 @@ 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.Matrix4f; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -63,7 +62,7 @@ void render(final ClientShip ship, final MaterialManager manager, final RenderLa if (manager instanceof InstancingEngine engine) { final Vector3d origin = VectorConversionsMCKt.toJOMLD(engine.getOriginCoordinate()); - final Matrix4d viewProjection = VectorConversionsMCKt.toJOML(event.viewProjection); + final Matrix4d viewProjection = new Matrix4d(event.viewProjection); final Matrix4d finalProjection = new Matrix4d() .mul(viewProjection) @@ -75,7 +74,7 @@ void render(final ClientShip ship, final MaterialManager manager, final RenderLa .transformPosition(event.camX, event.camY, event.camZ, new Vector3d()) .sub(origin); - final Matrix4f fnlProj = VectorConversionsMCKt.toMinecraft(finalProjection); + final Matrix4f fnlProj = new Matrix4f(finalProjection); ((MixinInstancingEngineDuck) engine).render( fnlProj, @@ -94,4 +93,3 @@ void render(final ClientShip ship, final MaterialManager manager, final RenderLa } } } -*/ 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 index 8b7fca15b..f72100a66 100644 --- 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 @@ -1,15 +1,14 @@ 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.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.Nullable; +import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.Shadow; @@ -33,4 +32,3 @@ public void render(final Matrix4f viewProjection, final double camX, final doubl }); } } -*/ diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java index 03df30043..9e9a3aea5 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.mixinducks; -/* import com.jozufozu.flywheel.api.MaterialManager; import java.util.WeakHashMap; import org.valkyrienskies.core.api.ships.ClientShip; @@ -10,4 +9,3 @@ public interface MixinBlockEntityInstanceManagerDuck { WeakHashMap getShipMaterialManagers(); } -*/ diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java index 227587868..d77668a80 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java @@ -1,10 +1,8 @@ package org.valkyrienskies.mod.mixinducks; -/* import com.jozufozu.flywheel.backend.RenderLayer; -import com.mojang.math.Matrix4f; +import org.joml.Matrix4f; public interface MixinInstancingEngineDuck { void render(Matrix4f viewProjection, double camX, double camY, double camZ, RenderLayer layer); } -*/ diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 3e18fb56a..2eb1ad8af 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -92,6 +92,11 @@ "feature.transform_particles.MixinLevelRenderer", "feature.transform_particles.MixinParticle", "feature.vs2_alpha_hud.MixinGui", + "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 a1f1afb80..82d38f020 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -65,10 +65,10 @@ dependencies { // modImplementation("curse.maven:cc-restitched-462672:3908334") // Create compat - // modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_version}+${minecraft_version}") { transitive = false } - // modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version}") - // 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}") { } + // modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.9-4") + modImplementation("com.tterrag.registrate_fabric:Registrate:${registrate_version}") + // modImplementation("io.github.fabricators_of_create.Porting-Lib:porting-lib:${port_lib_version}") // modImplementation("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") // modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") // modImplementation("io.github.tropheusj:milk-lib:${milk_lib_version}") diff --git a/fabric/gradle.properties b/fabric/gradle.properties index e90a472b3..bc72e69e3 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1,14 +1,14 @@ loader_platform=Fabric -create_version=0.5.0.i-961 +create_version=0.5.1-c-build.1110+mc1.20.1 # https://github.com/Fabricators-of-Create/Create/blob/mc1.18/fabric/dev/gradle.properties config_api_id=4143545 forge_config_api_port_version=4.2.10 # https://maven.tterrag.com/com/jozufozu/flywheel/Flywheel-Fabric -flywheel_version=0.6.8.a-4 -reach_entity_attributes_version=2.3.0 -registrate_version=1.1.50-MC1.19.2 -milk_lib_version=1.0.51 -port_lib_version=2.1.722 +flywheel_version=0.6.9-4 +reach_entity_attributes_version=2.4.0 +registrate_version=1.3.61-MC1.20 +milk_lib_version=1.2.60 +port_lib_version=2.1.1056+1.20 night_config_core_version=3.6.3 night_config_toml_version=3.6.3 jsr305_version=3.0.2 diff --git a/gradle.properties b/gradle.properties index f6c3a6a7f..e210e2956 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ architectury_version=6.3.49 fabric_loader_version=0.14.21 fabric_api_version=0.84.0+1.20.1 forge_version=1.20.1-47.0.18 -create_fabric_version=0.5.0.i-1017+1.19.2 +create_fabric_version=0.5.1-c-build.1110+mc1.20.1 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually kotlin.stdlib.default.dependency=false From 22633180602ce52c4ef746aaf982ca0875101167 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 18 Jul 2023 05:30:30 -0600 Subject: [PATCH 061/156] Fixed forge creative tab --- .../mod/common/ValkyrienSkiesMod.kt | 35 ++++++++----------- .../fabric/common/ValkyrienSkiesModFabric.kt | 6 +++- .../forge/common/ValkyrienSkiesModForge.kt | 13 +++++-- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt index 96909fddf..822682efe 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -1,7 +1,5 @@ package org.valkyrienskies.mod.common -import net.minecraft.core.Registry -import net.minecraft.core.registries.BuiltInRegistries import net.minecraft.core.registries.Registries import net.minecraft.network.chat.Component import net.minecraft.resources.ResourceKey @@ -12,7 +10,6 @@ import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.entity.BlockEntityType import org.valkyrienskies.core.api.ships.setAttachment import org.valkyrienskies.core.apigame.VSCore @@ -68,23 +65,19 @@ object ValkyrienSkiesMod { } } - fun registerCreativeTab() { - Registry.register( - BuiltInRegistries.CREATIVE_MODE_TAB, - VS_CREATIVE_TAB, - CreativeModeTab.builder(CreativeModeTab.Row.TOP, 0) - .title(Component.translatable("itemGroup.valkyrienSkies")) - .icon { ItemStack(SHIP_CREATOR_ITEM) } - .displayItems { _, output -> - output.accept(TEST_CHAIR_ITEM) - output.accept(TEST_HINGE_ITEM) - output.accept(TEST_FLAP_ITEM) - output.accept(TEST_WING_ITEM) - output.accept(SHIP_CREATOR_ITEM) - output.accept(SHIP_ASSEMBLER_ITEM) - output.accept(SHIP_CREATOR_ITEM_SMALLER) - } - .build() - ) + fun createCreativeTab(): CreativeModeTab { + return CreativeModeTab.builder(CreativeModeTab.Row.TOP, 0) + .title(Component.translatable("itemGroup.valkyrienSkies")) + .icon { ItemStack(SHIP_CREATOR_ITEM) } + .displayItems { _, output -> + output.accept(TEST_CHAIR_ITEM) + output.accept(TEST_HINGE_ITEM) + output.accept(TEST_FLAP_ITEM) + output.accept(TEST_WING_ITEM) + output.accept(SHIP_CREATOR_ITEM) + output.accept(SHIP_ASSEMBLER_ITEM) + output.accept(SHIP_CREATOR_ITEM_SMALLER) + } + .build() } } 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 a0c80e419..5379e98b4 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 @@ -119,7 +119,11 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE ) - ValkyrienSkiesMod.registerCreativeTab() + Registry.register( + BuiltInRegistries.CREATIVE_MODE_TAB, + ValkyrienSkiesMod.VS_CREATIVE_TAB, + ValkyrienSkiesMod.createCreativeTab() + ) CommandRegistrationCallback.EVENT.register { dispatcher, _, _ -> VSCommands.registerServerCommands(dispatcher) 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 2dda79fb1..4a7d3e997 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 @@ -1,6 +1,7 @@ package org.valkyrienskies.mod.forge.common import net.minecraft.commands.Commands.CommandSelection.* +import net.minecraft.core.registries.Registries import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.MobCategory @@ -13,12 +14,13 @@ import net.minecraftforge.client.ConfigScreenHandler import net.minecraftforge.client.event.EntityRenderersEvent import net.minecraftforge.client.event.RegisterKeyMappingsEvent import net.minecraftforge.event.AddReloadListenerEvent -import net.minecraftforge.event.TagsUpdatedEvent import net.minecraftforge.event.RegisterCommandsEvent +import net.minecraftforge.event.TagsUpdatedEvent import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent +import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext import net.minecraftforge.fml.loading.FMLEnvironment import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries @@ -28,6 +30,7 @@ import org.valkyrienskies.core.impl.config.VSConfigClass import org.valkyrienskies.core.impl.config.VSCoreConfig import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod +import org.valkyrienskies.mod.common.ValkyrienSkiesMod.MOD_ID import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestFlapBlock import org.valkyrienskies.mod.common.block.TestHingeBlock @@ -149,6 +152,12 @@ class ValkyrienSkiesModForge { TEST_HINGE_BLOCK_ENTITY_TYPE_REGISTRY = BLOCK_ENTITIES.register("test_hinge_block_entity") { BlockEntityType.Builder.of(::TestHingeBlockEntity, TestHingeBlock).build(null) } + + val deferredRegister = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MOD_ID); + deferredRegister.register("general") { + ValkyrienSkiesMod.createCreativeTab() + } + deferredRegister.register(modBus) } private fun registerResourceManagers(event: AddReloadListenerEvent) { @@ -198,7 +207,5 @@ class ValkyrienSkiesModForge { ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE = SHIP_MOUNTING_ENTITY_REGISTRY.get() ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM = SHIP_ASSEMBLER_ITEM_REGISTRY.get() ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE = TEST_HINGE_BLOCK_ENTITY_TYPE_REGISTRY.get() - - ValkyrienSkiesMod.registerCreativeTab() } } From 27372913c411626fb02d6bd701e53ef42714dce5 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 18 Jul 2023 19:41:27 -0600 Subject: [PATCH 062/156] Gradle smh --- fabric/build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 82d38f020..deff21c15 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -65,7 +65,8 @@ dependencies { // modImplementation("curse.maven:cc-restitched-462672:3908334") // Create compat - modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { } + modImplementation("curse.maven:forge-config-api-port-fabric-547434:4583000") // Gradle shenanigans + modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") // modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.9-4") modImplementation("com.tterrag.registrate_fabric:Registrate:${registrate_version}") // modImplementation("io.github.fabricators_of_create.Porting-Lib:porting-lib:${port_lib_version}") From df62462f1e7570b0b08f53783ecf2d2cb5d8a701 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 18 Jul 2023 19:44:08 -0600 Subject: [PATCH 063/156] Gradle smh my head --- common/build.gradle | 5 +++-- fabric/build.gradle | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index fba938c95..da710ced8 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -22,8 +22,9 @@ dependencies { // modCompileOnly("curse.maven:ftb-teams-404468:4229138") // modCompileOnly("curse.maven:ftb-chunks-314906:4229120") - //Common create compat, - //We just use a version from a platform and hope the classes exist on both versions and mixins apply correctly + // Common create compat, + // We just use a version from a platform and hope the classes exist on both versions and mixins apply correctly + modCompileOnly("curse.maven:forge-config-api-port-fabric-547434:4583000") // Gradle shenanigans modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { exclude group: 'com.github.AlphaMode', module: 'fakeconfigtoml' } modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.9-4") diff --git a/fabric/build.gradle b/fabric/build.gradle index deff21c15..d6f119231 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -65,7 +65,6 @@ dependencies { // modImplementation("curse.maven:cc-restitched-462672:3908334") // Create compat - modImplementation("curse.maven:forge-config-api-port-fabric-547434:4583000") // Gradle shenanigans modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") // modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.9-4") modImplementation("com.tterrag.registrate_fabric:Registrate:${registrate_version}") From 5ed97d32acbcc43d2af5668cc2048902f4cfabff Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 18 Jul 2023 19:58:37 -0600 Subject: [PATCH 064/156] Gradle smh my head x3 --- common/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/common/build.gradle b/common/build.gradle index da710ced8..ba3e3f80c 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -24,7 +24,6 @@ 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("curse.maven:forge-config-api-port-fabric-547434:4583000") // Gradle shenanigans modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { exclude group: 'com.github.AlphaMode', module: 'fakeconfigtoml' } modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.9-4") From c4d068cf4b0c01c57dc0d826f33a35449b164917 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 18 Jul 2023 20:58:33 -0600 Subject: [PATCH 065/156] Fix merge conflicts --- .../feature/mass_tooltip/MixinBlockItem.java | 3 +-- .../mod/common/command/ShipArgument.kt | 15 --------------- .../mod/common/command/VSCommands.kt | 12 +----------- .../resources/valkyrienskies-common.mixins.json | 1 - 4 files changed, 2 insertions(+), 29 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/mass_tooltip/MixinBlockItem.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/mass_tooltip/MixinBlockItem.java index fa9eac7dc..4b9155213 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/mass_tooltip/MixinBlockItem.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/mass_tooltip/MixinBlockItem.java @@ -4,7 +4,6 @@ import java.util.Objects; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; @@ -31,7 +30,7 @@ public class MixinBlockItem { final Double mass = Objects.requireNonNull(BlockStateInfo.INSTANCE.get(item.getBlock().defaultBlockState())) .getFirst(); - list.add(new TranslatableComponent("tooltip.valkyrienskies.mass") + list.add(Component.translatable("tooltip.valkyrienskies.mass") .append(VSGameConfig.CLIENT.getTooltip().getUseImperialUnits() ? getImperialText(mass) : ": " + mass + "kg").withStyle(ChatFormatting.DARK_GRAY)); } catch (final Exception ignored) { diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt index 7c51468ac..9687f8f4c 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.common.command -import com.google.gson.JsonObject import com.mojang.brigadier.StringReader import com.mojang.brigadier.arguments.ArgumentType import com.mojang.brigadier.context.CommandContext @@ -88,18 +87,4 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType } override fun getExamples(): Collection = EXAMPLES - - object Serializer : ArgumentSerializer { - override fun serializeToNetwork(arg: ShipArgument, buf: FriendlyByteBuf) { - buf.writeBoolean(arg.selectorOnly) - } - - override fun deserializeFromNetwork(buf: FriendlyByteBuf): ShipArgument { - return ShipArgument(buf.readBoolean()) - } - - override fun serializeToJson(arg: ShipArgument, json: JsonObject) { - json.addProperty("selectorOnly", arg.selectorOnly) - } - } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt index 2f0815a3f..0a3f73197 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt @@ -12,7 +12,7 @@ import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.EntityArgument import net.minecraft.commands.arguments.coordinates.BlockPosArgument import net.minecraft.commands.arguments.coordinates.Vec3Argument -import net.minecraft.network.chat.TranslatableComponent +import net.minecraft.network.chat.Component import net.minecraft.world.entity.Entity import net.minecraft.world.phys.BlockHitResult import org.joml.Vector3d @@ -44,16 +44,6 @@ object VSCommands { private const val TELEPORTED_MULTIPLE_SHIPS_SUCCESS = "command.valkyrienskies.teleport.multiple_ship_success" private const val TELEPORT_FIRST_ARG_CAN_ONLY_INPUT_1_SHIP = "command.valkyrienskies.mc_teleport.can_only_teleport_to_one_ship" - fun bootstrap() { - ArgumentTypes.register("valkyrienskies:ship", - ShipArgument::class.java, - ShipArgument.Serializer) - - ArgumentTypes.register("valkyrienskies:relative_vector", - RelativeVector3Argument::class.java, - EmptyArgumentSerializer(::RelativeVector3Argument)) - } - private fun literal(name: String) = LiteralArgumentBuilder.literal(name) diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 1f509c9bc..6c9030508 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -18,7 +18,6 @@ "feature.block_placement_orientation.MixinBlockItem", "feature.block_placement_orientation.MixinBlockPlaceContext", "feature.clip_replace.MixinLevel", - "feature.commands.MixinArgumentTypes", "feature.commands.MixinArgumentTypeInfos", "feature.commands.MixinCommandSourceStack", "feature.conduit_fix.ConduitMixin", From 75d0ef133a2b80edae646ce2bea99ad3aa2ebd08 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Wed, 19 Jul 2023 19:37:49 -0600 Subject: [PATCH 066/156] Moved vs2 maven to bottom --- build.gradle | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index fee094bd7..251e8a00c 100644 --- a/build.gradle +++ b/build.gradle @@ -56,16 +56,6 @@ subprojects { repositories { mavenCentral() - maven { - name = "Valkyrien Skies Internal" - url = project.vs_maven_url ?: 'https://maven.valkyrienskies.org' - if (project.vs_maven_username && project.vs_maven_password) { - credentials { - username = project.vs_maven_username - password = project.vs_maven_password - } - } - } if (!project.block_external_repositories) { mavenLocal() maven { @@ -95,6 +85,16 @@ subprojects { content { includeGroup("com.github.llamalad7.mixinextras") } } // MixinExtras smh my head } + maven { + name = "Valkyrien Skies Internal" + url = project.vs_maven_url ?: 'https://maven.valkyrienskies.org' + if (project.vs_maven_username && project.vs_maven_password) { + credentials { + username = project.vs_maven_username + password = project.vs_maven_password + } + } + } } // Remove automatically added repos From b2de01d9de117e513e032af6267a57bdd2c9c1aa Mon Sep 17 00:00:00 2001 From: StewStrong Date: Wed, 19 Jul 2023 19:50:21 -0600 Subject: [PATCH 067/156] Updated version to 2.2.0-beta.4 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 82baba634..32645f7bd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.19.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-1192 -mod_version=2.2.0-beta.3 +mod_version=2.2.0-beta.4 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 fabric_loader_version=0.14.11 From 2e2d63a807f0151e4cc218de4253fe641021246b Mon Sep 17 00:00:00 2001 From: StewStrong Date: Wed, 19 Jul 2023 20:12:53 -0600 Subject: [PATCH 068/156] Updated version to 2.3.0-beta.5 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index e210e2956..d3002e387 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-1201 -mod_version=2.3.0-beta.4 +mod_version=2.3.0-beta.5 maven_group=org.valkyrienskies.mod architectury_version=6.3.49 fabric_loader_version=0.14.21 From b3555ab2ad2f5ff44e6d42c4a203046ffd4ff797 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 5 Sep 2023 08:23:14 -0400 Subject: [PATCH 069/156] add breaks sodium 0.5.0 to fabric.mod.json --- fabric/src/main/resources/fabric.mod.json | 1 + 1 file changed, 1 insertion(+) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 9a4892d6a..42091e2a0 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -34,5 +34,6 @@ "fabric": "*" }, "breaks": { + "sodium": ">=0.5.0" } } From b794c55467f69c816b1eba8089f27abf1f46a7b9 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Thu, 16 Nov 2023 01:34:06 +0100 Subject: [PATCH 070/156] s --- build.gradle | 9 +-- common/build.gradle | 14 ++-- common/gradle.properties | 4 +- .../mod/mixin/client/MixinMinecraft.java | 6 +- .../MixinClientPacketListener.java | 6 +- .../client/renderer/MixinGameRenderer.java | 2 +- .../mixin/client/world/MixinClientLevel.java | 15 ++-- .../MixinClientSuggestionProvider.java | 2 +- .../commands/MixinCommandSourceStack.java | 2 +- .../LavaFluidMixin.java | 4 +- .../feature/mass_tooltip/MixinBlockItem.java | 3 +- .../client/MixinSimpleSoundInstance.java | 3 +- .../feature/world_border/MixinLevel.java | 8 ++- .../block/MixinRedstoneContactBlock.java | 4 +- .../create/cannons/MixinCannonMount.java | 4 +- .../MixinLevelRendererVanilla.java | 71 +++++++++++-------- .../mod/mixin/server/MixinPlayerList.java | 9 ++- .../mixin/server/command/MixinCommands.java | 4 +- .../MixinServerGamePacketListenerImpl.java | 7 +- .../world/MixinChunkMap$TrackedEntity.java | 2 +- .../mixin/server/world/MixinServerLevel.java | 11 +-- .../level/chunk/MixinChunkGenerator.java | 22 +++--- .../level/levelgen/MixinFlatLevelSource.java | 5 +- .../MixinNoiseBasedChunkGenerator.java | 16 ++--- .../mod/client/VSPhysicsEntityRenderer.kt | 3 +- .../client/audio/SimpleSoundInstanceOnShip.kt | 20 +++--- .../common/command/RelativeVector3Argument.kt | 5 +- .../mod/common/command/ShipArgument.kt | 6 +- .../mod/common/command/ShipArgumentParser.kt | 12 ++-- .../mod/common/command/VSCommands.kt | 28 ++++---- .../mod/common/item/ShipCreatorItem.kt | 4 +- fabric/build.gradle | 18 +++-- fabric/gradle.properties | 20 +++--- forge/build.gradle | 2 +- forge/gradle.properties | 6 +- gradle.properties | 33 ++++++--- 36 files changed, 220 insertions(+), 170 deletions(-) diff --git a/build.gradle b/build.gradle index 58eff658a..22d0e5286 100644 --- a/build.gradle +++ b/build.gradle @@ -119,19 +119,14 @@ subprojects { name = 'tterrag maven' url = 'https://maven.tterrag.com/' } - maven { url = "https://api.modrinth.com/maven" } // LazyDFU, Suggestion Tweaker + maven { url = "https://api.modrinth.com/maven" } // LazyDFU, Suggestion Tweaker, Create Big Cannons maven { url = "https://maven.shedaniel.me/" } // Cloth Config, REI + maven { url "https://maven.architectury.dev/" } maven { url = "https://mvn.devos.one/snapshots/" } // Fabric Create, Porting Lib, Forge Tags, Milk Lib maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } // Forge Config API Port maven { url = "https://maven.tterrag.com/" } // Registrate, Forge Create and Flywheel maven { url = "https://maven.cafeteria.dev/releases" } // Fake Player API maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes - maven { - url = "https://maven.realrobotix.me/createbigcannons/" // Create Big Cannons - content { - includeGroup "com.rbasamoyai" - } - } } } diff --git a/common/build.gradle b/common/build.gradle index 349552ef0..6be7605f9 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,15 +1,16 @@ dependencies { - annotationProcessor(implementation("com.github.LlamaLad7:MixinExtras:0.1.1")) + implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:0.2.0")) compileOnly 'com.google.code.findbugs:jsr305:3.0.2' // We depend on fabric loader here to use the fabric @Environment annotations // Do NOT use other classes from fabric loader modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modApi("me.shedaniel.cloth:cloth-config:4.14.64") + modApi("me.shedaniel.cloth:cloth-config:8.3.103") + //modApi "me.shedaniel.cloth:cloth-config-fabric:8.3.103" - modCompileOnly("curse.maven:sodium-394468:3669187") + modCompileOnly("maven.modrinth:sodium:mc1.19.2-0.4.4") // vs-core implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") { @@ -30,8 +31,11 @@ dependencies { { 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("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") - modCompileOnly("com.rbasamoyai:createbigcannons-fabric-${minecraft_version}:${createbigcannons_version}") + for (String module in port_lib_modules.split(",")) { + implementation("io.github.fabricators_of_create.Porting-Lib:$module:$port_lib_version+$minecraft_version") + } + //modCompileOnly("io.github.fabricators_of_create:Porting-Lib:Porting-Lib:${port_lib_version}+${minecraft_version}") + modCompileOnly("maven.modrinth:create-big-cannons:${createbigcannons_version}") } architectury { diff --git a/common/gradle.properties b/common/gradle.properties index 574b0f2ab..6ea2e969e 100644 --- a/common/gradle.properties +++ b/common/gradle.properties @@ -1,2 +1,2 @@ -port_lib_version=1.2.677-beta -port_lib_hash=cca931b +port_lib_version=2.1.1096 +port_lib_modules = accessors,base,entity,extensions,fake_players,networking,obj_loader,tags,transfer diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java index ae6ed83a6..8ce2565c8 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java @@ -70,15 +70,15 @@ public abstract class MixinMinecraft @WrapOperation( at = @At( value = "INVOKE", - target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;useItemOn(Lnet/minecraft/client/player/LocalPlayer;Lnet/minecraft/client/multiplayer/ClientLevel;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;" + target = "Lnet/minecraft/client/multiplayer/MultiPlayerGameMode;useItemOn(Lnet/minecraft/client/player/LocalPlayer;Lnet/minecraft/world/InteractionHand;Lnet/minecraft/world/phys/BlockHitResult;)Lnet/minecraft/world/InteractionResult;" ), method = "startUseItem" ) private InteractionResult useOriginalCrosshairForBlockPlacement(final MultiPlayerGameMode instance, - final LocalPlayer localPlayer, final ClientLevel clientLevel, final InteractionHand interactionHand, + final LocalPlayer localPlayer, final InteractionHand interactionHand, final BlockHitResult blockHitResult, final Operation useItemOn) { - return useItemOn.call(instance, localPlayer, clientLevel, interactionHand, + return useItemOn.call(instance, localPlayer, interactionHand, this.originalCrosshairTarget); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java index 8c863e45e..9c80967fb 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java @@ -51,10 +51,10 @@ private void handleShipMountingEntity(final ClientboundAddEntityPacket packet, f final double f = packet.getZ(); final Entity entity = ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE.create(level); final int i = packet.getId(); - entity.setPacketCoordinates(d, e, f); + entity.syncPacketPositionCodec(d, e, f); entity.moveTo(d, e, f); - entity.setXRot((float) (packet.getxRot() * 360) / 256.0f); - entity.setYRot((float) (packet.getyRot() * 360) / 256.0f); + entity.setXRot((float) (packet.getXRot() * 360) / 256.0f); + entity.setYRot((float) (packet.getYRot() * 360) / 256.0f); entity.setId(i); entity.setUUID(packet.getUUID()); this.level.putNonPlayerEntity(i, entity); 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 46f0bbaa6..04543da1a 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 @@ -292,7 +292,7 @@ private void setupCameraWithMountedShip(final LevelRenderer instance, final Pose // Use [camera.getPosition()] instead of [vec3] because mounting the player to the ship has changed the camera // position. prepareCullFrustum.call(instance, matrixStack, camera.getPosition(), - this.getProjectionMatrix(Math.max(fov, this.minecraft.options.fov))); + this.getProjectionMatrix(Math.max(fov, this.minecraft.options.fov().get()))); } // endregion } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientLevel.java index 2f532c166..de9148661 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientLevel.java @@ -2,7 +2,6 @@ import static org.valkyrienskies.mod.common.ValkyrienSkiesMod.getVsCore; -import java.util.Random; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.resources.sounds.SimpleSoundInstance; @@ -13,6 +12,7 @@ import net.minecraft.core.particles.ParticleTypes; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; +import net.minecraft.util.RandomSource; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.GameType; import net.minecraft.world.level.block.Blocks; @@ -42,7 +42,7 @@ @Mixin(ClientLevel.class) public abstract class MixinClientLevel implements IShipObjectWorldClientProvider { @Unique - private final Random vsRandom = new Random(); + private final RandomSource vsRandom = RandomSource.create(); @Shadow @Final @@ -186,20 +186,21 @@ private void animateTickVS( @Redirect( at = @At( value = "NEW", - target = "net/minecraft/client/resources/sounds/SimpleSoundInstance" + target = "(Lnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FFLnet/minecraft/util/RandomSource;DDD)Lnet/minecraft/client/resources/sounds/SimpleSoundInstance;" ), - method = "playLocalSound(DDDLnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FFZ)V" + method = "playSound(DDDLnet/minecraft/sounds/SoundEvent;Lnet/minecraft/sounds/SoundSource;FFZJ)V" ) private SimpleSoundInstance redirectNewSoundInstance(final SoundEvent soundEvent, final SoundSource soundSource, - final float volume, final float pitch, final double x, final double y, final double z) { + final float volume, final float pitch, final RandomSource randomSource, final double x, final double y, + final double z) { final Ship ship = VSGameUtilsKt.getShipManagingPos(ClientLevel.class.cast(this), x, y, z); if (ship != null) { - return new SimpleSoundInstanceOnShip(soundEvent, soundSource, volume, pitch, x, y, z, + return new SimpleSoundInstanceOnShip(soundEvent, soundSource, volume, pitch, randomSource, x, y, z, ship); } - return new SimpleSoundInstance(soundEvent, soundSource, volume, pitch, x, y, z); + return new SimpleSoundInstance(soundEvent, soundSource, volume, pitch, randomSource, x, y, z); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinClientSuggestionProvider.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinClientSuggestionProvider.java index 8e670f92d..a46ef9aba 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinClientSuggestionProvider.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinClientSuggestionProvider.java @@ -27,6 +27,6 @@ public ShipWorld getShipWorld() { @Override public void sendVSMessage(final Component component, final UUID uUID) { - minecraft.player.sendMessage(component, uUID); + minecraft.player.sendSystemMessage(component); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinCommandSourceStack.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinCommandSourceStack.java index 0dc7b1756..2d9fe7ce8 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinCommandSourceStack.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinCommandSourceStack.java @@ -30,6 +30,6 @@ public ShipWorldCore getShipWorld() { @Override public void sendVSMessage(final Component component, final UUID uUID) { - source.sendMessage(component, uUID); + source.sendSystemMessage(component); } } 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 b77ae5300..212503680 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 @@ -1,7 +1,7 @@ package org.valkyrienskies.mod.mixin.feature.fire_between_ship_and_world; -import java.util.Random; import net.minecraft.core.BlockPos; +import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.material.FlowingFluid; import net.minecraft.world.level.material.FluidState; @@ -19,7 +19,7 @@ public abstract class LavaFluidMixin extends FlowingFluid { private boolean isModifyingFireTick = false; @Inject(method = "randomTick", at = @At("TAIL")) - public void fireTickMixin(final Level level, final BlockPos pos, final FluidState state, final Random random, + public void fireTickMixin(final Level level, final BlockPos pos, final FluidState state, final RandomSource random, final CallbackInfo ci) { if (isModifyingFireTick) { return; diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/mass_tooltip/MixinBlockItem.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/mass_tooltip/MixinBlockItem.java index fa9eac7dc..4b9155213 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/mass_tooltip/MixinBlockItem.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/mass_tooltip/MixinBlockItem.java @@ -4,7 +4,6 @@ import java.util.Objects; import net.minecraft.ChatFormatting; import net.minecraft.network.chat.Component; -import net.minecraft.network.chat.TranslatableComponent; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.TooltipFlag; @@ -31,7 +30,7 @@ public class MixinBlockItem { final Double mass = Objects.requireNonNull(BlockStateInfo.INSTANCE.get(item.getBlock().defaultBlockState())) .getFirst(); - list.add(new TranslatableComponent("tooltip.valkyrienskies.mass") + list.add(Component.translatable("tooltip.valkyrienskies.mass") .append(VSGameConfig.CLIENT.getTooltip().getUseImperialUnits() ? getImperialText(mass) : ": " + mass + "kg").withStyle(ChatFormatting.DARK_GRAY)); } catch (final Exception ignored) { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java index f79788cc6..5419aa484 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java @@ -27,7 +27,8 @@ private static void forRecord(final SoundEvent sound, final double x, final doub final Ship ship = VSGameUtilsKt.getShipManagingPos(Minecraft.getInstance().level, x, y, z); if (ship != null) { cir.setReturnValue(new SimpleSoundInstanceOnShip( - sound, SoundSource.RECORDS, 4.0F, 1.0F, false, 0, SoundInstance.Attenuation.LINEAR, x, y, z, ship)); + sound, SoundSource.RECORDS, 4.0F, 1.0F, SoundInstance.createUnseededRandom(), false, 0, + SoundInstance.Attenuation.LINEAR, x, y, z, ship)); } } 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 498e703de..eba9fbc57 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 @@ -3,8 +3,10 @@ import java.util.function.Supplier; import net.minecraft.core.Holder; 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; @@ -26,8 +28,10 @@ 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 CallbackInfo ci) { + 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) { ((OfLevel) this.worldBorder).setLevel(Level.class.cast(this)); } 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 index 78a0274bb..f87322cca 100644 --- 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 @@ -9,10 +9,10 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map; -import java.util.Random; 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; @@ -61,7 +61,7 @@ private void injectOnRemove(BlockState state, Level worldIn, BlockPos pos, Block } @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, Random random, CallbackInfo ci, boolean hasValidContact) { + 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)) { 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 index fec8a0b57..92699c56d 100644 --- 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 @@ -33,12 +33,14 @@ public abstract class MixinCannonMount extends KineticBlockEntity implements Con 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; 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 6c9cf355c..711a71978 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 @@ -5,10 +5,8 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.mojang.blaze3d.shaders.Uniform; import com.mojang.blaze3d.systems.RenderSystem; -import com.mojang.blaze3d.vertex.BufferUploader; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexBuffer; -import com.mojang.blaze3d.vertex.VertexFormat; import com.mojang.math.Matrix4f; import com.mojang.math.Vector3f; import it.unimi.dsi.fastutil.objects.ObjectArrayList; @@ -207,73 +205,88 @@ private void renderChunkLayer(final RenderType renderType, final PoseStack poseS RenderSystem.assertOnRenderThread(); renderType.setupRenderState(); this.minecraft.getProfiler().push("filterempty"); - this.minecraft.getProfiler().popPush(() -> "render_" + renderType); - final boolean bl = renderType != RenderType.translucent(); + this.minecraft.getProfiler().popPush(() -> { + return "render_" + renderType; + }); + boolean bl = renderType != RenderType.translucent(); final ListIterator objectListIterator = chunksToRender.listIterator(bl ? 0 : chunksToRender.size()); - final VertexFormat vertexFormat = renderType.format(); - final ShaderInstance shaderInstance = RenderSystem.getShader(); - BufferUploader.reset(); - for (int k = 0; k < 12; ++k) { - final int l = RenderSystem.getShaderTexture(k); + ShaderInstance shaderInstance = RenderSystem.getShader(); + + for(int k = 0; k < 12; ++k) { + int l = RenderSystem.getShaderTexture(k); shaderInstance.setSampler("Sampler" + k, l); } + if (shaderInstance.MODEL_VIEW_MATRIX != null) { shaderInstance.MODEL_VIEW_MATRIX.set(poseStack.last().pose()); } + if (shaderInstance.PROJECTION_MATRIX != null) { shaderInstance.PROJECTION_MATRIX.set(matrix4f); } + if (shaderInstance.COLOR_MODULATOR != null) { shaderInstance.COLOR_MODULATOR.set(RenderSystem.getShaderColor()); } + if (shaderInstance.FOG_START != null) { shaderInstance.FOG_START.set(RenderSystem.getShaderFogStart()); } + if (shaderInstance.FOG_END != null) { shaderInstance.FOG_END.set(RenderSystem.getShaderFogEnd()); } + if (shaderInstance.FOG_COLOR != null) { shaderInstance.FOG_COLOR.set(RenderSystem.getShaderFogColor()); } + if (shaderInstance.FOG_SHAPE != null) { shaderInstance.FOG_SHAPE.set(RenderSystem.getShaderFogShape().getIndex()); } + if (shaderInstance.TEXTURE_MATRIX != null) { shaderInstance.TEXTURE_MATRIX.set(RenderSystem.getTextureMatrix()); } + if (shaderInstance.GAME_TIME != null) { shaderInstance.GAME_TIME.set(RenderSystem.getShaderGameTime()); } + RenderSystem.setupShaderLights(shaderInstance); shaderInstance.apply(); - final Uniform uniform = shaderInstance.CHUNK_OFFSET; - boolean bl2 = false; - while (bl ? objectListIterator.hasNext() : objectListIterator.hasPrevious()) { - final RenderChunkInfo renderChunkInfo2 = - bl ? (RenderChunkInfo) objectListIterator.next() : (RenderChunkInfo) objectListIterator.previous(); - final ChunkRenderDispatcher.RenderChunk renderChunk = renderChunkInfo2.chunk; - if (renderChunk.getCompiledChunk().isEmpty(renderType)) { - continue; + Uniform uniform = shaderInstance.CHUNK_OFFSET; + + while(true) { + if (bl) { + if (!objectListIterator.hasNext()) { + break; + } + } else if (!objectListIterator.hasPrevious()) { + break; } - final VertexBuffer vertexBuffer = renderChunk.getBuffer(renderType); - final BlockPos blockPos = renderChunk.getOrigin(); - if (uniform != null) { - uniform.set((float) ((double) blockPos.getX() - d), (float) ((double) blockPos.getY() - e), - (float) ((double) blockPos.getZ() - f)); - uniform.upload(); + + RenderChunkInfo renderChunkInfo2 = bl ? (RenderChunkInfo)objectListIterator.next() : (RenderChunkInfo)objectListIterator.previous(); + ChunkRenderDispatcher.RenderChunk renderChunk = renderChunkInfo2.chunk; + if (!renderChunk.getCompiledChunk().isEmpty(renderType)) { + VertexBuffer vertexBuffer = renderChunk.getBuffer(renderType); + BlockPos blockPos = renderChunk.getOrigin(); + if (uniform != null) { + uniform.set((float)((double)blockPos.getX() - d), (float)((double)blockPos.getY() - e), (float)((double)blockPos.getZ() - f)); + uniform.upload(); + } + + vertexBuffer.bind(); + vertexBuffer.draw(); } - vertexBuffer.drawChunkLayer(); - bl2 = true; } + if (uniform != null) { uniform.set(Vector3f.ZERO); } + shaderInstance.clear(); - if (bl2) { - vertexFormat.clearBufferState(); - } VertexBuffer.unbind(); - VertexBuffer.unbindVertexArray(); this.minecraft.getProfiler().pop(); renderType.clearRenderState(); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinPlayerList.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinPlayerList.java index defc53bf1..fdeafbfad 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinPlayerList.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/MixinPlayerList.java @@ -5,7 +5,7 @@ import java.util.List; import net.minecraft.ChatFormatting; import net.minecraft.network.Connection; -import net.minecraft.network.chat.TextComponent; +import net.minecraft.network.chat.Component; import net.minecraft.network.protocol.Packet; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; @@ -50,13 +50,12 @@ private void afterPlayerJoin(final Connection netManager, final ServerPlayer pla final MinecraftPlayer wrapped = VSGameUtilsKt.getPlayerWrapper(player); getVsCore().getHooks().afterClientJoinServer(wrapped); if (!KrunchSupport.INSTANCE.isKrunchSupported()) { - player.sendMessage( - new TextComponent( + player.sendSystemMessage( + Component.literal( "VS2 physics are disabled on this server, because Krunch is not supported on this server!" + " Current supported platforms are:" + " Windows x86-64, Linux x86-64, Linux aarch64, Macos x86-64, Macos arm64") - .withStyle(ChatFormatting.RED, ChatFormatting.BOLD), - null); + .withStyle(ChatFormatting.RED, ChatFormatting.BOLD)); } VSEntityManager.INSTANCE.syncHandlers(wrapped); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java index 90918c1a7..976b8534b 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/MixinCommands.java @@ -1,6 +1,8 @@ package org.valkyrienskies.mod.mixin.server.command; +import net.minecraft.commands.CommandBuildContext; import net.minecraft.commands.Commands; +import net.minecraft.commands.Commands.CommandSelection; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -13,7 +15,7 @@ public class MixinCommands { at = @At("TAIL"), method = "" ) - public void onInit(final Commands.CommandSelection registrationEnvironment, final CallbackInfo ci) { + public void onInit(CommandSelection commandSelection, CommandBuildContext commandBuildContext, CallbackInfo ci) { } } 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 b7c29d647..e92553a08 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,7 +14,6 @@ import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; import net.minecraft.server.network.ServerGamePacketListenerImpl; -import net.minecraft.world.level.ChunkPos; import net.minecraft.world.phys.Vec3; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Final; @@ -78,6 +77,7 @@ private Vec3 skipDistanceCheck2(final Vec3 instance, final Vec3 vec3, final Oper return VSGameUtilsKt.toWorldCoordinates(player.level, subtract.call(instance, vec3)); } + /* @WrapOperation( at = @At( value = "INVOKE", @@ -85,11 +85,12 @@ private Vec3 skipDistanceCheck2(final Vec3 instance, final Vec3 vec3, final Oper ), method = "handleUseItemOn" ) - private int skipDistanceCheck(final ChunkPos instance, final ChunkPos chunkPos, - final Operation getChessboardDistance) { + private int skipDistanceCheck(final ChunkPos instance, final ChunkPos chunkPos, final Operation getChessboardDistance) { return 0; } + */ + @WrapOperation( method = "handleMovePlayer", at = @At( diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java index 7080884f5..e8b7bc131 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java @@ -29,7 +29,7 @@ public class MixinChunkMap$TrackedEntity { // Changes entity position for tracking into world space if needed @ModifyExpressionValue(method = "updatePlayer", at = @At(value = "INVOKE", - target = "Lnet/minecraft/server/level/ServerEntity;sentPos()Lnet/minecraft/world/phys/Vec3;")) + target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;")) Vec3 includeShips(final Vec3 original) { final Vector3d pos = VectorConversionsMCKt.toJOML(original); final Ship ship = inCallShip = VSGameUtilsKt.getShipObjectManagingPos(this.entity.level, pos); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java index b3e4c96e9..985ac3f04 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java @@ -16,7 +16,6 @@ import java.util.function.BooleanSupplier; import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos.MutableBlockPos; -import net.minecraft.core.Holder; import net.minecraft.core.Position; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; @@ -25,11 +24,13 @@ import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.CustomSpawner; +import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.dimension.LevelStem; import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess; import net.minecraft.world.level.storage.ServerLevelData; import org.jetbrains.annotations.NotNull; @@ -88,9 +89,9 @@ public ServerShipWorldCore getShipObjectWorld() { @Inject(method = "", at = @At("RETURN")) void onInit(final MinecraftServer minecraftServer, final Executor executor, final LevelStorageAccess levelStorageAccess, - final ServerLevelData serverLevelData, final ResourceKey levelId, final Holder holder, - final ChunkProgressListener chunkProgressListener, final ChunkGenerator chunkGenerator, final boolean bl, - final long l, final List list, + final ServerLevelData serverLevelData, final ResourceKey levelId, final LevelStem levelStem, + final ChunkProgressListener chunkProgressListener, final boolean bl, + final long l, final List customSpawners, final boolean bl2, final CallbackInfo ci) { // This only happens when overworld gets loaded on startup, we have a mixin in MixinMinecraftServer for this specific case diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/chunk/MixinChunkGenerator.java b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/chunk/MixinChunkGenerator.java index 0b32dcda1..478468342 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/chunk/MixinChunkGenerator.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/chunk/MixinChunkGenerator.java @@ -5,16 +5,16 @@ import net.minecraft.core.Holder; import net.minecraft.core.HolderSet; import net.minecraft.core.RegistryAccess; -import net.minecraft.resources.ResourceKey; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.StructureFeatureManager; +import net.minecraft.world.level.StructureManager; import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkGenerator; -import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature; +import net.minecraft.world.level.levelgen.RandomState; +import net.minecraft.world.level.levelgen.structure.Structure; import net.minecraft.world.level.levelgen.structure.StructureSet; -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -24,30 +24,30 @@ @Mixin(ChunkGenerator.class) public class MixinChunkGenerator { - @Inject(method = "findNearestMapFeature", at = @At("HEAD"), cancellable = true) - private void preFindNearestMapFeature(ServerLevel serverLevel, HolderSet> holderSet, BlockPos blockPos, int i, boolean bl, final CallbackInfoReturnable>>> cir) { + @Inject(method = "findNearestMapStructure", at = @At("HEAD"), cancellable = true) + private void preFindNearestMapFeature(ServerLevel serverLevel, HolderSet holderSet, BlockPos blockPos, int i, boolean bl, CallbackInfoReturnable>> cir) { if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(blockPos.getX() >> 4, blockPos.getZ() >> 4)) { cir.setReturnValue(null); } } @Inject(method = "applyBiomeDecoration", at = @At("HEAD"), cancellable = true) - private void preApplyBiomeDecoration(WorldGenLevel worldGenLevel, ChunkAccess chunkAccess, StructureFeatureManager structureFeatureManager, CallbackInfo callbackInfo) { + 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 = "hasFeatureChunkInRange", at = @At("HEAD"), cancellable = true) - private void preHasFeatureChunkInRange(ResourceKey resourceKey, long l, int chunkX, int chunkZ, int k, final CallbackInfoReturnable cir) { + @Inject(method = "hasStructureChunkInRange", at = @At("HEAD"), cancellable = true) + private void preHasFeatureChunkInRange(Holder holder, RandomState randomState, long l, int chunkX, int chunkZ, int k, CallbackInfoReturnable cir) { if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkX, chunkZ)) { cir.setReturnValue(false); } } @Inject(method = "createStructures", at = @At("HEAD"), cancellable = true) - private void preCreateStructures(RegistryAccess registryAccess, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess, StructureManager structureManager, long l, CallbackInfo callbackInfo) { + 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(); @@ -55,7 +55,7 @@ private void preCreateStructures(RegistryAccess registryAccess, StructureFeature } @Inject(method = "createReferences", at = @At("HEAD"), cancellable = true) - private void preCreateReferences(WorldGenLevel worldGenLevel, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess, CallbackInfo callbackInfo) { + 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(); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinFlatLevelSource.java b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinFlatLevelSource.java index 4fa338f9b..502de11a5 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinFlatLevelSource.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinFlatLevelSource.java @@ -3,9 +3,10 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.StructureFeatureManager; +import net.minecraft.world.level.StructureManager; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.levelgen.FlatLevelSource; +import net.minecraft.world.level.levelgen.RandomState; import net.minecraft.world.level.levelgen.blending.Blender; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -16,7 +17,7 @@ @Mixin(FlatLevelSource.class) public class MixinFlatLevelSource { @Inject(method = "fillFromNoise", at = @At("HEAD"), cancellable = true) - private void preFillFromNoise(Executor executor, Blender blender, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess, CallbackInfoReturnable> cir) { + 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)); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinNoiseBasedChunkGenerator.java b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinNoiseBasedChunkGenerator.java index 08183a391..5f8274d75 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinNoiseBasedChunkGenerator.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinNoiseBasedChunkGenerator.java @@ -7,14 +7,15 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.LevelHeightAccessor; import net.minecraft.world.level.NoiseColumn; -import net.minecraft.world.level.StructureFeatureManager; +import net.minecraft.world.level.StructureManager; 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.GenerationStep.Carving; import net.minecraft.world.level.levelgen.NoiseBasedChunkGenerator; import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; import net.minecraft.world.level.levelgen.NoiseSettings; +import net.minecraft.world.level.levelgen.RandomState; import net.minecraft.world.level.levelgen.blending.Blender; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -31,12 +32,9 @@ public class MixinNoiseBasedChunkGenerator { @Final protected Holder settings; - @Shadow - @Final - private static BlockState[] EMPTY_COLUMN; @Inject(method = "getBaseColumn", at = @At("HEAD"), cancellable = true) - private void preGetBaseColumn(int i, int j, LevelHeightAccessor levelHeightAccessor, CallbackInfoReturnable cir) { + private void preGetBaseColumn(int i, int j, LevelHeightAccessor levelHeightAccessor, RandomState randomState, CallbackInfoReturnable cir) { if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(i, j)) { final NoiseSettings noiseSettings = this.settings.value().noiseSettings(); final int k = Math.max(noiseSettings.minY(), levelHeightAccessor.getMinBuildHeight()); @@ -45,7 +43,7 @@ private void preGetBaseColumn(int i, int j, LevelHeightAccessor levelHeightAcces } @Inject(method = "buildSurface", at = @At("HEAD"), cancellable = true) - private void preBuildSurface(WorldGenRegion worldGenRegion, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess, CallbackInfo ci) { + private void preBuildSurface(WorldGenRegion worldGenRegion, StructureManager structureFeatureManager, ChunkAccess chunkAccess, CallbackInfo ci) { final ChunkPos chunkPos = chunkAccess.getPos(); if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { ci.cancel(); @@ -53,7 +51,7 @@ private void preBuildSurface(WorldGenRegion worldGenRegion, StructureFeatureMana } @Inject(method = "applyCarvers", at = @At("HEAD"), cancellable = true) - private void preApplyCarvers(WorldGenRegion worldGenRegion, long l, BiomeManager biomeManager, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess, GenerationStep.Carving carving, CallbackInfo ci) { + private void preApplyCarvers(WorldGenRegion worldGenRegion, long l, RandomState randomState, BiomeManager biomeManager, StructureManager structureManager, ChunkAccess chunkAccess, Carving carving, CallbackInfo ci) { final ChunkPos chunkPos = chunkAccess.getPos(); if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { ci.cancel(); @@ -61,7 +59,7 @@ private void preApplyCarvers(WorldGenRegion worldGenRegion, long l, BiomeManager } @Inject(method = "fillFromNoise", at = @At("HEAD"), cancellable = true) - private void preFillFromNoise(Executor executor, Blender blender, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess, CallbackInfoReturnable> cir) { + 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)); 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 9cd062721..2fa8f8e04 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt @@ -9,6 +9,7 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider import net.minecraft.client.renderer.texture.OverlayTexture import net.minecraft.core.BlockPos import net.minecraft.resources.ResourceLocation +import net.minecraft.util.RandomSource import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.level.block.RenderShape.INVISIBLE import net.minecraft.world.level.block.RenderShape.MODEL @@ -60,7 +61,7 @@ class VSPhysicsEntityRenderer(context: EntityRendererProvider.Context) : EntityR level, blockRenderDispatcher.getBlockModel(blockState), blockState, blockPos, poseStack, multiBufferSource.getBuffer( ItemBlockRenderTypes.getMovingBlockRenderType(blockState) - ), false, Random(), blockState.getSeed(BlockPos.ZERO), OverlayTexture.NO_OVERLAY + ), false, RandomSource.create(), blockState.getSeed(BlockPos.ZERO), OverlayTexture.NO_OVERLAY ) poseStack.popPose() super.render(fallingBlockEntity, f, partialTick, poseStack, multiBufferSource, i) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/client/audio/SimpleSoundInstanceOnShip.kt b/common/src/main/kotlin/org/valkyrienskies/mod/client/audio/SimpleSoundInstanceOnShip.kt index 55ccfc1ba..690311d23 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/client/audio/SimpleSoundInstanceOnShip.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/client/audio/SimpleSoundInstanceOnShip.kt @@ -2,13 +2,14 @@ package org.valkyrienskies.mod.client.audio import net.minecraft.client.resources.sounds.SimpleSoundInstance import net.minecraft.client.resources.sounds.SoundInstance.Attenuation -import net.minecraft.client.resources.sounds.SoundInstance.Attenuation.LINEAR import net.minecraft.resources.ResourceLocation import net.minecraft.sounds.SoundEvent import net.minecraft.sounds.SoundSource +import net.minecraft.util.RandomSource +import org.valkyrienskies.core.api.ships.Ship import org.joml.Vector3d import org.joml.Vector3dc -import org.valkyrienskies.core.api.ships.Ship +import net.minecraft.client.resources.sounds.SoundInstance.Attenuation.LINEAR class SimpleSoundInstanceOnShip : SimpleSoundInstance, VelocityTickableSoundInstance { @@ -19,6 +20,7 @@ class SimpleSoundInstanceOnShip : SimpleSoundInstance, VelocityTickableSoundInst soundSource: SoundSource, volume: Float, pitch: Float, + random: RandomSource, looping: Boolean, delay: Int, attenuation: Attenuation, @@ -27,19 +29,21 @@ class SimpleSoundInstanceOnShip : SimpleSoundInstance, VelocityTickableSoundInst z: Double, relative: Boolean, ship: Ship - ) : super(resourceLocation, soundSource, volume, pitch, looping, delay, attenuation, x, y, z, relative) { + ) : super(resourceLocation, soundSource, volume, pitch, random, looping, delay, attenuation, x, y, z, relative) { this.ship = ship } constructor( - soundEvent: SoundEvent, soundSource: SoundSource, f: Float, g: Float, bl: Boolean, i: Int, - attenuation: Attenuation, d: Double, e: Double, h: Double, ship: Ship - ) : this(soundEvent.location, soundSource, f, g, bl, i, attenuation, d, e, h, false, ship) + soundEvent: SoundEvent, soundSource: SoundSource, volume: Float, pitch: Float, random: RandomSource, + looping: Boolean, delay: Int, + attenuation: Attenuation, x: Double, y: Double, z: Double, ship: Ship + ) : this(soundEvent.location, soundSource, volume, pitch, random, looping, delay, attenuation, x, y, z, false, ship) constructor( - soundEvent: SoundEvent, soundSource: SoundSource, f: Float, g: Float, d: Double, e: Double, h: Double, + soundEvent: SoundEvent, soundSource: SoundSource, volume: Float, pitch: Float, random: RandomSource, x: Double, + y: Double, z: Double, ship: Ship - ) : this(soundEvent, soundSource, f, g, false, 0, LINEAR, d, e, h, ship) + ) : this(soundEvent, soundSource, volume, pitch, random, false, 0, LINEAR, x, y, z, ship) private val originalPos = Vector3d(x, y, z) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3Argument.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3Argument.kt index d3b1d3f8b..29a59b17a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3Argument.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3Argument.kt @@ -10,7 +10,8 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.coordinates.RotationArgument import net.minecraft.commands.arguments.coordinates.WorldCoordinate -import net.minecraft.network.chat.TranslatableComponent +import net.minecraft.network.chat.Component +import net.minecraft.network.chat.Component.translatable import java.util.concurrent.CompletableFuture class RelativeVector3Argument : ArgumentType { @@ -164,7 +165,7 @@ class RelativeVector3Argument : ArgumentType { builder.suggest("${builder.remaining})") } throw SimpleCommandExceptionType( - TranslatableComponent("Expected )") + Component.translatable("Expected )") ).createWithContext(reader) } else { return DUMMY_EULER_ANGLES diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt index 153e2faff..c2e2179a1 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt @@ -10,7 +10,7 @@ import com.mojang.brigadier.suggestion.SuggestionsBuilder import net.minecraft.commands.CommandRuntimeException import net.minecraft.commands.synchronization.ArgumentSerializer import net.minecraft.network.FriendlyByteBuf -import net.minecraft.network.chat.TranslatableComponent +import net.minecraft.network.chat.Component.translatable import org.valkyrienskies.core.api.ships.Ship import org.valkyrienskies.mod.mixinducks.feature.command.VSCommandSource import java.util.concurrent.CompletableFuture @@ -92,9 +92,9 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType if (r.size == 1) return r.first() else throw ERROR_MANY_SHIP_FOUND } - private val ERROR_NO_SHIP_FOUND = CommandRuntimeException(TranslatableComponent("argument.valkyrienskies.ship.no_found")) + private val ERROR_NO_SHIP_FOUND = CommandRuntimeException(Component.translatable("argument.valkyrienskies.ship.no_found")) private val ERROR_MANY_SHIP_FOUND = - CommandRuntimeException(TranslatableComponent("argument.valkyrienskies.ship.multiple_found")) + CommandRuntimeException(Component.translatable("argument.valkyrienskies.ship.multiple_found")) } override fun getExamples(): Collection = EXAMPLES diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentParser.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentParser.kt index d35d69003..00adb0621 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentParser.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentParser.kt @@ -4,7 +4,7 @@ import com.mojang.brigadier.StringReader import com.mojang.brigadier.exceptions.DynamicCommandExceptionType import com.mojang.brigadier.exceptions.SimpleCommandExceptionType import com.mojang.brigadier.suggestion.SuggestionsBuilder -import net.minecraft.network.chat.TranslatableComponent +import net.minecraft.network.chat.Component import org.valkyrienskies.core.api.ships.properties.ShipId import org.valkyrienskies.mod.mixinducks.feature.command.VSCommandSource @@ -184,14 +184,14 @@ class ShipArgumentParser(private val source: VSCommandSource?, private var selec companion object { val ERROR_MISSING_SELECTOR_TYPE = - SimpleCommandExceptionType(TranslatableComponent("argument.ship.selector.missing")) + SimpleCommandExceptionType(Component.translatable("argument.ship.selector.missing")) val ERROR_INVALID_SLUG_OR_ID = - SimpleCommandExceptionType(TranslatableComponent("argument.ship.invalid")) + SimpleCommandExceptionType(Component.translatable("argument.ship.invalid")) val ERROR_EXPECTED_END_OF_OPTIONS = - SimpleCommandExceptionType(TranslatableComponent("argument.ship.options.unterminated")) + SimpleCommandExceptionType(Component.translatable("argument.ship.options.unterminated")) val ERROR_EXPECTED_OPTION_VALUE = - DynamicCommandExceptionType { TranslatableComponent("argument.ship.options.valueless", it) } + DynamicCommandExceptionType { Component.translatable("argument.ship.options.valueless", it) } val ERROR_UNKNOWN_OPTION = - DynamicCommandExceptionType { TranslatableComponent("argument.entity.options.unknown", it) } + DynamicCommandExceptionType { Component.translatable("argument.entity.options.unknown", it) } } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt index 7d3adb0ff..59c399f15 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt @@ -15,7 +15,7 @@ import net.minecraft.commands.arguments.coordinates.BlockPosArgument import net.minecraft.commands.arguments.coordinates.Vec3Argument import net.minecraft.commands.synchronization.ArgumentTypes import net.minecraft.commands.synchronization.EmptyArgumentSerializer -import net.minecraft.network.chat.TranslatableComponent +import net.minecraft.network.chat.Component.translatable import net.minecraft.world.entity.Entity import net.minecraft.world.phys.BlockHitResult import org.joml.Vector3d @@ -73,7 +73,7 @@ object VSCommands { try { val r = ShipArgument.getShips(it, "ships").toList() as List vsCore.deleteShips(it.source.shipWorld as ServerShipWorld, r) - it.source.sendVSMessage(TranslatableComponent(DELETED_SHIPS_MESSAGE, r.size)) + it.source.sendVSMessage(Component.translatable(DELETED_SHIPS_MESSAGE, r.size)) r.size } catch (e: Exception) { if (e !is CommandRuntimeException) LOGGER.throwing(e) @@ -89,7 +89,7 @@ object VSCommands { val isStatic = BoolArgumentType.getBool(it, "is-static") r.forEach { ship -> ship.isStatic = isStatic } it.source.sendVSMessage( - TranslatableComponent( + Component.translatable( SET_SHIP_STATIC_SUCCESS_MESSAGE, r.size, if (isStatic) "true" else "false" ) ) @@ -120,7 +120,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TranslatableComponent(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) + Component.translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -156,7 +156,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TranslatableComponent(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) + Component.translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -198,7 +198,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TranslatableComponent(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) + Component.translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -246,7 +246,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TranslatableComponent(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) + Component.translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -272,7 +272,7 @@ object VSCommands { val ship = sourceEntity.level.getShipManagingPos(rayTrace.blockPos) if (ship != null) { (it.source as VSCommandSource).sendVSMessage( - TranslatableComponent(GET_SHIP_SUCCESS_MESSAGE, ship.slug) + Component.translatable(GET_SHIP_SUCCESS_MESSAGE, ship.slug) ) success = true } @@ -280,12 +280,12 @@ object VSCommands { if (success) { 1 } else { - (it.source as VSCommandSource).sendVSMessage(TranslatableComponent(GET_SHIP_FAIL_MESSAGE)) + (it.source as VSCommandSource).sendVSMessage(Component.translatable(GET_SHIP_FAIL_MESSAGE)) 0 } } else { (it.source as VSCommandSource).sendVSMessage( - TranslatableComponent(GET_SHIP_ONLY_USABLE_BY_ENTITIES_MESSAGE) + Component.translatable(GET_SHIP_ONLY_USABLE_BY_ENTITIES_MESSAGE) ) 0 } @@ -304,7 +304,7 @@ object VSCommands { val newScale = DoubleArgumentType.getDouble(it, "newScale") val r = ShipArgument.getShips(it, "ships").toList() as List r.forEach { ship -> vsCore.scaleShip(world, ship, newScale) } - it.source.sendVSMessage(TranslatableComponent(SCALED_SHIPS_MESSAGE, r.size)) + it.source.sendVSMessage(Component.translatable(SCALED_SHIPS_MESSAGE, r.size)) r.size } catch (e: Exception) { if (e !is CommandRuntimeException) LOGGER.throwing(e) @@ -358,7 +358,7 @@ object VSCommands { argument("ships", ShipArgument.selectorOnly()).executes { val serverShips = ShipArgument.getShips(it, "ships").toList() as List val serverShip = serverShips.singleOrNull() ?: throw CommandRuntimeException( - TranslatableComponent(TELEPORT_FIRST_ARG_CAN_ONLY_INPUT_1_SHIP) + Component.translatable(TELEPORT_FIRST_ARG_CAN_ONLY_INPUT_1_SHIP) ) val source = it.source as CommandSourceStack val shipPos = serverShip.transform.positionInWorld @@ -377,7 +377,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TranslatableComponent(TELEPORTED_MULTIPLE_SHIPS_SUCCESS, serverShips.size) + Component.translatable(TELEPORTED_MULTIPLE_SHIPS_SUCCESS, serverShips.size) ) serverShips.size } @@ -395,7 +395,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TranslatableComponent(TELEPORTED_MULTIPLE_SHIPS_SUCCESS, serverShips.size) + Component.translatable(TELEPORTED_MULTIPLE_SHIPS_SUCCESS, serverShips.size) ) serverShips.size } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt index d9335bc28..95e0e8afe 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt @@ -1,7 +1,7 @@ package org.valkyrienskies.mod.common.item import net.minecraft.Util -import net.minecraft.network.chat.TextComponent +import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.InteractionResult import net.minecraft.world.item.Item @@ -52,7 +52,7 @@ class ShipCreatorItem( // Move the block from the world to a ship level.relocateBlock(blockPos, centerPos, true, serverShip, NONE) - ctx.player?.sendMessage(TextComponent("SHIPIFIED!"), Util.NIL_UUID) + ctx.player?.sendSystemMessage(Component.literal("SHIPIFIED!")) if (parentShip != null) { // Compute the ship transform val newShipPosInWorld = diff --git a/fabric/build.gradle b/fabric/build.gradle index 06289659f..f4f6c621b 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -25,7 +25,7 @@ loom { } dependencies { - include(annotationProcessor(implementation("com.github.LlamaLad7:MixinExtras:0.1.1"))) + include(implementation(annotationProcessor("io.github.llamalad7:mixinextras-fabric:0.2.0"))) modImplementation("net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}") @@ -40,8 +40,8 @@ dependencies { include(modImplementation("net.fabricmc:fabric-language-kotlin:1.10.10+kotlin.1.9.10")) include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:6.3.81")) - modImplementation("curse.maven:sodium-394468:3669187") - modImplementation("com.terraformersmc:modmenu:3.2.3") + modImplementation("maven.modrinth:sodium:mc1.19.2-0.4.4") + modImplementation("maven.modrinth:modmenu:4.2.0-beta.2") // Depend on the fabric API modImplementation("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}") @@ -61,7 +61,7 @@ dependencies { } // CC Restitched - modImplementation("curse.maven:cc-restitched-462672:3838648") + //modImplementation("curse.maven:cc-restitched-462672:3838648") // Create compat modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { @@ -69,7 +69,15 @@ dependencies { } 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:${port_lib_version}+${minecraft_version}") + + //https://mvn.devos.one/snapshots/io/github/fabricators_of_create/Porting-Lib/2.1.1096+1.19.2/Porting-Lib-2.1.1096+1.19.2.pom + //https://mvn.devos.one/snapshots/io/github/fabricators_of_create/Porting-Lib/Porting-Lib/2.1.1096+1.19.2/Porting-Lib-2.1.1096+1.19.2.pom + + for (String module in port_lib_modules.split(",")) { + modImplementation("io.github.fabricators_of_create.Porting-Lib:$module:$port_lib_version+$minecraft_version") + } + + //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}") modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 625cddbde..25a78e413 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1,18 +1,18 @@ loader_platform=Fabric -create_version=0.5.1-c-build.1092+mc1.18.2 +create_version=0.5.1-c-build.1160+mc1.19.2 # https://github.com/Fabricators-of-Create/Create/blob/mc1.18/fabric/dev/gradle.properties -config_api_id=3671141 -forge_config_api_port_version=3.2.4 -fake_player_api_version=0.3.0 +config_api_id=4143545 +forge_config_api_port_version=4.2.9 +fake_player_api_version=0.4.0 # https://maven.tterrag.com/com/jozufozu/flywheel/Flywheel-Fabric -reach_entity_attributes_version=2.1.1 -registrate_version=MC1.18.2-1.1.6 +reach_entity_attributes_version=2.3.0 +registrate_version=1.1.58-MC1.19.2 forge_tags_version=2.1 -milk_lib_version=0.3.2 -port_lib_version=1.2.677-beta -port_lib_hash=cca931b +milk_lib_version=1.0.51 +port_lib_version=2.1.1096 +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.0.2+1.18.2 +no_indium_version=1.1.0+1.19 diff --git a/forge/build.gradle b/forge/build.gradle index 6927771ed..dc1c97540 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -51,7 +51,7 @@ configurations { } dependencies { - include(forgeRuntimeLibrary(annotationProcessor(implementation("com.github.LlamaLad7:MixinExtras:0.1.1")))) + implementation(include("io.github.llamalad7:mixinextras-forge:0.2.0")) forge "net.minecraftforge:forge:${rootProject.forge_version}" diff --git a/forge/gradle.properties b/forge/gradle.properties index 56f246d1f..ff43bbf71 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -2,6 +2,6 @@ loader_platform=Forge loom.platform=forge kotlin.stdlib.default.dependency=false #Compat -create_version=0.5.1.e-318 -flywheel_version=0.6.10-105 -registrate_version=MC1.18.2-1.1.3 +create_version = 0.5.1.e-44 +flywheel_version = 0.6.10-20 +registrate_version = MC1.19-1.1.5 diff --git a/gradle.properties b/gradle.properties index 729994223..2b0ec5220 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,16 +1,31 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G -minecraft_version=1.18.2 +minecraft_version=1.19.2 enabled_platforms=quilt,fabric,forge -archives_base_name=valkyrienskies-118 +archives_base_name=valkyrienskies-119 mod_version=2.1.1-beta.3 maven_group=org.valkyrienskies.mod -architectury_version=4.10.86 -fabric_loader_version=0.14.11 -fabric_api_version=0.67.0+1.18.2 -forge_version=1.18.2-40.2.4 -create_fabric_version=0.5.1-c-build.1092+mc1.18.2 -flywheel_version_fabric=0.6.9-38 -createbigcannons_version= 0.5.2-nightly-e815ca4 + +# 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 + +# https://fabricmc.net/develop/ +fabric_api_version=0.76.1+1.19.2 + +# https://files.minecraftforge.net/net/minecraftforge/forge/ +forge_version=1.19.2-43.3.0 + +# https://modrinth.com/mod/create-fabric/version/ +create_fabric_version=0.5.1-c-build.1160+mc1.19.2 + +# https://github.com/Fabricators-of-Create/Create/blob/mc1.19/fabric/dev/gradle.properties +flywheel_version_fabric=0.6.9-6 + +# https://modrinth.com/mod/create-big-cannons/version/ +createbigcannons_version= 0.5.2.a + vs_core_version=1.1.0+f2a6aaad81 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually From 14cedf2eec3f6b1d6d26a7ded7f0cad2f48643eb Mon Sep 17 00:00:00 2001 From: mrsterner Date: Thu, 16 Nov 2023 02:36:40 +0100 Subject: [PATCH 071/156] 1.19.2 port --- common/build.gradle | 7 +- .../commands/MixinArgumentTypeInfos.java | 32 ++++++ .../feature/commands/MixinArgumentTypes.java | 26 ----- .../feature/entity_collision/MixinEntity.java | 4 +- .../MixinEncasedFanTileEntity.java | 2 + .../create/cannons/MixinCannonMount.java | 9 +- .../network/MixinServerPlayerGameMode.java | 24 ++--- .../MixinNoiseBasedChunkGenerator.java | 6 +- .../mod/common/command/ShipArgument.kt | 38 ++------ .../mod/common/command/ShipArgumentInfo.kt | 42 ++++++++ .../mod/common/command/VSCommands.kt | 97 +++++++++---------- .../mod/common/item/ShipAssemblerItem.kt | 6 +- .../mod/compat/clothconfig/VSClothConfig.kt | 13 ++- .../valkyrienskies-common.mixins.json | 2 +- fabric/build.gradle | 11 +-- .../ValkyrienFabricMixinConfigPlugin.java | 49 ---------- .../mixin/world/level/block/FireMixin.java | 14 +-- .../fabric/common/ValkyrienSkiesModFabric.kt | 4 +- .../valkyrienskies-fabric.mixins.json | 1 - forge/build.gradle | 1 + .../ValkyrienForgeMixinConfigPlugin.java | 49 ---------- .../mixin/world/level/block/FireMixin.java | 9 +- .../valkyrienskies-forge.mixins.json | 1 - 23 files changed, 180 insertions(+), 267 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypeInfos.java delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypes.java create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentInfo.kt delete mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/ValkyrienFabricMixinConfigPlugin.java delete mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/ValkyrienForgeMixinConfigPlugin.java diff --git a/common/build.gradle b/common/build.gradle index 6be7605f9..4dbde9a9d 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -31,10 +31,9 @@ dependencies { { 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}") - for (String module in port_lib_modules.split(",")) { - implementation("io.github.fabricators_of_create.Porting-Lib:$module:$port_lib_version+$minecraft_version") - } - //modCompileOnly("io.github.fabricators_of_create:Porting-Lib:Porting-Lib:${port_lib_version}+${minecraft_version}") + + //implementation("io.github.fabricators_of_create.Porting-Lib:Porting-Lib:$port_lib_version+$minecraft_version") + modCompileOnly("maven.modrinth:create-big-cannons:${createbigcannons_version}") } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypeInfos.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypeInfos.java new file mode 100644 index 000000000..88768fd63 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypeInfos.java @@ -0,0 +1,32 @@ +package org.valkyrienskies.mod.mixin.feature.commands; + +import com.mojang.brigadier.arguments.ArgumentType; +import net.minecraft.commands.synchronization.ArgumentTypeInfo; +import net.minecraft.commands.synchronization.ArgumentTypeInfos; +import net.minecraft.commands.synchronization.SingletonArgumentInfo; +import net.minecraft.core.Registry; +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.CallbackInfoReturnable; +import org.valkyrienskies.mod.common.command.RelativeVector3Argument; +import org.valkyrienskies.mod.common.command.ShipArgument; +import org.valkyrienskies.mod.common.command.ShipArgumentInfo; + +@Mixin(ArgumentTypeInfos.class) +public class MixinArgumentTypeInfos { + @Shadow + private static , T extends ArgumentTypeInfo.Template> ArgumentTypeInfo register( + Registry> arg, String string, Class class_, ArgumentTypeInfo arg2) { + throw new IllegalStateException(); + } + + @Inject(method = "bootstrap", at = @At("TAIL")) + private static void postBootstrap(final Registry> registry, + final CallbackInfoReturnable> ci) { + register(registry, "valkyrienskies:ship_argument", ShipArgument.class, new ShipArgumentInfo()); + register(registry, "valkyrienskies:relative_vector3_argument", RelativeVector3Argument.class, + SingletonArgumentInfo.contextFree(RelativeVector3Argument::new)); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypes.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypes.java deleted file mode 100644 index 05d072a3c..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypes.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.valkyrienskies.mod.mixin.feature.commands; - -import com.mojang.brigadier.arguments.ArgumentType; -import net.minecraft.commands.synchronization.ArgumentSerializer; -import net.minecraft.commands.synchronization.ArgumentTypes; -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.command.VSCommands; - -@Mixin(ArgumentTypes.class) -public class MixinArgumentTypes { - - @Shadow - public static > void register(final String id, final Class argClass, final ArgumentSerializer serializer) { - throw new AssertionError(); - } - - @Inject(method = "bootStrap()V", at = @At("RETURN")) - private static void register(final CallbackInfo ci) { - VSCommands.INSTANCE.bootstrap(); - } - -} 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 d862f68d3..f4142f122 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 @@ -2,10 +2,10 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import java.util.Random; import net.minecraft.core.BlockPos; import net.minecraft.core.particles.BlockParticleOption; import net.minecraft.core.particles.ParticleTypes; +import net.minecraft.util.RandomSource; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityDimensions; import net.minecraft.world.entity.MoverType; @@ -244,7 +244,7 @@ private void preSpawnSprintParticle(final CallbackInfo ci) { @Shadow @Final - protected Random random; + protected RandomSource random; @Shadow private EntityDimensions dimensions; 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 index e04dde8f3..2c317a400 100644 --- 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 @@ -32,4 +32,6 @@ public void setLevel(@NotNull Level level) { 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 index 92699c56d..593834577 100644 --- 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 @@ -1,13 +1,11 @@ package org.valkyrienskies.mod.mixin.mod_compat.create.cannons; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; 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 net.minecraft.world.phys.Vec3; import org.joml.Vector3d; import org.joml.Vector3dc; import org.spongepowered.asm.mixin.Mixin; @@ -33,13 +31,13 @@ public abstract class MixinCannonMount extends KineticBlockEntity implements Con public MixinCannonMount(BlockEntityType typeIn, BlockPos pos, BlockState state) { super(typeIn, pos, state); } -/* TODO + + /*TODO? @Override public void cacheRecoilVector(Vec3 vector, AbstractContraptionEntity cannon) { recoilVec = VectorConversionsMCKt.toJOML(vector); } - - */ + */ @Unique private void handleAssembly() { @@ -151,3 +149,4 @@ private void injectRead(CompoundTag compound, boolean clientPacket, CallbackInfo } } + diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java index 1b8d1017b..6f350f158 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java @@ -1,16 +1,16 @@ package org.valkyrienskies.mod.mixin.server.network; import net.minecraft.core.BlockPos; -import net.minecraft.core.Direction; -import net.minecraft.network.protocol.game.ServerboundPlayerActionPacket; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.ServerPlayerGameMode; +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.injection.At; -import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.config.VSGameConfig; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @@ -18,29 +18,29 @@ @Mixin(ServerPlayerGameMode.class) public class MixinServerPlayerGameMode { + @Final @Shadow - public ServerPlayer player; + protected ServerPlayer player; @Shadow - public ServerLevel level; + protected ServerLevel level; /** * Includes ships in server-side distance check when player breaks a block. */ - @ModifyVariable( + @Redirect( method = "handleBlockBreakAction", - at = @At("STORE"), - index = 11 + at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D") ) - public double handleBlockBreakAction(final double g, final BlockPos pos, - final ServerboundPlayerActionPacket.Action action, - final Direction direction, final int worldHeight) { + public double handleBlockBreakAction(final Vec3 instance, final Vec3 vec3) { + final BlockPos pos = new BlockPos(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) .distanceSquared(player.getX(), player.getY() + 1.5, player.getZ()); } else { - return 0; + return instance.distanceToSqr(vec3); } } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinNoiseBasedChunkGenerator.java b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinNoiseBasedChunkGenerator.java index 5f8274d75..a175996a9 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinNoiseBasedChunkGenerator.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinNoiseBasedChunkGenerator.java @@ -38,12 +38,12 @@ private void preGetBaseColumn(int i, int j, LevelHeightAccessor levelHeightAcces if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(i, j)) { final NoiseSettings noiseSettings = this.settings.value().noiseSettings(); final int k = Math.max(noiseSettings.minY(), levelHeightAccessor.getMinBuildHeight()); - cir.setReturnValue(new NoiseColumn(k, EMPTY_COLUMN)); + cir.setReturnValue(new NoiseColumn(k, new BlockState[0])); } } - @Inject(method = "buildSurface", at = @At("HEAD"), cancellable = true) - private void preBuildSurface(WorldGenRegion worldGenRegion, StructureManager structureFeatureManager, ChunkAccess chunkAccess, CallbackInfo ci) { + @Inject(method = "buildSurface(Lnet/minecraft/server/level/WorldGenRegion;Lnet/minecraft/world/level/StructureManager;Lnet/minecraft/world/level/levelgen/RandomState;Lnet/minecraft/world/level/chunk/ChunkAccess;)V", 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(); diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt index c2e2179a1..9c9aaf2d2 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt @@ -8,8 +8,8 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException import com.mojang.brigadier.suggestion.Suggestions import com.mojang.brigadier.suggestion.SuggestionsBuilder import net.minecraft.commands.CommandRuntimeException -import net.minecraft.commands.synchronization.ArgumentSerializer import net.minecraft.network.FriendlyByteBuf +import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component.translatable import org.valkyrienskies.core.api.ships.Ship import org.valkyrienskies.mod.mixinducks.feature.command.VSCommandSource @@ -24,14 +24,7 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType val reader = StringReader(builder.input) reader.cursor = builder.start - // This can be a valid ship argument in the following cases: - // * The reader is empty, so we can suggest @v - // * The reader is only 1 character long, and is "@", so we can suggest @v - // * The reader is 2 characters long, and is "@v", so we can suggest @v - var canThisBeShipArgument = !reader.canRead() || (reader.canRead() && reader.peek() == '@') - if (reader.canRead(2)) { - canThisBeShipArgument = canThisBeShipArgument && reader.peek(1) == 'v' - } + val startsWithAt = reader.canRead() && reader.peek() == '@' val parser = ShipArgumentParser(context.source as VSCommandSource, selectorOnly) @@ -42,15 +35,14 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType } // Reset cursor to fix suggestions - if (!canThisBeShipArgument) { - // Don't suggest a ship argument if the contents of reader cannot be a ship argument + if (!startsWithAt) { reader.cursor = builder.start - super.listSuggestions(context, builder) - } else { - val nBuilder = builder.createOffset(reader.cursor) - parser.suggestionProvider(nBuilder) - nBuilder.buildFuture() } + + val nBuilder = builder.createOffset(reader.cursor) + parser.suggestionProvider(nBuilder) + + nBuilder.buildFuture() } else super.listSuggestions(context, builder) override fun parse(reader: StringReader): ShipSelector = @@ -98,18 +90,4 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType } override fun getExamples(): Collection = EXAMPLES - - object Serializer : ArgumentSerializer { - override fun serializeToNetwork(arg: ShipArgument, buf: FriendlyByteBuf) { - buf.writeBoolean(arg.selectorOnly) - } - - override fun deserializeFromNetwork(buf: FriendlyByteBuf): ShipArgument { - return ShipArgument(buf.readBoolean()) - } - - override fun serializeToJson(arg: ShipArgument, json: JsonObject) { - json.addProperty("selectorOnly", arg.selectorOnly) - } - } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentInfo.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentInfo.kt new file mode 100644 index 000000000..eeedfb86e --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentInfo.kt @@ -0,0 +1,42 @@ +package org.valkyrienskies.mod.common.command + +import com.google.gson.JsonObject +import net.minecraft.commands.CommandBuildContext +import net.minecraft.commands.synchronization.ArgumentTypeInfo +import net.minecraft.network.FriendlyByteBuf +import org.valkyrienskies.mod.common.command.ShipArgument.Companion + +internal class ShipArgumentInfo : ArgumentTypeInfo { + override fun serializeToNetwork(template: ShipArgumentInfoTemplate, friendlyByteBuf: FriendlyByteBuf) { + friendlyByteBuf.writeBoolean(template.selectorOnly) + } + + override fun deserializeFromNetwork(friendlyByteBuf: FriendlyByteBuf): ShipArgumentInfoTemplate { + return ShipArgumentInfoTemplate( + this, friendlyByteBuf.readBoolean() + ) + } + + override fun unpack(argumentType: ShipArgument): ShipArgumentInfoTemplate { + return ShipArgumentInfoTemplate(this, argumentType.selectorOnly) + } + + override fun serializeToJson(template: ShipArgumentInfoTemplate, jsonObject: JsonObject) { + jsonObject.addProperty("selectorOnly", template.selectorOnly) + } +} + +internal class ShipArgumentInfoTemplate(private val info: ShipArgumentInfo, internal val selectorOnly: Boolean) : + ArgumentTypeInfo.Template { + override fun instantiate(commandBuildContext: CommandBuildContext): ShipArgument { + return if (selectorOnly) { + ShipArgument.selectorOnly() + } else { + Companion.ships() + } + } + + override fun type(): ArgumentTypeInfo { + return info + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt index 59c399f15..1fc4a2968 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt @@ -13,8 +13,7 @@ import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.EntityArgument import net.minecraft.commands.arguments.coordinates.BlockPosArgument import net.minecraft.commands.arguments.coordinates.Vec3Argument -import net.minecraft.commands.synchronization.ArgumentTypes -import net.minecraft.commands.synchronization.EmptyArgumentSerializer +import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component.translatable import net.minecraft.world.entity.Entity import net.minecraft.world.phys.BlockHitResult @@ -24,6 +23,8 @@ import org.valkyrienskies.core.api.world.ServerShipWorld import org.valkyrienskies.core.api.world.ShipWorld import org.valkyrienskies.core.apigame.ShipTeleportData import org.valkyrienskies.core.impl.game.ShipTeleportDataImpl +import org.valkyrienskies.core.impl.game.ships.ShipData +import org.valkyrienskies.core.impl.game.ships.ShipObject import org.valkyrienskies.core.util.x import org.valkyrienskies.core.util.y import org.valkyrienskies.core.util.z @@ -45,18 +46,6 @@ object VSCommands { private const val GET_SHIP_ONLY_USABLE_BY_ENTITIES_MESSAGE = "command.valkyrienskies.get_ship.only_usable_by_entities" private const val TELEPORTED_MULTIPLE_SHIPS_SUCCESS = "command.valkyrienskies.teleport.multiple_ship_success" private const val TELEPORT_FIRST_ARG_CAN_ONLY_INPUT_1_SHIP = "command.valkyrienskies.mc_teleport.can_only_teleport_to_one_ship" - private const val SCALED_SHIPS_MESSAGE = "command.valkyrienskies.scale.success" - private const val REQUIRED_PERMISSION = 2 - - fun bootstrap() { - ArgumentTypes.register("valkyrienskies:ship", - ShipArgument::class.java, - ShipArgument.Serializer) - - ArgumentTypes.register("valkyrienskies:relative_vector", - RelativeVector3Argument::class.java, - EmptyArgumentSerializer(::RelativeVector3Argument)) - } private fun literal(name: String) = LiteralArgumentBuilder.literal(name) @@ -79,7 +68,7 @@ object VSCommands { if (e !is CommandRuntimeException) LOGGER.throwing(e) throw e } - })).requires { (it as CommandSourceStack).hasPermission(REQUIRED_PERMISSION) } + })) .then( literal("set-static").then( argument("ships", ShipArgument.ships()).then( @@ -87,7 +76,16 @@ object VSCommands { try { val r = ShipArgument.getShips(it, "ships").toList() as List val isStatic = BoolArgumentType.getBool(it, "is-static") - r.forEach { ship -> ship.isStatic = isStatic } + r.forEach { ship -> + if (ship is ShipObject) { + // TODO: AAAAAAAAA THIS IS HORRIBLE how can the API support this? + (ship.shipData as ShipData).isStatic = isStatic + } else if (ship is ShipData) { + // TODO: AAAAAAAAA THIS IS HORRIBLE how can the API support this? + ship.isStatic = isStatic + } + + } it.source.sendVSMessage( Component.translatable( SET_SHIP_STATIC_SUCCESS_MESSAGE, r.size, if (isStatic) "true" else "false" @@ -100,7 +98,7 @@ object VSCommands { } }) ) - ).requires { (it as CommandSourceStack).hasPermission(REQUIRED_PERMISSION) } + ) .then( literal("teleport").then( argument("ships", ShipArgument.ships()).then( @@ -110,9 +108,8 @@ object VSCommands { val r = ShipArgument.getShips(it, "ships").toList() as List val position = Vec3Argument.getVec3(it as CommandContext, "position") - val dimensionId = (it.source as CommandSourceStack).level.dimensionId val shipTeleportData: ShipTeleportData = - ShipTeleportDataImpl(newPos = position.toJOML(), newDimension = dimensionId) + ShipTeleportDataImpl(newPos = position.toJOML()) r.forEach { ship -> vsCore.teleportShip( (it as CommandContext).source.shipWorld as ServerShipWorld, @@ -140,14 +137,12 @@ object VSCommands { ) val source = it.source as CommandSourceStack - val dimensionId = (it.source as CommandSourceStack).level.dimensionId val shipTeleportData: ShipTeleportData = ShipTeleportDataImpl( newPos = position.toJOML(), newRot = eulerAngles.toEulerRotationFromMCEntity( source.rotation.x.toDouble(), source.rotation.y.toDouble(), - ), - newDimension = dimensionId, + ) ) r.forEach { ship -> vsCore.teleportShip( @@ -181,15 +176,13 @@ object VSCommands { ) val source = it.source as CommandSourceStack - val dimensionId = (it.source as CommandSourceStack).level.dimensionId val shipTeleportData: ShipTeleportData = ShipTeleportDataImpl( newPos = position.toJOML(), newRot = eulerAngles.toEulerRotationFromMCEntity( source.rotation.x.toDouble(), source.rotation.y.toDouble(), ), - newVel = velocity.toVector3d(0.0, 0.0, 0.0), - newDimension = dimensionId, + newVel = velocity.toVector3d(0.0, 0.0, 0.0) ) r.forEach { ship -> vsCore.teleportShip( @@ -228,7 +221,6 @@ object VSCommands { ) val source = it.source as CommandSourceStack - val dimensionId = (it.source as CommandSourceStack).level.dimensionId val shipTeleportData: ShipTeleportData = ShipTeleportDataImpl( newPos = position.toJOML(), @@ -236,8 +228,7 @@ object VSCommands { source.rotation.x.toDouble(), source.rotation.y.toDouble(), ), newVel = velocity.toVector3d(0.0, 0.0, 0.0), - newOmega = angularVelocity.toVector3d(0.0, 0.0, 0.0), - newDimension = dimensionId, + newOmega = angularVelocity.toVector3d(0.0, 0.0, 0.0) ) r.forEach { ship -> vsCore.teleportShip( @@ -259,7 +250,7 @@ object VSCommands { ) ) ) - ).requires { (it as CommandSourceStack).hasPermission(REQUIRED_PERMISSION) } + ) .then(literal("get-ship").executes { try { val mcCommandContext = it as CommandContext @@ -294,25 +285,7 @@ object VSCommands { throw e } }) - .then( - literal("scale").then( - argument("ships", ShipArgument.ships()).then( - argument("newScale", DoubleArgumentType.doubleArg(0.1, 10.0)).executes { - try { - val world = - (it as CommandContext).source.shipWorld as ServerShipWorld - val newScale = DoubleArgumentType.getDouble(it, "newScale") - val r = ShipArgument.getShips(it, "ships").toList() as List - r.forEach { ship -> vsCore.scaleShip(world, ship, newScale) } - it.source.sendVSMessage(Component.translatable(SCALED_SHIPS_MESSAGE, r.size)) - r.size - } catch (e: Exception) { - if (e !is CommandRuntimeException) LOGGER.throwing(e) - throw e - } - }) - ) - ).requires { (it as CommandSourceStack).hasPermission(REQUIRED_PERMISSION) } + // Single ship commands .then( literal("ship").then( @@ -349,8 +322,28 @@ object VSCommands { } }) ) + + /* DISABLED UNTIL VS-BODIES IS READY + // Scale a ship + .then( + literal("scale") + .then(argument("newScale", FloatArgumentType.floatArg(0.001f)) + .executes { + try { + vsCore.scaleShip( + ShipArgument.getShip(it, "ship") as ServerShip, + FloatArgumentType.getFloat(it, "newScale") + ) + 1 + } catch (e: Exception) { + if (e !is CommandRuntimeException) LOGGER.throwing(e) + throw e + } + }) + ) + */ ) - ).requires { (it as CommandSourceStack).hasPermission(REQUIRED_PERMISSION) } + ) ) dispatcher.root.children.first { it.name == "teleport" }.apply { @@ -370,10 +363,9 @@ object VSCommands { val entity = EntityArgument.getEntity(it as CommandContext, "entity") serverShips.forEach { serverShip -> - val dimensionId = (it.source as CommandSourceStack).level.dimensionId vsCore.teleportShip( it.source.shipWorld as ServerShipWorld, serverShip, - ShipTeleportDataImpl(newPos = Vector3d(entity.x, entity.y, entity.z), newDimension = dimensionId) + ShipTeleportDataImpl(newPos = Vector3d(entity.x, entity.y, entity.z)) ) } (it as CommandContext).source.sendVSMessage( @@ -388,10 +380,9 @@ object VSCommands { val pos = BlockPosArgument.getSpawnablePos(it, "pos") serverShips.forEach { serverShip -> - val dimensionId = (it.source as CommandSourceStack).level.dimensionId vsCore.teleportShip( it.source.shipWorld as ServerShipWorld, serverShip, - ShipTeleportDataImpl(newPos = pos.toJOMLD(), newDimension = dimensionId) + ShipTeleportDataImpl(newPos = pos.toJOMLD()) ) } (it as CommandContext).source.sendVSMessage( diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipAssemblerItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipAssemblerItem.kt index 69a39780b..06693a335 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipAssemblerItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipAssemblerItem.kt @@ -1,7 +1,7 @@ package org.valkyrienskies.mod.common.item import net.minecraft.Util -import net.minecraft.network.chat.TextComponent +import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.InteractionResult import net.minecraft.world.item.Item @@ -20,7 +20,7 @@ class ShipAssemblerItem(properties: Properties) : Item(properties) { if (!level.isClientSide) { if (ctx.level.isChunkInShipyard(pos.x shr 4, pos.z shr 4)) { - ctx.player?.sendMessage(TextComponent("That chunk is already part of a ship!"), Util.NIL_UUID) + ctx.player?.sendSystemMessage(Component.literal("That chunk is already part of a ship!")) } else if (!blockState.isAir) { // Make a ship val set = DenseBlockPosSet() @@ -32,7 +32,7 @@ class ShipAssemblerItem(properties: Properties) : Item(properties) { val shipData = createNewShipWithBlocks(pos, set, level) - ctx.player?.sendMessage(TextComponent("SHIPIFIED!"), Util.NIL_UUID) + ctx.player?.sendSystemMessage(Component.literal("SHIPIFIED!")) } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt index e5fed4518..8081551a7 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt @@ -14,7 +14,6 @@ import net.minecraft.ChatFormatting.GRAY import net.minecraft.ChatFormatting.ITALIC import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component -import net.minecraft.network.chat.TextComponent import org.apache.commons.lang3.StringUtils import org.valkyrienskies.core.impl.config.SidedVSConfigClass import org.valkyrienskies.core.impl.config.VSConfigClass @@ -31,7 +30,7 @@ object VSClothConfig { configClasses.forEach { configClass -> configClass.sides.forEach { side -> val name = if (configClasses.size == 1) side.sideName else "${configClass.name} - ${side.sideName}" - addEntriesForConfig(getOrCreateCategory(TextComponent(name)), ::entryBuilder, side) + addEntriesForConfig(getOrCreateCategory(Component.literal(name)), ::entryBuilder, side) } } savingRunnable = Runnable { @@ -87,12 +86,12 @@ object VSClothConfig { val description: String? = schema["description"]?.asText() val title: String = schema["title"]?.asText(null) ?: key.splitCamelCaseAndCapitalize() - val titleComponent = TextComponent(title) + val titleComponent = Component.literal(title) fun getValidationMessageComponent(value: JsonNode): Optional { val errors = validate(value) return if (errors.isNotEmpty()) { - Optional.of(TextComponent(errors.joinToString())) + Optional.of(Component.literal(errors.joinToString())) } else { Optional.empty() } @@ -109,7 +108,7 @@ object VSClothConfig { val enum: ArrayNode? = schema["enum"] as? ArrayNode val type = schema["type"].asText() - val tooltip: TextComponent? = null + val tooltip: Component? = null when { type == "integer" -> { @@ -241,7 +240,7 @@ object VSClothConfig { val newValue = try { mapper.readTree(str) } catch (ex: JsonProcessingException) { - return@setErrorSupplier Optional.of(TextComponent(ex.message)) + return@setErrorSupplier Optional.of(Component.literal(ex.message)) } getValidationMessageComponent(newValue) @@ -252,7 +251,7 @@ object VSClothConfig { } if (description != null) { - entries.add(entryBuilder().startTextDescription(TextComponent(description).withStyle(GRAY, ITALIC)).build()) + entries.add(entryBuilder().startTextDescription(Component.literal(description).withStyle(GRAY, ITALIC)).build()) } return entries diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index b24ddc4e8..d51676575 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -23,7 +23,7 @@ "feature.block_placement_orientation.MixinBlockItem", "feature.block_placement_orientation.MixinBlockPlaceContext", "feature.clip_replace.MixinLevel", - "feature.commands.MixinArgumentTypes", + "feature.commands.MixinArgumentTypeInfos", "feature.commands.MixinCommandSourceStack", "feature.conduit_fix.ConduitMixin", "feature.container_distance_check.MixinRandomizableContainerBlockEntity", diff --git a/fabric/build.gradle b/fabric/build.gradle index f4f6c621b..91200a021 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -41,6 +41,7 @@ dependencies { include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:6.3.81")) modImplementation("maven.modrinth:sodium:mc1.19.2-0.4.4") + modRuntimeOnly("maven.modrinth:indium:1.0.9+mc1.19.2") modImplementation("maven.modrinth:modmenu:4.2.0-beta.2") // Depend on the fabric API @@ -61,7 +62,7 @@ dependencies { } // CC Restitched - //modImplementation("curse.maven:cc-restitched-462672:3838648") + modImplementation("maven.modrinth:cc-restitched:1.101.2+1.19.1") // Create compat modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { @@ -70,14 +71,8 @@ dependencies { modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version_fabric}") modImplementation("com.tterrag.registrate_fabric:Registrate:${registrate_version}") - //https://mvn.devos.one/snapshots/io/github/fabricators_of_create/Porting-Lib/2.1.1096+1.19.2/Porting-Lib-2.1.1096+1.19.2.pom - //https://mvn.devos.one/snapshots/io/github/fabricators_of_create/Porting-Lib/Porting-Lib/2.1.1096+1.19.2/Porting-Lib-2.1.1096+1.19.2.pom + modImplementation("io.github.fabricators_of_create.Porting-Lib:Porting-Lib:$port_lib_version+$minecraft_version") - for (String module in port_lib_modules.split(",")) { - modImplementation("io.github.fabricators_of_create.Porting-Lib:$module:$port_lib_version+$minecraft_version") - } - - //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}") modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/ValkyrienFabricMixinConfigPlugin.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/ValkyrienFabricMixinConfigPlugin.java deleted file mode 100644 index ae06dacd8..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/ValkyrienFabricMixinConfigPlugin.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin; - -import com.llamalad7.mixinextras.MixinExtrasBootstrap; -import java.util.List; -import java.util.Set; -import org.objectweb.asm.tree.ClassNode; -import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; - -/** - * For now, just using this class as an abusive early entrypoint to run the updater - */ -public class ValkyrienFabricMixinConfigPlugin implements IMixinConfigPlugin { - - @Override - public void onLoad(final String s) { - MixinExtrasBootstrap.init(); - } - - @Override - public String getRefMapperConfig() { - return null; - } - - @Override - public boolean shouldApplyMixin(final String s, final String s1) { - return true; - } - - @Override - public void acceptTargets(final Set set, final Set set1) { - - } - - @Override - public List getMixins() { - return null; - } - - @Override - public void preApply(final String s, final ClassNode classNode, final String s1, final IMixinInfo iMixinInfo) { - - } - - @Override - public void postApply(final String s, final ClassNode classNode, final String s1, final IMixinInfo iMixinInfo) { - - } -} 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 37e52f033..5f12bdf60 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 @@ -1,8 +1,8 @@ package org.valkyrienskies.mod.fabric.mixin.world.level.block; -import java.util.Random; import net.minecraft.core.BlockPos; 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.LevelReader; @@ -29,8 +29,8 @@ public abstract class FireMixin { public static IntegerProperty AGE; @Inject(method = "tick", at = @At("TAIL")) - public void fireTickMixin(final BlockState state, final ServerLevel level, final BlockPos pos, final Random random, - final CallbackInfo ci) { + public void fireTickMixin(BlockState state, ServerLevel level, BlockPos pos, + RandomSource random, CallbackInfo ci) { if (isModifyingFireTick) { return; } @@ -71,7 +71,7 @@ public void fireTickMixin(final BlockState state, final ServerLevel level, final } mutableBlockPos.setWithOffset(newPos, l, n, m); - final int p = this.getFireOdds(level, mutableBlockPos); + final int p = this.getIgniteOdds(level, mutableBlockPos); if (p > 0) { int q = (p + 40 + level.getDifficulty().getId() * 7) / (i + 30); if (bl2) { @@ -112,7 +112,7 @@ public void onPlaceMixin(final BlockState state, final Level level, final BlockP } @Shadow - private void checkBurnOut(final Level level, final BlockPos pos, final int chance, final Random random, + private void checkBurnOut(final Level level, final BlockPos pos, final int chance, final RandomSource random, final int age) { } @@ -122,8 +122,8 @@ protected boolean isNearRain(final Level level, final BlockPos pos) { } @Shadow - private int getFireOdds(final LevelReader level, final BlockPos pos) { - return getFireOdds(level, pos); + private int getIgniteOdds(final LevelReader level, final BlockPos pos) { + return getIgniteOdds(level, pos); } @Shadow 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 5ae9cea1f..13e5b2914 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 @@ -4,7 +4,7 @@ import net.fabricmc.api.EnvType import net.fabricmc.api.ModInitializer import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper import net.fabricmc.fabric.api.client.rendering.v1.EntityRendererRegistry -import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback +import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback import net.fabricmc.fabric.api.event.lifecycle.v1.CommonLifecycleEvents import net.fabricmc.fabric.api.`object`.builder.v1.block.entity.FabricBlockEntityTypeBuilder import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener @@ -143,7 +143,7 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE ) - CommandRegistrationCallback.EVENT.register { dispatcher, _ -> + CommandRegistrationCallback.EVENT.register { dispatcher ,d, _ -> VSCommands.registerServerCommands(dispatcher) } diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 59ece5b8c..9fdd01a92 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -2,7 +2,6 @@ "required": true, "package": "org.valkyrienskies.mod.fabric.mixin", "compatibilityLevel": "JAVA_8", - "plugin": "org.valkyrienskies.mod.fabric.mixin.ValkyrienFabricMixinConfigPlugin", "mixins": [ "compat.cc_restitched.MixinSpeakerPosition", "compat.cc_restitched.MixinTurtleBrain", diff --git a/forge/build.gradle b/forge/build.gradle index dc1c97540..6d9940132 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -51,6 +51,7 @@ configurations { } dependencies { + implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:0.2.0")) implementation(include("io.github.llamalad7:mixinextras-forge:0.2.0")) diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/ValkyrienForgeMixinConfigPlugin.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/ValkyrienForgeMixinConfigPlugin.java deleted file mode 100644 index f8ed1ff8c..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/ValkyrienForgeMixinConfigPlugin.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin; - -import com.llamalad7.mixinextras.MixinExtrasBootstrap; -import java.util.List; -import java.util.Set; -import org.objectweb.asm.tree.ClassNode; -import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; -import org.spongepowered.asm.mixin.extensibility.IMixinInfo; - -/** - * For now, just using this class as an abusive early entrypoint to run the updater - */ -public class ValkyrienForgeMixinConfigPlugin implements IMixinConfigPlugin { - - @Override - public void onLoad(final String s) { - MixinExtrasBootstrap.init(); - } - - @Override - public String getRefMapperConfig() { - return null; - } - - @Override - public boolean shouldApplyMixin(final String s, final String s1) { - return true; - } - - @Override - public void acceptTargets(final Set set, final Set set1) { - - } - - @Override - public List getMixins() { - return null; - } - - @Override - public void preApply(final String s, final ClassNode classNode, final String s1, final IMixinInfo iMixinInfo) { - - } - - @Override - public void postApply(final String s, final ClassNode classNode, final String s1, final IMixinInfo iMixinInfo) { - - } -} 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 27b470e6f..97b70494c 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 @@ -4,6 +4,7 @@ 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.LevelReader; @@ -30,7 +31,7 @@ public abstract class FireMixin { public static IntegerProperty AGE; @Inject(method = "tick", at = @At("TAIL")) - public void fireTickMixin(final BlockState state, final ServerLevel level, final BlockPos pos, final Random random, + public void fireTickMixin(final BlockState state, final ServerLevel level, final BlockPos pos, final RandomSource random, final CallbackInfo ci) { if (isModifyingFireTick) { return; @@ -71,7 +72,7 @@ public void fireTickMixin(final BlockState state, final ServerLevel level, final } mutableBlockPos.setWithOffset(newPos, l, n, m); - final int p = this.getFireOdds(level, mutableBlockPos); + final int p = this.getIgniteOdds(level, mutableBlockPos); if (p > 0) { int q = (p + 40 + level.getDifficulty().getId() * 7) / (i + 30); if (bl2) { @@ -112,7 +113,7 @@ public void onPlaceMixin(final BlockState state, final Level level, final BlockP } @Shadow - private void tryCatchFire(final Level arg, final BlockPos arg2, final int k, final Random random, final int l, + private void tryCatchFire(final Level arg, final BlockPos arg2, final int k, final RandomSource random, final int l, final Direction face) { } @@ -123,5 +124,5 @@ private void tryCatchFire(final Level arg, final BlockPos arg2, final int k, fin protected abstract boolean isNearRain(Level level, BlockPos blockPos); @Shadow - protected abstract int getFireOdds(LevelReader levelReader, BlockPos blockPos); + protected abstract int getIgniteOdds(LevelReader levelReader, BlockPos blockPos); } diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 448f11e1c..647a06f8d 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -2,7 +2,6 @@ "required": true, "package": "org.valkyrienskies.mod.forge.mixin", "compatibilityLevel": "JAVA_17", - "plugin": "org.valkyrienskies.mod.forge.mixin.ValkyrienForgeMixinConfigPlugin", "mixins": [ "compat.cc_tweaked.MixinSpeakerPosition", "compat.cc_tweaked.MixinTurtleBrain", From 79b7df28063e2b2a14f5f49342d7ec7a52a0b720 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Thu, 16 Nov 2023 03:03:07 +0100 Subject: [PATCH 072/156] 1.19.2 port --- .../client/renderer/MixinLevelRenderer.java | 26 +++++++------------ .../forge/common/ValkyrienSkiesModForge.kt | 24 +++++++++-------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java index 8b10eb471..59776e28c 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java @@ -2,37 +2,26 @@ import static org.valkyrienskies.mod.common.VSClientGameUtils.transformRenderWithShip; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; 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; import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.LightTexture; -import net.minecraft.client.renderer.block.BlockRenderDispatcher; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.BlockAndTintGetter; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.phys.Vec3; import net.minecraft.world.phys.shapes.CollisionContext; import net.minecraft.world.phys.shapes.VoxelShape; 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.Constant; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyConstant; 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.mixin.accessors.client.render.OverlayVertexConsumerAccessor; @Mixin(LevelRenderer.class) public abstract class MixinLevelRenderer { @@ -40,6 +29,9 @@ public abstract class MixinLevelRenderer { @Shadow private ClientLevel level; + @Unique private PoseStack matrixStack; + @Unique private Vec3 camera; + @Shadow private static void renderShape(final PoseStack matrixStack, final VertexConsumer vertexConsumer, final VoxelShape voxelShape, final double d, final double e, final double f, final float red, final float green, @@ -88,17 +80,17 @@ private void preRenderHitOutline(final PoseStack matrixStack, final VertexConsum } } + /** * This mixin makes block damage render on ships. */ + /* @WrapOperation(method = "renderLevel", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/block/BlockRenderDispatcher;renderBreakingTexture(Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/BlockAndTintGetter;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;)V")) private void renderBlockDamage(final BlockRenderDispatcher blockRenderManager, final BlockState state, final BlockPos blockPos, final BlockAndTintGetter blockRenderWorld, final PoseStack matrix, - final VertexConsumer vertexConsumer, final Operation renderBreakingTexture, final PoseStack matrixStack, - final float methodTickDelta, final long methodLimitTime, final boolean methodRenderBlockOutline, - final Camera methodCamera, final GameRenderer methodGameRenderer, - final LightTexture methodLightmapTextureManager, final Matrix4f methodMatrix4f) { + final VertexConsumer vertexConsumer, final Operation renderBreakingTexture) { + final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(level, blockPos); if (ship != null) { @@ -131,4 +123,6 @@ private void renderBlockDamage(final BlockRenderDispatcher blockRenderManager, f } } + */ + } 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 1906df862..9334eaac8 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 @@ -11,9 +11,9 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.Item.Properties import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.entity.BlockEntityType -import net.minecraftforge.client.ClientRegistry -import net.minecraftforge.client.ConfigGuiHandler.ConfigGuiFactory +import net.minecraftforge.client.ConfigScreenHandler import net.minecraftforge.client.event.EntityRenderersEvent +import net.minecraftforge.client.event.RegisterKeyMappingsEvent import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.RegisterCommandsEvent import net.minecraftforge.event.TagsUpdatedEvent @@ -56,8 +56,8 @@ import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig class ValkyrienSkiesModForge { private val BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ValkyrienSkiesMod.MOD_ID) private val ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ValkyrienSkiesMod.MOD_ID) - private val ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITIES, ValkyrienSkiesMod.MOD_ID) - private val BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, ValkyrienSkiesMod.MOD_ID) + private val ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, ValkyrienSkiesMod.MOD_ID) + private val BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, ValkyrienSkiesMod.MOD_ID) private val TEST_CHAIR_REGISTRY: RegistryObject private val TEST_HINGE_REGISTRY: RegistryObject private val TEST_FLAP_REGISTRY: RegistryObject @@ -91,16 +91,18 @@ class ValkyrienSkiesModForge { ITEMS.register(modBus) ENTITIES.register(modBus) BLOCK_ENTITIES.register(modBus) - modBus.addListener(::clientSetup) - modBus.addListener(::entityRenderers) + if (isClient) { + modBus.addListener(::registerKeyBindings) + modBus.addListener(::entityRenderers) + } modBus.addListener(::loadComplete) forgeBus.addListener(::registerCommands) forgeBus.addListener(::tagsUpdated) forgeBus.addListener(::registerResourceManagers) - ModLoadingContext.get().registerExtensionPoint(ConfigGuiFactory::class.java) { - ConfigGuiFactory { _, parent -> + ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory::class.java) { + ConfigScreenHandler.ConfigScreenFactory { _, parent -> VSClothConfig.createConfigScreenFor( parent, VSConfigClass.getRegisteredConfig(VSCoreConfig::class.java), @@ -166,9 +168,9 @@ class ValkyrienSkiesModForge { event.addListener(VSEntityHandlerDataLoader) } - private fun clientSetup(event: FMLClientSetupEvent) { + private fun registerKeyBindings(event: RegisterKeyMappingsEvent) { VSKeyBindings.clientSetup { - ClientRegistry.registerKeyBinding(it) + event.register(it) } } @@ -186,7 +188,7 @@ class ValkyrienSkiesModForge { private fun registerCommands(event: RegisterCommandsEvent) { VSCommands.registerServerCommands(event.dispatcher) - if (event.environment == ALL || event.environment == INTEGRATED) { + if (event.commandSelection == ALL || event.commandSelection == INTEGRATED) { VSCommands.registerClientCommands(event.dispatcher) } } From dc3851cd7b9cce62f35f7050000192c3396ed353 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Thu, 16 Nov 2023 12:20:09 +0100 Subject: [PATCH 073/156] 1.19.2 port forge also works now --- .../src/main/resources/valkyrienskies-common.mixins.json | 1 - .../mixin/server/network/MixinServerPlayerGameMode.java | 6 +++--- .../src/main/resources/valkyrienskies-fabric.mixins.json | 3 ++- forge/build.gradle | 2 +- .../mod/forge/common/ValkyrienSkiesModForge.kt | 8 ++++++++ 5 files changed, 14 insertions(+), 6 deletions(-) rename {common/src/main/java/org/valkyrienskies/mod => fabric/src/main/java/org/valkyrienskies/mod/fabric}/mixin/server/network/MixinServerPlayerGameMode.java (91%) diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index d51676575..ed62d8488 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -94,7 +94,6 @@ "server.command.MixinCommands", "server.command.level.MixinServerPlayer", "server.network.MixinServerGamePacketListenerImpl", - "server.network.MixinServerPlayerGameMode", "server.world.MixinChunkMap", "server.world.MixinChunkMap$TrackedEntity", "server.world.MixinServerLevel", diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerPlayerGameMode.java similarity index 91% rename from common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java rename to fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerPlayerGameMode.java index 6f350f158..5065a95b0 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/network/MixinServerPlayerGameMode.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerPlayerGameMode.java @@ -1,5 +1,6 @@ -package org.valkyrienskies.mod.mixin.server.network; +package org.valkyrienskies.mod.fabric.mixin.server.network; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -10,7 +11,6 @@ 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.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.config.VSGameConfig; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @@ -28,7 +28,7 @@ public class MixinServerPlayerGameMode { /** * Includes ships in server-side distance check when player breaks a block. */ - @Redirect( + @ModifyExpressionValue( method = "handleBlockBreakAction", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D") diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 9fdd01a92..3bfe6ae80 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -12,7 +12,8 @@ "compat.create.MixinControlledContraptionEntity", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", - "world.level.block.FireMixin" + "world.level.block.FireMixin", + "server.network.MixinServerPlayerGameMode" ], "client": [ "compat.create.client.MixinContraptionHandlerClient", diff --git a/forge/build.gradle b/forge/build.gradle index 6d9940132..e75567242 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -83,7 +83,7 @@ dependencies { forgeRuntimeLibrary('curse.maven:kotlinforforge-351264:4513187') // Cloth for config - include(modImplementation("me.shedaniel.cloth:cloth-config-forge:6.3.81")) + include(modImplementation("me.shedaniel.cloth:cloth-config-forge:8.3.103")) // Shade vs-core implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") 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 9334eaac8..585c2ac47 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 @@ -3,6 +3,7 @@ package org.valkyrienskies.mod.forge.common import net.minecraft.commands.Commands.CommandSelection.ALL import net.minecraft.commands.Commands.CommandSelection.INTEGRATED import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerPlayerGameMode import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.MobCategory import net.minecraft.world.item.BlockItem @@ -17,6 +18,8 @@ import net.minecraftforge.client.event.RegisterKeyMappingsEvent import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.RegisterCommandsEvent import net.minecraftforge.event.TagsUpdatedEvent +import net.minecraftforge.event.entity.player.PlayerInteractEvent +import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus @@ -99,6 +102,7 @@ class ValkyrienSkiesModForge { forgeBus.addListener(::registerCommands) forgeBus.addListener(::tagsUpdated) + forgeBus.addListener(::leftClickEvent) forgeBus.addListener(::registerResourceManagers) ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory::class.java) { @@ -197,6 +201,10 @@ class ValkyrienSkiesModForge { VSGameEvents.tagsAreLoaded.emit(Unit) } + private fun leftClickEvent(event: PlayerInteractEvent.LeftClickBlock){ + + } + private fun loadComplete(event: FMLLoadCompleteEvent) { ValkyrienSkiesMod.TEST_CHAIR = TEST_CHAIR_REGISTRY.get() ValkyrienSkiesMod.TEST_HINGE = TEST_HINGE_REGISTRY.get() From 5f841020953344747345d7136582d227fcbf7fc1 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Thu, 16 Nov 2023 13:51:21 +0100 Subject: [PATCH 074/156] 1.19.2 eh somehow this doesnt work anymore --- common/build.gradle | 5 ++--- common/gradle.properties | 4 ++++ fabric/build.gradle | 12 ++++++------ fabric/gradle.properties | 12 ++++++++++++ .../server/network/MixinServerPlayerGameMode.java | 4 ++-- forge/build.gradle | 12 +++++------- forge/gradle.properties | 8 ++++++++ .../compat/tis3d/MixinCasingTileEntityRender.java | 6 +++--- .../mod/forge/common/ValkyrienSkiesModForge.kt | 5 ----- 9 files changed, 42 insertions(+), 26 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index 4dbde9a9d..0964ac38e 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -7,10 +7,9 @@ dependencies { // Do NOT use other classes from fabric loader modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}" - modApi("me.shedaniel.cloth:cloth-config:8.3.103") - //modApi "me.shedaniel.cloth:cloth-config-fabric:8.3.103" + modApi("me.shedaniel.cloth:cloth-config:${cloth_config_version}") - modCompileOnly("maven.modrinth:sodium:mc1.19.2-0.4.4") + modCompileOnly("maven.modrinth:sodium:${sodium_version}") // vs-core implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") { diff --git a/common/gradle.properties b/common/gradle.properties index 6ea2e969e..8165c62f2 100644 --- a/common/gradle.properties +++ b/common/gradle.properties @@ -1,2 +1,6 @@ port_lib_version=2.1.1096 port_lib_modules = accessors,base,entity,extensions,fake_players,networking,obj_loader,tags,transfer + +cloth_config_version = 8.3.103 + +sodium_version = mc1.19.2-0.4.4 diff --git a/fabric/build.gradle b/fabric/build.gradle index 91200a021..20079d716 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -37,12 +37,12 @@ dependencies { } // Depend on the fabric kotlin mod - include(modImplementation("net.fabricmc:fabric-language-kotlin:1.10.10+kotlin.1.9.10")) - include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:6.3.81")) + include(modImplementation("net.fabricmc:fabric-language-kotlin:${kotlin_fabric_version}")) + include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}")) - modImplementation("maven.modrinth:sodium:mc1.19.2-0.4.4") - modRuntimeOnly("maven.modrinth:indium:1.0.9+mc1.19.2") - modImplementation("maven.modrinth:modmenu:4.2.0-beta.2") + modImplementation("maven.modrinth:sodium:${sodium_version}") + modRuntimeOnly("maven.modrinth:indium:${indium_version}") + modImplementation("maven.modrinth:modmenu:${modmenu_version}") // Depend on the fabric API modImplementation("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}") @@ -62,7 +62,7 @@ dependencies { } // CC Restitched - modImplementation("maven.modrinth:cc-restitched:1.101.2+1.19.1") + modImplementation("maven.modrinth:cc-restitched:${cc_restitched_version}") // Create compat modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 25a78e413..3815a8e9e 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -16,3 +16,15 @@ 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 + +sodium_version = mc1.19.2-0.4.4 + +cc_restitched_version = 1.101.2+1.19.1 + +kotlin_fabric_version = 1.10.10+kotlin.1.9.10 + +indium_version = 1.0.9+mc1.19.2 + +modmenu_version = 4.2.0-beta.2 + +cloth_config_version = 8.3.103 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 5065a95b0..44087ce6f 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 @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.fabric.mixin.server.network; -import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; @@ -11,6 +10,7 @@ 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.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.config.VSGameConfig; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @@ -28,7 +28,7 @@ public class MixinServerPlayerGameMode { /** * Includes ships in server-side distance check when player breaks a block. */ - @ModifyExpressionValue( + @Redirect( method = "handleBlockBreakAction", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D") diff --git a/forge/build.gradle b/forge/build.gradle index e75567242..fc8f612d4 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -64,7 +64,7 @@ dependencies { transitive = false } - modCompileOnly("curse.maven:rubidium-574856:4024781") + modCompileOnly("maven.modrinth:rubidium:${rubidium_version}") // Create compat modImplementation("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false } @@ -72,18 +72,16 @@ dependencies { modImplementation("com.tterrag.registrate:Registrate:${registrate_version}") // CC Tweaked - modCompileOnly("curse.maven:cc-tweaked-282001:4061947") + modCompileOnly("maven.modrinth:cc-tweaked:${cc_tweaked_version}") // TIS-3d - modCompileOnly("curse.maven:tis3d-238603:3738437") - //modImplementation("curse.maven:tis3d-238603:3738437") - //modImplementation("curse.maven:markdownmanual-502485:3738124") + modCompileOnly("maven.modrinth:tis3d:${tis3d_version}") // Add Kotlin for Forge (3.12.0) - forgeRuntimeLibrary('curse.maven:kotlinforforge-351264:4513187') + forgeRuntimeLibrary("maven.modrinth:kotlin-for-forge:${kotlin_version}") // Cloth for config - include(modImplementation("me.shedaniel.cloth:cloth-config-forge:8.3.103")) + include(modImplementation("me.shedaniel.cloth:cloth-config-forge:${cloth_config_version}")) // Shade vs-core implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") diff --git a/forge/gradle.properties b/forge/gradle.properties index ff43bbf71..030d51dd4 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -1,7 +1,15 @@ loader_platform=Forge loom.platform=forge kotlin.stdlib.default.dependency=false +#Deps +kotlin_version = 3.12.0 +cloth_config_version = 8.3.103 + #Compat 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 +#Extra +tis3d_version = MC1.19.2-forge-1.7.4 +rubidium_version = 0.6.2c 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 index 2b06a8e75..56518b307 100644 --- 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 @@ -1,6 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.tis3d; -import li.cil.tis3d.client.renderer.tileentity.CasingTileEntityRenderer; +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; @@ -13,9 +13,9 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; @Pseudo -@Mixin(CasingTileEntityRenderer.class) +@Mixin(CasingBlockEntityRenderer.class) public abstract class MixinCasingTileEntityRender { - @ModifyVariable(remap = false, method = "isBackFace(Lnet/minecraft/core/BlockPos;Lli/cil/tis3d/api/machine/Face;)Z", + @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); 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 585c2ac47..d52dbf13f 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 @@ -102,7 +102,6 @@ class ValkyrienSkiesModForge { forgeBus.addListener(::registerCommands) forgeBus.addListener(::tagsUpdated) - forgeBus.addListener(::leftClickEvent) forgeBus.addListener(::registerResourceManagers) ModLoadingContext.get().registerExtensionPoint(ConfigScreenHandler.ConfigScreenFactory::class.java) { @@ -201,10 +200,6 @@ class ValkyrienSkiesModForge { VSGameEvents.tagsAreLoaded.emit(Unit) } - private fun leftClickEvent(event: PlayerInteractEvent.LeftClickBlock){ - - } - private fun loadComplete(event: FMLLoadCompleteEvent) { ValkyrienSkiesMod.TEST_CHAIR = TEST_CHAIR_REGISTRY.get() ValkyrienSkiesMod.TEST_HINGE = TEST_HINGE_REGISTRY.get() From 5c994e531d7d50c7e3038a72cdfd17b40de5dbae Mon Sep 17 00:00:00 2001 From: mrsterner Date: Thu, 16 Nov 2023 14:19:05 +0100 Subject: [PATCH 075/156] 1.19.2 there we go, both fab and forg seems to work --- .../MixinServerGamePacketListenerImpl.java | 22 +++++++++++++++++++ .../valkyrienskies-fabric.mixins.json | 3 ++- forge/build.gradle | 3 ++- forge/gradle.properties | 2 +- 4 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerGamePacketListenerImpl.java diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerGamePacketListenerImpl.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerGamePacketListenerImpl.java new file mode 100644 index 000000000..5fac1ed43 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/server/network/MixinServerGamePacketListenerImpl.java @@ -0,0 +1,22 @@ +package org.valkyrienskies.mod.fabric.mixin.server.network; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import net.minecraft.server.network.ServerGamePacketListenerImpl; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; + +@Mixin(ServerGamePacketListenerImpl.class) +public abstract class MixinServerGamePacketListenerImpl { + @WrapOperation( + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" + ), + method = "handleUseItemOn" + ) + private double skipDistanceCheck(final Vec3 instance, final Vec3 chunkPos, final Operation getChessboardDistance) { + return 0; + } +} diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 3bfe6ae80..04d2ec57f 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -13,7 +13,8 @@ "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", "world.level.block.FireMixin", - "server.network.MixinServerPlayerGameMode" + "server.network.MixinServerPlayerGameMode", + "server.network.MixinServerGamePacketListenerImpl" ], "client": [ "compat.create.client.MixinContraptionHandlerClient", diff --git a/forge/build.gradle b/forge/build.gradle index fc8f612d4..0d868dcf2 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -64,7 +64,8 @@ dependencies { transitive = false } - modCompileOnly("maven.modrinth:rubidium:${rubidium_version}") + //modCompileOnly("curse.maven:rubidium-574856:4024781") + modCompileOnly("maven.modrinth:embeddium:${embeddium_version}") // Create compat modImplementation("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false } diff --git a/forge/gradle.properties b/forge/gradle.properties index 030d51dd4..a45b39707 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -12,4 +12,4 @@ registrate_version = MC1.19-1.1.5 cc_tweaked_version = 1.19.2-1.101.3 #Extra tis3d_version = MC1.19.2-forge-1.7.4 -rubidium_version = 0.6.2c +embeddium_version = 0.2.9+mc1.19.2 From 4c71fdbc2d480f69be34cb7cabade18696f56b42 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Thu, 16 Nov 2023 14:35:35 +0100 Subject: [PATCH 076/156] links to deps --- common/gradle.properties | 3 +++ fabric/gradle.properties | 15 +++++++++++++-- forge/gradle.properties | 3 +++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/common/gradle.properties b/common/gradle.properties index 8165c62f2..6d2b61dc9 100644 --- a/common/gradle.properties +++ b/common/gradle.properties @@ -1,6 +1,9 @@ +#https://mvn.devos.one/#/snapshots/io/github/fabricators_of_create/Porting-Lib/Porting-Lib 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 +# https://modrinth.com/mod/sodium/versions sodium_version = mc1.19.2-0.4.4 diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 3815a8e9e..46c0a545e 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1,14 +1,20 @@ loader_platform=Fabric create_version=0.5.1-c-build.1160+mc1.19.2 -# https://github.com/Fabricators-of-Create/Create/blob/mc1.18/fabric/dev/gradle.properties +# 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 forge_config_api_port_version=4.2.9 +# https://github.com/CafeteriaGuild/fake-player-api/blob/1.19/gradle.properties fake_player_api_version=0.4.0 -# https://maven.tterrag.com/com/jozufozu/flywheel/Flywheel-Fabric +# 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 + 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_modules = accessors,base,entity,extensions,fake_players,networking,obj_loader,tags,transfer night_config_core_version=3.6.3 @@ -17,14 +23,19 @@ jsr305_version=3.0.2 # https://modrinth.com/mod/no-indium/ no_indium_version=1.1.0+1.19 +#https://modrinth.com/mod/sodium/versions sodium_version = mc1.19.2-0.4.4 +#https://modrinth.com/mod/cc-restitched/versions cc_restitched_version = 1.101.2+1.19.1 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://linkie.shedaniel.me/dependencies?loader=fabric&version=1.19.2 modmenu_version = 4.2.0-beta.2 +# https://linkie.shedaniel.me/dependencies?loader=fabric&version=1.19.2 cloth_config_version = 8.3.103 diff --git a/forge/gradle.properties b/forge/gradle.properties index a45b39707..6b56dff03 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -6,10 +6,13 @@ kotlin_version = 3.12.0 cloth_config_version = 8.3.103 #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 #Extra +# https://modrinth.com/mod/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 From c5aeb87ae8f68a135eef3a53a7b26c7b56b1f2f2 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Thu, 16 Nov 2023 18:12:57 +0100 Subject: [PATCH 077/156] forgot to initialize items, oh whel ill pR this anyway --- common/gradle.properties | 8 +- .../resource/ResourceKeyAccessor.java | 4 +- .../accessors/util/math/Matrix4fAccessor.java | 2 +- .../mod/mixin/client/MixinCamera.java | 15 +- .../mod/mixin/client/MixinGame.java | 52 +-- .../mod/mixin/client/MixinMinecraft.java | 4 +- .../MixinClientPacketListener.java | 2 +- .../client/renderer/MixinGameRenderer.java | 24 +- .../mod/mixin/entity/MixinEntity.java | 4 +- .../SwimNodeEvaluatorMixin.java | 16 +- .../WalkNodeEvaluatorMixin.java | 2 +- .../feature/bed_fix/MixinServerPlayer.java | 2 +- .../feature/block_tint/MixinClientLevel.java | 2 +- .../feature/clip_replace/MixinLevel.java | 2 +- ...erBlockEntity.java => MixinContainer.java} | 10 +- .../feature/entity_collision/MixinEntity.java | 4 +- .../feature/explosions/MixinExplosion.java | 2 +- .../LavaFluidMixin.java | 2 +- .../feature/fluid_camera_fix/MixinCamera.java | 2 +- .../feature/ladders/MixinLivingEntity.java | 4 +- .../render_leashes/MixinMobRenderer.java | 2 +- .../MixinClientPacketListener.java | 4 +- .../shipyard_entities/MixinEntity.java | 8 +- .../MixinEntityRenderDispatcher.java | 6 +- .../shipyard_entities/MixinEntitySection.java | 4 +- .../MixinEntitySectionStorage.java | 8 +- .../shipyard_entities/MixinServerLevel.java | 2 +- .../client/MixinSimpleSoundInstance.java | 7 +- .../tick_ship_chunks/MixinChunkMap.java | 2 +- .../mixin/feature/vs2_alpha_hud/MixinGui.java | 14 +- .../water_in_ships_entity/MixinEntity.java | 2 +- .../feature/world_border/MixinLevel.java | 13 +- .../mod_compat/create/MixinContraption.java | 2 +- .../create/MixinContraptionCollider.java | 16 +- .../create/MixinEntityLauncher.java | 2 +- .../create/MixinSharedDepotBlockMethods.java | 4 +- .../create/block/MixinEjectorBlock.java | 6 +- .../block/MixinRedstoneContactBlock.java | 6 +- ...ixinCrushingWheelControllerTileEntity.java | 4 +- .../blockentity/MixinEjectorTileEntity.java | 2 +- .../create/client/MixinAABBOutline.java | 6 +- .../client/MixinBlockClusterOutline.java | 8 +- .../MixinCarriageContraptionInstance.java | 20 +- .../create/client/MixinMinecartInstance.java | 6 +- .../MixinOrientedContraptionEntity.java | 4 +- .../create/client/MixinOutline.java | 18 +- .../create/client/MixinSoundScapes.java | 6 +- .../client/MixinTileEntityRenderHelper.java | 2 +- .../create/client/MixinTrackBlockOutline.java | 2 +- .../create/client/MixinTrainRelocator.java | 2 +- .../MixinAbstractContraptionEntity.java | 24 +- .../MixinCarriageContraptionEntity.java | 4 +- .../create/entity/MixinSeatEntity.java | 6 +- .../packets/MixinControlsInputPacket.java | 2 +- .../MixinCurvedTrackDestroyPacket.java | 4 +- .../packets/MixinSuperGlueRemovalPacket.java | 4 +- .../MixinTileEntityConfigurationPacket.java | 2 +- .../MixinPitchOrientedContraptionEntity.java | 2 +- .../MixinBlockEntityInstanceManager.java | 2 +- .../flywheel/MixinInstanceManager.java | 4 +- .../flywheel/MixinInstanceWorld.java | 6 +- .../flywheel/MixinInstancingEngine.java | 2 +- .../ftb_chunks/MixinClaimedChunkManager.java | 4 +- .../optifine/MixinLevelRendererOptifine.java | 4 +- .../optifine/MixinViewAreaOptifine.java | 298 +++++++++--------- .../optifine_vanilla/MixinLevelRenderer.java | 2 +- .../MixinSoundPhysics.java | 2 +- .../MixinLevelRendererVanilla.java | 8 +- .../MixinViewAreaVanilla.java | 6 +- .../mixin/server/MixinMinecraftServer.java | 25 +- .../command/level/MixinServerPlayer.java | 8 +- .../MixinServerGamePacketListenerImpl.java | 11 +- .../world/MixinChunkMap$TrackedEntity.java | 2 +- .../mixin/server/world/MixinServerLevel.java | 17 +- .../mixin/world/chunk/MixinLevelChunk.java | 10 +- .../projectile/ProjectileUtilMixin.java | 4 +- .../world/level/MixinBlockCollisions.java | 5 +- .../level/chunk/MixinChunkGenerator.java | 11 +- .../mixinducks/MixinInstancingEngineDuck.java | 2 +- .../mod/client/VSPhysicsEntityRenderer.kt | 8 +- .../mod/common/BlockStateInfoProvider.kt | 3 +- .../common/DefaultBlockStateInfoProvider.kt | 11 +- .../valkyrienskies/mod/common/PlayerUtil.kt | 2 +- .../mod/common/VSClientGameUtils.kt | 25 -- .../valkyrienskies/mod/common/VSGameUtils.kt | 12 +- .../mod/common/ValkyrienSkiesMod.kt | 28 ++ .../mod/common/block/TestChairBlock.kt | 3 +- .../mod/common/block/TestFlapBlock.kt | 3 +- .../mod/common/block/TestHingeBlock.kt | 3 +- .../mod/common/block/TestSphereBlock.kt | 3 +- .../mod/common/block/TestWingBlock.kt | 3 +- .../mod/common/command/VSCommands.kt | 2 +- .../config/VSEntityHandlerDataLoader.kt | 4 +- .../mod/common/config/VSMassDataLoader.kt | 17 +- .../mod/common/entity/ShipMountingEntity.kt | 28 +- .../mod/common/entity/VSPhysicsEntity.kt | 27 +- .../handling/AbstractShipyardEntityHandler.kt | 5 +- .../common/entity/handling/VSEntityManager.kt | 7 +- .../entity/handling/WorldEntityHandler.kt | 4 +- .../mod/common/hooks/VSGameEvents.kt | 2 +- .../mod/common/networking/VSGamePackets.kt | 5 +- .../mod/common/util/EntityDragger.kt | 4 +- .../common/util/EntityShipCollisionUtils.kt | 4 +- .../mod/common/util/MinecraftPlayer.kt | 4 +- .../mod/common/world/RaycastUtils.kt | 4 +- .../mod/util/VectorConversionsMC.kt | 103 +----- .../valkyrienskies-common.mixins.json | 4 +- fabric/build.gradle | 4 +- fabric/gradle.properties | 28 +- .../cc_restitched/MixinTurtleBrain.java | 10 +- .../cc_restitched/MixinTurtleMoveCommand.java | 6 +- .../cc_restitched/MixinWirelessNetwork.java | 13 +- .../mixin/compat/create/MixinBlocks.java | 10 +- .../client/MixinContraptionRenderInfo.java | 2 +- .../create/client/MixinFlwContraption.java | 11 +- .../MixinSuperGlueSelectionHandler.java | 2 +- .../network/MixinServerPlayerGameMode.java | 2 +- .../mixin/world/level/block/FireMixin.java | 7 +- .../fabric/common/ValkyrienSkiesModFabric.kt | 41 ++- forge/gradle.properties | 12 +- .../cc_tweaked/MixinSpeakerPosition.java | 94 +++--- .../compat/cc_tweaked/MixinTurtleBrain.java | 232 +++++++------- .../cc_tweaked/MixinTurtleMoveCommand.java | 115 +++---- .../cc_tweaked/MixinWirelessNetwork.java | 82 ++--- .../mixin/compat/create/MixinBlocks.java | 6 +- .../client/MixinContraptionRenderInfo.java | 2 +- .../create/client/MixinFlwContraption.java | 6 +- .../MixinSuperGlueSelectionHandler.java | 4 +- .../sodium/MixinRenderSectionManager.java | 22 +- .../sodium/RenderSectionManagerDuck.java | 10 + ...MixinEnvironmentalTemperatureProvider.java | 6 +- .../forge_interact/MixinIForgePlayer.java | 8 +- .../mixin/world/level/block/FireMixin.java | 7 +- .../forge/common/ValkyrienSkiesModForge.kt | 24 +- .../valkyrienskies-forge.mixins.json | 4 - gradle.properties | 16 +- 136 files changed, 940 insertions(+), 1006 deletions(-) rename common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/{MixinRandomizableContainerBlockEntity.java => MixinContainer.java} (69%) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/sodium/RenderSectionManagerDuck.java diff --git a/common/gradle.properties b/common/gradle.properties index 6d2b61dc9..5385872a4 100644 --- a/common/gradle.properties +++ b/common/gradle.properties @@ -1,9 +1,9 @@ #https://mvn.devos.one/#/snapshots/io/github/fabricators_of_create/Porting-Lib/Porting-Lib -port_lib_version=2.1.1096 -port_lib_modules = accessors,base,entity,extensions,fake_players,networking,obj_loader,tags,transfer +port_lib_version=2.1.1127+1.20 +port_lib_modules = accessors,base,entity,extensions,fake_players,networking,obj_loader,tags,transfer,models,tool_actions,client_events,brewing # https://modrinth.com/mod/cloth-config/version/8.3.103+fabric -cloth_config_version = 8.3.103 +cloth_config_version = 11.1.106 # https://modrinth.com/mod/sodium/versions -sodium_version = mc1.19.2-0.4.4 +sodium_version = mc1.20-0.4.10 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..0dc3f0db5 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 @@ -9,12 +9,14 @@ @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 index 27c9ce982..95db378c7 100644 --- 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 @@ -1,6 +1,6 @@ package org.valkyrienskies.mod.mixin.accessors.util.math; -import com.mojang.math.Matrix4f; +import org.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; 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..c4f83ba3d 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,6 +14,7 @@ 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.primitives.AABBi; @@ -26,8 +25,8 @@ 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; +import org.joml.Vector3f; @Mixin(Camera.class) public abstract class MixinCamera implements IVSCamera { @@ -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 index c87b5dde2..7fdca259f 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinGame.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinGame.java @@ -1,26 +1,26 @@ -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(); - } -} +//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/MixinMinecraft.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java index 8ce2565c8..424b4f52a 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java @@ -6,7 +6,6 @@ import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.multiplayer.ClientPacketListener; import net.minecraft.client.multiplayer.MultiPlayerGameMode; -import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.player.LocalPlayer; import net.minecraft.client.server.IntegratedServer; import net.minecraft.world.InteractionHand; @@ -130,6 +129,7 @@ public void setGamePause(final boolean pauseOnly, final CallbackInfo ci) { } } + /* TODO no longer needed @Inject( method = "setCurrentServer", at = @At("HEAD") @@ -138,6 +138,8 @@ public void preSetCurrentServer(final ServerData serverData, final CallbackInfo ValkyrienSkiesMod.getVsCore().setClientUsesUDP(false); } + */ + @Override public void createShipObjectWorldClient() { if (shipObjectWorld != null) { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java index 9c80967fb..d17c3aabd 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/multiplayer/MixinClientPacketListener.java @@ -71,7 +71,7 @@ private void teleportingWithNoStep(final Entity instance, final double x, final double y, final double z, final float yRot, final float xRot, final int lerpSteps, final boolean teleport, final Operation lerpTo) { - if (VSGameUtilsKt.getShipObjectManagingPos(instance.level, instance.getX(), instance.getY(), instance.getZ()) != + if (VSGameUtilsKt.getShipObjectManagingPos(instance.level(), instance.getX(), instance.getY(), instance.getZ()) != null) { instance.setPos(x, y, z); lerpTo.call(instance, x, y, z, yRot, xRot, 1, teleport); 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 04543da1a..52a4e6772 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; @@ -33,7 +33,6 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; 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; @@ -64,7 +63,7 @@ private static HitResult entityRaycastNoTransform( final Vec3 vec3d2 = entity.getViewVector(tickDelta); final Vec3 vec3d3 = vec3d.add(vec3d2.x * maxDistance, vec3d2.y * maxDistance, vec3d2.z * maxDistance); return RaycastUtilsKt.clipIncludeShips( - entity.level, + entity.level(), new ClipContext( vec3d, vec3d3, @@ -227,7 +226,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, @@ -273,16 +272,15 @@ private void setupCameraWithMountedShip(final LevelRenderer instance, final Pose ); // Apply the ship render transform to [matrixStack] - final Quaternion invShipRenderRotation = VectorConversionsMCKt.toMinecraft( - playerShipMountedTo.getRenderTransform().getShipToWorldRotation().conjugate(new Quaterniond())); - matrixStack.mulPose(invShipRenderRotation); + final Quaterniond invShipRenderRotation = + playerShipMountedTo.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 f82f1e084..59d5db09d 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 @@ -72,8 +72,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..845101b18 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 @@ -23,7 +23,7 @@ public abstract class SwimNodeEvaluatorMixin extends NodeEvaluator { @WrapOperation( at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/BlockGetter;getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"), - method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;IIIZZ)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" + method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" ) private FluidState getFluidStateRedirectPathType(final BlockGetter instance, final BlockPos blockPos, final Operation getFluidState) { @@ -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; @@ -58,7 +58,7 @@ private FluidState getFluidStateRedirectPathType(final BlockGetter instance, fin @WrapOperation( at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/BlockGetter;getBlockState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/state/BlockState;"), - method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;IIIZZ)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" + method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" ) private BlockState getBlockStateRedirectPathType(final BlockGetter instance, final BlockPos blockPos, final Operation getBlockState) { @@ -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; @@ -85,7 +85,7 @@ private BlockState getBlockStateRedirectPathType(final BlockGetter instance, fin @WrapOperation( at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;isPathfindable(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/pathfinder/PathComputationType;)Z"), - method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;IIIZZ)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" + method = "getBlockPathType(Lnet/minecraft/world/level/BlockGetter;IIILnet/minecraft/world/entity/Mob;)Lnet/minecraft/world/level/pathfinder/BlockPathTypes;" ) private boolean isPathFindableRedirectPathType(final BlockState instance, final BlockGetter blockGetter, final BlockPos blockPos, final PathComputationType pathComputationType, @@ -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 @@ -122,7 +122,7 @@ private boolean isPathFindableRedirectPathType(final BlockState instance, final @WrapOperation( at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/PathNavigationRegion;getFluidState(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/material/FluidState;"), - method = "getNode" + method = "findAcceptedNode" ) private FluidState getFluidStateRedirectGetNode(final PathNavigationRegion instance, final BlockPos blockPos, final Operation getFluidState) { @@ -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/bed_fix/MixinServerPlayer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/bed_fix/MixinServerPlayer.java index 25298a479..f4a97bb84 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/bed_fix/MixinServerPlayer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/bed_fix/MixinServerPlayer.java @@ -32,7 +32,7 @@ private void isReachableBedBlock(final BlockPos blockPos, final CallbackInfoRetu final double origY = vec3.y; final double origZ = vec3.z; - VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level, origX, origY, origZ, 1, (x, y, z) -> { + VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level(), origX, origY, origZ, 1, (x, y, z) -> { cir.setReturnValue(Math.abs(this.getX() - x) <= 3.0 && Math.abs(this.getY() - y) <= 2.0 && Math.abs(this.getZ() - z) <= 3.0); }); 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/container_distance_check/MixinRandomizableContainerBlockEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java similarity index 69% rename from common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinRandomizableContainerBlockEntity.java rename to common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java index c1c55313d..10628cfc2 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinRandomizableContainerBlockEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/container_distance_check/MixinContainer.java @@ -1,23 +1,23 @@ package org.valkyrienskies.mod.mixin.feature.container_distance_check; +import net.minecraft.world.Container; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; 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(RandomizableContainerBlockEntity.class) -public class MixinRandomizableContainerBlockEntity { +@Mixin(Container.class) +public interface MixinContainer { @Redirect( - method = "stillValid", + method = "stillValidBlockEntity(Lnet/minecraft/world/level/block/entity/BlockEntity;Lnet/minecraft/world/entity/player/Player;I)Z", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/entity/player/Player;distanceToSqr(DDD)D" ) ) - private double includeShipsInDistanceCheck( + private static double includeShipsInDistanceCheck( final Player receiver, final double x, final double y, final double z) { return VSGameUtilsKt.squaredDistanceToInclShips(receiver, x, y, z); } 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 f4142f122..89e61a69e 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 @@ -134,7 +134,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); @@ -145,7 +145,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..a7f724a90 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 @@ -51,12 +51,12 @@ private void onClimbableMixin(final CallbackInfoReturnable cir) { final EntityAccessor thisAsAccessor = (EntityAccessor) this; final BlockPos originalBlockPosition = thisAsAccessor.getBlockPosition(); - VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level, origX, origY, origZ, 1, (x, y, z) -> { + VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level(), origX, origY, origZ, 1, (x, y, z) -> { // 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/render_leashes/MixinMobRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_leashes/MixinMobRenderer.java index 06387edec..99cc8b1db 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_leashes/MixinMobRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_leashes/MixinMobRenderer.java @@ -23,7 +23,7 @@ public Vec3 getRopeHoldPosition(final Entity instance, final float partialTicks, final Vec3 origVec = getRopeHoldPosition.call(instance, partialTicks); final Vector3d vec = VectorConversionsMCKt.toJOML(origVec); - final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(instance.level, vec); + final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(instance.level(), vec); if (ship != null) { ship.getShipToWorld().transformPosition(vec); return VectorConversionsMCKt.toMinecraft(vec); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java index 8ac35350d..e065d72a6 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java @@ -47,9 +47,9 @@ public class MixinClientPacketListener implements SeamlessCopyClientPacketListen @Inject( at = @At("HEAD"), - method = "cleanup" + method = "close" ) - private void beforeCleanup(final CallbackInfo ci) { + private void beforeClose(final CallbackInfo ci) { chunks.cleanup(); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java index 474bda757..ea348cbbe 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntity.java @@ -26,7 +26,7 @@ public abstract class MixinEntity { @Shadow - public abstract Level getLevel(); + public abstract Level level(); @Shadow public abstract void setPosRaw(double d, double e, double f); @@ -62,7 +62,7 @@ private void positionRider(final Entity instance, final Entity passengerI, final */ @Inject(method = "setPosRaw", at = @At(value = "HEAD"), cancellable = true) private void handlePosSet(final double x, final double y, final double z, final CallbackInfo ci) { - final Level level = getLevel(); + final Level level = level(); //noinspection ConstantValue if (!Player.class.isInstance(this) || level == null || isModifyingSetPos || !VSGameUtilsKt.isBlockInShipyard(level, x, y, z)) { @@ -83,7 +83,7 @@ private void handlePosSet(final double x, final double y, final double z, final @Inject( at = @At("HEAD"), - method = "teleportTo", + method = "teleportTo(DDD)V", cancellable = true ) private void beforeTeleportTo(final double d, final double e, final double f, final CallbackInfo ci) { @@ -129,7 +129,7 @@ private Entity preventSavingVehiclePosAsOurPos(final Entity originalVehicle) { @Inject(method = "setRemoved", at = @At("HEAD")) private void preSetRemoved(final RemovalReason removalReason, final CallbackInfo ci) { final Entity thisAsEntity = Entity.class.cast(this); - final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(thisAsEntity.level, + final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(thisAsEntity.level(), VectorConversionsMCKt.toJOML(thisAsEntity.position())); if (ship != null) { VSEntityManager.INSTANCE.getHandler(thisAsEntity).entityRemovedFromShipyard(thisAsEntity, ship); 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 c04a1fe09..18d24607e 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 @@ -35,7 +35,7 @@ void render( final EntityRenderer entityRenderer) { final ClientShip ship = - (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level, entity.blockPosition()); + (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level(), entity.blockPosition()); if (ship != null) { // Remove the earlier applied translation matrixStack.popPose(); @@ -47,7 +47,7 @@ void render( buffer, packedLight); } else if (entity.isPassenger()) { final ClientShip vehicleShip = - (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level, + (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level(), entity.getVehicle().blockPosition()); // If the entity is a passenger and that vehicle is in ship space if (vehicleShip != null) { @@ -66,7 +66,7 @@ boolean shouldRender(final boolean returns, final Entity entity, final Frustum f if (!returns) { final ClientShip ship = - (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level, entity.blockPosition()); + (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level(), entity.blockPosition()); if (ship != null) { AABB aABB = entity.getBoundingBoxForCulling().inflate(0.5); if (aABB.hasNaN() || aABB.getSize() == 0.0) { 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..96f0bfedd 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;Lnet/minecraft/util/AbortableIterationConsumer;)Lnet/minecraft/util/AbortableIterationConsumer$Continuation;", at = @At("HEAD"), ordinal = 0, argsOnly = true) @@ -41,7 +41,7 @@ AABB modifyAABB1(final AABB aabb) { } @ModifyVariable( - method = "getEntities(Lnet/minecraft/world/level/entity/EntityTypeTest;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Consumer;)V", + method = "getEntities(Lnet/minecraft/world/level/entity/EntityTypeTest;Lnet/minecraft/world/phys/AABB;Lnet/minecraft/util/AbortableIterationConsumer;)Lnet/minecraft/util/AbortableIterationConsumer$Continuation;", at = @At("HEAD"), ordinal = 0, argsOnly = true) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySectionStorage.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySectionStorage.java index 4aa6a15df..16c025c04 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySectionStorage.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntitySectionStorage.java @@ -1,7 +1,7 @@ package org.valkyrienskies.mod.mixin.feature.shipyard_entities; -import java.util.function.Consumer; import net.minecraft.core.SectionPos; +import net.minecraft.util.AbortableIterationConsumer; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.level.entity.EntitySection; @@ -23,7 +23,7 @@ public abstract class MixinEntitySectionStorage implements OfLevel { @Shadow - public abstract void forEachAccessibleNonEmptySection(AABB aABB, Consumer> consumer); + public abstract void forEachAccessibleNonEmptySection(AABB aABB, AbortableIterationConsumer> abortableIterationConsumer); @Unique private Level level; @@ -49,7 +49,7 @@ void onSectionCreate(final long l, final CallbackInfoReturnable> consumer, + void shipSections(final AABB aABB, final AbortableIterationConsumer> abortableIterationConsumer, final CallbackInfo ci) { if (level != null && !loopingShips) { @@ -63,7 +63,7 @@ void shipSections(final AABB aABB, final Consumer> consume // java.lang.IllegalArgumentException: Start element (9223367638808264704) is larger than end element (-9223372036854775808) try { - this.forEachAccessibleNonEmptySection(transformedAABB, consumer); + this.forEachAccessibleNonEmptySection(transformedAABB, abortableIterationConsumer); } catch (final IllegalArgumentException ex) { ex.printStackTrace(); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinServerLevel.java index cbfe081fb..2a0c91f21 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinServerLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinServerLevel.java @@ -36,7 +36,7 @@ void configureEntitySections(final CallbackInfo ci) { ) ) void preAddEntity(final Entity entity, final CallbackInfoReturnable cir) { - final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(entity.level, VectorConversionsMCKt.toJOML(entity.position())); + final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(entity.level(), VectorConversionsMCKt.toJOML(entity.position())); if (ship != null) { VSEntityManager.INSTANCE.getHandler(entity).freshEntityInShipyard(entity, ship); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java index 5419aa484..1797b4e21 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSimpleSoundInstance.java @@ -5,6 +5,7 @@ import net.minecraft.client.resources.sounds.SoundInstance; import net.minecraft.sounds.SoundEvent; import net.minecraft.sounds.SoundSource; +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; @@ -21,14 +22,14 @@ public class MixinSimpleSoundInstance { method = "forRecord", cancellable = true ) - private static void forRecord(final SoundEvent sound, final double x, final double y, final double z, + private static void forRecord(final SoundEvent sound, final Vec3 pos, final CallbackInfoReturnable cir) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(Minecraft.getInstance().level, x, y, z); + final Ship ship = VSGameUtilsKt.getShipManagingPos(Minecraft.getInstance().level, pos.x(), pos.y(), pos.z()); if (ship != null) { cir.setReturnValue(new SimpleSoundInstanceOnShip( sound, SoundSource.RECORDS, 4.0F, 1.0F, SoundInstance.createUnseededRandom(), false, 0, - SoundInstance.Attenuation.LINEAR, x, y, z, ship)); + SoundInstance.Attenuation.LINEAR, pos.x(), pos.y(), pos.z(), ship)); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/tick_ship_chunks/MixinChunkMap.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/tick_ship_chunks/MixinChunkMap.java index 4c11213ee..199934aa2 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/tick_ship_chunks/MixinChunkMap.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/tick_ship_chunks/MixinChunkMap.java @@ -29,7 +29,7 @@ private static void preDistanceToSqr(final ChunkPos chunkPos, final Entity entit final double d = chunkPos.x * 16 + 8; final double e = chunkPos.z * 16 + 8; final double retValue = - VSGameUtilsKt.squaredDistanceBetweenInclShips(entity.level, entity.getX(), 0, entity.getZ(), d, + VSGameUtilsKt.squaredDistanceBetweenInclShips(entity.level(), entity.getX(), 0, entity.getZ(), d, 0, e); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/vs2_alpha_hud/MixinGui.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/vs2_alpha_hud/MixinGui.java index 961c41325..7e0a488f9 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/vs2_alpha_hud/MixinGui.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/vs2_alpha_hud/MixinGui.java @@ -1,14 +1,12 @@ package org.valkyrienskies.mod.mixin.feature.vs2_alpha_hud; -import static net.minecraft.client.gui.GuiComponent.fill; - import com.google.common.base.Strings; -import com.mojang.blaze3d.vertex.PoseStack; import java.util.ArrayList; import java.util.List; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Font; import net.minecraft.client.gui.Gui; +import net.minecraft.client.gui.GuiGraphics; import net.minecraft.client.server.IntegratedServer; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -31,13 +29,11 @@ public class MixinGui { * Render the "VS 2 Alpha" text */ @Inject(method = "renderEffects", at = @At("HEAD")) - private void preRenderStatusEffectOverlay(final PoseStack matrices, final CallbackInfo ci) { + private void preRenderStatusEffectOverlay(final GuiGraphics guiGraphics, final CallbackInfo ci) { if (!VSGameConfig.CLIENT.getRenderDebugText()) { return; } - matrices.pushPose(); - final Font fontRenderer = minecraft.font; final List debugText = new ArrayList<>(); debugText.add("VS 2 Beta Build"); @@ -71,11 +67,9 @@ private void preRenderStatusEffectOverlay(final PoseStack matrices, final Callba final int posX = 1; - fill(matrices, posX, posY - 1, 2 + textLength + posX, posY + textHeight - 1, -1873784752); - fontRenderer.draw(matrices, string, 2.0F, (float) posY, 14737632); + guiGraphics.fill(posX, posY - 1, 2 + textLength + posX, posY + textHeight - 1, -1873784752); + guiGraphics.drawString(fontRenderer, string, 2, posY, 14737632); } } - - matrices.popPose(); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/water_in_ships_entity/MixinEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/water_in_ships_entity/MixinEntity.java index ecc3f5b40..66c430601 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/water_in_ships_entity/MixinEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/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/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..4f903f876 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 @@ -1,13 +1,7 @@ package org.valkyrienskies.mod.mixin.feature.world_border; -import java.util.function.Supplier; -import net.minecraft.core.Holder; -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; import org.spongepowered.asm.mixin.Shadow; @@ -27,12 +21,7 @@ public class MixinLevel { at = @At("RETURN"), 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) { - + private void setWorldBorderLevel(final CallbackInfo ci) { ((OfLevel) this.worldBorder).setLevel(Level.class.cast(this)); } 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 index bd6125806..4563a841b 100644 --- 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 @@ -16,7 +16,7 @@ private boolean wrapOp(Level level, Entity entity) { // 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())); + final BlockPos anchor = BlockPos.containing((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); 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 index 2b8910713..b22f08206 100644 --- 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 @@ -46,7 +46,7 @@ static Vec3 collide(Vec3 p_20273_, Entity e) { @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()))) { + if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), instance.blockPosition()) && VSGameUtilsKt.isBlockInShipyard(contraptionEnt.getCommandSenderWorld(), BlockPos.containing(contraptionEnt.getAnchorVec()))) { Ship ship = VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), contraptionEnt.getAnchorVec()); if (ship != null) { AABBd temp = new AABBd(); @@ -60,7 +60,7 @@ private static AABB entityGetBoundingBox(AbstractContraptionEntity abstractContr @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()))) { + if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), instance.blockPosition()) && VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), BlockPos.containing(abstractContraptionEntity.getAnchorVec()))) { Ship ship = VSGameUtilsKt.getShipManagingPos(abstractContraptionEntity.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor); if (ship != null) { Vector3d translatedPos = ship.getTransform().getWorldToShip().transformPosition(toJOML(tempVec)); @@ -77,7 +77,7 @@ private static Vec3 getSetEntityDeltaMovement(AbstractContraptionEntity abstract Ship ship = VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor); if (ship != null) { if (motion != null) { - if (!VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), new BlockPos(abstractContraptionEntity.getAnchorVec()))) { + if (!VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), BlockPos.containing(abstractContraptionEntity.getAnchorVec()))) { motion = toMinecraft(ship.getWorldToShip().transformDirection(toJOML(motion))); } else { motion = toMinecraft(ship.getShipToWorld().transformDirection(toJOML(motion))); @@ -108,7 +108,7 @@ private static void warn2(double x, double y, double 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)) && + if (VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), BlockPos.containing(x, y, z)) && !VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), instance.blockPosition())) { Ship ship = VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor); if (ship != null) { @@ -222,8 +222,8 @@ private static Vec3 redirectGetPrevPositionVec(AbstractContraptionEntity instanc 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 (VSGameUtilsKt.isBlockInShipyard(instance.level(), BlockPos.containing(instance.getAnchorVec())) && !VSGameUtilsKt.isBlockInShipyard(instance.level(), BlockPos.containing(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; @@ -234,7 +234,7 @@ private static Vec3 redirectGetPrevPositionVec(AbstractContraptionEntity instanc } - if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), new BlockPos(prevPos)) && VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), new BlockPos(instance.position()))) { + if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), BlockPos.containing(prevPos)) && VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), BlockPos.containing(instance.position()))) { //instance.setOldPosAndRot(); //prevPos = instance.position(); /* @@ -295,7 +295,7 @@ private static Vec3 redirectEntityPosition2(Entity instance) { @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))) { + && !VSGameUtilsKt.isBlockInShipyard(contraptionEntity.getCommandSenderWorld(), BlockPos.containing(entity))) { Ship ship = VSGameUtilsKt.getShipManagingPos(contraptionEntity.getCommandSenderWorld(), contraptionEntity.getContraption().anchor); if (ship != null) { 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 index 8d311cd22..fea23a23b 100644 --- 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 @@ -40,7 +40,7 @@ private void redirectSetDeltaMovement(Entity instance, double x, double y, doubl @Unique private Vec3 outMotion(Entity entity, Vec3 motion) { - Ship ship = VSGameUtilsKt.getShipManagingPos(entity.level, entity.getOnPos()); + Ship ship = VSGameUtilsKt.getShipManagingPos(entity.level(), entity.getOnPos()); if (ship != null) { Vector3d tempVec = VectorConversionsMCKt.toJOML(motion); ship.getTransform().getShipToWorld().transformDirection(tempVec); 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 index 927e5241e..3832885cd 100644 --- 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 @@ -17,11 +17,11 @@ public abstract class MixinSharedDepotBlockMethods { )) private static BlockPos redirectBlockPosition(Entity instance) { BlockPos result = instance.blockPosition(); - Ship ship = VSGameUtilsKt.getShipObjectManagingPos(instance.level, instance.getOnPos()); + 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)); + result = BlockPos.containing(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/block/MixinEjectorBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinEjectorBlock.java index 4759a6b94..f7af92f2a 100644 --- 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 @@ -26,8 +26,8 @@ private BlockPos redirectBlockPosition(Entity instance) { )) 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 (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); @@ -41,7 +41,7 @@ private Vec3 redirectEntityPosition(Entity instance) { 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()); + Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level(), instance.getOnPos()); if (ship != null) { Vector3d tempVec = new Vector3d(); ship.getTransform().getShipToWorld().transformPosition(x, y, z, tempVec); 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 index f87322cca..d87b25a06 100644 --- 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 @@ -74,7 +74,7 @@ private void injectTick(BlockState state, ServerLevel worldIn, BlockPos pos, Ran @Unique private static boolean hasContact(Level world, Ship ship, Vector3d searchPos, Direction direction, Ship shipItr) { - BlockState blockState = world.getBlockState(new BlockPos(VectorConversionsMCKt.toMinecraft(searchPos))); + BlockState blockState = world.getBlockState(BlockPos.containing(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())); @@ -123,8 +123,8 @@ private static void injectHasValidContact(LevelAccessor world, BlockPos pos, Dir } 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); + contactCache.put(Pair.of(worldLevel, pos), BlockPos.containing(VectorConversionsMCKt.toMinecraft(searchPos))); + world.scheduleTick(BlockPos.containing(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/blockentity/MixinCrushingWheelControllerTileEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinCrushingWheelControllerTileEntity.java index a8c8f864d..6bbbe1c1a 100644 --- 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 @@ -92,7 +92,7 @@ private double redirectEntityGetZ(Entity instance) { private Vec3 getTransformedPosition(Entity instance) { Vec3 result = instance.position(); - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, ((CrushingWheelControllerBlockEntity) (Object) this).getBlockPos()); + 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); @@ -103,7 +103,7 @@ private Vec3 getTransformedPosition(Entity instance) { private Vec3 directionShip2World(Entity instance, Vec3 direction) { Vec3 result = direction; - Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, ((CrushingWheelControllerBlockEntity) (Object) this).getBlockPos()); + 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); 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 index d1ff39aa5..1504ce54e 100644 --- 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 @@ -56,7 +56,7 @@ private List redirectGetEntitiesOfClass(Level instance, Class aC 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()); + 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); 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 index 3e7c98b72..e0ef100a8 100644 --- 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 @@ -2,8 +2,6 @@ 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; @@ -14,6 +12,8 @@ import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; import org.joml.Vector3dc; +import org.joml.Vector3f; +import org.joml.Vector4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -58,7 +58,7 @@ private void preRenderBox(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camer 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.mulPose(VectorConversionsMCKt.toFloat(renderTransform.getShipToWorldRotation())); renderBoxFaces(ms, buffer, cull, params.getHighlightedFace(), minPos, maxPos, color, lightmap); float lineWidth = params.getLineWidth(); 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 index 78b2c7014..f47164dcb 100644 --- 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 @@ -2,8 +2,6 @@ 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; @@ -17,6 +15,8 @@ import net.minecraft.core.Direction; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; +import org.joml.Vector3f; +import org.joml.Vector4f; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -76,7 +76,7 @@ private void preRenderFaces(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 cam 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.mulPose(VectorConversionsMCKt.toFloat(renderTransform.getShipToWorldRotation())); ms.translate( cw$cluster.anchor.getX() - renderTransform.getPositionInShip().x(), cw$cluster.anchor.getY() - renderTransform.getPositionInShip().y(), @@ -124,7 +124,7 @@ private void preRenderEdges(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 cam 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.mulPose(VectorConversionsMCKt.toFloat(renderTransform.getShipToWorldRotation())); ms.translate( cw$cluster.anchor.getX() - renderTransform.getPositionInShip().x(), cw$cluster.anchor.getY() - renderTransform.getPositionInShip().y(), 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 index 68db4f5c9..ce5aa7f14 100644 --- 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 @@ -4,9 +4,9 @@ import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; import com.jozufozu.flywheel.util.AnimationTickHolder; import com.jozufozu.flywheel.util.transform.TransformStack; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; 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; @@ -14,10 +14,11 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import org.joml.Matrix4d; +import org.joml.Matrix4f; import org.joml.Vector3d; +import org.joml.Vector3f; 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; @@ -30,11 +31,11 @@ public MixinCarriageContraptionInstance(MaterialManager materialManager, Entity super(materialManager, entity); } - @Redirect( + @WrapOperation(remap = false, method = "beginFrame", at = @At(value = "INVOKE", - target = "Lcom/jozufozu/flywheel/util/transform/TransformStack;translate(Lcom/mojang/math/Vector3f;)Ljava/lang/Object;") + target = "Lcom/jozufozu/flywheel/util/transform/TransformStack;translate(Lorg/joml/Vector3f;)Ljava/lang/Object;") ) - private Object redirectTranslate(final TransformStack instance, final Vector3f vector3f) { + private Object redirectTranslate(final TransformStack instance, final Vector3f vector3f, Operation operation) { final float partialTicks = AnimationTickHolder.getPartialTicks(); final Level level = this.world; @@ -56,10 +57,11 @@ private Object redirectTranslate(final TransformStack instance, final Vector3f v .translate(origin.mul(-1)) .mul(transform.getShipToWorld()) .translate(newPosition); - Matrix4f mat4f = VectorConversionsMCKt.toMinecraft(renderMatrix); - ((PoseStack) instance).last().pose().multiply(mat4f); + Matrix4f mat4f = new Matrix4f(renderMatrix); + ((PoseStack) instance).last().pose().mul(mat4f); } else { - instance.translate(vector3f); + operation.call(instance, vector3f); + //instance.translate(vector3f); } return null; } 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 index 630dc7075..e2b878848 100644 --- 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 @@ -6,11 +6,11 @@ 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.Matrix4f; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -49,8 +49,8 @@ private Object redirectTranslate(TransformStack instance, double x, double y, do .translate(origin.mul(-1)) .mul(transform.getShipToWorld()) .translate(newPosition); - Matrix4f mat4f = VectorConversionsMCKt.toMinecraft(renderMatrix); - ((PoseStack) instance).last().pose().multiply(mat4f); + Matrix4f mat4f = new Matrix4f(renderMatrix); + ((PoseStack) instance).last().pose().mul(mat4f); } else { instance.translate(x, y, z); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOrientedContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOrientedContraptionEntity.java index 8dae3ebf8..6b3a0ad4c 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOrientedContraptionEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOrientedContraptionEntity.java @@ -35,7 +35,7 @@ private void redirectRepositionOnCart(OrientedContraptionEntity instance, PoseSt if (ship != null) { Quaterniond quaternion = new Quaterniond(); ship.getRenderTransform().getShipToWorld().getNormalizedRotation(quaternion); - TransformStack.cast(matrixStack).rotateCentered(VectorConversionsMCKt.toMinecraft(quaternion)); + TransformStack.cast(matrixStack).rotateCentered(VectorConversionsMCKt.toFloat(quaternion)); } } @@ -47,7 +47,7 @@ private void redirectTranslate(final PoseStack instance, final double pose, fina if (ship != null) { Quaterniond quaternion = new Quaterniond(); ship.getRenderTransform().getShipToWorld().getNormalizedRotation(quaternion); - TransformStack.cast(instance).rotateCentered(VectorConversionsMCKt.toMinecraft(quaternion)); + TransformStack.cast(instance).rotateCentered(VectorConversionsMCKt.toFloat(quaternion)); } } 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 index 7c2f112b2..760a4dd13 100644 --- 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 @@ -2,16 +2,17 @@ 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.Matrix4d; import org.joml.Matrix4dc; import org.joml.Vector3d; import org.joml.Vector3dc; +import org.joml.Vector3f; +import org.joml.Vector4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; @@ -20,18 +21,17 @@ 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); + public abstract void bufferCuboidLine(PoseStack poseStack, VertexConsumer consumer, Vec3 camera, Vector3d start, 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) { + @Inject(method = "bufferCuboidLine(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/phys/Vec3;Lorg/joml/Vector3d;Lorg/joml/Vector3d;FLorg/joml/Vector4f;IZ)V", at = @At("HEAD"), cancellable = true) + private void preBufferCuboidLine0(PoseStack poseStack, VertexConsumer consumer, Vec3 camera, Vector3d start, 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); @@ -41,7 +41,7 @@ private void preBufferCuboidLine0(PoseStack poseStack, VertexConsumer consumer, 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); + bufferCuboidLine(poseStack, consumer, camera, new Vector3d(startTransformed.x(), startTransformed.y(), startTransformed.z()), new Vector3d(endTransformed.x(), endTransformed.y(), endTransformed.z()), scaledWidth, color, lightmap, disableNormals); ci.cancel(); } } @@ -65,7 +65,7 @@ private void preBufferCuboid(PoseStack.Pose pose, VertexConsumer consumer, Vecto float maxY = maxPos.y(); float maxZ = maxPos.z(); - final Matrix4dc newPosMatrix = VectorConversionsMCKt.toJOML(pose.pose()).mul(transform.getShipToWorld()); + final Matrix4dc newPosMatrix = new Matrix4d(pose.pose()).mul(transform.getShipToWorld());// VectorConversionsMCKt.toJOML(pose.pose()).mul(transform.getShipToWorld()); temp.set(minX, minY, maxZ); newPosMatrix.transformPosition(temp); @@ -386,7 +386,7 @@ private void preBufferCuboid(PoseStack.Pose pose, VertexConsumer consumer, Vecto } } - @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) + @Inject(method = "bufferQuad(Lcom/mojang/blaze3d/vertex/PoseStack$Pose;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lorg/joml/Vector3f;Lorg/joml/Vector3f;Lorg/joml/Vector3f;Lorg/joml/Vector3f;Lorg/joml/Vector4f;FFFFILorg/joml/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) { 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 index b0aa8caad..6a0433474 100644 --- 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 @@ -20,7 +20,7 @@ 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; + Level world = Minecraft.getInstance().player.level(); final Ship ship = VSGameUtilsKt.getShipManagingPos(world, newVec3); if (ship != null) { newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, newVec3); @@ -31,12 +31,12 @@ private static boolean redirectCloserThan(BlockPos instance, Vec3i vec3i, double @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; + 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); + result = BlockPos.containing(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 index 5b15a5eef..1486cf9c7 100644 --- 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 @@ -12,7 +12,7 @@ @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", + method = "renderBlockEntities(Lnet/minecraft/world/level/Level;Lcom/jozufozu/flywheel/core/virtual/VirtualRenderWorld;Ljava/lang/Iterable;Lcom/mojang/blaze3d/vertex/PoseStack;Lorg/joml/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;" diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java index 69d74d550..57496850d 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java @@ -56,7 +56,7 @@ private static Vec3 redirectedOrigin(final LocalPlayer instance, final float v) final Vec3 eyePos = instance.getEyePosition(v); if (isShip) { final List - ships = VSGameUtilsKt.transformToNearbyShipsAndWorld(instance.level, eyePos.x, eyePos.y, eyePos.z, 10); + ships = VSGameUtilsKt.transformToNearbyShipsAndWorld(instance.level(), eyePos.x, eyePos.y, eyePos.z, 10); if (ships.isEmpty()) { return eyePos; } 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 index c59d5bf4f..5503b227b 100644 --- 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 @@ -17,7 +17,7 @@ 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; + Level world = Minecraft.getInstance().player.level(); final Ship ship = VSGameUtilsKt.getShipManagingPos(world, arg); if (ship != null) { newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, (Vec3) arg); 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 index ea077730b..3cf9b394f 100644 --- 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 @@ -106,14 +106,14 @@ private void redirectTeleportTo(Entity instance, double x, double y, double z) { //Region end //Region start - fix entity rider position on ship contraptions @Override - public void positionRider(@NotNull Entity passenger) { + public void positionRider(@NotNull Entity passenger, MoveFunction callback) { if (!hasPassenger(passenger)) return; Vec3 riderPos = getPassengerPosition(passenger, 1); if (riderPos == null) return; if (!(passenger instanceof OrientedContraptionEntity)) { - Ship ship = VSGameUtilsKt.getShipManagingPos(passenger.level, riderPos.x, riderPos.y, riderPos.z); + Ship ship = VSGameUtilsKt.getShipManagingPos(passenger.level(), riderPos.x, riderPos.y, riderPos.z); riderPos.add(0, SeatEntity.getCustomEntitySeatOffset(passenger) - 1 / 8f, 0); if (ship != null) { riderPos = toMinecraft(ship.getShipToWorld().transformPosition(toJOML(riderPos))); @@ -162,7 +162,7 @@ private void redirectToGlobalVector(Vec3 localVec, final float partialTicks, fin 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 BlockPos.containing(actorPosInWorld.x(), actorPosInWorld.y(), actorPosInWorld.z()); } } return pos; @@ -196,22 +196,22 @@ private void preTickActors(final CallbackInfo ci) { final boolean stalledPreviously = contraption.stalled; - if (!level.isClientSide) + 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); + final MovementBehaviour actor = AllMovementBehaviours.getBehaviour(blockInfo.state()); if (actor == null) continue; final Vec3 oldMotion = context.motion; - final Vec3 actorPosition = toGlobalVector(VecHelper.getCenterOf(blockInfo.pos) + 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 BlockPos gridPosition = vs$getTargetPos(actor, context, BlockPos.containing(actorPosition), actorPosition); // BlockPos.containing(actorPosition); final boolean newPosVisited = !context.stall && shouldActorTrigger(context, blockInfo, actor, actorPosition, gridPosition); @@ -236,7 +236,7 @@ private void preTickActors(final CallbackInfo ci) { contraption.stalled |= context.stall; } if (!isAlive()) { - contraption.stop(level); + contraption.stop(level()); return; } skipActorStop = false; @@ -252,7 +252,7 @@ private void preTickActors(final CallbackInfo ci) { } } - if (!level.isClientSide) { + if (!level().isClientSide) { if (!stalledPreviously && contraption.stalled) onContraptionStalled(); entityData.set(STALLED, contraption.stalled); @@ -271,8 +271,8 @@ private void preTickActors(final CallbackInfo ci) { //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 (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; @@ -296,7 +296,7 @@ public void setWingGroupId(final int 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; + final Level level = thisAsAbstractContraptionEntity.level(); if (wingGroupId != -1 && level instanceof final ServerLevel serverLevel) { final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(serverLevel, VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); 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 index c2031e472..aeb7c87af 100644 --- 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 @@ -30,7 +30,7 @@ public abstract class MixinCarriageContraptionEntity { private void injectCaptureLevel( final BlockPos controlsLocalPos, final Collection heldControls, final Player player, final CallbackInfoReturnable cir) { - this.vs$world = player.level; + this.vs$world = player.level(); } @WrapOperation( @@ -42,7 +42,7 @@ private void injectCaptureLevel( ) 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))) { + if (VSGameUtilsKt.isBlockInShipyard(this.vs$world, BlockPos.containing(instance.x, instance.y, instance.z))) { final Ship ship = VSGameUtilsKt.getShipManagingPos(this.vs$world, instance); newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, instance); } 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 index ca277740c..c2e345670 100644 --- 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 @@ -26,15 +26,15 @@ public MixinSeatEntity(EntityType entityType, Level level) { } @Override - public void positionRider(@NotNull Entity passenger) { + public void positionRider(@NotNull Entity passenger, MoveFunction moveFunction) { if (!this.hasPassenger(passenger)) return; double d0 = this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(); Vec3 riderPos = new Vec3(this.getX(), d0 + getCustomEntitySeatOffset(passenger), this.getZ()); - Ship ship = VSGameUtilsKt.getShipManagingPos(passenger.level, riderPos.x, riderPos.y, riderPos.z); - if (VSGameUtilsKt.isBlockInShipyard(passenger.level, riderPos.x, riderPos.y, riderPos.z) && ship != null) { + Ship ship = VSGameUtilsKt.getShipManagingPos(passenger.level(), riderPos.x, riderPos.y, riderPos.z); + if (VSGameUtilsKt.isBlockInShipyard(passenger.level(), riderPos.x, riderPos.y, riderPos.z) && ship != null) { Vector3d tempVec = VectorConversionsMCKt.toJOML(riderPos); ship.getShipToWorld().transformPosition(tempVec, tempVec); riderPos = VectorConversionsMCKt.toMinecraft(tempVec); 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 index fcebd0771..e2c886363 100644 --- 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 @@ -27,7 +27,7 @@ public abstract class MixinControlsInputPacket { ) 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))) { + if (VSGameUtilsKt.isBlockInShipyard(this.level, BlockPos.containing(instance.x, instance.y, instance.z))) { final Ship ship = VSGameUtilsKt.getShipManagingPos(this.level, instance); newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, instance); } 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 index 24763945c..46540454d 100644 --- 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 @@ -34,7 +34,7 @@ private boolean redirectCloserThan(final BlockPos instance, final Vec3i vec3i, f 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); + blockPos = BlockPos.containing(tempVec.x, tempVec.y, tempVec.z); } return blockPos.closerThan(vec3i, v); } @@ -44,6 +44,6 @@ private boolean redirectCloserThan(final BlockPos instance, final Vec3i vec3i, f at = @At("HEAD"), locals = LocalCapture.CAPTURE_FAILHARD ) private void injectCaptureLevel(final ServerPlayer player, final TrackBlockEntity te, final CallbackInfo ci) { - this.world = player.level; + 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 index 3b034986d..51201bd99 100644 --- 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 @@ -17,8 +17,8 @@ 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 (VSGameUtilsKt.isBlockInShipyard(instance.level(), BlockPos.containing(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))); } 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 index d1eea4999..c60ce8636 100644 --- 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 @@ -29,7 +29,7 @@ private boolean redirectCloserThan(final BlockPos instance, final Vec3i vec3i, f 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); + blockPos = BlockPos.containing(tempVec.x, tempVec.y, tempVec.z); } return blockPos.closerThan(vec3i, v); } 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 index cd97ecbcc..bc569f5ee 100644 --- 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 @@ -37,7 +37,7 @@ protected void vsProcesssRiderPositionHook( if (original != null && controllerPos != null) { final Vector3d editOriginal = VectorConversionsMCKt.toJOML(original); - final Ship ship = VSGameUtilsKt.getShipObjectManagingPos(level, controllerPos); + final Ship ship = VSGameUtilsKt.getShipObjectManagingPos(level(), controllerPos); if (ship != null) { ship.getShipToWorld().transformPosition(editOriginal); 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 index 86ad788fa..6b06bb20f 100644 --- 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 @@ -57,7 +57,7 @@ void preCreateRaw(final BlockEntity blockEntity, final CallbackInfoReturnable vs$createMaterialManager()); final Vector3i c = ship.getChunkClaim().getCenterBlockCoordinates(VSGameUtilsKt.getYRange(nullableLevel), new Vector3i()); - ((InstancingEngineAccessor) manager).setOriginCoordinate(new BlockPos(c.x, c.y, c.z)); + ((InstancingEngineAccessor) manager).setOriginCoordinate(BlockPos.containing(c.x, c.y, c.z)); cir.setReturnValue(InstancedRenderRegistry.createInstance(manager, blockEntity)); } 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 index 1418ee7ce..8f1e8eb66 100644 --- 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 @@ -31,7 +31,7 @@ private BlockPos redirectGetWorldPos1(final DynamicInstance receiver) { VectorConversionsMCKt.toJOMLD(receiver.getWorldPosition()) ); - return new BlockPos(v.x, v.y, v.z); + return BlockPos.containing(v.x, v.y, v.z); } @Redirect( @@ -46,7 +46,7 @@ private BlockPos redirectGetWorldPos2(final TickableInstance receiver) { receiver.getWorldPosition(), VectorConversionsMCKt.toJOMLD(receiver.getWorldPosition())); - return new BlockPos(v.x, v.y, v.z); + return BlockPos.containing(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 index a66ba50c8..8631440b1 100644 --- 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 @@ -8,9 +8,9 @@ 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.Matrix4f; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -61,7 +61,7 @@ void renderShipTiles(final RenderLayerEvent event, final CallbackInfo ci) { if (manager instanceof final InstancingEngine engine) { final Vector3d origin = VectorConversionsMCKt.toJOMLD(engine.getOriginCoordinate()); - final Matrix4d viewProjection = VectorConversionsMCKt.toJOML(event.viewProjection); + final Matrix4d viewProjection = new Matrix4d(event.viewProjection); final Matrix4d finalProjection = new Matrix4d() .mul(viewProjection) @@ -73,7 +73,7 @@ void renderShipTiles(final RenderLayerEvent event, final CallbackInfo ci) { .transformPosition(event.camX, event.camY, event.camZ, new Vector3d()) .sub(origin); - final Matrix4f fnlProj = VectorConversionsMCKt.toMinecraft(finalProjection); + final Matrix4f fnlProj = new Matrix4f(finalProjection); ((MixinInstancingEngineDuck) engine).vs$render( fnlProj, 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 index cb843a8fd..fdc0f2f6b 100644 --- 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 @@ -4,9 +4,9 @@ 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.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.Shadow; 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..0d7c18cfc 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 @@ -40,7 +40,7 @@ public abstract class MixinClaimedChunkManager { return pos; } - final Level level = entity.level; + final Level level = entity.level(); final Ship ship = VSGameUtilsKt.getShipManagingPos(level, pos); if (ship == null) { @@ -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/MixinLevelRendererOptifine.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/optifine/MixinLevelRendererOptifine.java index 0590494e2..1e1543233 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/optifine/MixinLevelRendererOptifine.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/optifine/MixinLevelRendererOptifine.java @@ -115,7 +115,7 @@ // final VboRegion vboRegion, final CallbackInfo ci // ) { // final ClientShip shipObject = -// VSGameUtilsKt.getShipObjectManagingPos(level, new BlockPos(regionX, regionY, regionZ)); +// VSGameUtilsKt.getShipObjectManagingPos(level, BlockPos.containing(regionX, regionY, regionZ)); // if (shipObject != null) { // final Matrix4d chunkTransformMatrix = new Matrix4d() // .translate(-xIn, -yIn, -zIn) @@ -165,7 +165,7 @@ // private void addShipVisibleChunksForBlockEntitiesAndEntities( // final Camera camera, final Frustum frustum, final boolean hasForcedFrustum, final int frame, // final boolean spectator, final CallbackInfo ci) { -// final BlockPos.MutableBlockPos tempPos = new BlockPos.MutableBlockPos(); +// final BlockPos.MutableBlockPos tempPos = BlockPos.containing.MutableBlockPos(); // final ViewAreaAccessor chunkStorageAccessor = (ViewAreaAccessor) viewArea; // for (final ClientShip shipObject : VSGameUtilsKt.getShipObjectWorld(level).getLoadedShips()) { // // Don't bother rendering the ship if its AABB isn't visible to the frustum 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..b2b130a69 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 @@ -1,150 +1,152 @@ -package org.valkyrienskies.mod.mixin.mod_compat.optifine; -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry; -import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; -import java.util.Map; -import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.client.renderer.ViewArea; -import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher; -import net.minecraft.core.BlockPos; -import net.minecraft.util.Mth; -import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.Level; -import net.optifine.Config; -import net.optifine.render.VboRegion; -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.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.mixinducks.client.render.IVSViewAreaMethods; +//package org.valkyrienskies.mod.mixin.mod_compat.optifine; +// +//import it.unimi.dsi.fastutil.longs.Long2ObjectMap; +//import it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry; +//import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +//import java.util.Map; +//import net.minecraft.client.renderer.LevelRenderer; +//import net.minecraft.client.renderer.ViewArea; +//import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher; +//import net.minecraft.core.BlockPos; +//import net.minecraft.util.Mth; +//import net.minecraft.world.level.ChunkPos; +//import net.minecraft.world.level.Level; +//import net.optifine.Config; +//import net.optifine.render.VboRegion; +//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.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//import org.valkyrienskies.mod.common.VSGameUtilsKt; +//import org.valkyrienskies.mod.mixinducks.client.render.IVSViewAreaMethods; +// +///** +// * The purpose of this mixin is to allow {@link ViewArea} to render ship chunks. +// */ +//@Mixin(ViewArea.class) +//public abstract class MixinViewAreaOptifine implements IVSViewAreaMethods { +// +// // Maps chunk position to an array of BuiltChunk, indexed by the y value. +// private final Long2ObjectMap vs$shipRenderChunks = +// new Long2ObjectOpenHashMap<>(); +// @Shadow +// @Final +// protected Level level; +// @Shadow +// protected int chunkGridSizeY; +// // This creates render chunks +// private ChunkRenderDispatcher vs$chunkBuilder; +// +// /** +// * This mixin stores the [chunkBuilder] object from the constructor. It is used to create new render chunks. +// */ +// @Inject(method = "", at = @At("TAIL")) +// private void postInit(final ChunkRenderDispatcher chunkBuilder, final Level world, final int viewDistance, +// final LevelRenderer worldRenderer, final CallbackInfo callbackInfo) { +// +// this.vs$chunkBuilder = chunkBuilder; +// } +// +// @Shadow(remap = false) +// protected abstract void updateVboRegion(ChunkRenderDispatcher.RenderChunk renderChunk); +// +// /** +// * This mixin creates render chunks for ship chunks. +// */ +// @Inject(method = "setDirty", at = @At("HEAD"), cancellable = true) +// private void preScheduleRebuild(final int x, final int y, final int z, final boolean important, +// final CallbackInfo callbackInfo) { +// +// if (y < 0 || y >= chunkGridSizeY) { +// return; // Weird, but just ignore it +// } +// if (VSGameUtilsKt.isChunkInShipyard(level, x, z)) { +// final long chunkPosAsLong = ChunkPos.asLong(x, z); +// final ChunkRenderDispatcher.RenderChunk[] renderChunksArray = +// vs$shipRenderChunks.computeIfAbsent(chunkPosAsLong, +// k -> new ChunkRenderDispatcher.RenderChunk[chunkGridSizeY]); +// +// if (renderChunksArray[y] == null) { +// final ChunkRenderDispatcher.RenderChunk builtChunk = +// vs$chunkBuilder.new RenderChunk(0, x << 4, y << 4, z << 4); +// renderChunksArray[y] = builtChunk; +// if (Config.isVbo() && Config.isRenderRegions()) { +// updateVboRegion(renderChunksArray[y]); +// } +// } +// +// renderChunksArray[y].setDirty(important); +// callbackInfo.cancel(); +// } +// } +// +// /** +// * This mixin allows {@link ViewArea} to return the render chunks for ships. +// */ +// @Inject(method = "getRenderChunkAt", at = @At("HEAD"), cancellable = true) +// private void preGetRenderedChunk(final BlockPos pos, +// final CallbackInfoReturnable callbackInfoReturnable) { +// 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 +// } +// +// if (VSGameUtilsKt.isChunkInShipyard(level, chunkX, chunkZ)) { +// final long chunkPosAsLong = ChunkPos.asLong(chunkX, chunkZ); +// final ChunkRenderDispatcher.RenderChunk[] renderChunksArray = vs$shipRenderChunks.get(chunkPosAsLong); +// if (renderChunksArray == null) { +// callbackInfoReturnable.setReturnValue(null); +// return; +// } +// final ChunkRenderDispatcher.RenderChunk renderChunk = renderChunksArray[chunkY]; +// callbackInfoReturnable.setReturnValue(renderChunk); +// } +// } +// +// @Shadow(remap = false) +// private Map mapVboRegions; +// +// @Override +// public void unloadChunk(final int chunkX, final int chunkZ) { +// if (VSGameUtilsKt.isChunkInShipyard(level, chunkX, chunkZ)) { +// final ChunkRenderDispatcher.RenderChunk[] chunks = +// vs$shipRenderChunks.remove(ChunkPos.asLong(chunkX, chunkZ)); +// if (chunks != null) { +// for (final ChunkRenderDispatcher.RenderChunk chunk : chunks) { +// chunk.releaseBuffers(); +// } +// } +// final VboRegion[] vboRegions = mapVboRegions.remove(new ChunkPos(chunkX, chunkZ)); +// if (vboRegions != null) { +// for (final VboRegion vboRegion : vboRegions) { +// if (vboRegion != null) { +// vboRegion.deleteGlBuffers(); +// } +// } +// } +// } +// } +// +// /** +// * Clear VS ship render chunks so that we don't leak memory +// */ +// @Inject(method = "releaseAllBuffers", at = @At("HEAD")) +// private void postReleaseAllBuffers(final CallbackInfo ci) { +// for (final Entry entry : vs$shipRenderChunks.long2ObjectEntrySet()) { +// for (final ChunkRenderDispatcher.RenderChunk renderChunk : entry.getValue()) { +// if (renderChunk != null) { +// renderChunk.releaseBuffers(); +// } +// } +// } +// vs$shipRenderChunks.clear(); +// } +//} -/** - * The purpose of this mixin is to allow {@link ViewArea} to render ship chunks. - */ -@Mixin(ViewArea.class) -public abstract class MixinViewAreaOptifine implements IVSViewAreaMethods { - - // Maps chunk position to an array of BuiltChunk, indexed by the y value. - private final Long2ObjectMap vs$shipRenderChunks = - new Long2ObjectOpenHashMap<>(); - @Shadow - @Final - protected Level level; - @Shadow - protected int chunkGridSizeY; - // This creates render chunks - private ChunkRenderDispatcher vs$chunkBuilder; - - /** - * This mixin stores the [chunkBuilder] object from the constructor. It is used to create new render chunks. - */ - @Inject(method = "", at = @At("TAIL")) - private void postInit(final ChunkRenderDispatcher chunkBuilder, final Level world, final int viewDistance, - final LevelRenderer worldRenderer, final CallbackInfo callbackInfo) { - - this.vs$chunkBuilder = chunkBuilder; - } - - @Shadow(remap = false) - protected abstract void updateVboRegion(ChunkRenderDispatcher.RenderChunk renderChunk); - - /** - * This mixin creates render chunks for ship chunks. - */ - @Inject(method = "setDirty", at = @At("HEAD"), cancellable = true) - private void preScheduleRebuild(final int x, final int y, final int z, final boolean important, - final CallbackInfo callbackInfo) { - - if (y < 0 || y >= chunkGridSizeY) { - return; // Weird, but just ignore it - } - if (VSGameUtilsKt.isChunkInShipyard(level, x, z)) { - final long chunkPosAsLong = ChunkPos.asLong(x, z); - final ChunkRenderDispatcher.RenderChunk[] renderChunksArray = - vs$shipRenderChunks.computeIfAbsent(chunkPosAsLong, - k -> new ChunkRenderDispatcher.RenderChunk[chunkGridSizeY]); - - if (renderChunksArray[y] == null) { - final ChunkRenderDispatcher.RenderChunk builtChunk = - vs$chunkBuilder.new RenderChunk(0, x << 4, y << 4, z << 4); - renderChunksArray[y] = builtChunk; - if (Config.isVbo() && Config.isRenderRegions()) { - updateVboRegion(renderChunksArray[y]); - } - } - - renderChunksArray[y].setDirty(important); - callbackInfo.cancel(); - } - } - - /** - * This mixin allows {@link ViewArea} to return the render chunks for ships. - */ - @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); - - if (chunkY < 0 || chunkY >= chunkGridSizeY) { - return; // Weird, but ignore it - } - - if (VSGameUtilsKt.isChunkInShipyard(level, chunkX, chunkZ)) { - final long chunkPosAsLong = ChunkPos.asLong(chunkX, chunkZ); - final ChunkRenderDispatcher.RenderChunk[] renderChunksArray = vs$shipRenderChunks.get(chunkPosAsLong); - if (renderChunksArray == null) { - callbackInfoReturnable.setReturnValue(null); - return; - } - final ChunkRenderDispatcher.RenderChunk renderChunk = renderChunksArray[chunkY]; - callbackInfoReturnable.setReturnValue(renderChunk); - } - } - - @Shadow(remap = false) - private Map mapVboRegions; - - @Override - public void unloadChunk(final int chunkX, final int chunkZ) { - if (VSGameUtilsKt.isChunkInShipyard(level, chunkX, chunkZ)) { - final ChunkRenderDispatcher.RenderChunk[] chunks = - vs$shipRenderChunks.remove(ChunkPos.asLong(chunkX, chunkZ)); - if (chunks != null) { - for (final ChunkRenderDispatcher.RenderChunk chunk : chunks) { - chunk.releaseBuffers(); - } - } - final VboRegion[] vboRegions = mapVboRegions.remove(new ChunkPos(chunkX, chunkZ)); - if (vboRegions != null) { - for (final VboRegion vboRegion : vboRegions) { - if (vboRegion != null) { - vboRegion.deleteGlBuffers(); - } - } - } - } - } - - /** - * Clear VS ship render chunks so that we don't leak memory - */ - @Inject(method = "releaseAllBuffers", at = @At("HEAD")) - private void postReleaseAllBuffers(final CallbackInfo ci) { - for (final Entry entry : vs$shipRenderChunks.long2ObjectEntrySet()) { - for (final ChunkRenderDispatcher.RenderChunk renderChunk : entry.getValue()) { - if (renderChunk != null) { - renderChunk.releaseBuffers(); - } - } - } - vs$shipRenderChunks.clear(); - } -} 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/sound_physics_remastered/MixinSoundPhysics.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sound_physics_remastered/MixinSoundPhysics.java index de87e5605..cd1ef96fa 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sound_physics_remastered/MixinSoundPhysics.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sound_physics_remastered/MixinSoundPhysics.java @@ -13,7 +13,7 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; @Pseudo -@Mixin(targets = "com.sonicether.soundphysics.SoundPhysics") +@Mixin(targets = "com.sonicether.soundphysics.SoundPhysics", remap = false) public abstract class MixinSoundPhysics { @Shadow 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 711a71978..3d6c40e78 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; @@ -26,7 +24,9 @@ import net.minecraft.core.Vec3i; import net.minecraft.world.entity.player.Player; import org.jetbrains.annotations.Nullable; +import org.joml.Matrix4f; import org.joml.Vector3dc; +import org.joml.Vector3f; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -155,7 +155,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 = "*" ) @@ -282,7 +282,7 @@ private void renderChunkLayer(final RenderType renderType, final PoseStack poseS } if (uniform != null) { - uniform.set(Vector3f.ZERO); + uniform.set(new Vector3f()); } 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 fce1429bb..6294d134f 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 @@ -21,20 +21,13 @@ import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.block.state.properties.BlockStateProperties; import net.minecraft.world.level.border.WorldBorder; import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraft.world.level.dimension.DimensionType; -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.Vec3; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -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.Unique; @@ -42,14 +35,11 @@ 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.LoadedServerShip; import org.valkyrienskies.core.api.ships.properties.IShipActiveChunksSet; import org.valkyrienskies.core.apigame.GameServer; -import org.valkyrienskies.core.apigame.ShipTeleportData; import org.valkyrienskies.core.apigame.world.IPlayer; import org.valkyrienskies.core.apigame.world.ServerShipWorldCore; import org.valkyrienskies.core.apigame.world.VSPipeline; -import org.valkyrienskies.core.impl.game.ShipTeleportDataImpl; import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.ShipSavedData; import org.valkyrienskies.mod.common.VSGameUtilsKt; @@ -57,10 +47,8 @@ import org.valkyrienskies.mod.common.config.MassDatapackResolver; import org.valkyrienskies.mod.common.hooks.VSGameEvents; import org.valkyrienskies.mod.common.util.EntityDragger; -import org.valkyrienskies.mod.common.util.ShipSettingsKt; import org.valkyrienskies.mod.common.util.VSLevelChunk; import org.valkyrienskies.mod.common.util.VSServerLevel; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.common.world.ChunkManagement; import org.valkyrienskies.mod.util.KrunchSupport; @@ -235,9 +223,10 @@ private void postTick(final CallbackInfo ci) { EntityDragger.INSTANCE.dragEntitiesWithShips(level.getAllEntities()); } - handleShipPortals(); + //TODO must reimplement + // handleShipPortals(); } - +/* TODO must redo @Unique private void handleShipPortals() { // Teleport ships that touch portals @@ -250,8 +239,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(); @@ -290,6 +279,8 @@ private void handleShipPortals() { } } + */ +/* TODO Must redo @Unique private void shipChangeDimension(@NotNull final ServerLevel srcLevel, @NotNull final ServerLevel destLevel, @Nullable final BlockPos portalEntrancePos, @NotNull final LoadedServerShip shipObject) { final PortalInfo portalInfo = findDimensionEntryPoint(srcLevel, destLevel, portalEntrancePos, shipObject.getTransform().getPositionInWorld()); @@ -350,6 +341,8 @@ private PortalInfo findDimensionEntryPoint(@NotNull final ServerLevel srcLevel, }).orElse(null); } + */ + @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/command/level/MixinServerPlayer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/level/MixinServerPlayer.java index f3ecca12d..dd6a239e3 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/level/MixinServerPlayer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/command/level/MixinServerPlayer.java @@ -14,8 +14,6 @@ @Mixin(ServerPlayer.class) public abstract class MixinServerPlayer { - @Shadow - public abstract ServerLevel getLevel(); @Shadow public abstract void teleportTo(double d, double e, double f); @@ -26,7 +24,8 @@ public abstract class MixinServerPlayer { cancellable = true ) private void beforeTeleportTo(final double x, final double y, final double z, final CallbackInfo ci) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(getLevel(), x, y, z); + ServerLevel level = ((ServerPlayer) (Object) this).serverLevel(); + final Ship ship = VSGameUtilsKt.getShipManagingPos(level, x, y, z); if (ship != null) { ci.cancel(); final Vector3d inWorld = VSGameUtilsKt.toWorldCoordinates(ship, x, y, z); @@ -40,7 +39,8 @@ private void beforeTeleportTo(final double x, final double y, final double z, fi cancellable = true ) private void beforeDismountTo(final double x, final double y, final double z, final CallbackInfo ci) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(getLevel(), x, y, z); + ServerLevel level = ((ServerPlayer) (Object) this).serverLevel(); + final Ship ship = VSGameUtilsKt.getShipManagingPos(level, x, y, z); if (ship != null) { ci.cancel(); final Vector3d inWorld = VSGameUtilsKt.toWorldCoordinates(ship, x, y, z); 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..efdce9a08 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; @@ -74,7 +75,7 @@ private int noFlyKick(final int original) { method = "handleUseItemOn" ) private Vec3 skipDistanceCheck2(final Vec3 instance, final Vec3 vec3, final Operation subtract) { - return VSGameUtilsKt.toWorldCoordinates(player.level, subtract.call(instance, vec3)); + return VSGameUtilsKt.toWorldCoordinates(player.level(), subtract.call(instance, vec3)); } /* @@ -139,14 +140,14 @@ 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 ServerShip ship = VSGameUtilsKt.getShipManagingPos((ServerLevel) player.level, blockPos); + 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 if (ship != null) { @@ -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/server/world/MixinChunkMap$TrackedEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java index e8b7bc131..7ea390797 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap$TrackedEntity.java @@ -32,7 +32,7 @@ public class MixinChunkMap$TrackedEntity { target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;")) Vec3 includeShips(final Vec3 original) { final Vector3d pos = VectorConversionsMCKt.toJOML(original); - final Ship ship = inCallShip = VSGameUtilsKt.getShipObjectManagingPos(this.entity.level, pos); + final Ship ship = inCallShip = VSGameUtilsKt.getShipObjectManagingPos(this.entity.level(), pos); if (ship != null) { return VectorConversionsMCKt.toMinecraft(ship.getShipToWorld().transformPosition(pos)); } else { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java index 985ac3f04..3971c68fd 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java @@ -12,27 +12,19 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Optional; -import java.util.concurrent.Executor; import java.util.function.BooleanSupplier; import net.minecraft.core.BlockPos; import net.minecraft.core.BlockPos.MutableBlockPos; import net.minecraft.core.Position; -import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.CustomSpawner; -import net.minecraft.world.level.Level; import net.minecraft.world.level.block.state.BlockState; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; -import net.minecraft.world.level.dimension.LevelStem; -import net.minecraft.world.level.storage.LevelStorageSource.LevelStorageAccess; -import net.minecraft.world.level.storage.ServerLevelData; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.joml.Vector3d; @@ -87,12 +79,7 @@ public ServerShipWorldCore getShipObjectWorld() { } @Inject(method = "", at = @At("RETURN")) - void onInit(final MinecraftServer minecraftServer, final Executor executor, - final LevelStorageAccess levelStorageAccess, - final ServerLevelData serverLevelData, final ResourceKey levelId, final LevelStem levelStem, - final ChunkProgressListener chunkProgressListener, final boolean bl, - final long l, final List customSpawners, - final boolean bl2, final CallbackInfo ci) { + void onInit(final CallbackInfo ci) { // This only happens when overworld gets loaded on startup, we have a mixin in MixinMinecraftServer for this specific case if (getShipObjectWorld() != null) { @@ -167,7 +154,7 @@ private boolean includeShipsInParticleDistanceCheck( for (int z = 0; z < 16; z++) { final BlockState blockState = chunkSection.getBlockState(x, y, z); final int posX = (chunkX << 4) + x; - final int posY = chunkSection.bottomBlockY() + y; + final int posY = worldChunk.getMinBuildHeight() + y; final int posZ = (chunkZ << 4) + z; if (blockState.getBlock() instanceof WingBlock) { mutableBlockPos.set(posX, posY, posZ); 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 ad158569f..6ef89c925 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; @@ -81,10 +82,11 @@ 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); + //new LevelChunkSection(registry); + sections[i] = new LevelChunkSection(registry); } this.setLightCorrect(false); @@ -118,10 +120,10 @@ 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); + sections[i] = new LevelChunkSection(registry); } // this.inhabitedTime = l; diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/world/entity/projectile/ProjectileUtilMixin.java b/common/src/main/java/org/valkyrienskies/mod/mixin/world/entity/projectile/ProjectileUtilMixin.java index 1e5205e8a..26c233439 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/world/entity/projectile/ProjectileUtilMixin.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/entity/projectile/ProjectileUtilMixin.java @@ -26,11 +26,11 @@ private static void beforeGetEntityHitResult( final Entity entity, final Vec3 vec3, final Vec3 vec32, final AABB aABB, final Predicate predicate, final double d, final CallbackInfoReturnable<@Nullable EntityHitResult> cir) { - if (!VSGameUtilsKt.getShipsIntersecting(entity.level, aABB).iterator().hasNext()) { + if (!VSGameUtilsKt.getShipsIntersecting(entity.level(), aABB).iterator().hasNext()) { return; } - cir.setReturnValue(RaycastUtilsKt.raytraceEntities(entity.level, entity, vec3, vec32, aABB, predicate, d)); + cir.setReturnValue(RaycastUtilsKt.raytraceEntities(entity.level(), entity, vec3, vec32, aABB, predicate, d)); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinBlockCollisions.java b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinBlockCollisions.java index 28a9f4b31..1acd44e66 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinBlockCollisions.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinBlockCollisions.java @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.mixin.world.level; +import java.util.function.BiFunction; import net.minecraft.core.Cursor3D; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; @@ -35,8 +36,8 @@ public class MixinBlockCollisions { @Mutable private VoxelShape entityShape; - @Inject(method = "(Lnet/minecraft/world/level/CollisionGetter;Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;Z)V", at = @At("RETURN")) - private void postInit(final CollisionGetter collisionGetter, final Entity entity, final AABB aabb, final boolean bl, final CallbackInfo ci) { + @Inject(method = "", at = @At("RETURN")) + private void postInit(CollisionGetter collisionGetter, Entity entity, AABB aabb, boolean bl, BiFunction biFunction, CallbackInfo ci) { if (BugFixUtil.INSTANCE.isCollisionBoxToBig(aabb)) { final AABB newBox = new AABB(aabb.minX, aabb.minY, aabb.minZ, aabb.minX, aabb.minY, aabb.minZ); this.entityShape = Shapes.create(newBox); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/chunk/MixinChunkGenerator.java b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/chunk/MixinChunkGenerator.java index 478468342..d7590470e 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/chunk/MixinChunkGenerator.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/chunk/MixinChunkGenerator.java @@ -11,9 +11,8 @@ import net.minecraft.world.level.WorldGenLevel; import net.minecraft.world.level.chunk.ChunkAccess; import net.minecraft.world.level.chunk.ChunkGenerator; -import net.minecraft.world.level.levelgen.RandomState; +import net.minecraft.world.level.chunk.ChunkGeneratorStructureState; import net.minecraft.world.level.levelgen.structure.Structure; -import net.minecraft.world.level.levelgen.structure.StructureSet; import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -39,6 +38,8 @@ private void preApplyBiomeDecoration(WorldGenLevel worldGenLevel, ChunkAccess ch } } + //TODO + /* @Inject(method = "hasStructureChunkInRange", at = @At("HEAD"), cancellable = true) private void preHasFeatureChunkInRange(Holder holder, RandomState randomState, long l, int chunkX, int chunkZ, int k, CallbackInfoReturnable cir) { if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkX, chunkZ)) { @@ -46,8 +47,12 @@ private void preHasFeatureChunkInRange(Holder holder, RandomState } } + */ + @Inject(method = "createStructures", at = @At("HEAD"), cancellable = true) - private void preCreateStructures(RegistryAccess registryAccess, RandomState randomState, StructureManager structureManager, ChunkAccess chunkAccess, StructureTemplateManager structureTemplateManager, long l, CallbackInfo callbackInfo) { + private void preCreateStructures(RegistryAccess registryAccess, + ChunkGeneratorStructureState chunkGeneratorStructureState, StructureManager structureManager, + ChunkAccess chunkAccess, StructureTemplateManager structureTemplateManager, CallbackInfo callbackInfo) { final ChunkPos chunkPos = chunkAccess.getPos(); if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { callbackInfo.cancel(); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java index ff8cb7cf7..f2582622c 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java @@ -1,7 +1,7 @@ package org.valkyrienskies.mod.mixinducks; import com.jozufozu.flywheel.backend.RenderLayer; -import com.mojang.math.Matrix4f; +import org.joml.Matrix4f; public interface MixinInstancingEngineDuck { void vs$render(Matrix4f viewProjection, double camX, double camY, double camZ, RenderLayer layer); 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..040950d37 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt @@ -13,6 +13,8 @@ import net.minecraft.util.RandomSource import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.level.block.RenderShape.INVISIBLE import net.minecraft.world.level.block.RenderShape.MODEL +import org.joml.Quaterniondc +import org.joml.Quaternionf import org.valkyrienskies.core.impl.game.ships.ShipObjectClientWorld import org.valkyrienskies.mod.common.IShipObjectWorldClientProvider import org.valkyrienskies.mod.common.ValkyrienSkiesMod @@ -29,7 +31,7 @@ class VSPhysicsEntityRenderer(context: EntityRendererProvider.Context) : EntityR if (blockState.renderShape != MODEL) { return } - val level = fallingBlockEntity.getLevel() + val level = fallingBlockEntity.level() if (blockState === level.getBlockState( fallingBlockEntity.blockPosition() ) || blockState.renderShape == INVISIBLE @@ -51,10 +53,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.containing(fallingBlockEntity.x, fallingBlockEntity.boundingBox.maxY, fallingBlockEntity.z) poseStack.translate(offsetX, offsetY, offsetZ) - poseStack.mulPose(renderTransform.shipToWorldRotation.toMinecraft()) + poseStack.mulPose(Quaternionf(renderTransform.shipToWorldRotation)) 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 4a6ce7419..a94660be1 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -46,8 +46,7 @@ object BlockStateInfo { // registry for mods to add their weights val REGISTRY = MappedRegistry( ResourceKey.createRegistryKey(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "blockstate_providers")), - Lifecycle.experimental(), - null + Lifecycle.experimental() ) private lateinit var SORTED_REGISTRY: List diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt index 373b4254c..54f5ce073 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt @@ -1,7 +1,8 @@ package org.valkyrienskies.mod.common +import net.minecraft.world.level.block.Blocks +import net.minecraft.world.level.block.LiquidBlock import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.Material import org.valkyrienskies.core.apigame.world.chunks.BlockType import org.valkyrienskies.physics_api.Lod1BlockStateId import org.valkyrienskies.physics_api.Lod1LiquidBlockStateId @@ -28,9 +29,9 @@ object DefaultBlockStateInfoProvider : BlockStateInfoProvider { override fun getBlockStateType(blockState: BlockState): BlockType { if (blockState.isAir) return vsCore.blockTypes.air - val blockMaterial = blockState.material - if (blockMaterial.isLiquid) - return if (blockMaterial == Material.LAVA) vsCore.blockTypes.lava else vsCore.blockTypes.water - return if (blockMaterial.isSolid) vsCore.blockTypes.solid else vsCore.blockTypes.air + val block = blockState.block + if (block is LiquidBlock) + return if (block == Blocks.LAVA) vsCore.blockTypes.lava else vsCore.blockTypes.water + return if (blockState.isSolid) vsCore.blockTypes.solid else vsCore.blockTypes.air } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt index ce0890a0b..c1550aeca 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt @@ -25,7 +25,7 @@ object PlayerUtil { @JvmStatic fun transformPlayerTemporarily(player: Player, ship: LoadedShip?) { - if (player.level.isBlockInShipyard(player.x, player.y, player.z)) { + if (player.level().isBlockInShipyard(player.x, player.y, player.z)) { // player is already in shipyard return } 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 090da4119..1ae005c71 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 { @@ -61,29 +60,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, @@ -132,4 +108,3 @@ object VSClientGameUtils { ) } } - 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 8a51aa7e5..8fbae6f3d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -73,13 +73,17 @@ 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( + val toReturn: ResourceKey = ResourceKeyAccessor.callCreate( ResourceLocation(registryNamespace, registryName), ResourceLocation(namespace, name) ) + levelResourceKeyMap[dimensionId] = toReturn + return toReturn } return cached } @@ -115,7 +119,7 @@ val Player.playerWrapper get() = (this as PlayerDuck).vs_getPlayer() * Like [Entity.squaredDistanceTo] except the destination is transformed into world coordinates if it is a ship */ fun Entity.squaredDistanceToInclShips(x: Double, y: Double, z: Double) = - level.squaredDistanceBetweenInclShips(x, y, z, this.x, this.y, this.z) + level().squaredDistanceBetweenInclShips(x, y, z, this.x, this.y, this.z) /** * Calculates the squared distance between to points. @@ -308,7 +312,7 @@ fun ClientLevel?.transformRenderAABBToWorld(pos: Position, aabb: AABB): AABB { return aabb } -fun Entity.getShipManaging(): Ship? = this.level.getShipManagingPos(this.position()) +fun Entity.getShipManaging(): Ship? = this.level().getShipManagingPos(this.position()) // Level fun Level?.getShipManagingPos(chunkX: Int, chunkZ: Int) = diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt index 6dac43e54..55163462f 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -1,8 +1,14 @@ package org.valkyrienskies.mod.common +import net.minecraft.core.registries.Registries +import net.minecraft.network.chat.Component +import net.minecraft.resources.ResourceKey +import net.minecraft.resources.ResourceLocation import net.minecraft.server.MinecraftServer import net.minecraft.world.entity.EntityType +import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.entity.BlockEntityType import org.valkyrienskies.core.api.ships.setAttachment @@ -22,9 +28,13 @@ object ValkyrienSkiesMod { const val MOD_ID = "valkyrienskies" lateinit var TEST_CHAIR: Block + lateinit var TEST_CHAIR_ITEM: Item lateinit var TEST_HINGE: Block + lateinit var TEST_HINGE_ITEM: Item lateinit var TEST_FLAP: Block + lateinit var TEST_FLAP_ITEM: Item lateinit var TEST_WING: Block + lateinit var TEST_WING_ITEM: Item lateinit var TEST_SPHERE: Block lateinit var SHIP_CREATOR_ITEM: Item lateinit var SHIP_ASSEMBLER_ITEM: Item @@ -34,6 +44,8 @@ object ValkyrienSkiesMod { lateinit var PHYSICS_ENTITY_TYPE: EntityType lateinit var TEST_HINGE_BLOCK_ENTITY_TYPE: BlockEntityType + val VS_CREATIVE_TAB = ResourceKey.create(Registries.CREATIVE_MODE_TAB, ResourceLocation("valkyrienskies")) + @JvmStatic var currentServer: MinecraftServer? = null @@ -56,4 +68,20 @@ object ValkyrienSkiesMod { event.ship.setAttachment(GameTickForceApplier()) } } + + fun createCreativeTab(): CreativeModeTab { + return CreativeModeTab.builder(CreativeModeTab.Row.TOP, 0) + .title(Component.translatable("itemGroup.valkyrienSkies")) + .icon { ItemStack(SHIP_CREATOR_ITEM) } + .displayItems { _, output -> + output.accept(TEST_CHAIR_ITEM) + output.accept(TEST_HINGE_ITEM) + output.accept(TEST_FLAP_ITEM) + output.accept(TEST_WING_ITEM) + output.accept(SHIP_CREATOR_ITEM) + output.accept(SHIP_ASSEMBLER_ITEM) + output.accept(SHIP_CREATOR_ITEM_SMALLER) + } + .build() + } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestChairBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestChairBlock.kt index 0a12f90c5..01b589c1e 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestChairBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestChairBlock.kt @@ -14,7 +14,6 @@ import net.minecraft.world.level.block.HorizontalDirectionalBlock import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.material.Material import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -28,7 +27,7 @@ import org.valkyrienskies.mod.common.util.toDoubles object TestChairBlock : HorizontalDirectionalBlock( - Properties.of(Material.WOOL).strength(1.0f, 120.0f).sound(SoundType.WOOL) + Properties.of().strength(1.0f, 120.0f).sound(SoundType.WOOL) ) { private val SEAT_AABB: VoxelShape = box(0.0, 0.0, 0.0, 16.0, 8.0, 16.0) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestFlapBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestFlapBlock.kt index 60a505200..33c2a429d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestFlapBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestFlapBlock.kt @@ -15,7 +15,6 @@ import net.minecraft.world.level.block.DirectionalBlock import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.material.Material import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import org.valkyrienskies.core.api.ships.Wing @@ -23,7 +22,7 @@ import org.valkyrienskies.mod.common.util.toJOMLD object TestFlapBlock : DirectionalBlock( - Properties.of(Material.METAL).strength(10.0f, 1200.0f).sound(SoundType.METAL) + Properties.of().strength(10.0f, 1200.0f).sound(SoundType.METAL) ), WingBlock { private val EAST_AABB = box(4.0, 0.0, 0.0, 12.0, 16.0, 16.0) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestHingeBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestHingeBlock.kt index b22a496ec..b2cf03379 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestHingeBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestHingeBlock.kt @@ -24,7 +24,6 @@ import net.minecraft.world.level.block.entity.BlockEntityTicker import net.minecraft.world.level.block.entity.BlockEntityType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.material.Material import net.minecraft.world.phys.BlockHitResult import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape @@ -47,7 +46,7 @@ import kotlin.math.roundToInt object TestHingeBlock : DirectionalBlock( - Properties.of(Material.METAL).strength(10.0f, 1200.0f).sound(SoundType.METAL) + Properties.of().strength(10.0f, 1200.0f).sound(SoundType.METAL) ), EntityBlock { private val EAST_AABB = box(0.0, 0.0, 0.0, 8.0, 16.0, 16.0) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestSphereBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestSphereBlock.kt index cfdb38ac8..3449b717a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestSphereBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestSphereBlock.kt @@ -4,12 +4,11 @@ import net.minecraft.core.BlockPos import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.Material import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.Shapes import net.minecraft.world.phys.shapes.VoxelShape -object TestSphereBlock : Block(Properties.of(Material.STONE)) { +object TestSphereBlock : Block(Properties.of()) { override fun getVisualShape( blockState: BlockState?, blockGetter: BlockGetter?, blockPos: BlockPos?, collisionContext: CollisionContext? ): VoxelShape { diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt index b7c9e808a..57542ced8 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt @@ -15,7 +15,6 @@ import net.minecraft.world.level.block.DirectionalBlock import net.minecraft.world.level.block.SoundType import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.block.state.StateDefinition -import net.minecraft.world.level.material.Material import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import org.valkyrienskies.core.api.ships.Wing @@ -23,7 +22,7 @@ import org.valkyrienskies.mod.common.util.toJOMLD object TestWingBlock : DirectionalBlock( - Properties.of(Material.METAL).strength(10.0f, 1200.0f).sound(SoundType.METAL) + Properties.of().strength(10.0f, 1200.0f).sound(SoundType.METAL) ), WingBlock { private val EAST_AABB = box(4.0, 0.0, 0.0, 12.0, 16.0, 16.0) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt index 1fc4a2968..63597f2db 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt @@ -260,7 +260,7 @@ object VSCommands { if (sourceEntity != null) { val rayTrace = sourceEntity.pick(10.0, 1.0.toFloat(), false) if (rayTrace is BlockHitResult) { - val ship = sourceEntity.level.getShipManagingPos(rayTrace.blockPos) + val ship = sourceEntity.level().getShipManagingPos(rayTrace.blockPos) if (ship != null) { (it.source as VSCommandSource).sendVSMessage( Component.translatable(GET_SHIP_SUCCESS_MESSAGE, ship.slug) 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 a40f37daf..097e1bed6 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 @@ -17,7 +18,6 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.FluidState import net.minecraft.world.level.material.Fluids -import net.minecraft.world.level.material.Material import net.minecraft.world.phys.shapes.VoxelShape import org.joml.Vector3f import org.joml.Vector3i @@ -72,7 +72,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): VSBlockType? = blockStateToId[blockState]!! @@ -116,7 +116,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()) { @@ -127,7 +127,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 ) ) @@ -394,10 +394,9 @@ object MassDatapackResolver : BlockStateInfoProvider { if (blockState.isAir) { blockType = vsCore.blockTypes.air } else { - val blockMaterial = blockState.material - blockType = if (blockMaterial.isLiquid) { + blockType = if (blockState.liquid()) { getFluidState(blockState.fluidState).second - } else if (blockMaterial.isSolid) { + } else if (blockState.isSolid) { val voxelShape = blockState.getShape(dummyBlockGetter, BlockPos.ZERO) val collisionShape: Lod1SolidCollisionShape = if (voxelShapeToCollisionShapeMap.contains(voxelShape)) { @@ -414,7 +413,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 solidStateId = nextSolidId++ 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 fb62268ca..f8eb1f0fb 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 @@ -34,20 +35,21 @@ open class ShipMountingEntity(type: EntityType, level: Level override fun tick() { super.tick() - if (!level.isClientSide && passengers.isEmpty()) { + if (!level().isClientSide && passengers.isEmpty()) { // Kill this entity if nothing is riding it kill() return } - if (level.getShipObjectManagingPos(blockPosition()) != null) + if (level().getShipObjectManagingPos(blockPosition()) != null) sendDrivingPacket() } // This is a partial fix for mounting ships that have been deleted // TODO: Make a full fix eventually + /* override fun positionRider(entity: Entity) { - if (level.isBlockInShipyard(position()) && level.getShipManagingPos(position()) == null) { + if (level().isBlockInShipyard(position()) && level().getShipManagingPos(position()) == null) { // Stop rider positioning if we can't find the ship entity.removeVehicle() return @@ -55,10 +57,12 @@ open class ShipMountingEntity(type: EntityType, level: Level super.positionRider(entity) } + */ + // This is a partial fix for mounting ships that have been deleted // TODO: Make a full fix eventually override fun getDismountLocationForPassenger(livingEntity: LivingEntity): Vec3 { - if (level.isBlockInShipyard(position()) && level.getShipManagingPos(position()) == null) { + if (level().isBlockInShipyard(position()) && level().getShipManagingPos(position()) == null) { // Don't teleport to the ship if we can't find the ship return livingEntity.position() } @@ -72,14 +76,14 @@ open class ShipMountingEntity(type: EntityType, level: Level override fun defineSynchedData() {} override fun remove(removalReason: RemovalReason) { - if (this.isController && !level.isClientSide) - (level.getShipObjectManagingPos(blockPosition()) as LoadedServerShip?) + if (this.isController && !level().isClientSide) + (level().getShipObjectManagingPos(blockPosition()) as LoadedServerShip?) ?.setAttachment(null) super.remove(removalReason) } private fun sendDrivingPacket() { - if (!level.isClientSide) return + if (!level().isClientSide) return // todo: custom keybinds for going up down and all around but for now lets just use the mc defaults val opts = Minecraft.getInstance().options val forward = opts.keyUp.isDown @@ -99,11 +103,15 @@ open class ShipMountingEntity(type: EntityType, level: Level PacketPlayerDriving(impulse, sprint, cruise).sendToServer() } - 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 b636d67ff..879b890f7 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 @@ -52,9 +53,9 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En throw IllegalStateException("Cannot define physicsEntityData, its already defined!") } this.physicsEntityData = physicsEntityData - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { var defaultRot = Rotations(0.0f, 0.0f, 0.0f) - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { val eulerAngles = physicsEntityData.transform.shipToWorldRotation.getEulerAnglesXYZ(Vector3d()) defaultRot = Rotations(eulerAngles.x.toFloat(), eulerAngles.y.toFloat(), eulerAngles.z.toFloat()) } @@ -66,7 +67,7 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En if (lerpPos == null) { lerpPos = position().toJOML() } - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { val physicsEntityServerCopy = physicsEntityServer if (physicsEntityServerCopy != null) { val transform = physicsEntityServerCopy.shipTransform @@ -123,7 +124,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) } @@ -136,12 +137,12 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En // Used when teleporting through nether portals to create a new entity that's almost the same as this one // Note how a new shipId is generated, since this is meant to be a new copy not the exact same one private fun loadForTeleport(compoundTag: CompoundTag) { - if (!this.level.isClientSide && physicsEntityData != null) { + if (!this.level().isClientSide && physicsEntityData != null) { throw IllegalStateException("This entity is already loaded!") } val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY) val oldPhysicsEntityData = getMapper().readValue(physicsEntityDataAsBytes) - val newShipId = (level.shipObjectWorld as ShipObjectServerWorld).allocateShipId(level.dimensionId) + val newShipId = (level().shipObjectWorld as ShipObjectServerWorld).allocateShipId(level().dimensionId) val newPhysicsEntityData = oldPhysicsEntityData.copyPhysicsEntityDataWithNewId(newShipId) // Change the shipId to be something new setPhysicsEntityData(newPhysicsEntityData) @@ -149,7 +150,7 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En } override fun load(compoundTag: CompoundTag) { - if (!this.level.isClientSide && physicsEntityData != null) { + if (!this.level().isClientSide && physicsEntityData != null) { throw IllegalStateException("This entity is already loaded!") } val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY) @@ -160,15 +161,15 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En override fun setLevelCallback(callback: EntityInLevelCallback?) { super.setLevelCallback(callback) - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { val isNull = (callback == null) || callback == EntityInLevelCallback.NULL if (!isNull) { // Try adding the rigid body of this entity from the world if (physicsEntityServer != null) { throw IllegalStateException("Rigid body is already in the world!") } - physicsEntityServer = (level.shipObjectWorld as ServerShipWorldCore).createPhysicsEntity( - physicsEntityData!!, level.dimensionId + physicsEntityServer = (level().shipObjectWorld as ServerShipWorldCore).createPhysicsEntity( + physicsEntityData!!, level().dimensionId ) } else { // Try removing the rigid body of this entity from the world @@ -176,7 +177,7 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En return // throw IllegalStateException("Rigid body does not exist in the world!") } - (level.shipObjectWorld as ServerShipWorldCore).deletePhysicsEntity(physicsEntityData!!.shipId) + (level().shipObjectWorld as ServerShipWorldCore).deletePhysicsEntity(physicsEntityData!!.shipId) physicsEntityServer = null } } @@ -193,12 +194,12 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En override fun moveTo(d: Double, e: Double, f: Double, g: Float, h: Float) { super.moveTo(d, e, f, g, h) - if (!this.level.isClientSide) { + if (!this.level().isClientSide) { val physicsEntityServerCopy = physicsEntityServer if (physicsEntityServerCopy != null) { val newPos = Vector3d(d, e, f) val teleportData = ShipTeleportDataImpl(newPos = newPos) - (this.level.shipObjectWorld as ShipObjectServerWorld).teleportPhysicsEntity(this.physicsEntityServer!!, teleportData) + (this.level().shipObjectWorld as ShipObjectServerWorld).teleportPhysicsEntity(this.physicsEntityServer!!, teleportData) } else { physicsEntityData!!.transform = ShipTransformImpl.create( Vector3d(d, e, f), 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..f3d585039 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 @@ -4,6 +4,7 @@ import com.mojang.blaze3d.vertex.PoseStack import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.entity.EntityRenderer import net.minecraft.world.entity.Entity +import org.joml.Quaternionf import org.joml.Vector3d import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.Ship @@ -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(Quaternionf(transform.shipToWorldRotation)) 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(Quaternionf(ship.renderTransform.shipToWorldRotation)) } } 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 8a45a3a62..900e9c645 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 @@ -2,6 +2,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 @@ -72,7 +73,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 +92,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/entity/handling/WorldEntityHandler.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/WorldEntityHandler.kt index 295792c93..ca1f9fa77 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/WorldEntityHandler.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/WorldEntityHandler.kt @@ -37,12 +37,12 @@ object WorldEntityHandler : VSEntityHandler { } override fun positionSetFromVehicle(self: Entity, vehicle: Entity, x: Double, y: Double, z: Double) { - val (wx, wy, wz) = self.level.toWorldCoordinates(x, y, z) + val (wx, wy, wz) = self.level().toWorldCoordinates(x, y, z) self.setPos(wx, wy, wz) } override fun getTeleportPos(self: Entity, pos: Vector3d): Vector3d { - return self.level.toWorldCoordinates(pos) + return self.level().toWorldCoordinates(pos) } override fun applyRenderOnMountedEntity( 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 fd3a1ccaf..65124d70f 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.impl.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 7c1efeb1b..4e245c9b6 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,7 @@ 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 @@ -30,7 +31,7 @@ object VSGamePackets { val seat = player.vehicle as? ShipMountingEntity ?: return@registerServerHandler if (seat.isController) { - val ship = seat.level.getShipObjectManagingPos(seat.blockPosition()) as? LoadedServerShip + val ship = seat.level().getShipObjectManagingPos(seat.blockPosition()) as? LoadedServerShip ?: return@registerServerHandler val attachment: SeatedControllingPlayer = ship.getAttachment() @@ -48,7 +49,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/EntityDragger.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDragger.kt index 64472ca35..4a2403548 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDragger.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDragger.kt @@ -20,7 +20,7 @@ object EntityDragger { */ fun dragEntitiesWithShips(entities: Iterable) { entities.forEach { entity -> - val shipMountedTo = entity.level.getShipObjectEntityMountedTo(entity) + val shipMountedTo = entity.level().getShipObjectEntityMountedTo(entity) // Don't drag entities that are already mounted to a ship if (shipMountedTo != null) return@forEach @@ -34,7 +34,7 @@ object EntityDragger { if (shipDraggingEntity != null) { if (entityDraggingInformation.isEntityBeingDraggedByAShip()) { // Compute how much we should drag the entity - val shipData = entity.level.shipObjectWorld.queryableShipData.getById(shipDraggingEntity) + val shipData = entity.level().shipObjectWorld.queryableShipData.getById(shipDraggingEntity) if (shipData != null) { dragTheEntity = true 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 89b3128f8..80997f52f 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 @@ -27,7 +27,7 @@ object EntityShipCollisionUtils { @JvmStatic fun isCollidingWithUnloadedShips(entity: Entity): Boolean { - val level = entity.level + val level = entity.level() if (level is ServerLevel || (level.isClientSide && level is ClientLevel)) { if (level.isClientSide && level is ClientLevel && !level.shipObjectWorld.isSyncedWithServer) { @@ -77,7 +77,7 @@ 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 // 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/util/MinecraftPlayer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/MinecraftPlayer.kt index 9a0397035..75ec785d3 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/MinecraftPlayer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/MinecraftPlayer.kt @@ -33,7 +33,7 @@ class MinecraftPlayer(playerObject: Player) : IPlayer { get() = vsCore.hooks.isPhysicalClient || player.hasPermissions(4) override val dimension: DimensionId - get() = player.level.dimensionId + get() = player.level().dimensionId override fun getPosition(dest: Vector3d): Vector3d { return dest.set(player.x, player.y, player.z) @@ -42,7 +42,7 @@ class MinecraftPlayer(playerObject: Player) : IPlayer { override fun getPlayerState(): PlayerState { var mountedShip: ShipId? = null var mountedPos: Vector3dc? = null - player.level.getShipObjectEntityMountedTo(player)?.let { + player.level().getShipObjectEntityMountedTo(player)?.let { mountedShip = it.id mountedPos = player.vehicle!!.getPassengerPos(player.myRidingOffset, 0.0f) } 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/util/VectorConversionsMC.kt b/common/src/main/kotlin/org/valkyrienskies/mod/util/VectorConversionsMC.kt index 964379f76..dbb47cbd0 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,5 @@ 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 +7,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 +20,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 +64,7 @@ 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 AABBdc.toMinecraft() = AABB(minX(), minY(), minZ(), maxX(), maxY(), maxZ()) fun AABB.toJOML() = AABBd().set(this) @@ -119,16 +107,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 +127,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 ed62d8488..a69c1b4e7 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -26,7 +26,7 @@ "feature.commands.MixinArgumentTypeInfos", "feature.commands.MixinCommandSourceStack", "feature.conduit_fix.ConduitMixin", - "feature.container_distance_check.MixinRandomizableContainerBlockEntity", + "feature.container_distance_check.MixinContainer", "feature.dispensers.MixinDefaultDispenseItemBehavior", "feature.distance_replace.MixinEntity", "feature.entity_collision.MixinEntity", @@ -114,7 +114,6 @@ "accessors.client.render.chunk.RenderChunkAccessor", "accessors.client.world.ClientChunkCacheStorageAccessor", "client.MixinCamera", - "client.MixinGame", "client.MixinMinecraft", "client.multiplayer.MixinClientPacketListener", "client.player.MixinLocalPlayer", @@ -166,7 +165,6 @@ "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", "mod_compat.sodium.MixinChunkTracker", diff --git a/fabric/build.gradle b/fabric/build.gradle index 20079d716..39224c5a5 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -62,7 +62,7 @@ dependencies { } // CC Restitched - modImplementation("maven.modrinth:cc-restitched:${cc_restitched_version}") + modImplementation("maven.modrinth:cc-tweaked:${cc_tweaked_version}") // Create compat modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { @@ -71,7 +71,7 @@ dependencies { 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("io.github.fabricators_of_create.Porting-Lib:Porting-Lib:$port_lib_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..10f60d1be 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1,41 +1,41 @@ loader_platform=Fabric 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 +config_api_id=4583000 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L25 forge_config_api_port_version=4.2.9 # https://github.com/CafeteriaGuild/fake-player-api/blob/1.19/gradle.properties -fake_player_api_version=0.4.0 +fake_player_api_version=0.6.0 # https://github.com/JamiesWhiteShirt/reach-entity-attributes/tags -reach_entity_attributes_version=2.3.0 +reach_entity_attributes_version=2.4.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.3.62-MC1.20.1 forge_tags_version=2.1 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L33 -milk_lib_version=1.0.51 +milk_lib_version=1.2.60 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L35 -port_lib_version=2.1.1096 -port_lib_modules = accessors,base,entity,extensions,fake_players,networking,obj_loader,tags,transfer +port_lib_version=2.1.1127+1.20 +port_lib_modules = accessors,base,entity,extensions,fake_players,networking,obj_loader,tags,transfer,models,tool_actions,client_events,brewing 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.20 #https://modrinth.com/mod/sodium/versions -sodium_version = mc1.19.2-0.4.4 +sodium_version = mc1.20-0.4.10 -#https://modrinth.com/mod/cc-restitched/versions -cc_restitched_version = 1.101.2+1.19.1 +# https://modrinth.com/mod/cc-tweaked/version/Uq4DlqWv +cc_tweaked_version = 1.105.0 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 +indium_version = 1.0.21+mc1.20.1 # https://linkie.shedaniel.me/dependencies?loader=fabric&version=1.19.2 -modmenu_version = 4.2.0-beta.2 +modmenu_version = 7.1.0 # https://linkie.shedaniel.me/dependencies?loader=fabric&version=1.19.2 -cloth_config_version = 8.3.103 +cloth_config_version = 11.1.106 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..e92496411 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 @@ -1,6 +1,6 @@ package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; -import dan200.computercraft.shared.turtle.blocks.TileTurtle; +import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity; import dan200.computercraft.shared.turtle.core.TurtleBrain; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -27,10 +27,10 @@ @Mixin(TurtleBrain.class) public abstract class MixinTurtleBrain { @Shadow - public abstract TileTurtle getOwner(); + public abstract TurtleBlockEntity getOwner(); @Shadow - public abstract void setOwner(TileTurtle owner); + public abstract void setOwner(TurtleBlockEntity owner); @Shadow public abstract Level getLevel(); @@ -41,7 +41,7 @@ public abstract class MixinTurtleBrain { index = 2 ) private BlockPos ValkyrienSkies2$teleportToBlockPos(final BlockPos pos) { - final TileTurtle currentOwner = getOwner(); + final TurtleBlockEntity currentOwner = getOwner(); final BlockPos oldPos = currentOwner.getBlockPos(); final Level world = getLevel(); @@ -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/cc_restitched/MixinTurtleMoveCommand.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java index 7e44efd49..f1e8aae59 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java @@ -4,8 +4,8 @@ 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.server.level.ServerLevel; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; import org.joml.Vector3d; @@ -23,8 +23,8 @@ public abstract class MixinTurtleMoveCommand { @Inject(method = "canEnter", at = @At("RETURN"), cancellable = true) private static void ValkyrienSkies2$canEnter( - final TurtlePlayer turtlePlayer, final Level world, @Nonnull final BlockPos position, - final CallbackInfoReturnable cir) { + TurtlePlayer turtlePlayer, ServerLevel world, BlockPos position, + CallbackInfoReturnable cir) { if (cir.getReturnValue().isSuccess()) { final Ship ship = VSGameUtilsKt.getShipManagingPos(world, position); if (ship == null) { diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java index 62dbb0c1c..eb6560d4b 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java @@ -1,8 +1,8 @@ package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; -import dan200.computercraft.api.network.IPacketReceiver; -import dan200.computercraft.api.network.IPacketSender; import dan200.computercraft.api.network.Packet; +import dan200.computercraft.api.network.PacketReceiver; +import dan200.computercraft.api.network.PacketSender; import dan200.computercraft.shared.peripheral.modem.wireless.WirelessNetwork; import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; @@ -16,8 +16,8 @@ @Pseudo @Mixin(WirelessNetwork.class) public class MixinWirelessNetwork { - private static IPacketReceiver shipReceiver; - private static IPacketSender shipSender; + private static PacketReceiver shipReceiver; + private static PacketSender shipSender; @ModifyVariable(method = "tryTransmit", at = @At(value = "STORE"), @@ -37,9 +37,8 @@ public class MixinWirelessNetwork { } @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) { + private static void ValkyrienSkies2$tryTransmit(PacketReceiver receiver, Packet packet, double range, + boolean interdimensional, CallbackInfo ci) { shipReceiver = receiver; shipSender = packet.sender(); } 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 index ac355ef2f..8585dd93a 100644 --- 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 @@ -32,11 +32,11 @@ public class MixinBlocks { ) protected BlockPos redirectBlockPosition(final Entity entity) { final Iterator ships = - VSGameUtilsKt.getShipsIntersecting(entity.level, entity.getBoundingBox()).iterator(); + 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)); + return BlockPos.containing(Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.z)); } else { return entity.blockPosition(); } @@ -51,11 +51,9 @@ protected BlockPos redirectBlockPosition(final Entity entity) { require = 0 ) Vec3 redirectPosition(final Entity entity) { - final Iterator ships = - VSGameUtilsKt.getShipsIntersecting(entity.level, entity.getBoundingBox()).iterator(); + final Iterator ships = VSGameUtilsKt.getShipsIntersecting(entity.level(), entity.getBoundingBox()).iterator(); if (ships.hasNext()) { - return VectorConversionsMCKt.toMinecraft(ships.next().getWorldToShip() - .transformPosition(VectorConversionsMCKt.toJOML(entity.position()))); + 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/client/MixinContraptionRenderInfo.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionRenderInfo.java index be7946f45..912c0a79d 100644 --- 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 @@ -20,7 +20,7 @@ public class MixinContraptionRenderInfo { method = "beginFrame" ) private AABB redirectGetAABBForCulling(final AbstractContraptionEntity receiver) { - return VSGameUtilsKt.transformRenderAABBToWorld(((ClientLevel) receiver.level), receiver.position(), + 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/MixinFlwContraption.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinFlwContraption.java index dadc3e560..f7dfcb979 100644 --- 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 @@ -1,13 +1,13 @@ 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.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -27,9 +27,8 @@ public MixinFlwContraption( } @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) { + private static void beforeSetupModelViewPartial(Matrix4f matrix, Matrix4f modelMatrix, + AbstractContraptionEntity entity, double camX, double camY, double camZ, float pt, CallbackInfo ci) { if (VSGameUtilsKt.getShipManaging(entity) instanceof final ClientShip ship) { VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), @@ -42,7 +41,7 @@ private static void beforeSetupModelViewPartial(final Matrix4f matrix, final Mat camZ ); - matrix.multiply(modelMatrix); + matrix.mul(modelMatrix); ci.cancel(); } } @@ -56,6 +55,6 @@ private static void beforeSetupModelViewPartial(final Matrix4f matrix, final Mat ) 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); + 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 index 3bfbff08f..9375965f1 100644 --- 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 @@ -34,7 +34,7 @@ private Vec3 redirectGetTraceOrigin(Player playerIn) { AABB searchAABB = new AABB(origin, target).inflate(0.25, 2, 0.25); - final Iterator ships = VSGameUtilsKt.getShipsIntersecting(playerIn.level, searchAABB).iterator(); + final Iterator ships = VSGameUtilsKt.getShipsIntersecting(playerIn.level(), searchAABB).iterator(); if (ships.hasNext()) { Ship ship = ships.next(); 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..ca05d28ff 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 @@ -2,6 +2,7 @@ import net.minecraft.core.BlockPos; import net.minecraft.server.level.ServerLevel; +import net.minecraft.tags.BiomeTags; import net.minecraft.util.RandomSource; import net.minecraft.world.level.Level; import net.minecraft.world.level.LevelAccessor; @@ -43,7 +44,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 +52,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.getBiome(newPos).is(BiomeTags.INCREASED_FIRE_BURNOUT); 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 +105,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/ValkyrienSkiesModFabric.kt b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ValkyrienSkiesModFabric.kt index 13e5b2914..e9762703c 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 @@ -21,6 +22,7 @@ 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 import net.minecraft.world.item.Item.Properties import net.minecraft.world.level.block.Block import org.valkyrienskies.core.apigame.VSCoreFactory @@ -64,17 +66,17 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_WING = TestWingBlock ValkyrienSkiesMod.TEST_SPHERE = TestSphereBlock 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.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, @@ -115,34 +117,40 @@ class ValkyrienSkiesModFabric : ModInitializer { registerBlockAndItem("test_wing", ValkyrienSkiesMod.TEST_WING) registerBlockAndItem("test_sphere", ValkyrienSkiesMod.TEST_SPHERE) 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 ) + Registry.register( + BuiltInRegistries.CREATIVE_MODE_TAB, + ValkyrienSkiesMod.VS_CREATIVE_TAB, + ValkyrienSkiesMod.createCreativeTab() + ) + CommandRegistrationCallback.EVENT.register { dispatcher ,d, _ -> VSCommands.registerServerCommands(dispatcher) } @@ -206,14 +214,13 @@ class ValkyrienSkiesModFabric : ModInitializer { } } - private fun registerBlockAndItem(registryName: String, block: Block) { + private fun registerBlockAndItem(registryName: String, block: Block): Item { 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)) - ) + val item = BlockItem(block, Properties()) + Registry.register(BuiltInRegistries.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, registryName), item) + return item } } diff --git a/forge/gradle.properties b/forge/gradle.properties index 6b56dff03..3efbace5d 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -7,12 +7,12 @@ cloth_config_version = 8.3.103 #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-22 +flywheel_version = 0.6.10-7 +registrate_version = MC1.20-1.3.3 +cc_tweaked_version = 1.109.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.20.1-forge-1.7.5 # https://modrinth.com/mod/embeddium/versions -embeddium_version = 0.2.9+mc1.19.2 +embeddium_version = 0.2.9+mc1.20.1 diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java index fa6304a8a..7b50b3865 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java @@ -1,47 +1,47 @@ -package org.valkyrienskies.mod.forge.mixin.compat.cc_tweaked; - -import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Pseudo -@Mixin(SpeakerPosition.class) -public abstract class MixinSpeakerPosition { - @Shadow - public abstract Level level(); - - @Inject(method = "position", at = @At("RETURN"), remap = false, cancellable = true) - public void ValkyrienSkies2$position(final CallbackInfoReturnable cir) { - final Vec3 pos = cir.getReturnValue(); - final Ship ship = VSGameUtilsKt.getShipObjectManagingPos(level(), pos.x, pos.y, pos.z); - if (ship != null) { - cir.setReturnValue(VSGameUtilsKt.toWorldCoordinates(level(), pos)); - } - } - - @Redirect( - method = "withinDistance", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" - ) - ) - public double ValkyrienSkies$distanceToSqr(final Vec3 instance, final Vec3 d) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(level(), instance); - if (ship != null) { - return VSGameUtilsKt.squaredDistanceBetweenInclShips(level(), instance.x, instance.y, instance.z, d.x, d.y, - d.z); - } - - return instance.distanceToSqr(d); - } -} +//package org.valkyrienskies.mod.forge.mixin.compat.cc_tweaked; +// +//import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; +//import net.minecraft.world.level.Level; +//import net.minecraft.world.phys.Vec3; +//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.Redirect; +//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//import org.valkyrienskies.core.api.ships.Ship; +//import org.valkyrienskies.mod.common.VSGameUtilsKt; +// +//@Pseudo +//@Mixin(SpeakerPosition.class) +//public abstract class MixinSpeakerPosition { +// @Shadow +// public abstract Level level(); +// +// @Inject(method = "position", at = @At("RETURN"), remap = false, cancellable = true) +// public void ValkyrienSkies2$position(final CallbackInfoReturnable cir) { +// final Vec3 pos = cir.getReturnValue(); +// final Ship ship = VSGameUtilsKt.getShipObjectManagingPos(level(), pos.x, pos.y, pos.z); +// if (ship != null) { +// cir.setReturnValue(VSGameUtilsKt.toWorldCoordinates(level(), pos)); +// } +// } +// +// @Redirect( +// method = "withinDistance", +// at = @At( +// value = "INVOKE", +// target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" +// ) +// ) +// public double ValkyrienSkies$distanceToSqr(final Vec3 instance, final Vec3 d) { +// final Ship ship = VSGameUtilsKt.getShipManagingPos(level(), instance); +// if (ship != null) { +// return VSGameUtilsKt.squaredDistanceBetweenInclShips(level(), instance.x, instance.y, instance.z, d.x, d.y, +// d.z); +// } +// +// return instance.distanceToSqr(d); +// } +//} 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 index a5ca0bd71..b0b4da969 100644 --- 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 @@ -1,116 +1,116 @@ -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; - } -} +//package org.valkyrienskies.mod.forge.mixin.compat.cc_tweaked; +// +//import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity; +//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 TurtleBlockEntity getOwner(); +// +// @Shadow +// public abstract void setOwner(TurtleBlockEntity 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 TurtleBlockEntity 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 = BlockPos.containing(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 index 4798d7249..422a245f4 100644 --- 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 @@ -1,57 +1,58 @@ -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()); - } -} +//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 index f623cc254..1dbb0e7c1 100644 --- 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 @@ -1,41 +1,41 @@ -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(); - } -} +//package org.valkyrienskies.mod.forge.mixin.compat.cc_tweaked; +// +//import dan200.computercraft.api.network.Packet; +//import dan200.computercraft.api.network.PacketReceiver; +//import dan200.computercraft.api.network.PacketSender; +//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 PacketReceiver shipReceiver; +// private static PacketSender 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 PacketReceiver 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/create/MixinBlocks.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinBlocks.java index 685ee1b7c..8c33c3bd6 100644 --- 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 @@ -32,11 +32,11 @@ public class MixinBlocks { ) protected BlockPos redirectBlockPosition(final Entity entity) { final Iterator ships = - VSGameUtilsKt.getShipsIntersecting(entity.level, entity.getBoundingBox()).iterator(); + 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)); + return BlockPos.containing(Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.z)); } else { return entity.blockPosition(); } @@ -52,7 +52,7 @@ protected BlockPos redirectBlockPosition(final Entity entity) { ) Vec3 redirectPosition(final Entity entity) { final Iterator ships = - VSGameUtilsKt.getShipsIntersecting(entity.level, entity.getBoundingBox()).iterator(); + VSGameUtilsKt.getShipsIntersecting(entity.level(), entity.getBoundingBox()).iterator(); if (ships.hasNext()) { return VectorConversionsMCKt.toMinecraft(ships.next().getWorldToShip() .transformPosition(VectorConversionsMCKt.toJOML(entity.position()))); 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 index 8dc7af3b2..b26c3021d 100644 --- 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 @@ -19,7 +19,7 @@ public class MixinContraptionRenderInfo { method = "beginFrame" ) private AABB redirectGetAABBForCulling(final AbstractContraptionEntity receiver) { - return VSGameUtilsKt.transformRenderAABBToWorld(((ClientLevel) receiver.level), receiver.position(), + 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 index e96a27a1d..6c2c09ca3 100644 --- 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 @@ -1,13 +1,13 @@ 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.joml.Matrix4f; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -42,7 +42,7 @@ private static void beforeSetupModelViewPartial(final Matrix4f matrix, final Mat camZ ); - matrix.multiply(modelMatrix); + matrix.mul(modelMatrix); ci.cancel(); } } @@ -56,6 +56,6 @@ private static void beforeSetupModelViewPartial(final Matrix4f matrix, final Mat ) 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); + 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 index f8e013bb0..9782855f0 100644 --- 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 @@ -28,13 +28,13 @@ public abstract class MixinSuperGlueSelectionHandler { @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; + double range = playerIn.getAttribute(ForgeMod.ENTITY_REACH.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(); + final Iterator ships = VSGameUtilsKt.getShipsIntersecting(playerIn.level(), searchAABB).iterator(); if (ships.hasNext()) { Ship ship = ships.next(); 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 index b62c9af72..87e9fb10b 100644 --- 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 @@ -2,11 +2,14 @@ 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.ChunkRenderer; import me.jellysquid.mods.sodium.client.render.chunk.RenderSectionManager; -import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass; +import me.jellysquid.mods.sodium.client.render.chunk.lists.SortedRenderLists; +import me.jellysquid.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; +import me.jellysquid.mods.sodium.client.render.viewport.CameraTransform; +import org.joml.Matrix4d; +import org.joml.Matrix4f; import org.joml.Vector3dc; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -14,20 +17,21 @@ 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; + private ChunkRenderer chunkRenderer; + + @Shadow + private SortedRenderLists renderLists; @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) { + final TerrainRenderPass pass, final double camX, final double camY, final double camZ) { RenderDevice.INSTANCE.makeActive(); @@ -44,7 +48,7 @@ private void redirectRenderLayer(final CommandList list, final ChunkRenderMatric 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())); + new CameraTransform(center.x(), center.y(), center.z())); list.close(); }); } diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/sodium/RenderSectionManagerDuck.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/sodium/RenderSectionManagerDuck.java new file mode 100644 index 000000000..f1d3e9121 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/sodium/RenderSectionManagerDuck.java @@ -0,0 +1,10 @@ +package org.valkyrienskies.mod.forge.mixin.compat.sodium; + +import java.util.WeakHashMap; +import me.jellysquid.mods.sodium.client.render.chunk.lists.ChunkRenderListIterable; +import org.valkyrienskies.core.api.ships.ClientShip; + +public interface RenderSectionManagerDuck { + WeakHashMap getShipRenderLists(); + +} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfcambiental/MixinEnvironmentalTemperatureProvider.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfcambiental/MixinEnvironmentalTemperatureProvider.java index f6a8523cb..1d99feed4 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfcambiental/MixinEnvironmentalTemperatureProvider.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfcambiental/MixinEnvironmentalTemperatureProvider.java @@ -23,15 +23,15 @@ public interface MixinEnvironmentalTemperatureProvider { static boolean calculateEnclosure(final Player player, final int radius) { // VS: Use player.blockPosition() instead of getOnPos() if getOnPos() is in a ship. BlockPos pos = player.getOnPos(); - if (VSGameUtilsKt.isBlockInShipyard(player.level, pos)) { + if (VSGameUtilsKt.isBlockInShipyard(player.level(), pos)) { pos = player.blockPosition(); } // Original method final PathNavigationRegion - region = new PathNavigationRegion(player.level, pos.above().offset(-radius, -radius, -radius), + region = new PathNavigationRegion(player.level(), pos.above().offset(-radius, -radius, -radius), pos.above().offset(radius, 400, radius)); - final Bee guineaPig = new Bee(EntityType.BEE, player.level); + final Bee guineaPig = new Bee(EntityType.BEE, player.level()); guineaPig.setPos(player.getPosition(0.0F)); guineaPig.setBaby(true); final FlyNodeEvaluator evaluator = new FlyNodeEvaluator(); diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java index 2c712438a..aae6afa18 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java @@ -22,11 +22,11 @@ public interface MixinIForgePlayer { * Include ships in server-side distance check when player interacts with a block. */ @Overwrite(remap = false) - default boolean canInteractWith(final BlockPos pos, final double padding) { + default boolean canReach(final BlockPos pos, final double padding) { if (VSGameConfig.SERVER.getEnableInteractDistanceChecks()) { - final double reach = this.self().getReachDistance() + padding; + final double reach = this.self().getEntityReach() + padding; final Vec3 eyes = this.self().getEyePosition(); - return VSGameUtilsKt.squaredDistanceBetweenInclShips(this.self().level, + return VSGameUtilsKt.squaredDistanceBetweenInclShips(this.self().level(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, @@ -44,7 +44,7 @@ default boolean isCloseEnough(final Entity entity, final double distance) { final Vec3 targetCenter = entity.getPosition(1.0F).add(0.0, (double) (entity.getBbHeight() / 2.0F), 0.0); final Optional hit = entity.getBoundingBox().clip(eye, targetCenter); return (hit.isPresent() ? - VSGameUtilsKt.squaredDistanceBetweenInclShips(this.self().level, + VSGameUtilsKt.squaredDistanceBetweenInclShips(this.self().level(), hit.get().x, hit.get().y, hit.get().z, eye.x, eye.y, eye.z) : this.self().distanceToSqr(entity)) < distance * distance; } else { 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 97b70494c..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 @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.forge.mixin.world.level.block; -import java.util.Random; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; import net.minecraft.server.level.ServerLevel; @@ -44,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); @@ -52,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); @@ -105,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/ValkyrienSkiesModForge.kt b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ValkyrienSkiesModForge.kt index d52dbf13f..2d2209179 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 @@ -2,8 +2,8 @@ package org.valkyrienskies.mod.forge.common import net.minecraft.commands.Commands.CommandSelection.ALL import net.minecraft.commands.Commands.CommandSelection.INTEGRATED +import net.minecraft.core.registries.Registries import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerPlayerGameMode import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.MobCategory import net.minecraft.world.item.BlockItem @@ -18,12 +18,9 @@ import net.minecraftforge.client.event.RegisterKeyMappingsEvent import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.RegisterCommandsEvent import net.minecraftforge.event.TagsUpdatedEvent -import net.minecraftforge.event.entity.player.PlayerInteractEvent -import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent import net.minecraftforge.fml.loading.FMLEnvironment import net.minecraftforge.registries.DeferredRegister @@ -35,6 +32,7 @@ import org.valkyrienskies.core.impl.config.VSCoreConfig import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.client.VSPhysicsEntityRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod +import org.valkyrienskies.mod.common.ValkyrienSkiesMod.MOD_ID import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestFlapBlock import org.valkyrienskies.mod.common.block.TestHingeBlock @@ -79,7 +77,7 @@ class ValkyrienSkiesModForge { val vsCore = if (isClient) { VSCoreFactory.instance.newVsCoreClient(ForgeHooksImpl) } else { - org.valkyrienskies.core.apigame.VSCoreFactory.instance.newVsCoreServer(ForgeHooksImpl) + VSCoreFactory.instance.newVsCoreServer(ForgeHooksImpl) } VSForgeNetworking.registerPacketHandlers(vsCore.hooks) @@ -121,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 }) } SHIP_CREATOR_SMALLER_ITEM_REGISTRY = ITEMS.register("ship_creator_smaller") { ShipCreatorItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), { VSGameConfig.SERVER.miniShipSize }, { VSGameConfig.SERVER.minScaling } ) @@ -137,7 +135,7 @@ class ValkyrienSkiesModForge { PHYSICS_ENTITY_CREATOR_ITEM_REGISTRY = ITEMS.register("physics_entity_creator") { PhysicsEntityCreatorItem( - Properties().tab(CreativeModeTab.TAB_MISC), + Properties(), ) } @@ -160,10 +158,16 @@ 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) } + + val deferredRegister = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MOD_ID); + deferredRegister.register("general") { + ValkyrienSkiesMod.createCreativeTab() + } + deferredRegister.register(modBus) } private fun registerResourceManagers(event: AddReloadListenerEvent) { @@ -184,7 +188,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/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 647a06f8d..02da34610 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -3,10 +3,6 @@ "package": "org.valkyrienskies.mod.forge.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ - "compat.cc_tweaked.MixinSpeakerPosition", - "compat.cc_tweaked.MixinTurtleBrain", - "compat.cc_tweaked.MixinTurtleMoveCommand", - "compat.cc_tweaked.MixinWirelessNetwork", "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", "compat.create.MixinControlledContraptionEntity", diff --git a/gradle.properties b/gradle.properties index 2b0ec5220..f892d36ac 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,29 +1,29 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G -minecraft_version=1.19.2 +minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge -archives_base_name=valkyrienskies-119 +archives_base_name=valkyrienskies-120 mod_version=2.1.1-beta.3 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ -architectury_version=6.5.85 +architectury_version=9.1.12 # https://fabricmc.net/develop/ fabric_loader_version=0.14.24 # https://fabricmc.net/develop/ -fabric_api_version=0.76.1+1.19.2 +fabric_api_version=0.90.7+1.20.1 # https://files.minecraftforge.net/net/minecraftforge/forge/ -forge_version=1.19.2-43.3.0 +forge_version=1.20.1-47.2.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-d-build.1161+mc1.20.1 # https://github.com/Fabricators-of-Create/Create/blob/mc1.19/fabric/dev/gradle.properties flywheel_version_fabric=0.6.9-6 -# https://modrinth.com/mod/create-big-cannons/version/ +# https://modrinth.com/mod/create-big-cannons/versions createbigcannons_version= 0.5.2.a vs_core_version=1.1.0+f2a6aaad81 From 17ee0c92b2fcad75fbdcfd941dae27d4837c7a82 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Thu, 16 Nov 2023 21:22:51 +0100 Subject: [PATCH 078/156] items actually init --- .../valkyrienskies/mod/common/ValkyrienSkiesMod.kt | 12 ++++-------- .../mod/forge/common/ValkyrienSkiesModForge.kt | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt index 55163462f..d14b0ee8e 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -28,13 +28,9 @@ object ValkyrienSkiesMod { const val MOD_ID = "valkyrienskies" lateinit var TEST_CHAIR: Block - lateinit var TEST_CHAIR_ITEM: Item lateinit var TEST_HINGE: Block - lateinit var TEST_HINGE_ITEM: Item lateinit var TEST_FLAP: Block - lateinit var TEST_FLAP_ITEM: Item lateinit var TEST_WING: Block - lateinit var TEST_WING_ITEM: Item lateinit var TEST_SPHERE: Block lateinit var SHIP_CREATOR_ITEM: Item lateinit var SHIP_ASSEMBLER_ITEM: Item @@ -74,10 +70,10 @@ object ValkyrienSkiesMod { .title(Component.translatable("itemGroup.valkyrienSkies")) .icon { ItemStack(SHIP_CREATOR_ITEM) } .displayItems { _, output -> - output.accept(TEST_CHAIR_ITEM) - output.accept(TEST_HINGE_ITEM) - output.accept(TEST_FLAP_ITEM) - output.accept(TEST_WING_ITEM) + output.accept(TEST_CHAIR.asItem()) + output.accept(TEST_HINGE.asItem()) + output.accept(TEST_FLAP.asItem()) + output.accept(TEST_WING.asItem()) output.accept(SHIP_CREATOR_ITEM) output.accept(SHIP_ASSEMBLER_ITEM) output.accept(SHIP_CREATOR_ITEM_SMALLER) 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 2d2209179..4e76cef24 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 @@ -7,7 +7,6 @@ import net.minecraft.resources.ResourceLocation 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 import net.minecraft.world.item.Item.Properties import net.minecraft.world.level.block.Block From 47d4fcc862bb66772ef25372ccf53dcfc494049c Mon Sep 17 00:00:00 2001 From: mrsterner Date: Thu, 16 Nov 2023 23:41:49 +0100 Subject: [PATCH 079/156] clokwork thingy --- .../create/entity/MixinAbstractContraptionEntity.java | 8 ++++++++ .../create/MixinAbstractContraptionEntityDuck.java | 4 ++++ gradle.properties | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) 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 index ea077730b..91da2aaae 100644 --- 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 @@ -7,6 +7,7 @@ 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.actors.seat.SeatEntity; import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; @@ -60,6 +61,13 @@ 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"); 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 index 2bd8894bf..b7eca7b8b 100644 --- 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 @@ -1,5 +1,9 @@ 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/gradle.properties b/gradle.properties index 2b0ec5220..27e0fa6c0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.19.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-119 -mod_version=2.1.1-beta.3 +mod_version=2.1.2 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ From 3e440e1c7db4f0036e1e2bac7e5a013e95db6bd6 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Thu, 16 Nov 2023 23:50:48 +0100 Subject: [PATCH 080/156] clockwork thingy --- .../create/entity/MixinAbstractContraptionEntity.java | 9 +++++++++ .../create/MixinAbstractContraptionEntityDuck.java | 4 ++++ 2 files changed, 13 insertions(+) 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 index 3cf9b394f..257586982 100644 --- 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 @@ -7,6 +7,7 @@ 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.actors.seat.SeatEntity; import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; @@ -60,6 +61,11 @@ public MixinAbstractContraptionEntity(EntityType entityType, Level level) { super(entityType, level); } + @Override + public StructureTransform getStructureTransform() { + return makeStructureTransform(); + } + @Unique private static final Logger LOGGER = LogManager.getLogger("Clockwork.MixinAbstractContraptionEntity"); @@ -190,6 +196,9 @@ private void redirectToGlobalVector(Vec3 localVec, final float partialTicks, fin @Shadow protected abstract void onContraptionStalled(); + @Shadow + protected abstract StructureTransform makeStructureTransform(); + @Inject(method = "tickActors", at = @At("HEAD"), cancellable = true, remap = false) private void preTickActors(final CallbackInfo ci) { ci.cancel(); 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 index 2bd8894bf..b7eca7b8b 100644 --- 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 @@ -1,5 +1,9 @@ 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(); } From 2c49c70bf759dfcd1535d7550f36e807fbd0cbb7 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Fri, 17 Nov 2023 10:59:48 +0100 Subject: [PATCH 081/156] clockwork thingy --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index f892d36ac..6111de22c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-120 -mod_version=2.1.1-beta.3 +mod_version=2.1.3 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ From 21ee5648c0b16600d1bfba26168d5578340340fd Mon Sep 17 00:00:00 2001 From: mrsterner Date: Fri, 17 Nov 2023 11:16:23 +0100 Subject: [PATCH 082/156] merge conflict misses --- .../valkyrienskies/mod/mixin/server/world/MixinChunkMap.java | 2 +- .../org/valkyrienskies/mod/common/item/ShipCreatorItem.kt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java index 982aac48e..34e0d47c1 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java @@ -5,8 +5,8 @@ import java.util.Iterator; import java.util.List; import java.util.Set; -import java.util.concurrent.CompletableFuture; import java.util.function.Supplier; +import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt index c70884fef..95e0e8afe 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt @@ -2,7 +2,6 @@ package org.valkyrienskies.mod.common.item import net.minecraft.Util import net.minecraft.network.chat.Component -import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.InteractionResult import net.minecraft.world.item.Item From f027d53143359f24132f5e202b7d6af7a338bc77 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Fri, 17 Nov 2023 12:25:12 +0100 Subject: [PATCH 083/156] merge conflict misses --- .../mixin/mod_compat/create/accessors/Matrix3dAccessor.java | 4 ++-- .../create/entity/MixinAbstractContraptionEntity.java | 3 +-- .../kotlin/org/valkyrienskies/mod/compat/CreateConversions.kt | 3 +-- common/src/main/resources/valkyrienskies-common.mixins.json | 2 -- fabric/gradle.properties | 2 +- .../mixin/compat/cc_restitched/MixinSpeakerPosition.java | 3 +-- .../mixin/compat/cc_restitched/MixinTurtleMoveCommand.java | 4 ++-- .../forge/mixin/compat/create/client/MixinFlwContraption.java | 4 ++-- .../mod/forge/mixin/compat/create/client/MixinValueBox.java | 4 ++-- .../forge/mixin/compat/tis3d/MixinInfraredPacketEntity.java | 4 ++-- .../mod/forge/mixin/compat/tis3d/MixinRenderContextImpl.java | 4 ++-- 11 files changed, 16 insertions(+), 21 deletions(-) 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 index d9e0018be..7e7c54995 100644 --- 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 @@ -1,6 +1,6 @@ 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; @@ -34,4 +34,4 @@ public interface Matrix3dAccessor { @Accessor("m22") double getM22(); } -*/ + 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 index 257586982..c78caa995 100644 --- 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 @@ -320,8 +320,7 @@ private void postTick(final CallbackInfo ci) { @Override public Matrix4dc computeContraptionWingTransform() { final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); - final Matrix3d rotationMatrix = - CreateConversionsKt.toJOML(thisAsAbstractContraptionEntity.getRotationState().asMatrix()); + final Matrix3d rotationMatrix = CreateConversionsKt.toJOML(thisAsAbstractContraptionEntity.getRotationState().asMatrix()); final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.getAnchorVec()); return new Matrix4d(rotationMatrix).setTranslation(pos); } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateConversions.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateConversions.kt index 6b34056b0..dff475f40 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateConversions.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateConversions.kt @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.compat -/* import org.joml.Matrix3d import org.valkyrienskies.mod.mixin.mod_compat.create.accessors.Matrix3dAccessor @@ -12,4 +11,4 @@ fun com.simibubi.create.foundation.collision.Matrix3d.toJOML(): Matrix3d { accessor.m20, accessor.m21, accessor.m22 ) } -*/ + diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index a69c1b4e7..c0187f86e 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -48,7 +48,6 @@ "feature.shipyard_entities.MixinTransientEntitySectionManager", "feature.spawn_player_on_ship.MixinServerGamePacketListenerImpl", "feature.tick_ship_chunks.MixinChunkMap", - "feature.water_in_ships_entity.MixinEntity", "feature.world_border.MixinLevel", "feature.world_border.MixinWorldBorder", "mod_compat.create.IMixinDeployerHandler", @@ -87,7 +86,6 @@ "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.MixinMinecraftServer", "server.MixinPlayerList", diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 10f60d1be..765de32ce 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -27,7 +27,7 @@ no_indium_version=1.1.0+1.20 sodium_version = mc1.20-0.4.10 # https://modrinth.com/mod/cc-tweaked/version/Uq4DlqWv -cc_tweaked_version = 1.105.0 +cc_tweaked_version = 1.109.0 kotlin_fabric_version = 1.10.10+kotlin.1.9.10 diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java index 22202c555..bc9435367 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java @@ -1,6 +1,6 @@ package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; -/* + import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; @@ -47,4 +47,3 @@ public abstract class MixinSpeakerPosition { return instance.distanceToSqr(d); } } -*/ diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java index fb49d3a8b..a33ae1e57 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java @@ -1,6 +1,6 @@ package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; -/* + import dan200.computercraft.api.turtle.TurtleCommandResult; import dan200.computercraft.shared.turtle.core.TurtleMoveCommand; import dan200.computercraft.shared.turtle.core.TurtlePlayer; @@ -56,4 +56,4 @@ private static Vector3d getShipPosFromWorldPos(final Level world, final BlockPos return new Vector3d(position.getX(), position.getY(), position.getZ()); } } -*/ + 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 index 0f632788e..61db03642 100644 --- 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 @@ -1,6 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create.client; -/* + import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.simibubi.create.content.contraptions.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.Contraption; @@ -60,4 +60,4 @@ private AABB transformLightboxToWorld(final AABB aabb, final double negCamX, fin 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/MixinValueBox.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java index 999de85d4..2c842d2f2 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java @@ -1,6 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create.client; -/* + import com.mojang.blaze3d.vertex.PoseStack; import com.simibubi.create.foundation.blockEntity.behaviour.ValueBox; import org.spongepowered.asm.mixin.Mixin; @@ -22,4 +22,4 @@ public void redirectTranslate(final PoseStack instance, final double x, final do VSClientGameUtils.transformRenderIfInShipyard(instance, x, y, z); } } -*/ + 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 index 61f2958ec..2521ef964 100644 --- 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 @@ -1,6 +1,6 @@ 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; @@ -32,4 +32,4 @@ public class MixinInfraredPacketEntity { 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 index 024c53f5b..c00cea355 100644 --- 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 @@ -1,6 +1,6 @@ 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; @@ -40,4 +40,4 @@ public abstract class MixinRenderContextImpl { } } } -*/ + From b55add7cb3a2fb34225e12a45032e7230960d28a Mon Sep 17 00:00:00 2001 From: mrsterner Date: Fri, 17 Nov 2023 12:35:24 +0100 Subject: [PATCH 084/156] added missing mixins --- .../src/main/resources/valkyrienskies-common.mixins.json | 4 +++- .../src/main/resources/valkyrienskies-fabric.mixins.json | 9 ++++++--- .../src/main/resources/valkyrienskies-forge.mixins.json | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index c0187f86e..138fc72d2 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -113,6 +113,7 @@ "accessors.client.world.ClientChunkCacheStorageAccessor", "client.MixinCamera", "client.MixinMinecraft", + "client.gui.screens.MixinConnectScreen", "client.multiplayer.MixinClientPacketListener", "client.player.MixinLocalPlayer", "client.player.MixinPlayer", @@ -172,7 +173,8 @@ "mod_compat.sound_physics_remastered.MixinSoundPhysics", "mod_compat.vanilla_renderer.MixinLevelRendererVanilla", "mod_compat.vanilla_renderer.MixinViewAreaVanilla", - "mod_compat.vanilla_renderer.RenderChunkInfoAccessor" + "mod_compat.vanilla_renderer.RenderChunkInfoAccessor", + "realms.MixinRealmsConnect" ], "injectors": { "defaultRequire": 1 diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 04d2ec57f..c37b6fe1a 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -12,17 +12,20 @@ "compat.create.MixinControlledContraptionEntity", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", - "world.level.block.FireMixin", + "server.network.MixinServerGamePacketListenerImpl", "server.network.MixinServerPlayerGameMode", - "server.network.MixinServerGamePacketListenerImpl" + "world.level.block.FireMixin" ], "client": [ + "client.render.MixinLevelRenderer", "compat.create.client.MixinContraptionHandlerClient", "compat.create.client.MixinContraptionRenderInfo", "compat.create.client.MixinCullingBlockEntityIterator", "compat.create.client.MixinFlwContraption", "compat.create.client.MixinSuperGlueSelectionHandler", - "compat.create.client.MixinValueBox" + "compat.create.client.MixinValueBox", + "feature.duplicate_keybindings.KeyMappingAccessor", + "feature.duplicate_keybindings.MixinKeyMapping" ], "injectors": { "defaultRequire": 1 diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 02da34610..0b83f0895 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -10,6 +10,7 @@ "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", "feature.forge_interact.MixinIForgePlayer", + "feature.water_in_ships_entity.MixinEntity", "world.level.block.FireMixin" ], "client": [ From 57666867655a8ec0894c4dc148d633f4a9c92b03 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Fri, 17 Nov 2023 13:12:16 +0100 Subject: [PATCH 085/156] fix cc --- common/build.gradle | 2 - fabric/build.gradle | 9 +- .../cc_restitched/MixinSpeakerPosition.java | 98 ++++---- .../cc_restitched/MixinTurtleBrain.java | 226 +++++++++--------- .../cc_restitched/MixinTurtleMoveCommand.java | 112 ++++----- .../cc_restitched/MixinWirelessNetwork.java | 86 +++---- .../valkyrienskies-fabric.mixins.json | 4 - 7 files changed, 267 insertions(+), 270 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index 0964ac38e..301e677df 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -31,8 +31,6 @@ dependencies { modCompileOnly("net.fabricmc.fabric-api:fabric-api:${fabric_api_version}") 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}") } diff --git a/fabric/build.gradle b/fabric/build.gradle index 39224c5a5..70f11602c 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -62,7 +62,7 @@ dependencies { } // CC Restitched - modImplementation("maven.modrinth:cc-tweaked:${cc_tweaked_version}") + //modImplementation("curse.maven:cc-tweaked-282001:${cc_tweaked_version}") // Create compat modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { @@ -71,9 +71,12 @@ dependencies { 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") + //modImplementation("io.github.fabricators_of_create.Porting-Lib:Porting-Lib:$port_lib_version") + for (String module in port_lib_modules.split(",")) { + modImplementation("io.github.fabricators_of_create.Porting-Lib:$module:$port_lib_version") + } - modImplementation("me.alphamode:ForgeTags:${forge_tags_version}") + //modImplementation("me.alphamode:ForgeTags:${forge_tags_version}") modImplementation("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") modImplementation("dev.cafeteria:fake-player-api:${fake_player_api_version}") diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java index bc9435367..046ea6751 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java @@ -1,49 +1,49 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; - - -import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.api.ships.LoadedShip; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Pseudo -@Mixin(SpeakerPosition.class) -public abstract class MixinSpeakerPosition { - @Shadow - public abstract Level level(); - - @Inject(method = "position", at = @At("RETURN"), remap = false, cancellable = true) - public void ValkyrienSkies2$position(final CallbackInfoReturnable cir) { - final Vec3 pos = cir.getReturnValue(); - final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(level(), pos.x, pos.y, pos.z); - if (ship != null) { - cir.setReturnValue(VSGameUtilsKt.toWorldCoordinates(level(), pos)); - } - } - - @Redirect( - method = "withinDistance", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" - ) - ) - public double ValkyrienSkies$distanceToSqr(final Vec3 instance, final Vec3 d) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(level(), instance); - if (ship != null) { - return VSGameUtilsKt.squaredDistanceBetweenInclShips(level(), instance.x, instance.y, instance.z, d.x, d.y, - d.z); - } - - return instance.distanceToSqr(d); - } -} +//package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; +// +// +//import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; +//import net.minecraft.world.level.Level; +//import net.minecraft.world.phys.Vec3; +//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.Redirect; +//import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +//import org.valkyrienskies.core.api.ships.LoadedShip; +//import org.valkyrienskies.core.api.ships.Ship; +//import org.valkyrienskies.mod.common.VSGameUtilsKt; +// +//@Pseudo +//@Mixin(SpeakerPosition.class) +//public abstract class MixinSpeakerPosition { +// @Shadow +// public abstract Level level(); +// +// @Inject(method = "position", at = @At("RETURN"), remap = false, cancellable = true) +// public void ValkyrienSkies2$position(final CallbackInfoReturnable cir) { +// final Vec3 pos = cir.getReturnValue(); +// final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(level(), pos.x, pos.y, pos.z); +// if (ship != null) { +// cir.setReturnValue(VSGameUtilsKt.toWorldCoordinates(level(), pos)); +// } +// } +// +// @Redirect( +// method = "withinDistance", +// at = @At( +// value = "INVOKE", +// target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" +// ) +// ) +// public double ValkyrienSkies$distanceToSqr(final Vec3 instance, final Vec3 d) { +// final Ship ship = VSGameUtilsKt.getShipManagingPos(level(), instance); +// if (ship != null) { +// return VSGameUtilsKt.squaredDistanceBetweenInclShips(level(), instance.x, instance.y, instance.z, d.x, d.y, +// d.z); +// } +// +// return instance.distanceToSqr(d); +// } +//} 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 e92496411..d345e3103 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 @@ -1,115 +1,115 @@ package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; -import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity; -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 TurtleBlockEntity getOwner(); - - @Shadow - public abstract void setOwner(TurtleBlockEntity 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 - ) - private BlockPos ValkyrienSkies2$teleportToBlockPos(final BlockPos pos) { - final TurtleBlockEntity currentOwner = getOwner(); - final BlockPos oldPos = currentOwner.getBlockPos(); - 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 = BlockPos.containing(tPos.x, tPos.y, tPos.z); - return newPos; - } -} +//import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity; +//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 TurtleBlockEntity getOwner(); +// +// @Shadow +// public abstract void setOwner(TurtleBlockEntity 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 +// ) +// private BlockPos ValkyrienSkies2$teleportToBlockPos(final BlockPos pos) { +// final TurtleBlockEntity currentOwner = getOwner(); +// final BlockPos oldPos = currentOwner.getBlockPos(); +// 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 = BlockPos.containing(tPos.x, tPos.y, tPos.z); +// return newPos; +// } +//} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java index a33ae1e57..45da38805 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java @@ -1,59 +1,59 @@ package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; - -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 net.minecraft.core.BlockPos; -import net.minecraft.server.level.ServerLevel; -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"), cancellable = true) - private static void ValkyrienSkies2$canEnter( - TurtlePlayer turtlePlayer, ServerLevel world, BlockPos position, - 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()); - } -} +// +//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 net.minecraft.core.BlockPos; +//import net.minecraft.server.level.ServerLevel; +//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"), cancellable = true) +// private static void ValkyrienSkies2$canEnter( +// TurtlePlayer turtlePlayer, ServerLevel world, BlockPos position, +// 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/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java index eb6560d4b..e6082e180 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java @@ -1,45 +1,45 @@ package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; -import dan200.computercraft.api.network.Packet; -import dan200.computercraft.api.network.PacketReceiver; -import dan200.computercraft.api.network.PacketSender; -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.ModifyVariable; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Pseudo -@Mixin(WirelessNetwork.class) -public class MixinWirelessNetwork { - private static PacketReceiver shipReceiver; - private static PacketSender shipSender; - - @ModifyVariable(method = "tryTransmit", - at = @At(value = "STORE"), - name = "distanceSq", - remap = false - ) - private static double ValkyrienSkies2$distanceSq(final double original) { - final Vec3 posOnShip = shipReceiver.getPosition(); - final Vec3 posInWorld = shipSender.getPosition(); - - final double distance = - VSGameUtilsKt.squaredDistanceBetweenInclShips(shipReceiver.getLevel(), - posOnShip.x, posOnShip.y, posOnShip.z, - posInWorld.x, posInWorld.y, posInWorld.z); - - return distance; - } - - @Inject(at = @At("HEAD"), method = "tryTransmit", remap = false) - private static void ValkyrienSkies2$tryTransmit(PacketReceiver receiver, Packet packet, double range, - boolean interdimensional, CallbackInfo ci) { - shipReceiver = receiver; - shipSender = packet.sender(); - } -} +//import dan200.computercraft.api.network.Packet; +//import dan200.computercraft.api.network.PacketReceiver; +//import dan200.computercraft.api.network.PacketSender; +//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.ModifyVariable; +//import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +//import org.valkyrienskies.mod.common.VSGameUtilsKt; +// +//@Pseudo +//@Mixin(WirelessNetwork.class) +//public class MixinWirelessNetwork { +// private static PacketReceiver shipReceiver; +// private static PacketSender shipSender; +// +// @ModifyVariable(method = "tryTransmit", +// at = @At(value = "STORE"), +// name = "distanceSq", +// remap = false +// ) +// private static double ValkyrienSkies2$distanceSq(final double original) { +// final Vec3 posOnShip = shipReceiver.getPosition(); +// final Vec3 posInWorld = shipSender.getPosition(); +// +// final double distance = +// VSGameUtilsKt.squaredDistanceBetweenInclShips(shipReceiver.getLevel(), +// posOnShip.x, posOnShip.y, posOnShip.z, +// posInWorld.x, posInWorld.y, posInWorld.z); +// +// return distance; +// } +// +// @Inject(at = @At("HEAD"), method = "tryTransmit", remap = false) +// private static void ValkyrienSkies2$tryTransmit(PacketReceiver receiver, Packet packet, double range, +// boolean interdimensional, CallbackInfo ci) { +// shipReceiver = receiver; +// shipSender = packet.sender(); +// } +//} diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index c37b6fe1a..7fc83c134 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -3,10 +3,6 @@ "package": "org.valkyrienskies.mod.fabric.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ - "compat.cc_restitched.MixinSpeakerPosition", - "compat.cc_restitched.MixinTurtleBrain", - "compat.cc_restitched.MixinTurtleMoveCommand", - "compat.cc_restitched.MixinWirelessNetwork", "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", "compat.create.MixinControlledContraptionEntity", From 8171a8aa275ac6e20a64778dc43e114c912328c1 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Fri, 17 Nov 2023 15:04:32 +0100 Subject: [PATCH 086/156] your shit together fabric --- fabric/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 20079d716..ff5d98e89 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -61,7 +61,7 @@ dependencies { exclude module: "jsonschema.module.addon" } - // CC Restitched + // CC Restitchedget modImplementation("maven.modrinth:cc-restitched:${cc_restitched_version}") // Create compat @@ -73,7 +73,7 @@ dependencies { modImplementation("io.github.fabricators_of_create.Porting-Lib:Porting-Lib:$port_lib_version+$minecraft_version") - modImplementation("me.alphamode:ForgeTags:${forge_tags_version}") + //modImplementation("me.alphamode:ForgeTags:${forge_tags_version}") modImplementation("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") modImplementation("dev.cafeteria:fake-player-api:${fake_player_api_version}") From 40c42434503edffeef7ddfb557ff89ff683f3dd4 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Fri, 17 Nov 2023 20:31:53 +0100 Subject: [PATCH 087/156] get out of here joml --- forge/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/forge/build.gradle b/forge/build.gradle index 0d868dcf2..7032ac4c7 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -115,7 +115,6 @@ dependencies { forgeRuntimeLibrary include("javax.inject:javax.inject:1") { transitive = false } // JOML for Math - forgeRuntimeLibrary include("org.joml:joml:1.10.4") { transitive = false } forgeRuntimeLibrary include("org.joml:joml-primitives:1.10.0") { transitive = false } // Apache Commons Math for Linear Programming From 6f85423bfe85f04aece35b9f82d0f6d5d0e013e7 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Fri, 17 Nov 2023 20:32:17 +0100 Subject: [PATCH 088/156] get out of here joml --- forge/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/forge/build.gradle b/forge/build.gradle index 0d868dcf2..7032ac4c7 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -115,7 +115,6 @@ dependencies { forgeRuntimeLibrary include("javax.inject:javax.inject:1") { transitive = false } // JOML for Math - forgeRuntimeLibrary include("org.joml:joml:1.10.4") { transitive = false } forgeRuntimeLibrary include("org.joml:joml-primitives:1.10.0") { transitive = false } // Apache Commons Math for Linear Programming From f998b17c80bf8681f289f3160fe91b81296ce395 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Fri, 17 Nov 2023 20:32:46 +0100 Subject: [PATCH 089/156] jk get back in here joml --- forge/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/forge/build.gradle b/forge/build.gradle index 7032ac4c7..0d868dcf2 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -115,6 +115,7 @@ dependencies { forgeRuntimeLibrary include("javax.inject:javax.inject:1") { transitive = false } // JOML for Math + forgeRuntimeLibrary include("org.joml:joml:1.10.4") { transitive = false } forgeRuntimeLibrary include("org.joml:joml-primitives:1.10.0") { transitive = false } // Apache Commons Math for Linear Programming From cc41f27b0224bfe8d76f45c8d719d2e849f1edf1 Mon Sep 17 00:00:00 2001 From: mrsterner Date: Fri, 17 Nov 2023 23:41:12 +0100 Subject: [PATCH 090/156] im become death destroyer of joml --- forge/build.gradle | 12 ++++++++++-- gradle.properties | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index 7032ac4c7..368b8faff 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -85,37 +85,45 @@ dependencies { include(modImplementation("me.shedaniel.cloth:cloth-config-forge:${cloth_config_version}")) // Shade vs-core - implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") + implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}"){ + exclude group: 'org.joml', module: 'joml' + } forgeRuntimeLibrary shadowCommon("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") { + exclude group: 'org.joml', module: 'joml' transitive = false } // region Manually include every single dependency of vs-core (total meme) forgeRuntimeLibrary include("org.valkyrienskies.core:api:${rootProject.vs_core_version}") { + exclude group: 'org.joml', module: 'joml' transitive = false } forgeRuntimeLibrary shadowCommon("org.valkyrienskies.core:api-game:${rootProject.vs_core_version}") { + exclude group: 'org.joml', module: 'joml' transitive = false } forgeRuntimeLibrary include("org.valkyrienskies.core:util:${rootProject.vs_core_version}") { + exclude group: 'org.joml', module: 'joml' transitive = false } forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+10c94b01e2") { + exclude group: 'org.joml', module: 'joml' transitive = false } forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+94304c13aa") { + exclude group: 'org.joml', module: 'joml' transitive = false } forgeRuntimeLibrary include("javax.inject:javax.inject:1") { transitive = false } // JOML for Math - forgeRuntimeLibrary include("org.joml:joml-primitives:1.10.0") { transitive = false } + forgeRuntimeLibrary include("org.joml:joml-primitives:1.10.0") // Apache Commons Math for Linear Programming forgeRuntimeLibrary include("org.apache.commons:commons-math3:3.6.1") { transitive = false } diff --git a/gradle.properties b/gradle.properties index 6111de22c..f6bf0becc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-120 -mod_version=2.1.3 +mod_version=2.1.4 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ From 83894b973db82834b40d91267b3444a74af49d0f Mon Sep 17 00:00:00 2001 From: mrsterner Date: Mon, 20 Nov 2023 13:23:12 +0100 Subject: [PATCH 091/156] im become death destroyer of joml --- .../mod/mixin/mod_compat/create/entity/MixinSeatEntity.java | 2 +- common/src/main/resources/valkyrienskies-common.mixins.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) 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 index 9f73c8afc..6e894f544 100644 --- 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 @@ -23,7 +23,7 @@ public MixinSeatEntity(final EntityType entityType, final Level level) { */ @Overwrite public @NotNull Vec3 getDismountLocationForPassenger(final @NotNull LivingEntity livingEntity) { - if (VSGameUtilsKt.isBlockInShipyard(level(), position()) && VSGameUtilsKt.getShipManagingPos(level, position()) == null) { + 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(); } diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 605fa7734..0c1e40ed0 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -27,7 +27,6 @@ "feature.commands.MixinCommandSourceStack", "feature.conduit_fix.ConduitMixin", "feature.container_distance_check.MixinContainer", - "feature.container_distance_check.MixinRandomizableContainerBlockEntity", "feature.dismount_dead_entities.MixinLivingEntity", "feature.dispensers.MixinDefaultDispenseItemBehavior", "feature.distance_replace.MixinEntity", From c2e8c77b4f9017cae26f4492b606a5b21b647bc0 Mon Sep 17 00:00:00 2001 From: MrSterner <32911664+mrsterner@users.noreply.github.com> Date: Thu, 30 Nov 2023 22:25:26 +0100 Subject: [PATCH 092/156] fixed create valuebox rendering on ships (#637) --- .../create/client/MixinValueBox.java | 38 +++++++++++++++++++ .../mod/common/VSClientGameUtils.kt | 5 +++ .../valkyrienskies-common.mixins.json | 1 + .../compat/create/client/MixinValueBox.java | 25 ------------ .../valkyrienskies-fabric.mixins.json | 3 +- .../compat/create/client/MixinValueBox.java | 23 ----------- .../valkyrienskies-forge.mixins.json | 1 - 7 files changed, 45 insertions(+), 51 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinValueBox.java delete mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java delete mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java 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 new file mode 100644 index 000000000..acd4792f1 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinValueBox.java @@ -0,0 +1,38 @@ +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/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt index 090da4119..116d3658c 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt @@ -33,6 +33,11 @@ object VSClientGameUtils { } } + @JvmStatic + fun getClientShip(offsetX: Double, offsetY: Double, offsetZ: Double): ClientShip? { + return Minecraft.getInstance().level?.getShipObjectManagingPos(offsetX, offsetY, offsetZ) + } + /** * Modify the last transform of [poseStack] to be the following: * diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index d91a6d85b..9c5d41cef 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -75,6 +75,7 @@ "mod_compat.create.blockentity.MixinCrushingWheelControllerTileEntity", "mod_compat.create.blockentity.MixinEjectorTileEntity", "mod_compat.create.blockentity.MixinEncasedFanTileEntity", + "mod_compat.create.client.MixinValueBox", "mod_compat.create.entity.MixinAbstractContraptionEntity", "mod_compat.create.entity.MixinCarriageContraptionEntity", "mod_compat.create.entity.MixinControlledContraptionEntity", diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java deleted file mode 100644 index b946ce720..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.foundation.blockEntity.behaviour.ValueBox; -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(ValueBox.class) -public class MixinValueBox { - - @Redirect( - method = "render", - at = @At( - value = "INVOKE", - target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V" - ), - require = 0 - ) - public void redirectTranslate(final PoseStack instance, final double x, final double y, final double z) { - VSClientGameUtils.transformRenderIfInShipyard(instance, x, y, z); - } - -} diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 04d2ec57f..c646cb2f7 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -21,8 +21,7 @@ "compat.create.client.MixinContraptionRenderInfo", "compat.create.client.MixinCullingBlockEntityIterator", "compat.create.client.MixinFlwContraption", - "compat.create.client.MixinSuperGlueSelectionHandler", - "compat.create.client.MixinValueBox" + "compat.create.client.MixinSuperGlueSelectionHandler" ], "injectors": { "defaultRequire": 1 diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java deleted file mode 100644 index cf0f8f2bb..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.foundation.blockEntity.behaviour.ValueBox; -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(ValueBox.class) -public class MixinValueBox { - @Redirect( - method = "render", - at = @At( - value = "INVOKE", - target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V" - ), - require = 0 - ) - public void redirectTranslate(final PoseStack instance, final double x, final double y, final double z) { - VSClientGameUtils.transformRenderIfInShipyard(instance, x, y, z); - } -} diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 34deb5e14..e029a1dcf 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -23,7 +23,6 @@ "compat.create.client.MixinContraptionRenderInfo", "compat.create.client.MixinFlwContraption", "compat.create.client.MixinSuperGlueSelectionHandler", - "compat.create.client.MixinValueBox", "compat.sodium.MixinRenderSectionManager", "compat.tis3d.MixinCasingTileEntityRender", "compat.tis3d.MixinRenderContextImpl" From be944c11b47bf0e2503c70711209ee7a2f7d8eb1 Mon Sep 17 00:00:00 2001 From: MrSterner <32911664+mrsterner@users.noreply.github.com> Date: Thu, 30 Nov 2023 22:26:23 +0100 Subject: [PATCH 093/156] 1.20.1/main/fixed create valuebox rendering on ships (#638) * fixed create valuebox rendering on ships --- .../MixinLivingEntity.java | 6 +-- .../create/client/MixinValueBox.java | 38 +++++++++++++++++++ .../mod_compat/create/pr/MixinSeatBlock.java | 4 +- .../mod/common/VSClientGameUtils.kt | 5 +++ .../valkyrienskies-common.mixins.json | 1 + fabric/build.gradle | 5 +-- .../compat/create/client/MixinValueBox.java | 25 ------------ .../valkyrienskies-fabric.mixins.json | 1 - .../compat/create/client/MixinValueBox.java | 25 ------------ .../valkyrienskies-forge.mixins.json | 1 - 10 files changed, 51 insertions(+), 60 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinValueBox.java delete mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java delete mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/dismount_dead_entities/MixinLivingEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/dismount_dead_entities/MixinLivingEntity.java index 015a452d1..979eecbd8 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/dismount_dead_entities/MixinLivingEntity.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/dismount_dead_entities/MixinLivingEntity.java @@ -32,9 +32,9 @@ public MixinLivingEntity(final EntityType entityType, final Level level) { */ @Inject(method = "dismountVehicle", at = @At("HEAD"), cancellable = true) private void preDismountVehicle(final Entity entity, final CallbackInfo ci) { - if (!this.isRemoved() && entity.isRemoved() || this.level.getBlockState(entity.blockPosition()).is(BlockTags.PORTALS)) { - if (VSGameUtilsKt.isBlockInShipyard(level, entity.position())) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(level, entity.position()); + if (!this.isRemoved() && entity.isRemoved() || this.level().getBlockState(entity.blockPosition()).is(BlockTags.PORTALS)) { + if (VSGameUtilsKt.isBlockInShipyard(level(), entity.position())) { + final Ship ship = VSGameUtilsKt.getShipManagingPos(level(), entity.position()); if (ship != null) { final Vector3dc transformedPos = ship.getTransform().getShipToWorld().transformPosition(VectorConversionsMCKt.toJOML(entity.position())); final double d = Math.max(this.getY(), transformedPos.y()); 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 new file mode 100644 index 000000000..acd4792f1 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinValueBox.java @@ -0,0 +1,38 @@ +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/pr/MixinSeatBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/pr/MixinSeatBlock.java index 5da93a395..50fb1f488 100644 --- 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 @@ -51,11 +51,11 @@ private BlockPos wrapBlockPosInUpdateEntityAfterFallOn( if (draggingInformation.isEntityBeingDraggedByAShip()) { final Long shipStandingOnId = draggingInformation.getLastShipStoodOn(); if (shipStandingOnId != null) { - final Ship ship = VSGameUtilsKt.getShipObjectWorld(entity.level).getLoadedShips().getById(shipStandingOnId); + 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 BlockPos.containing(posInShip.x(), posInShip.y(), posInShip.z()); } } } 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 1ae005c71..2e9943a58 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt @@ -32,6 +32,11 @@ object VSClientGameUtils { } } + @JvmStatic + fun getClientShip(offsetX: Double, offsetY: Double, offsetZ: Double): ClientShip? { + return Minecraft.getInstance().level?.getShipObjectManagingPos(offsetX, offsetY, offsetZ) + } + /** * Modify the last transform of [poseStack] to be the following: * diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 0c1e40ed0..9bd0a09f9 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -76,6 +76,7 @@ "mod_compat.create.blockentity.MixinCrushingWheelControllerTileEntity", "mod_compat.create.blockentity.MixinEjectorTileEntity", "mod_compat.create.blockentity.MixinEncasedFanTileEntity", + "mod_compat.create.client.MixinValueBox", "mod_compat.create.entity.MixinAbstractContraptionEntity", "mod_compat.create.entity.MixinCarriageContraptionEntity", "mod_compat.create.entity.MixinControlledContraptionEntity", diff --git a/fabric/build.gradle b/fabric/build.gradle index 2ac0f49cc..0f2c84234 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -58,13 +58,12 @@ dependencies { exclude module: "netty-buffer" exclude module: "fastutil" exclude module: "kotlin-stdlib-jdk8" // Don't shade kotlin-stdlib-jdk8, even though vs-core depends on it -<<<<<<<<< Temporary merge branch 1 + exclude group: "com.google.guava" } // CC Restitched - modImplementation("curse.maven:cc-restitched-462672:3908334") -========= + modImplementation("curse.maven:cc-restitched-462672:3908334"){ exclude module: "jsonschema.module.addon" } diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java deleted file mode 100644 index b946ce720..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create.client; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.foundation.blockEntity.behaviour.ValueBox; -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(ValueBox.class) -public class MixinValueBox { - - @Redirect( - method = "render", - at = @At( - value = "INVOKE", - target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V" - ), - require = 0 - ) - public void redirectTranslate(final PoseStack instance, final double x, final double y, final double z) { - VSClientGameUtils.transformRenderIfInShipyard(instance, x, y, z); - } - -} diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 7fc83c134..53773d791 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -19,7 +19,6 @@ "compat.create.client.MixinCullingBlockEntityIterator", "compat.create.client.MixinFlwContraption", "compat.create.client.MixinSuperGlueSelectionHandler", - "compat.create.client.MixinValueBox", "feature.duplicate_keybindings.KeyMappingAccessor", "feature.duplicate_keybindings.MixinKeyMapping" ], diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java deleted file mode 100644 index 2c842d2f2..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinValueBox.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create.client; - - -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.foundation.blockEntity.behaviour.ValueBox; -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(ValueBox.class) -public class MixinValueBox { - @Redirect( - method = "render", - at = @At( - value = "INVOKE", - target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V" - ), - require = 0 - ) - public void redirectTranslate(final PoseStack instance, final double x, final double y, final double z) { - VSClientGameUtils.transformRenderIfInShipyard(instance, x, y, z); - } -} - diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 0b83f0895..8446ba7f7 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -19,7 +19,6 @@ "compat.create.client.MixinContraptionRenderInfo", "compat.create.client.MixinFlwContraption", "compat.create.client.MixinSuperGlueSelectionHandler", - "compat.create.client.MixinValueBox", "compat.sodium.MixinRenderSectionManager", "compat.tis3d.MixinCasingTileEntityRender", "compat.tis3d.MixinRenderContextImpl" From 4a0b4b3cf60a05694a611b42b0534bb81db743f6 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sat, 23 Dec 2023 06:26:21 -0700 Subject: [PATCH 094/156] Moved vs maven to the bottom to fix gradle not working --- build.gradle | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/build.gradle b/build.gradle index 22d0e5286..b21a5193d 100644 --- a/build.gradle +++ b/build.gradle @@ -93,16 +93,6 @@ subprojects { includeModule "curse.maven", "kotlinforforge-351264" } } - maven { - name = "Valkyrien Skies Internal" - url = project.vs_maven_url ?: 'https://maven.valkyrienskies.org' - if (project.vs_maven_username && project.vs_maven_password) { - credentials { - username = project.vs_maven_username - password = project.vs_maven_password - } - } - } if (!project.block_external_repositories) { mavenLocal() maven { @@ -128,6 +118,16 @@ subprojects { maven { url = "https://maven.cafeteria.dev/releases" } // Fake Player API maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes } + maven { + name = "Valkyrien Skies Internal" + url = project.vs_maven_url ?: 'https://maven.valkyrienskies.org' + if (project.vs_maven_username && project.vs_maven_password) { + credentials { + username = project.vs_maven_username + password = project.vs_maven_password + } + } + } } // Remove automatically added repos From 39b8d01fbb587c64dd02e5eec85779880a6486d9 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sat, 23 Dec 2023 08:05:06 -0700 Subject: [PATCH 095/156] Changed version to 2.1.2-beta.1 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 3feb1e9f7..19d98b4c7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.19.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-119 -mod_version=2.1.2 +mod_version=2.1.2-beta.1 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ From cf2626161b3185c4e337ac3904778859727894dd Mon Sep 17 00:00:00 2001 From: MrSterner <32911664+mrsterner@users.noreply.github.com> Date: Sat, 30 Dec 2023 10:53:01 +0100 Subject: [PATCH 096/156] added a null check and fixed missing parenthesis (#651) * fixed create valuebox rendering on ships * hm forgot () * hm forgot a inject :skull: * hm forgot a inject :skull: * added back the `block_external_repositories` --- .gitignore | 1 + .../mod/mixin/client/MixinMinecraft.java | 10 ++++++++++ .../seamless_copy/MixinClientPacketListener.java | 2 +- fabric/build.gradle | 6 +++--- gradle.properties | 4 ++-- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 299156b30..e6b122f2a 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ forge*changelog.txt # Files generated for Fabric /fabric/src/generated/ +/.architectury-transformer/debug.log diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java index 424b4f52a..691fd4cda 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/MixinMinecraft.java @@ -159,4 +159,14 @@ public void deleteShipObjectWorldClient() { shipObjectWorldCopy.destroyWorld(); shipObjectWorld = null; } + + @Inject( + method = "clearLevel", + at = @At("TAIL") + ) + private void postClearLevel(final CallbackInfo ci) { + if (shipObjectWorld != null) { + deleteShipObjectWorldClient(); + } + } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java index e065d72a6..049d4369d 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/seamless_copy/MixinClientPacketListener.java @@ -63,7 +63,7 @@ private void beforeClose(final CallbackInfo ci) { cancellable = true ) private void beforeHandleLevelChunk(final ClientboundLevelChunkWithLightPacket packet, final CallbackInfo ci) { - if (chunks.queue(packet.getX(), packet.getZ(), packet, level)) { + if (level != null && chunks.queue(packet.getX(), packet.getZ(), packet, level)) { ci.cancel(); } } diff --git a/fabric/build.gradle b/fabric/build.gradle index 0f2c84234..207057909 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -63,9 +63,9 @@ dependencies { } // CC Restitched - modImplementation("curse.maven:cc-restitched-462672:3908334"){ - exclude module: "jsonschema.module.addon" - } + //modImplementation("curse.maven:cc-restitched-462672:3908334"){ + // exclude module: "jsonschema.module.addon" + //} // CC Restitched //modImplementation("curse.maven:cc-tweaked-282001:${cc_tweaked_version}") diff --git a/gradle.properties b/gradle.properties index f6bf0becc..6294a666b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-120 -mod_version=2.1.4 +mod_version=2.1.6 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ @@ -26,7 +26,7 @@ flywheel_version_fabric=0.6.9-6 # https://modrinth.com/mod/create-big-cannons/versions createbigcannons_version= 0.5.2.a -vs_core_version=1.1.0+f2a6aaad81 +vs_core_version=1.1.0+d0aa57abb9 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually kotlin.stdlib.default.dependency=false From cb72d0f763fe0877176f58c901931079384b6f52 Mon Sep 17 00:00:00 2001 From: MrSterner <32911664+mrsterner@users.noreply.github.com> Date: Sat, 30 Dec 2023 16:31:12 +0100 Subject: [PATCH 097/156] loot container dupe fix (#668) * fixed create valuebox rendering on ships * loot container dupe fix --- .../kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt b/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt index 8dfc6199c..099b846a5 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt @@ -6,6 +6,7 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.Rotation import net.minecraft.world.level.block.Rotation.NONE +import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.chunk.LevelChunk import org.valkyrienskies.core.api.ships.ServerShip @@ -40,6 +41,11 @@ fun relocateBlock( it.clearContent() } + // so loot containers dont drop its content + if (it is RandomizableContainerBlockEntity) { + it.setLootTable(null, 0) + } + tag } From 02c6c71138b0a90b7e08d083e4abc8223bad15a3 Mon Sep 17 00:00:00 2001 From: MrSterner <32911664+mrsterner@users.noreply.github.com> Date: Sat, 30 Dec 2023 16:31:23 +0100 Subject: [PATCH 098/156] loot container dupe fix (#669) * fixed create valuebox rendering on ships * hm forgot () * hm forgot a inject :skull: * hm forgot a inject :skull: * added back the `block_external_repositories` * loot container dupe fix --- .../kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt b/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt index 8dfc6199c..099b846a5 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt @@ -6,6 +6,7 @@ import net.minecraft.world.level.Level import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.Rotation import net.minecraft.world.level.block.Rotation.NONE +import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.chunk.LevelChunk import org.valkyrienskies.core.api.ships.ServerShip @@ -40,6 +41,11 @@ fun relocateBlock( it.clearContent() } + // so loot containers dont drop its content + if (it is RandomizableContainerBlockEntity) { + it.setLootTable(null, 0) + } + tag } From eace2ef186ffb042710ee63d66ad41c9369ee9c4 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sat, 30 Dec 2023 12:20:01 -0700 Subject: [PATCH 099/156] Increment version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 42b3794e2..b34061fed 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.19.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-119 -mod_version=2.1.2-beta.1 +mod_version=2.1.2-beta.2 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ From 3c80849edf4b830b245592671654bacefb343c99 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 31 Dec 2023 06:06:25 -0700 Subject: [PATCH 100/156] Fixed ValkyrienSkiesMod.PHYSICS_ENTITY_CREATOR_ITEM not being initialized on forge --- .../mod/forge/common/ValkyrienSkiesModForge.kt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) 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 76d9b64c6..921640ec3 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 @@ -3,7 +3,6 @@ package org.valkyrienskies.mod.forge.common import net.minecraft.commands.Commands.CommandSelection.ALL import net.minecraft.commands.Commands.CommandSelection.INTEGRATED import net.minecraft.resources.ResourceLocation -import net.minecraft.server.level.ServerPlayerGameMode import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.MobCategory import net.minecraft.world.item.BlockItem @@ -18,12 +17,9 @@ import net.minecraftforge.client.event.RegisterKeyMappingsEvent import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.RegisterCommandsEvent import net.minecraftforge.event.TagsUpdatedEvent -import net.minecraftforge.event.entity.player.PlayerInteractEvent -import net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent import net.minecraftforge.fml.loading.FMLEnvironment import net.minecraftforge.registries.DeferredRegister @@ -212,5 +208,6 @@ class ValkyrienSkiesModForge { ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE = PHYSICS_ENTITY_TYPE_REGISTRY.get() ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM = SHIP_ASSEMBLER_ITEM_REGISTRY.get() ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE = TEST_HINGE_BLOCK_ENTITY_TYPE_REGISTRY.get() + ValkyrienSkiesMod.PHYSICS_ENTITY_CREATOR_ITEM = PHYSICS_ENTITY_CREATOR_ITEM_REGISTRY.get() } } From 6ba8a8b1140f0b6a6259b61ac22be6300e5ed736 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 31 Dec 2023 06:22:27 -0700 Subject: [PATCH 101/156] Fixed forge not working --- .../mod/common/ValkyrienSkiesMod.kt | 1 + .../mod/common/item/ShipCreatorItem.kt | 1 - .../mod/forge/common/ValkyrienSkiesModForge.kt | 18 +++++++++--------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt index d14b0ee8e..0fb4029ba 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -77,6 +77,7 @@ object ValkyrienSkiesMod { output.accept(SHIP_CREATOR_ITEM) output.accept(SHIP_ASSEMBLER_ITEM) output.accept(SHIP_CREATOR_ITEM_SMALLER) + output.accept(PHYSICS_ENTITY_CREATOR_ITEM) } .build() } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt index 95e0e8afe..b4ad34e82 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ShipCreatorItem.kt @@ -1,6 +1,5 @@ package org.valkyrienskies.mod.common.item -import net.minecraft.Util import net.minecraft.network.chat.Component import net.minecraft.server.level.ServerLevel import net.minecraft.world.InteractionResult 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 354982fb0..58faea254 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 @@ -20,7 +20,6 @@ import net.minecraftforge.event.TagsUpdatedEvent import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus -import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent import net.minecraftforge.fml.event.lifecycle.FMLLoadCompleteEvent import net.minecraftforge.fml.loading.FMLEnvironment import net.minecraftforge.registries.DeferredRegister @@ -53,12 +52,12 @@ import org.valkyrienskies.mod.common.item.ShipAssemblerItem import org.valkyrienskies.mod.common.item.ShipCreatorItem import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig -@Mod(ValkyrienSkiesMod.MOD_ID) +@Mod(MOD_ID) class ValkyrienSkiesModForge { - private val BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, ValkyrienSkiesMod.MOD_ID) - private val ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, ValkyrienSkiesMod.MOD_ID) - private val ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, ValkyrienSkiesMod.MOD_ID) - private val BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, ValkyrienSkiesMod.MOD_ID) + private val BLOCKS = DeferredRegister.create(ForgeRegistries.BLOCKS, MOD_ID) + private val ITEMS = DeferredRegister.create(ForgeRegistries.ITEMS, MOD_ID) + private val ENTITIES = DeferredRegister.create(ForgeRegistries.ENTITY_TYPES, MOD_ID) + private val BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITY_TYPES, MOD_ID) private val TEST_CHAIR_REGISTRY: RegistryObject private val TEST_HINGE_REGISTRY: RegistryObject private val TEST_FLAP_REGISTRY: RegistryObject @@ -144,7 +143,7 @@ class ValkyrienSkiesModForge { ::ShipMountingEntity, MobCategory.MISC ).sized(.3f, .3f) - .build(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_mounting_entity").toString()) + .build(ResourceLocation(MOD_ID, "ship_mounting_entity").toString()) } PHYSICS_ENTITY_TYPE_REGISTRY = ENTITIES.register("vs_physics_entity") { @@ -154,7 +153,7 @@ class ValkyrienSkiesModForge { ).sized(.3f, .3f) .setUpdateInterval(1) .clientTrackingRange(10) - .build(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "vs_physics_entity").toString()) + .build(ResourceLocation(MOD_ID, "vs_physics_entity").toString()) } SHIP_ASSEMBLER_ITEM_REGISTRY = @@ -163,7 +162,7 @@ class ValkyrienSkiesModForge { BlockEntityType.Builder.of(::TestHingeBlockEntity, TestHingeBlock).build(null) } - val deferredRegister = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MOD_ID); + val deferredRegister = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, MOD_ID) deferredRegister.register("general") { ValkyrienSkiesMod.createCreativeTab() } @@ -216,5 +215,6 @@ class ValkyrienSkiesModForge { ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE = PHYSICS_ENTITY_TYPE_REGISTRY.get() ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM = SHIP_ASSEMBLER_ITEM_REGISTRY.get() ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE = TEST_HINGE_BLOCK_ENTITY_TYPE_REGISTRY.get() + ValkyrienSkiesMod.PHYSICS_ENTITY_CREATOR_ITEM = PHYSICS_ENTITY_CREATOR_ITEM_REGISTRY.get() } } From 72bd3df263ad03758cf4cf890c40cc18bbedd314 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 31 Dec 2023 15:09:37 -0700 Subject: [PATCH 102/156] Removed forge tags from build.gradle --- fabric/build.gradle | 1 - fabric/gradle.properties | 1 - 2 files changed, 2 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 207057909..41bee0ba4 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -82,7 +82,6 @@ dependencies { modImplementation("io.github.fabricators_of_create.Porting-Lib:$module:$port_lib_version") } - //modImplementation("me.alphamode:ForgeTags:${forge_tags_version}") modImplementation("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") modImplementation("dev.cafeteria:fake-player-api:${fake_player_api_version}") diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 765de32ce..99711d555 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -11,7 +11,6 @@ reach_entity_attributes_version=2.4.0 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L32C14-L32C14 registrate_version=1.3.62-MC1.20.1 -forge_tags_version=2.1 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L33 milk_lib_version=1.2.60 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L35 From 876f5b5f2475f4e252a63e6778b4fde9cad11787 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 31 Dec 2023 15:22:02 -0700 Subject: [PATCH 103/156] Disabled indium in dev environment --- fabric/build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 41bee0ba4..2a66d659b 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -41,7 +41,8 @@ dependencies { include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}")) modImplementation("maven.modrinth:sodium:${sodium_version}") - modRuntimeOnly("maven.modrinth:indium:${indium_version}") + // Disable indium until we update sodium to newer versions + // modRuntimeOnly("maven.modrinth:indium:${indium_version}") modImplementation("maven.modrinth:modmenu:${modmenu_version}") // Depend on the fabric API From 93dc01c6328bda7dcfe0b4152d019797e417923a Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 31 Dec 2023 16:53:46 -0700 Subject: [PATCH 104/156] Updated cloth config on forge --- forge/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge/gradle.properties b/forge/gradle.properties index 3efbace5d..5471ecadc 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -3,7 +3,7 @@ loom.platform=forge kotlin.stdlib.default.dependency=false #Deps kotlin_version = 3.12.0 -cloth_config_version = 8.3.103 +cloth_config_version = 11.1.106 #Compat # https://github.com/Creators-of-Create/Create/wiki/Depending-on-Create From 151ecf5193fccf20a50fb0d4f0f001e4d6a16bfd Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 31 Dec 2023 17:04:22 -0700 Subject: [PATCH 105/156] Fixed creative tab name --- .../src/main/resources/assets/valkyrienskies/lang/en_us.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/main/resources/assets/valkyrienskies/lang/en_us.json b/common/src/main/resources/assets/valkyrienskies/lang/en_us.json index ddd33df22..61876437a 100644 --- a/common/src/main/resources/assets/valkyrienskies/lang/en_us.json +++ b/common/src/main/resources/assets/valkyrienskies/lang/en_us.json @@ -20,5 +20,6 @@ "command.valkyrienskies.get_ship.fail": "No ship found", "command.valkyrienskies.get_ship.only_usable_by_entities": "/vs get-ship can only be run by entities!", "tooltip.valkyrienskies.mass": "Mass", - "command.valkyrienskies.scale.success": "Scaled %d ships!" + "command.valkyrienskies.scale.success": "Scaled %d ships!", + "itemGroup.valkyrienSkies": "Valkyrien Skies" } From a8a4822dfd37f6eb1a1dc50c7e8db13c5bc81a91 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 31 Dec 2023 19:25:50 -0700 Subject: [PATCH 106/156] Fixed forge block reach being too small --- .../mixin/feature/forge_interact/MixinIForgePlayer.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java index aae6afa18..5ed417167 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/forge_interact/MixinIForgePlayer.java @@ -18,13 +18,16 @@ public interface MixinIForgePlayer { @Shadow Player self(); + @Shadow + double getBlockReach(); + /** * Include ships in server-side distance check when player interacts with a block. */ @Overwrite(remap = false) default boolean canReach(final BlockPos pos, final double padding) { if (VSGameConfig.SERVER.getEnableInteractDistanceChecks()) { - final double reach = this.self().getEntityReach() + padding; + final double reach = this.getBlockReach() + padding; final Vec3 eyes = this.self().getEyePosition(); return VSGameUtilsKt.squaredDistanceBetweenInclShips(this.self().level(), pos.getX() + 0.5, From a52f38bd68363eb4a938f5f991f92fb170abefca Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 31 Dec 2023 20:00:08 -0700 Subject: [PATCH 107/156] Fixed fabric server not working --- fabric/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 2a66d659b..888b16d0b 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -83,7 +83,7 @@ dependencies { modImplementation("io.github.fabricators_of_create.Porting-Lib:$module:$port_lib_version") } - modImplementation("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") + modImplementation("curse.maven:forge-config-api-port-fabric-547434:$config_api_id") modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") modImplementation("dev.cafeteria:fake-player-api:${fake_player_api_version}") modImplementation("io.github.tropheusj:milk-lib:${milk_lib_version}") From 39085d5cee7db4d08b065eb2792d64a1ed283634 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 31 Dec 2023 20:52:02 -0700 Subject: [PATCH 108/156] Increment version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index e096aab2a..e6d2c283f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-120 -mod_version=2.1.3-beta.1 +mod_version=2.1.3-beta.2 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ From 5eef9017066f5fcec002aa61e2ea8cf14ef90982 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 5 Jan 2024 17:57:12 -0500 Subject: [PATCH 109/156] Add credits to FluffyJenkins for Create compat --- README.md | 8 ++++++++ .../valkyrienskies/mod/mixin/mod_compat/create/README.md | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/README.md diff --git a/README.md b/README.md index c0ab5778b..5592c99ca 100644 --- a/README.md +++ b/README.md @@ -45,3 +45,11 @@ Occasionally forge will break in strange ways. When this occurs, delete all the `Error occurred during initialization of VM Could not reserve enough space for 4194304KB object heap` For patch the problem go to gradle.properties and change `org.gradle.jvmargs=-Xmx4096M` to `org.gradle.jvmargs=-Xmx1024` or `org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G` to `org.gradle.jvmargs=-Xmx1G -XX:MaxMetaspaceSize=1G` + +## Attributions + +Valkyrien Skies 2 was originally created by Triode and Rubydesic. You can check +other contributors by viewing the git history. + +The Create compatibility code was originally and largely written by [FluffyJenkins](https://github.com/FluffyJenkins/), +but the git history was clobbered when we transferred the code from Clockwork 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 new file mode 100644 index 000000000..2784f766a --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/README.md @@ -0,0 +1,8 @@ +# 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. From 21efe383e00fa41d81355d1edf11feca4fced05b Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 5 Jan 2024 17:57:12 -0500 Subject: [PATCH 110/156] Add credits to FluffyJenkins for Create compat --- README.md | 8 ++++++++ .../valkyrienskies/mod/mixin/mod_compat/create/README.md | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/README.md diff --git a/README.md b/README.md index c0ab5778b..5592c99ca 100644 --- a/README.md +++ b/README.md @@ -45,3 +45,11 @@ Occasionally forge will break in strange ways. When this occurs, delete all the `Error occurred during initialization of VM Could not reserve enough space for 4194304KB object heap` For patch the problem go to gradle.properties and change `org.gradle.jvmargs=-Xmx4096M` to `org.gradle.jvmargs=-Xmx1024` or `org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G` to `org.gradle.jvmargs=-Xmx1G -XX:MaxMetaspaceSize=1G` + +## Attributions + +Valkyrien Skies 2 was originally created by Triode and Rubydesic. You can check +other contributors by viewing the git history. + +The Create compatibility code was originally and largely written by [FluffyJenkins](https://github.com/FluffyJenkins/), +but the git history was clobbered when we transferred the code from Clockwork 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 new file mode 100644 index 000000000..2784f766a --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/README.md @@ -0,0 +1,8 @@ +# 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. From 0b8f5b6277bd413d65906ed2fcc9338f84eaa4e2 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Mon, 29 Jan 2024 12:41:39 -0500 Subject: [PATCH 111/156] Move ValueBox mixin to client (#682) Avoid crash on dedicated server --- common/src/main/resources/valkyrienskies-common.mixins.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 8aeefe907..24a97da23 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -76,7 +76,6 @@ "mod_compat.create.blockentity.MixinCrushingWheelControllerTileEntity", "mod_compat.create.blockentity.MixinEjectorTileEntity", "mod_compat.create.blockentity.MixinEncasedFanTileEntity", - "mod_compat.create.client.MixinValueBox", "mod_compat.create.entity.MixinAbstractContraptionEntity", "mod_compat.create.entity.MixinCarriageContraptionEntity", "mod_compat.create.entity.MixinControlledContraptionEntity", @@ -161,6 +160,7 @@ "mod_compat.create.client.MixinTileEntityRenderHelper", "mod_compat.create.client.MixinTrackBlockOutline", "mod_compat.create.client.MixinTrainRelocator", + "mod_compat.create.client.MixinValueBox", "mod_compat.flywheel.InstancingEngineAccessor", "mod_compat.flywheel.MixinBlockEntityInstanceManager", "mod_compat.flywheel.MixinInstanceManager", From daf123148a3e32691acc5270162df92c9bd24271 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Mon, 29 Jan 2024 12:41:46 -0500 Subject: [PATCH 112/156] Move ValueBox mixin to client (#683) Avoid crash on dedicated server --- common/src/main/resources/valkyrienskies-common.mixins.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 3a9851d19..3a6c4a24a 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -76,7 +76,6 @@ "mod_compat.create.blockentity.MixinCrushingWheelControllerTileEntity", "mod_compat.create.blockentity.MixinEjectorTileEntity", "mod_compat.create.blockentity.MixinEncasedFanTileEntity", - "mod_compat.create.client.MixinValueBox", "mod_compat.create.entity.MixinAbstractContraptionEntity", "mod_compat.create.entity.MixinCarriageContraptionEntity", "mod_compat.create.entity.MixinControlledContraptionEntity", @@ -160,6 +159,7 @@ "mod_compat.create.client.MixinTileEntityRenderHelper", "mod_compat.create.client.MixinTrackBlockOutline", "mod_compat.create.client.MixinTrainRelocator", + "mod_compat.create.client.MixinValueBox", "mod_compat.flywheel.InstancingEngineAccessor", "mod_compat.flywheel.MixinBlockEntityInstanceManager", "mod_compat.flywheel.MixinInstanceManager", From 7b6093624b8f263477ff81be88d4257a4a40cd26 Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins <31552479+FluffyJenkins@users.noreply.github.com> Date: Mon, 29 Jan 2024 17:56:20 +0000 Subject: [PATCH 113/156] Create Compat(1.19.2): Fixed track outlines and picking (#693) * Fixed track outlines on ships and fixed interaction bug when near curved track and a ship * Moved around mixins to disable track outline mixins if interactive is installed * logging --- .../ValkyrienCommonMixinConfigPlugin.java | 10 ++ .../create/client/MixinTrackBlockOutline.java | 85 ++++++----- .../trackOutlines/MixinBigOutlines.java | 92 ++++++++++++ .../trackOutlines/MixinTrackBlockOutline.java | 134 ++++++++++++++++++ .../valkyrienskies-common.mixins.json | 2 + 5 files changed, 286 insertions(+), 37 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinBigOutlines.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java 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 3bc09f14e..ba5ad1b0a 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java @@ -7,6 +7,7 @@ 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; /** @@ -72,6 +73,15 @@ 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/mod_compat/create/client/MixinTrackBlockOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java index 69d74d550..0eb6df4d8 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java @@ -1,82 +1,93 @@ package org.valkyrienskies.mod.mixin.mod_compat.create.client; import com.simibubi.create.content.trains.track.TrackBlockOutline; +import com.simibubi.create.content.trains.track.TrackBlockOutline.BezierPointSelection; import com.simibubi.create.foundation.utility.RaycastHelper; -import java.util.List; 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.joml.Vector3d; 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.LocalCapture; +import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @Mixin(TrackBlockOutline.class) public class MixinTrackBlockOutline { + + @Shadow + public static BezierPointSelection result; + @Unique + private static boolean valkyrienskies$toShip = false; @Unique - private static boolean isShip = false; + private static Ship valkyrienskies$ship; @Unique - private static BlockPos shipBlockPos; + private static Vec3 valkyrienskies$originalOrigin; @Inject( - method = "pickCurves", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" - ), locals = LocalCapture.CAPTURE_FAILHARD + method = "pickCurves", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" + ), locals = LocalCapture.CAPTURE_FAILHARD ) private static void stuff(final CallbackInfo ci, final Minecraft mc) { - if (mc.hitResult != null && mc.level != null && mc.hitResult.getType() == Type.BLOCK) { - shipBlockPos = ((BlockHitResult) mc.hitResult).getBlockPos(); - - final List - ships = VSGameUtilsKt.transformToNearbyShipsAndWorld(mc.level, shipBlockPos.getX(), shipBlockPos.getY(), - shipBlockPos.getZ(), 10); - isShip = !ships.isEmpty(); + if (mc.hitResult != null && mc.level != null && mc.player != null) { + 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(BlockPos.containing(mc.hitResult.location)).isAir(); + } else if (hitResultOnShip) { + valkyrienskies$toShip = true; + valkyrienskies$ship = + VSGameUtilsKt.getShipManagingPos(mc.level, ((BlockHitResult) mc.hitResult).getBlockPos()); + } } } @Redirect( - method = "pickCurves()V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" - ) + method = "pickCurves", + 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 (isShip) { - final List - ships = VSGameUtilsKt.transformToNearbyShipsAndWorld(instance.level, eyePos.x, eyePos.y, eyePos.z, 10); - if (ships.isEmpty()) { - return eyePos; - } - final Vector3d tempVec = ships.get(0); - return new Vec3(tempVec.x, tempVec.y, tempVec.z); + if (valkyrienskies$toShip) { + valkyrienskies$originalOrigin = eyePos; + return VectorConversionsMCKt.toMinecraft( + valkyrienskies$ship.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(eyePos))); } else { return eyePos; } } @Redirect( - method = "pickCurves()V", - 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;" - ) + method = "pickCurves", + 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 (isShip) { - return new Vec3(shipBlockPos.getX(), shipBlockPos.getY(), shipBlockPos.getZ()); + 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/client/trackOutlines/MixinBigOutlines.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinBigOutlines.java new file mode 100644 index 000000000..94ffa3406 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinBigOutlines.java @@ -0,0 +1,92 @@ +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 stuff(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(BlockPos.containing(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/client/trackOutlines/MixinTrackBlockOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java new file mode 100644 index 000000000..1b8fbad96 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java @@ -0,0 +1,134 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client.trackOutlines; + +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.Ship; +import org.valkyrienskies.core.impl.game.ships.ShipObjectClient; +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 ShipObjectClient ship; + if ((ship = (ShipObjectClient) 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.toFloat(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 BlockPos.containing(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 ShipObjectClient ship; + if ((ship = (ShipObjectClient) 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/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 24a97da23..925b09556 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -160,6 +160,8 @@ "mod_compat.create.client.MixinTileEntityRenderHelper", "mod_compat.create.client.MixinTrackBlockOutline", "mod_compat.create.client.MixinTrainRelocator", + "mod_compat.create.client.trackOutlines.MixinBigOutlines", + "mod_compat.create.client.trackOutlines.MixinTrackBlockOutline", "mod_compat.create.client.MixinValueBox", "mod_compat.flywheel.InstancingEngineAccessor", "mod_compat.flywheel.MixinBlockEntityInstanceManager", From 93b62e42528e96a61bf008483210e17bd8494c68 Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins <31552479+FluffyJenkins@users.noreply.github.com> Date: Mon, 29 Jan 2024 17:57:13 +0000 Subject: [PATCH 114/156] Create Compat(1.20.1): Fixed track outlines and picking (#694) * Fixed track outlines on ships and fixed interaction bug when near curved track and a ship * Moved around mixins to disable track outline mixins if interactive is installed * logging --- .../ValkyrienCommonMixinConfigPlugin.java | 10 ++ .../create/client/MixinTrackBlockOutline.java | 85 ++++++----- .../trackOutlines/MixinBigOutlines.java | 92 ++++++++++++ .../trackOutlines/MixinTrackBlockOutline.java | 134 ++++++++++++++++++ .../valkyrienskies-common.mixins.json | 2 + 5 files changed, 286 insertions(+), 37 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinBigOutlines.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java 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 3bc09f14e..ba5ad1b0a 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java @@ -7,6 +7,7 @@ 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; /** @@ -72,6 +73,15 @@ 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/mod_compat/create/client/MixinTrackBlockOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java index 57496850d..0eb6df4d8 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java @@ -1,82 +1,93 @@ package org.valkyrienskies.mod.mixin.mod_compat.create.client; import com.simibubi.create.content.trains.track.TrackBlockOutline; +import com.simibubi.create.content.trains.track.TrackBlockOutline.BezierPointSelection; import com.simibubi.create.foundation.utility.RaycastHelper; -import java.util.List; 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.joml.Vector3d; 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.LocalCapture; +import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @Mixin(TrackBlockOutline.class) public class MixinTrackBlockOutline { + + @Shadow + public static BezierPointSelection result; + @Unique + private static boolean valkyrienskies$toShip = false; @Unique - private static boolean isShip = false; + private static Ship valkyrienskies$ship; @Unique - private static BlockPos shipBlockPos; + private static Vec3 valkyrienskies$originalOrigin; @Inject( - method = "pickCurves", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" - ), locals = LocalCapture.CAPTURE_FAILHARD + method = "pickCurves", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" + ), locals = LocalCapture.CAPTURE_FAILHARD ) private static void stuff(final CallbackInfo ci, final Minecraft mc) { - if (mc.hitResult != null && mc.level != null && mc.hitResult.getType() == Type.BLOCK) { - shipBlockPos = ((BlockHitResult) mc.hitResult).getBlockPos(); - - final List - ships = VSGameUtilsKt.transformToNearbyShipsAndWorld(mc.level, shipBlockPos.getX(), shipBlockPos.getY(), - shipBlockPos.getZ(), 10); - isShip = !ships.isEmpty(); + if (mc.hitResult != null && mc.level != null && mc.player != null) { + 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(BlockPos.containing(mc.hitResult.location)).isAir(); + } else if (hitResultOnShip) { + valkyrienskies$toShip = true; + valkyrienskies$ship = + VSGameUtilsKt.getShipManagingPos(mc.level, ((BlockHitResult) mc.hitResult).getBlockPos()); + } } } @Redirect( - method = "pickCurves()V", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" - ) + method = "pickCurves", + 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 (isShip) { - final List - ships = VSGameUtilsKt.transformToNearbyShipsAndWorld(instance.level(), eyePos.x, eyePos.y, eyePos.z, 10); - if (ships.isEmpty()) { - return eyePos; - } - final Vector3d tempVec = ships.get(0); - return new Vec3(tempVec.x, tempVec.y, tempVec.z); + if (valkyrienskies$toShip) { + valkyrienskies$originalOrigin = eyePos; + return VectorConversionsMCKt.toMinecraft( + valkyrienskies$ship.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(eyePos))); } else { return eyePos; } } @Redirect( - method = "pickCurves()V", - 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;" - ) + method = "pickCurves", + 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 (isShip) { - return new Vec3(shipBlockPos.getX(), shipBlockPos.getY(), shipBlockPos.getZ()); + 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/client/trackOutlines/MixinBigOutlines.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinBigOutlines.java new file mode 100644 index 000000000..94ffa3406 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinBigOutlines.java @@ -0,0 +1,92 @@ +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 stuff(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(BlockPos.containing(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/client/trackOutlines/MixinTrackBlockOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java new file mode 100644 index 000000000..1b8fbad96 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java @@ -0,0 +1,134 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client.trackOutlines; + +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.Ship; +import org.valkyrienskies.core.impl.game.ships.ShipObjectClient; +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 ShipObjectClient ship; + if ((ship = (ShipObjectClient) 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.toFloat(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 BlockPos.containing(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 ShipObjectClient ship; + if ((ship = (ShipObjectClient) 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/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 3a6c4a24a..4d7c28650 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -159,6 +159,8 @@ "mod_compat.create.client.MixinTileEntityRenderHelper", "mod_compat.create.client.MixinTrackBlockOutline", "mod_compat.create.client.MixinTrainRelocator", + "mod_compat.create.client.trackOutlines.MixinBigOutlines", + "mod_compat.create.client.trackOutlines.MixinTrackBlockOutline", "mod_compat.create.client.MixinValueBox", "mod_compat.flywheel.InstancingEngineAccessor", "mod_compat.flywheel.MixinBlockEntityInstanceManager", From 4504235abdc6984cb5d6c1a189dfe25bb1b73136 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Mon, 29 Jan 2024 19:22:07 +0100 Subject: [PATCH 115/156] Wierd, the errors were not showing in PR? --- .../mod_compat/create/client/MixinTrackBlockOutline.java | 2 +- .../create/client/trackOutlines/MixinBigOutlines.java | 2 +- .../create/client/trackOutlines/MixinTrackBlockOutline.java | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java index 0eb6df4d8..1a49c57ca 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java @@ -49,7 +49,7 @@ private static void stuff(final CallbackInfo ci, final Minecraft mc) { 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(BlockPos.containing(mc.hitResult.location)).isAir(); + valkyrienskies$toShip = mc.level.getBlockState(new BlockPos(mc.hitResult.location)).isAir(); } else if (hitResultOnShip) { valkyrienskies$toShip = true; valkyrienskies$ship = 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 index 94ffa3406..8ca181ed5 100644 --- 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 @@ -46,7 +46,7 @@ private static void stuff(final CallbackInfo ci, final Minecraft mc) { 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(BlockPos.containing(mc.hitResult.location)).isAir(); + valkyrienskies$toShip = mc.level.getBlockState(new BlockPos(mc.hitResult.location)).isAir(); } else if (hitResultOnShip) { valkyrienskies$toShip = true; valkyrienskies$ship = diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java index 1b8fbad96..83141fca5 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java @@ -77,7 +77,7 @@ private static PoseStack redirectTransformStackTranslate(final PoseStack ms) { ms.translate(worldVec.x - valkyrienskies$cameraVec3.x, worldVec.y - valkyrienskies$cameraVec3.y, worldVec.z - valkyrienskies$cameraVec3.z); - ms.mulPose(VectorConversionsMCKt.toFloat(rotation)); + ms.mulPose(VectorConversionsMCKt.toMinecraft(rotation)); ms.translate(-.5, -.125f, -.5); } } @@ -96,7 +96,7 @@ private static BlockPos modIsWithinBounds(final BlockPos blockPos) { if (level != null) { final Ship ship; if ((ship = VSGameUtilsKt.getShipManagingPos(level, blockPos)) != null) { - return BlockPos.containing(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld() + return new BlockPos(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld() .transformPosition(VectorConversionsMCKt.toJOMLD(blockPos)))); } } From 97bf648df1c3200dc5dcd4e94086d516113b736c Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins <31552479+FluffyJenkins@users.noreply.github.com> Date: Sun, 18 Feb 2024 15:10:50 +0000 Subject: [PATCH 116/156] Create Compat(1.19.2): Removed old file causing crashes/renamed function (#736) --- .../create/client/MixinTrackBlockOutline.java | 95 ------------------- .../trackOutlines/MixinBigOutlines.java | 2 +- .../valkyrienskies-common.mixins.json | 1 - 3 files changed, 1 insertion(+), 97 deletions(-) delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java deleted file mode 100644 index 1a49c57ca..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.simibubi.create.content.trains.track.TrackBlockOutline; -import com.simibubi.create.content.trains.track.TrackBlockOutline.BezierPointSelection; -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.Vec3; -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.LocalCapture; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(TrackBlockOutline.class) -public class MixinTrackBlockOutline { - - @Shadow - public static BezierPointSelection result; - @Unique - private static boolean valkyrienskies$toShip = false; - @Unique - private static Ship valkyrienskies$ship; - @Unique - private static Vec3 valkyrienskies$originalOrigin; - - @Inject( - method = "pickCurves", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" - ), locals = LocalCapture.CAPTURE_FAILHARD - ) - private static void stuff(final CallbackInfo ci, final Minecraft mc) { - if (mc.hitResult != null && mc.level != null && mc.player != null) { - 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 = "pickCurves", - 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 = "pickCurves", - 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/client/trackOutlines/MixinBigOutlines.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinBigOutlines.java index 8ca181ed5..cc559d91b 100644 --- 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 @@ -37,7 +37,7 @@ public class MixinBigOutlines { target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" ), locals = LocalCapture.CAPTURE_FAILHARD ) - private static void stuff(final CallbackInfo ci, final Minecraft mc) { + 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()); diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 925b09556..f6a391bc7 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -158,7 +158,6 @@ "mod_compat.create.client.MixinPlacementHelpers", "mod_compat.create.client.MixinSoundScapes", "mod_compat.create.client.MixinTileEntityRenderHelper", - "mod_compat.create.client.MixinTrackBlockOutline", "mod_compat.create.client.MixinTrainRelocator", "mod_compat.create.client.trackOutlines.MixinBigOutlines", "mod_compat.create.client.trackOutlines.MixinTrackBlockOutline", From 9ed2ddedcc03616f347143033d6dee1e559c12c6 Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins <31552479+FluffyJenkins@users.noreply.github.com> Date: Sun, 18 Feb 2024 15:11:29 +0000 Subject: [PATCH 117/156] Create Compat(1.20.1): Removed old file causing crashes/renamed function (#738) --- .../create/client/MixinTrackBlockOutline.java | 95 ------------------- .../trackOutlines/MixinBigOutlines.java | 2 +- .../valkyrienskies-common.mixins.json | 1 - 3 files changed, 1 insertion(+), 97 deletions(-) delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java deleted file mode 100644 index 0eb6df4d8..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.simibubi.create.content.trains.track.TrackBlockOutline; -import com.simibubi.create.content.trains.track.TrackBlockOutline.BezierPointSelection; -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.Vec3; -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.LocalCapture; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(TrackBlockOutline.class) -public class MixinTrackBlockOutline { - - @Shadow - public static BezierPointSelection result; - @Unique - private static boolean valkyrienskies$toShip = false; - @Unique - private static Ship valkyrienskies$ship; - @Unique - private static Vec3 valkyrienskies$originalOrigin; - - @Inject( - method = "pickCurves", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" - ), locals = LocalCapture.CAPTURE_FAILHARD - ) - private static void stuff(final CallbackInfo ci, final Minecraft mc) { - if (mc.hitResult != null && mc.level != null && mc.player != null) { - 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(BlockPos.containing(mc.hitResult.location)).isAir(); - } else if (hitResultOnShip) { - valkyrienskies$toShip = true; - valkyrienskies$ship = - VSGameUtilsKt.getShipManagingPos(mc.level, ((BlockHitResult) mc.hitResult).getBlockPos()); - } - } - } - - @Redirect( - method = "pickCurves", - 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 = "pickCurves", - 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/client/trackOutlines/MixinBigOutlines.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinBigOutlines.java index 94ffa3406..4850ad4a7 100644 --- 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 @@ -37,7 +37,7 @@ public class MixinBigOutlines { target = "Lnet/minecraft/client/player/LocalPlayer;getEyePosition(F)Lnet/minecraft/world/phys/Vec3;" ), locals = LocalCapture.CAPTURE_FAILHARD ) - private static void stuff(final CallbackInfo ci, final Minecraft mc) { + 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()); diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 4d7c28650..a180a939e 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -157,7 +157,6 @@ "mod_compat.create.client.MixinPlacementHelpers", "mod_compat.create.client.MixinSoundScapes", "mod_compat.create.client.MixinTileEntityRenderHelper", - "mod_compat.create.client.MixinTrackBlockOutline", "mod_compat.create.client.MixinTrainRelocator", "mod_compat.create.client.trackOutlines.MixinBigOutlines", "mod_compat.create.client.trackOutlines.MixinTrackBlockOutline", From ab16a4469e438cde4282976e3746b75cff5cabd2 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 26 Mar 2024 01:59:57 -0400 Subject: [PATCH 118/156] sodium 0.5 support; bump version to 2.3.0-beta.5 (#778) --- common/gradle.properties | 2 +- .../mod/compat/SodiumCompat.java | 12 +- .../ValkyrienCommonMixinConfigPlugin.java | 9 +- .../client/world/MixinClientChunkCache.java | 4 +- .../mod_compat/sodium/MixinChunkTracker.java | 51 ++++++-- .../sodium/MixinRegionChunkRenderer.java | 104 --------------- .../sodium/MixinRenderSectionManager.java | 104 +++++---------- .../sodium/MixinSodiumWorldRenderer.java | 119 ++++++++++++------ .../sodium/RegionChunkRendererDuck.java | 7 -- .../sodium/RenderSectionManagerDuck.java | 4 +- .../valkyrienskies-common.mixins.json | 3 +- fabric/build.gradle | 16 +-- fabric/gradle.properties | 2 +- .../sodium/MixinRenderSectionManager.java | 31 +++-- fabric/src/main/resources/fabric.mod.json | 3 +- .../sodium/MixinRenderSectionManager.java | 12 +- .../sodium/RenderSectionManagerDuck.java | 10 -- gradle.properties | 2 +- 18 files changed, 200 insertions(+), 295 deletions(-) delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRegionChunkRenderer.java delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/sodium/RegionChunkRendererDuck.java delete mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/sodium/RenderSectionManagerDuck.java diff --git a/common/gradle.properties b/common/gradle.properties index 5385872a4..a61644dcc 100644 --- a/common/gradle.properties +++ b/common/gradle.properties @@ -6,4 +6,4 @@ port_lib_modules = accessors,base,entity,extensions,fake_players,networking,obj_ cloth_config_version = 11.1.106 # https://modrinth.com/mod/sodium/versions -sodium_version = mc1.20-0.4.10 +sodium_version = mc1.20.1-0.5.8 diff --git a/common/src/main/java/org/valkyrienskies/mod/compat/SodiumCompat.java b/common/src/main/java/org/valkyrienskies/mod/compat/SodiumCompat.java index 599941a08..ff72ba879 100644 --- a/common/src/main/java/org/valkyrienskies/mod/compat/SodiumCompat.java +++ b/common/src/main/java/org/valkyrienskies/mod/compat/SodiumCompat.java @@ -1,19 +1,21 @@ package org.valkyrienskies.mod.compat; -import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer; +import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkStatus; +import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkTrackerHolder; +import net.minecraft.client.multiplayer.ClientLevel; import org.valkyrienskies.mod.mixin.ValkyrienCommonMixinConfigPlugin; public class SodiumCompat { - public static void onChunkAdded(final int x, final int z) { + public static void onChunkAdded(final ClientLevel level, final int x, final int z) { if (ValkyrienCommonMixinConfigPlugin.getVSRenderer() == VSRenderer.SODIUM) { - SodiumWorldRenderer.instance().onChunkAdded(x, z); + ChunkTrackerHolder.get(level).onChunkStatusAdded(x, z, ChunkStatus.FLAG_HAS_BLOCK_DATA); } } - public static void onChunkRemoved(final int x, final int z) { + public static void onChunkRemoved(final ClientLevel level, final int x, final int z) { if (ValkyrienCommonMixinConfigPlugin.getVSRenderer() == VSRenderer.SODIUM) { - SodiumWorldRenderer.instance().onChunkRemoved(x, z); + ChunkTrackerHolder.get(level).onChunkStatusRemoved(x, z, ChunkStatus.FLAG_HAS_BLOCK_DATA); } } 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..8baef82ba 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java @@ -58,17 +58,18 @@ public String getRefMapperConfig() { @Override public boolean shouldApplyMixin(final String s, final String mixinClassName) { + final VSRenderer renderer = getVSRenderer(); if (mixinClassName.contains("org.valkyrienskies.mod.mixin.mod_compat.sodium")) { - return getVSRenderer() == VSRenderer.SODIUM; + return renderer == VSRenderer.SODIUM; } if (mixinClassName.contains("org.valkyrienskies.mod.mixin.mod_compat.optifine_vanilla")) { - return getVSRenderer() != VSRenderer.SODIUM; + return renderer == VSRenderer.VANILLA || renderer == VSRenderer.OPTIFINE; } if (mixinClassName.contains("org.valkyrienskies.mod.mixin.mod_compat.vanilla_renderer")) { - return getVSRenderer() == VSRenderer.VANILLA; + return renderer == VSRenderer.VANILLA; } if (mixinClassName.contains("org.valkyrienskies.mod.mixin.mod_compat.optifine")) { - return getVSRenderer() == VSRenderer.OPTIFINE; + return renderer == VSRenderer.OPTIFINE; } if (mixinClassName.contains("org.valkyrienskies.mod.mixin.feature.render_pathfinding")) { return PATH_FINDING_DEBUG; diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientChunkCache.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientChunkCache.java index 0f4fb6db1..28a764996 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientChunkCache.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientChunkCache.java @@ -71,7 +71,7 @@ private void preLoadChunkFromPacket(final int x, final int z, } this.level.onChunkLoaded(new ChunkPos(x, z)); - SodiumCompat.onChunkAdded(x, z); + SodiumCompat.onChunkAdded(this.level, x, z); cir.setReturnValue(worldChunk); } } @@ -84,7 +84,7 @@ public void preUnload(final int chunkX, final int chunkZ, final CallbackInfo ci) ((IVSViewAreaMethods) ((LevelRendererAccessor) ((ClientLevelAccessor) level).getLevelRenderer()).getViewArea()) .unloadChunk(chunkX, chunkZ); } - SodiumCompat.onChunkRemoved(chunkX, chunkZ); + SodiumCompat.onChunkRemoved(this.level, chunkX, chunkZ); ci.cancel(); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinChunkTracker.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinChunkTracker.java index bffba17b9..fec276cf1 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinChunkTracker.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinChunkTracker.java @@ -1,27 +1,62 @@ package org.valkyrienskies.mod.mixin.mod_compat.sodium; import it.unimi.dsi.fastutil.longs.Long2IntOpenHashMap; -import me.jellysquid.mods.sodium.client.render.chunk.ChunkTracker; +import it.unimi.dsi.fastutil.longs.LongOpenHashSet; +import it.unimi.dsi.fastutil.longs.LongSet; +import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkStatus; +import me.jellysquid.mods.sodium.client.render.chunk.map.ChunkTracker; +import net.minecraft.client.Minecraft; import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; 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.VSGameUtilsKt; -@Mixin(value = ChunkTracker.class, remap = false) +@Mixin(ChunkTracker.class) public class MixinChunkTracker { + + @Shadow + @Final + private Long2IntOpenHashMap chunkStatus; + + @Shadow + @Final + private LongOpenHashSet chunkReady; + + @Shadow + @Final + private LongSet unloadQueue; + @Shadow @Final - private Long2IntOpenHashMap single; + private LongSet loadQueue; + + @Inject(method = "updateMerged", at = @At("HEAD"), cancellable = true, remap = false) + public void beforeUpdateMerged(final int x, final int z, final CallbackInfo ci) { + final Level level = Minecraft.getInstance().level; + if (level == null || !VSGameUtilsKt.isChunkInShipyard(level, x, z)) { + return; + } - @Inject(method = "onLightDataAdded", at = @At("HEAD"), cancellable = true) - private void cancelDataLight(final int x, final int z, final CallbackInfo ci) { final long key = ChunkPos.asLong(x, z); - final int existingFlags = this.single.get(key); - if ((existingFlags & 1) == 0) { - ci.cancel(); // Cancel instead of throwing an error for now + + final int flags = this.chunkStatus.get(key); + + if (flags == ChunkStatus.FLAG_ALL) { + if (this.chunkReady.add(key) && !this.unloadQueue.remove(key)) { + this.loadQueue.add(key); + } + } else { + if (this.chunkReady.remove(key) && !this.loadQueue.remove(key)) { + this.unloadQueue.add(key); + } } + + ci.cancel(); } + } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRegionChunkRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRegionChunkRenderer.java deleted file mode 100644 index 18f2d1376..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRegionChunkRenderer.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.sodium; - -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; -import java.util.List; -import me.jellysquid.mods.sodium.client.render.chunk.ChunkCameraContext; -import me.jellysquid.mods.sodium.client.render.chunk.RegionChunkRenderer; -import me.jellysquid.mods.sodium.client.render.chunk.RenderSection; -import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderBounds; -import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass; -import net.minecraft.client.Minecraft; -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.ClientShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.mixinducks.mod_compat.sodium.RegionChunkRendererDuck; - -@Mixin(value = RegionChunkRenderer.class, remap = false, priority = 1101) -public class MixinRegionChunkRenderer implements RegionChunkRendererDuck { - - @Unique - private final Vector3d camInWorld = new Vector3d(); - - @Unique - private final Vector3d camInShip = new Vector3d(); - - @WrapOperation( - at = @At( - value = "INVOKE", - target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSection;getBounds()Lme/jellysquid/mods/sodium/client/render/chunk/data/ChunkRenderBounds;" - ), - method = "buildDrawBatches" - ) - private ChunkRenderBounds injectBuildDrawBatches( - final RenderSection section, final Operation getBounds, final List sections, - final BlockRenderPass pass, final ChunkCameraContext c - ) { - final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, - section.getChunkX(), section.getChunkZ()); - - if (ship != null) { - ship.getRenderTransform().getWorldToShip().transformPosition(camInWorld, camInShip); - final ChunkRenderBounds originalBounds = getBounds.call(section); - return new ChunkRenderBounds(originalBounds.x1 - 1.9f, originalBounds.y1 - 1.9f, - originalBounds.z1 - 1.9f, originalBounds.x2 + 1.9f, originalBounds.y2 + 1.9f, - originalBounds.z2 + 1.9f); - } else { - camInShip.set(camInWorld); - return getBounds.call(section); - } - } - - @WrapOperation( - at = @At( - value = "FIELD", - target = "Lme/jellysquid/mods/sodium/client/render/chunk/RegionChunkRenderer;isBlockFaceCullingEnabled:Z" - ), - method = "buildDrawBatches" - ) - private boolean redirectEnabledCulling(final RegionChunkRenderer instance, final Operation operation) { - return false; - } - - @Redirect( - at = @At( - value = "FIELD", - target = "Lme/jellysquid/mods/sodium/client/render/chunk/ChunkCameraContext;posX:F" - ), - method = "buildDrawBatches" - ) - private float redirectCameraPosX(final ChunkCameraContext instance) { - return (float) camInShip.x; - } - - @Redirect( - at = @At( - value = "FIELD", - target = "Lme/jellysquid/mods/sodium/client/render/chunk/ChunkCameraContext;posY:F" - ), - method = "buildDrawBatches" - ) - private float redirectCameraPosY(final ChunkCameraContext instance) { - return (float) camInShip.y; - } - - @Redirect( - at = @At( - value = "FIELD", - target = "Lme/jellysquid/mods/sodium/client/render/chunk/ChunkCameraContext;posZ:F" - ), - method = "buildDrawBatches" - ) - private float redirectCameraPosZ(final ChunkCameraContext instance) { - return (float) camInShip.z; - } - - @Override - public void setCameraForCulling(final double x, final double y, final double z) { - camInWorld.set(x, y, z); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRenderSectionManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRenderSectionManager.java index dabb6f95e..20003e3e3 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRenderSectionManager.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRenderSectionManager.java @@ -1,76 +1,66 @@ package org.valkyrienskies.mod.mixin.mod_compat.sodium; -import it.unimi.dsi.fastutil.PriorityQueue; -import it.unimi.dsi.fastutil.objects.ObjectList; +import java.util.ArrayDeque; import java.util.Map; import java.util.WeakHashMap; -import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderList; import me.jellysquid.mods.sodium.client.render.chunk.ChunkUpdateType; -import me.jellysquid.mods.sodium.client.render.chunk.RegionChunkRenderer; import me.jellysquid.mods.sodium.client.render.chunk.RenderSection; import me.jellysquid.mods.sodium.client.render.chunk.RenderSectionManager; -import me.jellysquid.mods.sodium.client.render.chunk.data.ChunkRenderBounds; -import me.jellysquid.mods.sodium.client.util.frustum.Frustum; +import me.jellysquid.mods.sodium.client.render.chunk.lists.SortedRenderLists; +import me.jellysquid.mods.sodium.client.render.chunk.lists.VisibleChunkCollector; +import me.jellysquid.mods.sodium.client.render.viewport.Viewport; import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; -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.valkyrienskies.core.api.ships.ClientShip; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.mixinducks.mod_compat.sodium.RenderSectionManagerDuck; +/** + * Hi! Not many people read Valkyrien Skies' code, and even fewer will read this particular file. If you're + * here because you're contributing to VS, thank you so much! This is complex stuff, and your work is appreciated by + * all of our users. + *

+ * If you're here because you develop a competitor mod, we can't stop you from using this code - but at least have + * the decency to give credit to us, the original authors, and abide by the terms of our open source license. Don't + * pretend that you wrote this code. That's not cool. + * + * @author Rubydesic + */ @Mixin(value = RenderSectionManager.class, remap = false) public abstract class MixinRenderSectionManager implements RenderSectionManagerDuck { @Unique - private final WeakHashMap shipRenderLists = new WeakHashMap<>(); + private final WeakHashMap shipRenderLists = new WeakHashMap<>(); @Override - public WeakHashMap getShipRenderLists() { + public WeakHashMap vs_getShipRenderLists() { return shipRenderLists; } @Shadow @Final private ClientLevel world; - @Shadow - @Final - private ObjectList tickableChunks; - @Shadow - @Final - private RegionChunkRenderer chunkRenderer; - @Shadow - @Final - private Map> rebuildQueues; - @Shadow - private float cameraX; - @Shadow - private float cameraY; - @Shadow - private float cameraZ; @Shadow protected abstract RenderSection getRenderSection(int x, int y, int z); @Shadow - protected abstract void addEntitiesToRenderLists(RenderSection render); - - @Shadow - @Final - private static double NEARBY_CHUNK_DISTANCE; + private Map> rebuildLists; - @Inject(at = @At("TAIL"), method = "iterateChunks") - private void afterIterateChunks(final Camera camera, final Frustum frustum, final int frame, + @Inject(at = @At("TAIL"), method = "createTerrainRenderList") + private void afterIterateChunks(final Camera camera, final Viewport viewport, final int frame, final boolean spectator, final CallbackInfo ci) { for (final ClientShip ship : VSGameUtilsKt.getShipObjectWorld(Minecraft.getInstance()).getLoadedShips()) { + final VisibleChunkCollector collector = new VisibleChunkCollector(frame); + ship.getActiveChunksSet().forEach((x, z) -> { for (int y = world.getMinSection(); y < world.getMaxSection(); y++) { final RenderSection section = getRenderSection(x, y, z); @@ -79,51 +69,21 @@ private void afterIterateChunks(final Camera camera, final Frustum frustum, fina continue; } - if (section.getPendingUpdate() != null) { - final PriorityQueue queue = this.rebuildQueues.get(section.getPendingUpdate()); - if (queue.size() < (2 << 4) - 1) { - queue.enqueue(section); - } - } - - final ChunkRenderBounds b = section.getBounds(); - final AABBd b2 = new AABBd(b.x1 - 6e-1, b.y1 - 6e-1, b.z1 - 6e-1, - b.x2 + 6e-1, b.y2 + 6e-1, b.z2 + 6e-1) - .transform(ship.getRenderTransform().getShipToWorld()); - - if (section.isEmpty() || - !frustum.isBoxVisible((float) b2.minX, (float) b2.minY, (float) b2.minZ, - (float) b2.maxX, (float) b2.maxY, (float) b2.maxZ)) { - continue; - } - - shipRenderLists.computeIfAbsent(ship, k -> new ChunkRenderList()).add(section); - - if (section.isTickable()) { - tickableChunks.add(section); - } - - addEntitiesToRenderLists(section); + collector.visit(section, true); } }); - } - } - @Redirect( - at = @At( - value = "INVOKE", - target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSectionManager;isChunkPrioritized(Lme/jellysquid/mods/sodium/client/render/chunk/RenderSection;)Z" - ), - method = "scheduleRebuild" - ) - private boolean redirectIsChunkPrioritized(final RenderSectionManager instance, final RenderSection render) { - return VSGameUtilsKt.squaredDistanceBetweenInclShips(world, - render.getOriginX() + 8, render.getOriginY() + 8, render.getOriginZ() + 8, - this.cameraX, this.cameraY, this.cameraZ) <= NEARBY_CHUNK_DISTANCE; + shipRenderLists.put(ship, collector.createRenderLists()); + + // merge rebuild lists + for (final var entry : collector.getRebuildLists().entrySet()) { + this.rebuildLists.get(entry.getKey()).addAll(entry.getValue()); + } + } } - @Inject(at = @At("TAIL"), method = "resetLists") + @Inject(at = @At("TAIL"), method = "resetRenderLists") private void afterResetLists(final CallbackInfo ci) { - shipRenderLists.values().forEach(ChunkRenderList::clear); + shipRenderLists.clear(); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinSodiumWorldRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinSodiumWorldRenderer.java index 1ed8a2766..c33a1b112 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinSodiumWorldRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinSodiumWorldRenderer.java @@ -1,86 +1,125 @@ package org.valkyrienskies.mod.mixin.mod_compat.sodium; -import static org.valkyrienskies.mod.common.VSClientGameUtils.transformRenderWithShip; - +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.mojang.blaze3d.vertex.PoseStack; import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import java.util.SortedSet; import me.jellysquid.mods.sodium.client.render.SodiumWorldRenderer; import me.jellysquid.mods.sodium.client.render.chunk.RenderSectionManager; -import net.minecraft.client.Camera; -import net.minecraft.client.Minecraft; +import me.jellysquid.mods.sodium.client.render.chunk.lists.SortedRenderLists; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.MultiBufferSource; +import net.minecraft.client.renderer.MultiBufferSource.BufferSource; import net.minecraft.client.renderer.RenderBuffers; import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; import net.minecraft.core.BlockPos; import net.minecraft.server.level.BlockDestructionProgress; +import net.minecraft.world.entity.Entity; import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.phys.Vec3; 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.ClientShip; +import org.valkyrienskies.mod.common.VSClientGameUtils; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.mixinducks.mod_compat.sodium.RenderSectionManagerDuck; @Mixin(SodiumWorldRenderer.class) -public class MixinSodiumWorldRenderer { +public abstract class MixinSodiumWorldRenderer { @Shadow private ClientLevel world; @Shadow private RenderSectionManager renderSectionManager; - @Unique - private boolean vs$prevFrameHadShips = false; + private SortedRenderLists currentRenderLists; - /** - * @reason Fix ship ghosts when ships are deleted and camera hasn't moved, and ships not rendering when teleported - * and camera hasn't moved - */ - @Inject(method = "updateChunks", at = @At("HEAD")) - private void preUpdateChunks(final CallbackInfo callbackInfo) { - final boolean curFrameHasShips = - !VSGameUtilsKt.getShipObjectWorld(Minecraft.getInstance()).getLoadedShips().isEmpty(); - // Mark the graph dirty if ships were loaded this frame or the previous one - if (vs$prevFrameHadShips || curFrameHasShips) { - this.renderSectionManager.markGraphDirty(); + @Redirect( + method = "renderBlockEntity", + at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V") + ) + private static void renderShipBlockEntityInShipyard(final PoseStack instance, final double d, final double e, + final double f, final PoseStack ignore, final RenderBuffers bufferBuilders, + final Long2ObjectMap> blockBreakingProgressions, + final float tickDelta, final MultiBufferSource.BufferSource immediate, final double camX, final double camY, + final double camZ, final BlockEntityRenderDispatcher dispatcher, final BlockEntity entity) { + + final BlockPos pos = entity.getBlockPos(); + final ClientLevel level = (ClientLevel) dispatcher.level; + final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(level, pos); + + if (ship == null) { + instance.translate(d, e, f); + } else { + VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), instance, pos, camX, camY, camZ); } - vs$prevFrameHadShips = curFrameHasShips; } - @Redirect(method = "renderTileEntities", at = @At(value = "INVOKE", - target = "Lnet/minecraft/client/renderer/blockentity/BlockEntityRenderDispatcher;render(Lnet/minecraft/world/level/block/entity/BlockEntity;FLcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;)V")) - private void renderShipChunkBlockEntity(final BlockEntityRenderDispatcher instance, final BlockEntity blockEntity, - final float partialTicks, final PoseStack matrixStack, final MultiBufferSource buffer, final PoseStack matrices, + @Shadow + protected abstract void renderBlockEntities(PoseStack matrices, RenderBuffers bufferBuilders, + Long2ObjectMap> blockBreakingProgressions, float tickDelta, + BufferSource immediate, double x, double y, double z, BlockEntityRenderDispatcher blockEntityRenderer); + + @Redirect( + method = "renderBlockEntities(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/RenderBuffers;Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;Lnet/minecraft/client/Camera;F)V", + at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/render/SodiumWorldRenderer;renderBlockEntities(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/RenderBuffers;Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;FLnet/minecraft/client/renderer/MultiBufferSource$BufferSource;DDDLnet/minecraft/client/renderer/blockentity/BlockEntityRenderDispatcher;)V") + ) + public void renderShipBlockEntities(final SodiumWorldRenderer instance, final PoseStack matrices, final RenderBuffers bufferBuilders, - final Long2ObjectMap> blockBreakingProgressions, final Camera camera, - final float tickDelta) { - - final BlockPos blockEntityPos = blockEntity.getBlockPos(); - final ClientShip shipObject = VSGameUtilsKt.getShipObjectManagingPos(world, blockEntityPos); - if (shipObject != null) { - final Vec3 cam = camera.getPosition(); - matrixStack.popPose(); - matrixStack.pushPose(); - transformRenderWithShip(shipObject.getRenderTransform(), matrixStack, blockEntityPos, cam.x(), cam.y(), - cam.z()); + final Long2ObjectMap> blockBreakingProgressions, final float tickDelta, + final MultiBufferSource.BufferSource immediate, final double x, final double y, final double z, + final BlockEntityRenderDispatcher blockEntityRenderer) { + + + renderBlockEntities(matrices, bufferBuilders, blockBreakingProgressions, tickDelta, immediate, x, y, z, blockEntityRenderer); + + for (final SortedRenderLists renderLists : ((RenderSectionManagerDuck) this.renderSectionManager).vs_getShipRenderLists().values()) { + this.currentRenderLists = renderLists; + renderBlockEntities(matrices, bufferBuilders, blockBreakingProgressions, tickDelta, immediate, x, y, z, blockEntityRenderer); + } + + this.currentRenderLists = null; + } + + @ModifyExpressionValue( + method = "renderBlockEntities(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/RenderBuffers;Lit/unimi/dsi/fastutil/longs/Long2ObjectMap;FLnet/minecraft/client/renderer/MultiBufferSource$BufferSource;DDDLnet/minecraft/client/renderer/blockentity/BlockEntityRenderDispatcher;)V", + at = @At(value = "INVOKE", + target = "Lme/jellysquid/mods/sodium/client/render/chunk/RenderSectionManager;getRenderLists()Lme/jellysquid/mods/sodium/client/render/chunk/lists/SortedRenderLists;") + ) + private SortedRenderLists redirectGetRenderLists(final SortedRenderLists original) { + if (currentRenderLists != null) { + return currentRenderLists; + } else { + return original; } - instance.render(blockEntity, tickDelta, matrixStack, buffer); } +// /** +// * @reason Fix ship ghosts when ships are deleted and camera hasn't moved, and ships not rendering when teleported +// * and camera hasn't moved +// */ +// @Inject(method = "updateChunks", at = @At("HEAD")) +// private void preUpdateChunks(final CallbackInfo callbackInfo) { +// final boolean curFrameHasShips = +// !VSGameUtilsKt.getShipObjectWorld(Minecraft.getInstance()).getLoadedShips().isEmpty(); +// // Mark the graph dirty if ships were loaded this frame or the previous one +// if (vs$prevFrameHadShips || curFrameHasShips) { +// this.renderSectionManager.markGraphDirty(); +// } +// vs$prevFrameHadShips = curFrameHasShips; +// } + /** * Fix entities in ships not rendering when Sodium is installed */ - @Inject(method = "doesChunkHaveFlag", at = @At("HEAD"), cancellable = true, remap = false) - private void preDoesChunkHaveFlag(final int x, final int z, final int status, final CallbackInfoReturnable cir) { - if (VSGameUtilsKt.isChunkInShipyard(world, x, z)) { + @Inject(method = "isEntityVisible", at = @At("HEAD"), cancellable = true) + private void isEntityVisible(final Entity entity, final CallbackInfoReturnable cir) { + if (VSGameUtilsKt.isBlockInShipyard(world, entity.position())) { cir.setReturnValue(true); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/sodium/RegionChunkRendererDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/sodium/RegionChunkRendererDuck.java deleted file mode 100644 index 4820e889d..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/sodium/RegionChunkRendererDuck.java +++ /dev/null @@ -1,7 +0,0 @@ -package org.valkyrienskies.mod.mixinducks.mod_compat.sodium; - -public interface RegionChunkRendererDuck { - - void setCameraForCulling(double x, double y, double z); - -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/sodium/RenderSectionManagerDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/sodium/RenderSectionManagerDuck.java index c288d46a8..df054c0b6 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/sodium/RenderSectionManagerDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/sodium/RenderSectionManagerDuck.java @@ -1,11 +1,11 @@ package org.valkyrienskies.mod.mixinducks.mod_compat.sodium; import java.util.WeakHashMap; -import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderList; +import me.jellysquid.mods.sodium.client.render.chunk.lists.SortedRenderLists; import org.valkyrienskies.core.api.ships.ClientShip; public interface RenderSectionManagerDuck { - WeakHashMap getShipRenderLists(); + WeakHashMap vs_getShipRenderLists(); } diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index a180a939e..200c9c779 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -168,10 +168,9 @@ "mod_compat.flywheel.MixinInstancingEngine", "mod_compat.optifine.RenderChunkInfoAccessorOptifine", "mod_compat.optifine_vanilla.MixinLevelRenderer", - "mod_compat.sodium.MixinChunkTracker", - "mod_compat.sodium.MixinRegionChunkRenderer", "mod_compat.sodium.MixinRenderSectionManager", "mod_compat.sodium.MixinSodiumWorldRenderer", + "mod_compat.sodium.MixinChunkTracker", "mod_compat.sound_physics_remastered.MixinSoundPhysics", "mod_compat.vanilla_renderer.MixinLevelRendererVanilla", "mod_compat.vanilla_renderer.MixinViewAreaVanilla", diff --git a/fabric/build.gradle b/fabric/build.gradle index 888b16d0b..9a6013530 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -72,21 +72,21 @@ dependencies { //modImplementation("curse.maven:cc-tweaked-282001:${cc_tweaked_version}") // Create compat - modImplementation("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { + modCompileOnly("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}") + modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version_fabric}") + modCompileOnly("com.tterrag.registrate_fabric:Registrate:${registrate_version}") //modImplementation("io.github.fabricators_of_create.Porting-Lib:Porting-Lib:$port_lib_version") for (String module in port_lib_modules.split(",")) { - modImplementation("io.github.fabricators_of_create.Porting-Lib:$module:$port_lib_version") + modCompileOnly("io.github.fabricators_of_create.Porting-Lib:$module:$port_lib_version") } - modImplementation("curse.maven:forge-config-api-port-fabric-547434:$config_api_id") - modImplementation("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") - modImplementation("dev.cafeteria:fake-player-api:${fake_player_api_version}") - modImplementation("io.github.tropheusj:milk-lib:${milk_lib_version}") + modCompileOnly("curse.maven:forge-config-api-port-fabric-547434:$config_api_id") + modCompileOnly("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") + modCompileOnly("dev.cafeteria:fake-player-api:${fake_player_api_version}") + modCompileOnly("io.github.tropheusj:milk-lib:${milk_lib_version}") } // Copy the VS common access widener to the generated resources folder diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 99711d555..fd0ec50c9 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -23,7 +23,7 @@ jsr305_version=3.0.2 no_indium_version=1.1.0+1.20 #https://modrinth.com/mod/sodium/versions -sodium_version = mc1.20-0.4.10 +sodium_version = mc1.20.1-0.5.8 # https://modrinth.com/mod/cc-tweaked/version/Uq4DlqWv cc_tweaked_version = 1.109.0 diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/sodium/MixinRenderSectionManager.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/sodium/MixinRenderSectionManager.java index 887d465e9..76b7666ca 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/sodium/MixinRenderSectionManager.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/sodium/MixinRenderSectionManager.java @@ -1,21 +1,21 @@ package org.valkyrienskies.mod.fabric.mixin.compat.sodium; +import com.llamalad7.mixinextras.sugar.Local; 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.ChunkRenderer; import me.jellysquid.mods.sodium.client.render.chunk.RenderSectionManager; -import me.jellysquid.mods.sodium.client.render.chunk.passes.BlockRenderPass; +import me.jellysquid.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; +import me.jellysquid.mods.sodium.client.render.viewport.CameraTransform; import org.joml.Matrix4f; 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.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.valkyrienskies.mod.common.VSClientGameUtils; -import org.valkyrienskies.mod.mixinducks.mod_compat.sodium.RegionChunkRendererDuck; import org.valkyrienskies.mod.mixinducks.mod_compat.sodium.RenderSectionManagerDuck; @Mixin(value = RenderSectionManager.class, remap = false) @@ -23,26 +23,23 @@ public class MixinRenderSectionManager { @Shadow @Final - private RegionChunkRenderer chunkRenderer; + private ChunkRenderer chunkRenderer; - @Redirect(at = @At(value = "INVOKE", target = "Lme/jellysquid/mods/sodium/client/gl/device/CommandList;flush()V"), + @Inject(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) { + private void redirectRenderLayer(final ChunkRenderMatrices matrices, final TerrainRenderPass pass, + final double camX, final double camY, final double camZ, final CallbackInfo ci, @Local final CommandList commandList) { - RenderDevice.INSTANCE.makeActive(); - - ((RenderSectionManagerDuck) this).getShipRenderLists().forEach((ship, renderList) -> { + ((RenderSectionManagerDuck) this).vs_getShipRenderLists().forEach((ship, renderList) -> { final Matrix4f newModelView = new Matrix4f(matrices.modelView()); final Vector3dc center = ship.getRenderTransform().getPositionInShip(); VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), newModelView, center.x(), center.y(), center.z(), camX, camY, camZ); final ChunkRenderMatrices newMatrices = new ChunkRenderMatrices(matrices.projection(), newModelView); - ((RegionChunkRendererDuck) chunkRenderer).setCameraForCulling(camX, camY, camZ); - chunkRenderer.render(newMatrices, list, renderList, pass, - new ChunkCameraContext(center.x(), center.y(), center.z())); - list.close(); + chunkRenderer.render(newMatrices, commandList, renderList, pass, + new CameraTransform(center.x(), center.y(), center.z())); + commandList.close(); }); } diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 248f4c0db..42525baea 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -34,6 +34,7 @@ "fabric-api": "*" }, "breaks": { - "sodium": ">=0.5.0" + "sodium": "<0.5.8", + "nvidium": "*" } } 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 index 87e9fb10b..591efb0d2 100644 --- 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 @@ -1,11 +1,9 @@ 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.ChunkRenderMatrices; import me.jellysquid.mods.sodium.client.render.chunk.ChunkRenderer; import me.jellysquid.mods.sodium.client.render.chunk.RenderSectionManager; -import me.jellysquid.mods.sodium.client.render.chunk.lists.SortedRenderLists; import me.jellysquid.mods.sodium.client.render.chunk.terrain.TerrainRenderPass; import me.jellysquid.mods.sodium.client.render.viewport.CameraTransform; import org.joml.Matrix4d; @@ -16,7 +14,7 @@ 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; @Mixin(value = RenderSectionManager.class, remap = false) public class MixinRenderSectionManager { @@ -25,17 +23,12 @@ public class MixinRenderSectionManager { @Final private ChunkRenderer chunkRenderer; - @Shadow - private SortedRenderLists renderLists; - @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 TerrainRenderPass pass, final double camX, final double camY, final double camZ) { - RenderDevice.INSTANCE.makeActive(); - - ((RenderSectionManagerDuck) this).getShipRenderLists().forEach((ship, renderList) -> { + ((RenderSectionManagerDuck) this).vs_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()) @@ -46,7 +39,6 @@ private void redirectRenderLayer(final CommandList list, final ChunkRenderMatric final ChunkRenderMatrices newMatrices = new ChunkRenderMatrices(matrices.projection(), new Matrix4f(newModelView)); - ((RegionChunkRendererDuck) chunkRenderer).setCameraForCulling(camX, camY, camZ); chunkRenderer.render(newMatrices, list, renderList, pass, new CameraTransform(center.x(), center.y(), center.z())); list.close(); diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/sodium/RenderSectionManagerDuck.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/sodium/RenderSectionManagerDuck.java deleted file mode 100644 index f1d3e9121..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/sodium/RenderSectionManagerDuck.java +++ /dev/null @@ -1,10 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.sodium; - -import java.util.WeakHashMap; -import me.jellysquid.mods.sodium.client.render.chunk.lists.ChunkRenderListIterable; -import org.valkyrienskies.core.api.ships.ClientShip; - -public interface RenderSectionManagerDuck { - WeakHashMap getShipRenderLists(); - -} diff --git a/gradle.properties b/gradle.properties index e6d2c283f..d143be07f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-120 -mod_version=2.1.3-beta.2 +mod_version=2.3.0-beta.5 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ From d9e0db7d3354dcd03c4a8a40c3d72ed3ee664cba Mon Sep 17 00:00:00 2001 From: MrSterner <32911664+mrsterner@users.noreply.github.com> Date: Sat, 30 Mar 2024 17:55:59 +0100 Subject: [PATCH 119/156] Fixed patch f crash and added some support for Create utilities (#743) * Added support for Create utilities VoidValueBox position and fixed MixinTrackBlockOutline * added javadoc i guess --- build.gradle | 1 + common/build.gradle | 3 + .../MixinVoidLinkBehaviour.java | 49 +++++++ .../valkyrienskies-common.mixins.json | 4 +- fabric/build.gradle | 4 + fabric/gradle.properties | 2 +- .../trackOutlines/MixinTrackBlockOutline.java | 2 +- .../valkyrienskies-fabric.mixins.json | 1 + forge/build.gradle | 4 + .../trackOutlines/MixinTrackBlockOutline.java | 132 ++++++++++++++++++ .../valkyrienskies-forge.mixins.json | 3 +- gradle.properties | 8 +- 12 files changed, 205 insertions(+), 8 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_utilities/MixinVoidLinkBehaviour.java rename {common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat => fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat}/create/client/trackOutlines/MixinTrackBlockOutline.java (98%) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java diff --git a/build.gradle b/build.gradle index b21a5193d..0a5ab5923 100644 --- a/build.gradle +++ b/build.gradle @@ -113,6 +113,7 @@ subprojects { maven { url = "https://maven.shedaniel.me/" } // Cloth Config, REI maven { url "https://maven.architectury.dev/" } maven { url = "https://mvn.devos.one/snapshots/" } // Fabric Create, Porting Lib, Forge Tags, Milk Lib + maven { url = "https://mvn.devos.one/releases/" } maven { url = "https://raw.githubusercontent.com/Fuzss/modresources/main/maven/" } // Forge Config API Port maven { url = "https://maven.tterrag.com/" } // Registrate, Forge Create and Flywheel maven { url = "https://maven.cafeteria.dev/releases" } // Fake Player API diff --git a/common/build.gradle b/common/build.gradle index 301e677df..9ca139efc 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -32,6 +32,9 @@ dependencies { modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version_fabric}") modCompileOnly("maven.modrinth:create-big-cannons:${createbigcannons_version}") + + modCompileOnly("maven.modrinth:create-utilities:${create_utilities_version}") + modImplementation("teamreborn:energy:${energy_version}") } architectury { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_utilities/MixinVoidLinkBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_utilities/MixinVoidLinkBehaviour.java new file mode 100644 index 000000000..1faa9d0f0 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_utilities/MixinVoidLinkBehaviour.java @@ -0,0 +1,49 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create_utilities; + +import me.duquee.createutilities.blocks.voidtypes.VoidLinkBehaviour; +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; +import org.valkyrienskies.mod.mixin.mod_compat.create.behaviour.MixinLinkBehaviour; + +@Mixin(VoidLinkBehaviour.class) +public class MixinVoidLinkBehaviour { + + /** + * Identical to {@link MixinLinkBehaviour} but for Create: Utilities Void link + */ + @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 = ((VoidLinkBehaviour) (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/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 200c9c779..e9c168279 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -87,6 +87,7 @@ "mod_compat.create.packets.MixinTrainRelocationPacket", "mod_compat.create.pr.MixinSeatBlock", "mod_compat.create_big_cannons.MixinPitchOrientedContraptionEntity", + "mod_compat.create_utilities.MixinVoidLinkBehaviour", "mod_compat.reachentityattributes.MixinReachEntityAttributes", "server.MixinMinecraftServer", "server.MixinPlayerList", @@ -158,9 +159,8 @@ "mod_compat.create.client.MixinSoundScapes", "mod_compat.create.client.MixinTileEntityRenderHelper", "mod_compat.create.client.MixinTrainRelocator", - "mod_compat.create.client.trackOutlines.MixinBigOutlines", - "mod_compat.create.client.trackOutlines.MixinTrackBlockOutline", "mod_compat.create.client.MixinValueBox", + "mod_compat.create.client.trackOutlines.MixinBigOutlines", "mod_compat.flywheel.InstancingEngineAccessor", "mod_compat.flywheel.MixinBlockEntityInstanceManager", "mod_compat.flywheel.MixinInstanceManager", diff --git a/fabric/build.gradle b/fabric/build.gradle index 9a6013530..326ab0277 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -40,6 +40,7 @@ dependencies { include(modImplementation("net.fabricmc:fabric-language-kotlin:${kotlin_fabric_version}")) include(modImplementation("me.shedaniel.cloth:cloth-config-fabric:${cloth_config_version}")) + modCompileOnly("maven.modrinth:create-utilities:${create_utilities_version}") modImplementation("maven.modrinth:sodium:${sodium_version}") // Disable indium until we update sodium to newer versions // modRuntimeOnly("maven.modrinth:indium:${indium_version}") @@ -48,6 +49,9 @@ dependencies { // Depend on the fabric API modImplementation("net.fabricmc.fabric-api:fabric-api:${rootProject.fabric_api_version}") + modImplementation("teamreborn:energy:${energy_version}") { + transitive = false + } implementation("org.valkyrienskies.core:impl:${rootProject.vs_core_version}") { exclude module: "netty-buffer" diff --git a/fabric/gradle.properties b/fabric/gradle.properties index fd0ec50c9..75db1882c 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-f-build.1335+mc1.20.1 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L24 config_api_id=4583000 # https://github.com/Fabricators-of-Create/Create/blob/4724359545de070788221dbb6387c31e582e9d45/gradle.properties#L25 diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java similarity index 98% rename from common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java rename to fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java index 1b8fbad96..f71208b95 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java @@ -1,4 +1,4 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client.trackOutlines; +package org.valkyrienskies.mod.fabric.mixin.compat.create.client.trackOutlines; import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.blaze3d.vertex.VertexConsumer; diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 53773d791..64d9da890 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -6,6 +6,7 @@ "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", "compat.create.MixinControlledContraptionEntity", + "compat.create.client.trackOutlines.MixinTrackBlockOutline", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", "server.network.MixinServerGamePacketListenerImpl", diff --git a/forge/build.gradle b/forge/build.gradle index 1ac96a971..8b6268115 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -75,6 +75,10 @@ dependencies { // CC Tweaked modCompileOnly("maven.modrinth:cc-tweaked:${cc_tweaked_version}") + modCompileOnly("maven.modrinth:create-utilities:0.2.0+1.20.1") + modImplementation("teamreborn:energy:${energy_version}") { + transitive = false + } // TIS-3d modCompileOnly("maven.modrinth:tis3d:${tis3d_version}") diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java new file mode 100644 index 000000000..be2aa2349 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java @@ -0,0 +1,132 @@ +package org.valkyrienskies.mod.forge.mixin.compat.create.client.trackOutlines; + +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.Block; +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.Ship; +import org.valkyrienskies.core.impl.game.ships.ShipObjectClient; +import org.valkyrienskies.mod.common.VSClientGameUtils; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(value = TrackBlockOutline.class, remap = false) +public class MixinTrackBlockOutline { + @Unique + private static Vec3 valkyrienskies$cameraVec3; + @Unique + private static Vec3 valkyrienskies$vec; + @Unique + private static Vec3 valkyrienskies$angles; + + @Inject(method = "drawCurveSelection(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/phys/Vec3;)V", + 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(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/phys/Vec3;)V", + 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 ShipObjectClient ship; + if ((ship = (ShipObjectClient) 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.toFloat(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 BlockPos.containing(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(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 ShipObjectClient ship; + if ((ship = (ShipObjectClient) 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/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 896f1f787..c7b04283b 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -6,11 +6,12 @@ "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", "compat.create.MixinControlledContraptionEntity", + "compat.create.client.trackOutlines.MixinTrackBlockOutline", "compat.immersivengineering.MixinBlockEntityInventory", + "compat.modular_routers.MixinRouterMenu", "compat.tfc.MixinTFCChunkGenerator", "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", - "compat.modular_routers.MixinRouterMenu", "feature.forge_interact.MixinIForgePlayer", "feature.water_in_ships_entity.MixinEntity", "world.level.block.FireMixin" diff --git a/gradle.properties b/gradle.properties index d143be07f..9e2c1f161 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,22 +9,24 @@ maven_group=org.valkyrienskies.mod architectury_version=9.1.12 # https://fabricmc.net/develop/ -fabric_loader_version=0.14.24 +fabric_loader_version=0.15.7 # https://fabricmc.net/develop/ -fabric_api_version=0.90.7+1.20.1 +fabric_api_version=0.92.0+1.20.1 # https://files.minecraftforge.net/net/minecraftforge/forge/ forge_version=1.20.1-47.2.0 # https://modrinth.com/mod/create-fabric/versions -create_fabric_version=0.5.1-d-build.1161+mc1.20.1 +create_fabric_version=0.5.1-f-build.1335+mc1.20.1 # https://github.com/Fabricators-of-Create/Create/blob/mc1.19/fabric/dev/gradle.properties flywheel_version_fabric=0.6.9-6 # https://modrinth.com/mod/create-big-cannons/versions createbigcannons_version= 0.5.2.a +create_utilities_version=0.2.1+1.20.1 +energy_version=2.3.0 vs_core_version=1.1.0+b19b27c4a4 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks From fcae3be735bf4413e74c2a90270ea1d4177fd081 Mon Sep 17 00:00:00 2001 From: Pama1234 <62501730+pama1234@users.noreply.github.com> Date: Tue, 23 Apr 2024 04:17:37 +0800 Subject: [PATCH 120/156] fix crash with Sodium and Litematica (#819) --- .../mod/mixin/mod_compat/sodium/MixinSodiumWorldRenderer.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinSodiumWorldRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinSodiumWorldRenderer.java index c33a1b112..13f7dd449 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinSodiumWorldRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinSodiumWorldRenderer.java @@ -50,6 +50,10 @@ private static void renderShipBlockEntityInShipyard(final PoseStack instance, fi final double camZ, final BlockEntityRenderDispatcher dispatcher, final BlockEntity entity) { final BlockPos pos = entity.getBlockPos(); + + // fix for https://github.com/ValkyrienSkies/Valkyrien-Skies-2/issues/818 + if(!(dispatcher.level instanceof ClientLevel)) return; + final ClientLevel level = (ClientLevel) dispatcher.level; final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(level, pos); From 682a6e853cb3bbc5a85acfd52da3cd781ff203b0 Mon Sep 17 00:00:00 2001 From: Fionera Date: Fri, 3 May 2024 02:00:12 +0200 Subject: [PATCH 121/156] Prevent shading of commons-lang3 (#798) commons-lang3 is always provided at runtime, don't shade it to prevent incompatibilities. Closes #617, #616 --- fabric/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/fabric/build.gradle b/fabric/build.gradle index 326ab0277..2e5490396 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -126,6 +126,7 @@ shadowJar { duplicatesStrategy DuplicatesStrategy.EXCLUDE // Ignore duplicate valkyrienskies-common.accesswidener files dependencies { exclude(dependency("org.jetbrains.kotlin:.*:.*")) // Don't shade kotlin! + exclude(dependency("org.apache.commons:commons-lang3:.*")) // Don't apache-commons, see #617 } // Exclude dummy Optifine classes exclude "net/optifine/**" From 7ce55e212dc8c0f8da9a4397920a9fd7417c62b7 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Thu, 23 May 2024 22:04:25 -0400 Subject: [PATCH 122/156] initial work on api --- common/build.gradle | 3 +- .../mod/compat/FlywheelEvents.java | 13 +- .../mixin/server/MixinMinecraftServer.java | 20 +- .../mod/api/SeatedControllingPlayer.kt | 7 + .../org/valkyrienskies/mod/api/VsApi.kt | 58 ++++ .../mod/api/events/PostRenderShipEvent.kt | 6 + .../mod/api/events/PreRenderShipEvent.kt | 6 + .../mod/api/events/RegisterBlockStateEvent.kt | 25 ++ .../events/RegisterBlockStateEventImpl.kt | 36 +++ .../mod/api_impl/events/VsApiImpl.kt | 40 +++ .../mod/common/BlockStateInfoProvider.kt | 4 - .../common/DefaultBlockStateInfoProvider.kt | 6 - .../valkyrienskies/mod/common/VSGameUtils.kt | 4 +- .../mod/common/ValkyrienSkiesMod.kt | 12 +- .../common/assembly/SeamlessChunksManager.kt | 15 +- .../mod/common/assembly/ShipAssembly.kt | 6 +- .../mod/common/config/VSMassDataLoader.kt | 306 +++++++----------- .../mod/common/entity/ShipMountingEntity.kt | 6 +- .../common/entity/handling/VSEntityManager.kt | 7 +- .../mod/common/hooks/VSGameEvents.kt | 2 +- .../mod/common/networking/VSGamePackets.kt | 9 +- .../common/util/EntityShipCollisionUtils.kt | 6 +- .../mod/compat/clothconfig/VSClothConfig.kt | 7 +- .../forge/common/ValkyrienSkiesModForge.kt | 7 +- gradle.properties | 2 +- 25 files changed, 359 insertions(+), 254 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api/events/PostRenderShipEvent.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api/events/PreRenderShipEvent.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api/events/RegisterBlockStateEvent.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/RegisterBlockStateEventImpl.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VsApiImpl.kt diff --git a/common/build.gradle b/common/build.gradle index 9ca139efc..39472623e 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -16,7 +16,8 @@ dependencies { exclude module: "netty-buffer" exclude module: "fastutil" } - + implementation("org.valkyrienskies.core:api:${rootProject.vs_core_version}") + implementation("org.valkyrienskies.core:api-game:${rootProject.vs_core_version}") implementation("org.valkyrienskies.core:util:${rootProject.vs_core_version}") // FTB Stuffs diff --git a/common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java b/common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java index 8e5076018..1ceebe383 100644 --- a/common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java +++ b/common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java @@ -4,8 +4,6 @@ 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 { @@ -18,11 +16,12 @@ public class FlywheelEvents { ); private static synchronized void registerEvents() { - ShipUnloadEventClient.Companion.on(event -> { - for (final InstanceWorld instanceWorld : weakLoadedInstanceWorlds) { - ((MixinBlockEntityInstanceManagerDuck) instanceWorld.getBlockEntityInstanceManager()).vs$removeShipManager(event.getShip()); - } - }); + // TODO api fix +// ShipUnloadEventClient.Companion.on(event -> { +// for (final InstanceWorld instanceWorld : weakLoadedInstanceWorlds) { +// ((MixinBlockEntityInstanceManagerDuck) instanceWorld.getBlockEntityInstanceManager()).vs$removeShipManager(event.getShip()); +// } +// }); } public static void onInstanceWorldLoad(final InstanceWorld instanceWorld) { 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 6294d134f..00092cddf 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 @@ -112,6 +112,14 @@ public VSPipeline getVsPipeline() { ) ) private void postCreateLevels(final CallbackInfo ci) { + // Register blocks + if (!MassDatapackResolver.INSTANCE.getRegisteredBlocks()) { + final List blockStateList = new ArrayList<>(Block.BLOCK_STATE_REGISTRY.size()); + Block.BLOCK_STATE_REGISTRY.forEach((blockStateList::add)); + MassDatapackResolver.INSTANCE.registerAllBlockStates(blockStateList); + ValkyrienSkiesMod.getVsCore().registerBlockStates(MassDatapackResolver.INSTANCE.getBlockStateData()); + } + // Load ship data from the world storage final ShipSavedData shipSavedData = overworld().getDataStorage() .computeIfAbsent(ShipSavedData::load, ShipSavedData.Companion::createEmpty, ShipSavedData.SAVED_DATA_ID); @@ -128,18 +136,6 @@ private void postCreateLevels(final CallbackInfo ci) { // Create ship world and VS Pipeline vsPipeline = shipSavedData.getPipeline(); - // Register blocks - if (!MassDatapackResolver.INSTANCE.getRegisteredBlocks()) { - final List blockStateList = new ArrayList<>(Block.BLOCK_STATE_REGISTRY.size()); - Block.BLOCK_STATE_REGISTRY.forEach((blockStateList::add)); - MassDatapackResolver.INSTANCE.registerAllBlockStates(blockStateList); - } - vsPipeline.registerBlocks( - MassDatapackResolver.INSTANCE.getSolidBlockStates(), - MassDatapackResolver.INSTANCE.getLiquidBlockStates(), - MassDatapackResolver.INSTANCE.getBlockStateData() - ); - KrunchSupport.INSTANCE.setKrunchSupported(!vsPipeline.isUsingDummyPhysics()); shipWorld = vsPipeline.getShipWorld(); diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/SeatedControllingPlayer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/SeatedControllingPlayer.kt index a2a5e5a60..0aff70925 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/api/SeatedControllingPlayer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/SeatedControllingPlayer.kt @@ -1,7 +1,14 @@ package org.valkyrienskies.mod.api import net.minecraft.core.Direction +import org.valkyrienskies.mod.common.entity.ShipMountingEntity +/** + * A utility class that is attached to ships and gives the inputs from a player + * mounted to a [ShipMountingEntity] + */ +@Deprecated("This API will be removed at a later date. " + + "Addons should make their own seat entities and handle their own inputs. ") class SeatedControllingPlayer(val seatInDirection: Direction) { var forwardImpulse: Float = 0.0f var leftImpulse: Float = 0.0f diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt new file mode 100644 index 000000000..61cb0c671 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt @@ -0,0 +1,58 @@ +package org.valkyrienskies.mod.api + +import net.minecraft.client.gui.screens.Screen +import net.minecraft.client.multiplayer.ClientLevel +import net.minecraft.core.BlockPos +import net.minecraft.world.level.ChunkPos +import net.minecraft.world.level.Level +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.entity.Entity + +import org.jetbrains.annotations.ApiStatus.* +import org.valkyrienskies.core.api.event.ListenableEvent +import org.valkyrienskies.core.api.ships.* +import org.valkyrienskies.mod.api.events.PostRenderShipEvent +import org.valkyrienskies.mod.api.events.PreRenderShipEvent +import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent + +@NonExtendable +interface VsApi { + + companion object { + @get:JvmStatic + val instance: VsApi get() = TODO() + } + + /** + * This event gets called when it's time to register physics block states for Minecraft block states. + */ + @get:Experimental + val registerBlockStateEvent: ListenableEvent + + @get:Experimental + val preRenderShipEvent: ListenableEvent + + @get:Experimental + val postRenderShipEvent: ListenableEvent + + fun isShipMountingEntity(entity: Entity): Boolean + + @Deprecated(message = "The legacy VS config system will be replaced soon. " + + "Migrate to another config library, or the new system when it's released. ") + fun createConfigScreenLegacy(parent: Screen, vararg configs: Class<*>): Screen + + /** + * Get the ship with the chunk claim that contains [pos], if it exists. + * + * If either parameter is null, this will return null. + * + * @param level The [Level] to look for the ship in. If [level] is a + * [ServerLevel], this will return a [ServerShip]. If [level] is a + * [ClientLevel], this will return a [ClientShip]. + * + * @param pos A block position in the Shipyard + */ + fun getShipManagingBlock(level: Level?, pos: BlockPos?): Ship? + + fun getShipManagingChunk(level: Level?, pos: ChunkPos?): Ship? +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PostRenderShipEvent.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PostRenderShipEvent.kt new file mode 100644 index 000000000..33bbd6de3 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PostRenderShipEvent.kt @@ -0,0 +1,6 @@ +package org.valkyrienskies.mod.api.events + +import org.jetbrains.annotations.ApiStatus.Experimental + +@Experimental +interface PostRenderShipEvent diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PreRenderShipEvent.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PreRenderShipEvent.kt new file mode 100644 index 000000000..2d99dbf51 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PreRenderShipEvent.kt @@ -0,0 +1,6 @@ +package org.valkyrienskies.mod.api.events + +import org.jetbrains.annotations.ApiStatus.Experimental + +@Experimental +interface PreRenderShipEvent diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/events/RegisterBlockStateEvent.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/RegisterBlockStateEvent.kt new file mode 100644 index 000000000..12800615b --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/RegisterBlockStateEvent.kt @@ -0,0 +1,25 @@ +package org.valkyrienskies.mod.api.events + +import net.minecraft.world.level.block.state.BlockState +import org.jetbrains.annotations.ApiStatus.Experimental +import org.valkyrienskies.core.api.physics.blockstates.LiquidState +import org.valkyrienskies.core.api.physics.blockstates.SolidState + +@Experimental +interface RegisterBlockStateEvent { + + fun newLiquidStateBuilder(): LiquidState.Builder + fun buildLiquidState(block: LiquidState.Builder.() -> Unit): LiquidState + fun newSolidStateBuilder(): SolidState.Builder + fun buildSolidState(block: SolidState.Builder.() -> Unit): SolidState + + fun register(state: BlockState, solidState: SolidState) + fun register(state: BlockState, liquidState: LiquidState) + + /** + * Registers the Minecraft [state] to be represented by [LiquidState] and [SolidState] in the same block. + * This is useful for e.g., a waterlogged chest, where the [liquidState] would be water and the [solidState] would + * be the chest shape. + */ + fun register(state: BlockState, liquidState: LiquidState, solidState: SolidState) +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/RegisterBlockStateEventImpl.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/RegisterBlockStateEventImpl.kt new file mode 100644 index 000000000..683019ebe --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/RegisterBlockStateEventImpl.kt @@ -0,0 +1,36 @@ +package org.valkyrienskies.mod.api_impl.events + +import net.minecraft.world.level.block.state.BlockState +import org.valkyrienskies.core.api.physics.blockstates.LiquidState +import org.valkyrienskies.core.api.physics.blockstates.SolidState +import org.valkyrienskies.core.apigame.physics.blockstates.VsBlockState +import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent +import org.valkyrienskies.mod.common.ValkyrienSkiesMod.vsCore + +class RegisterBlockStateEventImpl : RegisterBlockStateEvent { + val toRegister = mutableListOf>() + + override fun newLiquidStateBuilder(): LiquidState.Builder = + vsCore.newLiquidStateBuilder() + + override fun buildLiquidState(block: LiquidState.Builder.() -> Unit): LiquidState = + vsCore.newLiquidStateBuilder().apply(block).build() + + override fun newSolidStateBuilder(): SolidState.Builder = + vsCore.newSolidStateBuilder() + + override fun buildSolidState(block: SolidState.Builder.() -> Unit): SolidState = + vsCore.newSolidStateBuilder().apply(block).build() + + override fun register(state: BlockState, solidState: SolidState) { + toRegister.add(Pair(state, VsBlockState(solidState, null))) + } + + override fun register(state: BlockState, liquidState: LiquidState) { + toRegister.add(Pair(state, VsBlockState(null, liquidState))) + } + + override fun register(state: BlockState, liquidState: LiquidState, solidState: SolidState) { + toRegister.add(Pair(state, VsBlockState(solidState, liquidState))) + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VsApiImpl.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VsApiImpl.kt new file mode 100644 index 000000000..bb683afbe --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VsApiImpl.kt @@ -0,0 +1,40 @@ +package org.valkyrienskies.mod.api_impl.events + +import net.minecraft.client.gui.screens.Screen +import net.minecraft.core.BlockPos +import net.minecraft.world.entity.Entity +import net.minecraft.world.level.ChunkPos +import net.minecraft.world.level.Level +import org.valkyrienskies.core.api.ships.Ship +import org.valkyrienskies.core.util.events.EventEmitterImpl +import org.valkyrienskies.mod.api.VsApi +import org.valkyrienskies.mod.api.events.PostRenderShipEvent +import org.valkyrienskies.mod.api.events.PreRenderShipEvent +import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent +import org.valkyrienskies.mod.common.entity.ShipMountingEntity +import org.valkyrienskies.mod.common.getShipManagingPos +import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig + +class VsApiImpl : VsApi { + + override val registerBlockStateEvent = EventEmitterImpl() + override val preRenderShipEvent = EventEmitterImpl() + override val postRenderShipEvent = EventEmitterImpl() + + override fun isShipMountingEntity(entity: Entity): Boolean { + return entity is ShipMountingEntity + } + + override fun createConfigScreenLegacy(parent: Screen, vararg configs: Class<*>): Screen { + return VSClothConfig.createConfigScreenFor(parent, *configs) + } + + + override fun getShipManagingBlock(level: Level?, pos: BlockPos?): Ship? { + return pos?.let { level?.getShipManagingPos(it) } + } + + override fun getShipManagingChunk(level: Level?, pos: ChunkPos?): Ship? { + return pos?.let { level?.getShipManagingPos(it) } + } +} 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 a94660be1..1cdd6595e 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -35,10 +35,6 @@ interface BlockStateInfoProvider { // Get the id of the block state fun getBlockStateType(blockState: BlockState): BlockType? - - val solidBlockStates: List - val liquidBlockStates: List - val blockStateData: List> } object BlockStateInfo { diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt index 54f5ce073..d69962eae 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt @@ -13,12 +13,6 @@ import org.valkyrienskies.physics_api.voxel.Lod1SolidBlockState object DefaultBlockStateInfoProvider : BlockStateInfoProvider { override val priority: Int get() = Int.MIN_VALUE - override val solidBlockStates: List - get() = TODO() - override val liquidBlockStates: List - get() = TODO() - override val blockStateData: List> - get() = TODO() override fun getBlockStateMass(blockState: BlockState): Double { if (blockState.isAir) return 0.0 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 7deaab3ea..4b91b8b14 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -197,7 +197,7 @@ fun Level?.transformToNearbyShipsAndWorld( this?.transformToNearbyShipsAndWorld(x, y, z, aabbRadius, cb::accept) } -inline fun Level?.transformToNearbyShipsAndWorld( +inline fun Level.transformToNearbyShipsAndWorld( x: Double, y: Double, z: Double, aabbRadius: Double, cb: (Double, Double, Double) -> Unit ) { val currentShip = getShipManagingPos(x, y, z) @@ -212,7 +212,7 @@ inline fun Level?.transformToNearbyShipsAndWorld( cb(posInWorld.x(), posInWorld.y(), posInWorld.z()) } - for (nearbyShip in shipObjectWorld.allShips.getIntersecting(aabb)) { + for (nearbyShip in shipObjectWorld.allShips.getIntersecting(aabb, dimensionId)) { if (nearbyShip == currentShip) continue val posInShip = nearbyShip.worldToShip.transformPosition(posInWorld, temp0) cb(posInShip.x(), posInShip.y(), posInShip.z()) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt index 0fb4029ba..46d3d4d17 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -15,8 +15,10 @@ import org.valkyrienskies.core.api.ships.setAttachment import org.valkyrienskies.core.apigame.VSCore import org.valkyrienskies.core.apigame.VSCoreClient import org.valkyrienskies.core.impl.config.VSConfigClass -import org.valkyrienskies.core.impl.config.VSCoreConfig +import org.valkyrienskies.core.impl.config_impl.VSCoreConfig import org.valkyrienskies.core.impl.hooks.VSEvents +import org.valkyrienskies.mod.api.VsApi +import org.valkyrienskies.mod.api_impl.events.VsApiImpl import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.config.VSGameConfig import org.valkyrienskies.mod.common.entity.ShipMountingEntity @@ -51,6 +53,9 @@ object ValkyrienSkiesMod { @JvmStatic val vsCoreClient get() = vsCore as VSCoreClient + @JvmStatic + val api = VsApiImpl() + fun init(core: VSCore) { this.vsCore = core @@ -58,9 +63,8 @@ object ValkyrienSkiesMod { VSGamePackets.register() VSGamePackets.registerHandlers() - VSConfigClass.registerConfig("vs_core", VSCoreConfig::class.java) - VSConfigClass.registerConfig("vs", VSGameConfig::class.java) - VSEvents.ShipLoadEvent.on { event -> + core.registerConfigLegacy("vs", VSGameConfig::class.java) + VSEvents.shipLoadEvent.on { event -> event.ship.setAttachment(GameTickForceApplier()) } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SeamlessChunksManager.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SeamlessChunksManager.kt index bb8aac7ab..f79def783 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SeamlessChunksManager.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SeamlessChunksManager.kt @@ -12,7 +12,6 @@ import net.minecraft.world.level.ChunkPos import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.properties.ChunkClaim import org.valkyrienskies.core.impl.hooks.VSEvents.ShipLoadEventClient -import org.valkyrienskies.core.impl.networking.simple.registerClientHandler import org.valkyrienskies.core.util.pollUntilEmpty import org.valkyrienskies.mod.common.getShipManagingPos import org.valkyrienskies.mod.common.isChunkInShipyard @@ -44,12 +43,14 @@ class SeamlessChunksManager(private val listener: ClientPacketListener) { private val stalledChunks = LongOpenHashSet() init { - PacketStopChunkUpdates::class.registerClientHandler { (chunks) -> - chunks.forEach { stalledChunks.add(it.toMinecraft().toLong()) } - } - PacketRestartChunkUpdates::class.registerClientHandler { packet -> - Minecraft.getInstance().execute { - onRestartUpdates(packet) + with(vsCore.simplePacketNetworking) { + PacketStopChunkUpdates::class.registerClientHandler { (chunks) -> + chunks.forEach { stalledChunks.add(it.toMinecraft().toLong()) } + } + PacketRestartChunkUpdates::class.registerClientHandler { packet -> + Minecraft.getInstance().execute { + onRestartUpdates(packet) + } } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt index 8df8aea74..41a7b3c4d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt @@ -5,10 +5,9 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.ChunkPos import org.joml.Vector3d import org.valkyrienskies.core.api.ships.ServerShip -import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet import org.valkyrienskies.core.impl.game.ships.ShipData import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl -import org.valkyrienskies.core.impl.networking.simple.sendToClient +import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.executeIf import org.valkyrienskies.mod.common.isTickingChunk @@ -17,12 +16,13 @@ import org.valkyrienskies.mod.common.networking.PacketStopChunkUpdates import org.valkyrienskies.mod.common.playerWrapper import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.toJOML +import org.valkyrienskies.mod.common.vsCore import org.valkyrienskies.mod.util.relocateBlock import org.valkyrienskies.mod.util.updateBlock fun createNewShipWithBlocks( centerBlock: BlockPos, blocks: DenseBlockPosSet, level: ServerLevel -): ServerShip { +): ServerShip = with(vsCore.simplePacketNetworking) { if (blocks.isEmpty()) throw IllegalArgumentException() val ship = level.shipObjectWorld.createNewShipAtBlock(centerBlock.toJOML(), false, 1.0, level.dimensionId) 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 097e1bed6..cea506318 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,6 +4,7 @@ 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 @@ -19,30 +20,25 @@ import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.FluidState import net.minecraft.world.level.material.Fluids import net.minecraft.world.phys.shapes.VoxelShape -import org.joml.Vector3f -import org.joml.Vector3i +import org.joml.Vector3d +import org.joml.primitives.AABBi +import org.joml.primitives.AABBic +import org.valkyrienskies.core.api.physics.blockstates.CollisionPoint +import org.valkyrienskies.core.api.physics.blockstates.LiquidState +import org.valkyrienskies.core.api.physics.blockstates.BoxesBlockShape +import org.valkyrienskies.core.api.physics.blockstates.SolidBlockShape +import org.valkyrienskies.core.apigame.physics.blockstates.VsBlockState import org.valkyrienskies.core.apigame.world.chunks.BlockType -import org.valkyrienskies.core.game.VSBlockType -import org.valkyrienskies.core.impl.collision.Lod1SolidShapeUtils -import org.valkyrienskies.core.impl.game.BlockTypeImpl +import org.valkyrienskies.mod.api_impl.events.RegisterBlockStateEventImpl +import org.valkyrienskies.mod.api_impl.events.VsApiImpl import org.valkyrienskies.mod.common.BlockStateInfoProvider +import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.hooks.VSGameEvents import org.valkyrienskies.mod.common.vsCore import org.valkyrienskies.mod.mixin.accessors.world.level.block.SlabBlockAccessor import org.valkyrienskies.mod.mixin.accessors.world.level.block.StairBlockAccessor import org.valkyrienskies.mod.util.logger -import org.valkyrienskies.physics_api.Lod1BlockStateId -import org.valkyrienskies.physics_api.Lod1LiquidBlockStateId -import org.valkyrienskies.physics_api.Lod1SolidBlockStateId -import org.valkyrienskies.physics_api.voxel.CollisionPoint -import org.valkyrienskies.physics_api.voxel.Lod1LiquidBlockState -import org.valkyrienskies.physics_api.voxel.Lod1SolidBlockState -import org.valkyrienskies.physics_api.voxel.Lod1SolidBoxesCollisionShape -import org.valkyrienskies.physics_api.voxel.Lod1SolidCollisionShape -import org.valkyrienskies.physics_api.voxel.LodBlockBoundingBox import java.util.Optional -import kotlin.math.max -import kotlin.math.min import kotlin.math.roundToInt private data class VSBlockStateInfo( @@ -51,15 +47,14 @@ private data class VSBlockStateInfo( val mass: Double, val friction: Double, val elasticity: Double, - val type: VSBlockType?, + val type: BlockType?, ) object MassDatapackResolver : BlockStateInfoProvider { private val map = hashMapOf() - private val _solidBlockStates: MutableList = ArrayList() - private val _liquidBlockStates: MutableList = ArrayList() - private val _blockStateData: MutableList> = ArrayList() - private val blockStateToId: MutableMap = HashMap() + private val mcBlockStateToVs: MutableMap = HashMap() + + val blockStateData: Collection = mcBlockStateToVs.values val loader get() = VSMassDataLoader() @@ -74,19 +69,14 @@ object MassDatapackResolver : BlockStateInfoProvider { override fun getBlockStateMass(blockState: BlockState): Double? = map[BuiltInRegistries.BLOCK.getKey(blockState.block)]?.mass - override fun getBlockStateType(blockState: BlockState): VSBlockType? = - blockStateToId[blockState]!! + override fun getBlockStateType(blockState: BlockState): BlockType? { + val vsState = mcBlockStateToVs[blockState] ?: return null + return vsCore.blockTypes.getType(vsState) + } var registeredBlocks = false private set - override val solidBlockStates: List - get() = _solidBlockStates - override val liquidBlockStates: List - get() = _liquidBlockStates - override val blockStateData: List> - get() = _blockStateData - class VSMassDataLoader : SimpleJsonResourceReloadListener(Gson(), "vs_mass") { private val tags = mutableListOf() @@ -119,7 +109,7 @@ object MassDatapackResolver : BlockStateInfoProvider { BuiltInRegistries.BLOCK.getTag(TagKey.create(Registries.BLOCK, tagInfo.id)) if (tag != null) { - if (!tag.isPresent()) { + if (!tag.isPresent) { logger.warn("No specified tag '${tagInfo.id}' doesn't exist!") return@forEach } @@ -173,38 +163,39 @@ object MassDatapackResolver : BlockStateInfoProvider { } } - private fun generateStairCollisionShapes(stairShapes: Array): Map { + private fun generateStairCollisionShapes(stairShapes: Array): Map { val testPoints = listOf( - CollisionPoint(Vector3f(.25f, .25f, .25f), .25f), - CollisionPoint(Vector3f(.25f, .25f, .75f), .25f), - CollisionPoint(Vector3f(.25f, .75f, .25f), .25f), - CollisionPoint(Vector3f(.25f, .75f, .75f), .25f), - CollisionPoint(Vector3f(.75f, .25f, .25f), .25f), - CollisionPoint(Vector3f(.75f, .25f, .75f), .25f), - CollisionPoint(Vector3f(.75f, .75f, .25f), .25f), - CollisionPoint(Vector3f(.75f, .75f, .75f), .25f), + CollisionPoint(.25f, .25f, .25f, .25f), + CollisionPoint(.25f, .25f, .75f, .25f), + CollisionPoint(.25f, .75f, .25f, .25f), + CollisionPoint(.25f, .75f, .75f, .25f), + CollisionPoint(.75f, .25f, .25f, .25f), + CollisionPoint(.75f, .25f, .75f, .25f), + CollisionPoint(.75f, .75f, .25f, .25f), + CollisionPoint(.75f, .75f, .75f, .25f), ) val testBoxes = listOf( - LodBlockBoundingBox.createVSBoundingBox(0, 0, 0, 7, 7, 7), - LodBlockBoundingBox.createVSBoundingBox(0, 0, 8, 7, 7, 15), - LodBlockBoundingBox.createVSBoundingBox(0, 8, 0, 7, 15, 7), - LodBlockBoundingBox.createVSBoundingBox(0, 8, 8, 7, 15, 15), - LodBlockBoundingBox.createVSBoundingBox(8, 0, 0, 15, 7, 7), - LodBlockBoundingBox.createVSBoundingBox(8, 0, 8, 15, 7, 15), - LodBlockBoundingBox.createVSBoundingBox(8, 8, 0, 15, 15, 7), - LodBlockBoundingBox.createVSBoundingBox(8, 8, 8, 15, 15, 15), + AABBi(0, 0, 0, 7, 7, 7), + AABBi(0, 0, 8, 7, 7, 15), + AABBi(0, 8, 0, 7, 15, 7), + AABBi(0, 8, 8, 7, 15, 15), + AABBi(8, 0, 0, 15, 7, 7), + AABBi(8, 0, 8, 15, 7, 15), + AABBi(8, 8, 0, 15, 15, 7), + AABBi(8, 8, 8, 15, 15, 15), ) - val map: MutableMap = HashMap() + val map: MutableMap = HashMap() stairShapes.forEach { stairShape -> val points: MutableList = ArrayList() - val positiveBoxes: MutableList = ArrayList() - val negativeBoxes: MutableList = ArrayList() + val positiveBoxes: MutableList = ArrayList() + val negativeBoxes: MutableList = ArrayList() + testPoints.forEachIndexed { index, testPoint -> var added = false stairShape.forAllBoxes { minX, minY, minZ, maxX, maxY, maxZ -> - if (testPoint.pos.x() in minX .. maxX && testPoint.pos.y() in minY .. maxY && testPoint.pos.z() in minZ .. maxZ) { + if (testPoint.x in minX .. maxX && testPoint.y in minY .. maxY && testPoint.z in minZ .. maxZ) { points.add(testPoint) added = true return@forAllBoxes @@ -216,52 +207,39 @@ object MassDatapackResolver : BlockStateInfoProvider { negativeBoxes.add(testBoxes[index]) } } - val minTotalAABB = Vector3i(positiveBoxes[0].minX.toInt(), positiveBoxes[0].minY.toInt(), positiveBoxes[0].minZ.toInt()) - val maxTotalAABB = Vector3i(positiveBoxes[0].maxX.toInt(), positiveBoxes[0].maxY.toInt(), positiveBoxes[0].maxZ.toInt()) - for (i in 1 until positiveBoxes.size) { - minTotalAABB.x = min(minTotalAABB.x, positiveBoxes[i].minX.toInt()) - minTotalAABB.y = min(minTotalAABB.y, positiveBoxes[i].minY.toInt()) - minTotalAABB.z = min(minTotalAABB.z, positiveBoxes[i].minZ.toInt()) - maxTotalAABB.x = max(maxTotalAABB.x, positiveBoxes[i].maxX.toInt()) - maxTotalAABB.y = max(maxTotalAABB.y, positiveBoxes[i].maxY.toInt()) - maxTotalAABB.z = max(maxTotalAABB.z, positiveBoxes[i].maxZ.toInt()) - } - val overallBox = LodBlockBoundingBox.createVSBoundingBox( - minTotalAABB.x.toByte(), minTotalAABB.y.toByte(), minTotalAABB.z.toByte(), maxTotalAABB.x.toByte(), - maxTotalAABB.y.toByte(), maxTotalAABB.z.toByte() - ) - val collisionShape = Lod1SolidBoxesCollisionShape( - overallBoundingBox = overallBox, - collisionPoints = points, - solidBoxes = Lod1SolidShapeUtils.mergeBoxes(positiveBoxes), - negativeBoxes = Lod1SolidShapeUtils.mergeBoxes(negativeBoxes), - ) + + val collisionShape = vsCore.newSolidStateBoxesShapeBuilder() + .addCollisionPoints(points) + .addPositiveBoxes(vsCore.solidShapeUtils.mergeBoxes(positiveBoxes)) + .addNegativeBoxes(vsCore.solidShapeUtils.mergeBoxes(negativeBoxes)) + .build() + map[stairShape] = collisionShape } return map } - private fun generateShapeFromVoxel(voxelShape: VoxelShape): Lod1SolidBoxesCollisionShape? { - val posBoxes = ArrayList() + private fun generateShapeFromVoxel(voxelShape: VoxelShape): BoxesBlockShape? { + val posBoxes = ArrayList() var failed = false var maxBoxesToTest = 20 voxelShape.forAllBoxes { minX, minY, minZ, maxX, maxY, maxZ -> if (failed) { return@forAllBoxes } - val lodMinX = (minX * 16).roundToInt().toByte() - val lodMinY = (minY * 16).roundToInt().toByte() - val lodMinZ = (minZ * 16).roundToInt().toByte() - val lodMaxX = ((maxX * 16).roundToInt() - 1).toByte() - val lodMaxY = ((maxY * 16).roundToInt() - 1).toByte() - val lodMaxZ = ((maxZ * 16).roundToInt() - 1).toByte() + val lodMinX = (minX * 16).roundToInt() + val lodMinY = (minY * 16).roundToInt() + val lodMinZ = (minZ * 16).roundToInt() + val lodMaxX = ((maxX * 16).roundToInt() - 1) + val lodMaxY = ((maxY * 16).roundToInt() - 1) + val lodMaxZ = ((maxZ * 16).roundToInt() - 1) if (lodMinX !in 0..15 || lodMinY !in 0..15 || lodMinZ !in 0..15 || lodMaxX !in 0..15 || lodMaxY !in 0..15 || lodMaxZ !in 0..15) { // Out of range failed = true return@forAllBoxes } else { posBoxes.add( - LodBlockBoundingBox.createVSBoundingBox(lodMinX, lodMinY, lodMinZ, lodMaxX, lodMaxY, lodMaxZ) + AABBi(lodMinX, lodMinY, lodMinZ, lodMaxX, lodMaxY, lodMaxZ) ) } if (maxBoxesToTest == 0) { @@ -271,68 +249,33 @@ object MassDatapackResolver : BlockStateInfoProvider { } } return if (!failed) { - Lod1SolidShapeUtils.generateShapeFromBoxes(posBoxes) + try { + vsCore.solidShapeUtils.generateShapeFromBoxes(posBoxes) + } catch (ex: IllegalArgumentException) { + println("WTF ERROR WHILE PROCESSING $voxelShape") + null + } } else { null } } fun registerAllBlockStates(blockStates: Iterable) { - val fullLodBoundingBox = LodBlockBoundingBox.createVSBoundingBox(0, 0, 0, 15, 15, 15) + val fullLodBoundingBox = AABBi(0, 0, 0, 15, 15, 15) val fullBlockCollisionPoints = listOf( - CollisionPoint(Vector3f(.25f, .25f, .25f), .25f), - CollisionPoint(Vector3f(.25f, .25f, .75f), .25f), - CollisionPoint(Vector3f(.25f, .75f, .25f), .25f), - CollisionPoint(Vector3f(.25f, .75f, .75f), .25f), - CollisionPoint(Vector3f(.75f, .25f, .25f), .25f), - CollisionPoint(Vector3f(.75f, .25f, .75f), .25f), - CollisionPoint(Vector3f(.75f, .75f, .25f), .25f), - CollisionPoint(Vector3f(.75f, .75f, .75f), .25f), + CollisionPoint(.25f, .25f, .25f, .25f), + CollisionPoint(.25f, .25f, .75f, .25f), + CollisionPoint(.25f, .75f, .25f, .25f), + CollisionPoint(.25f, .75f, .75f, .25f), + CollisionPoint(.75f, .25f, .25f, .25f), + CollisionPoint(.75f, .25f, .75f, .25f), + CollisionPoint(.75f, .75f, .25f, .25f), + CollisionPoint(.75f, .75f, .75f, .25f), ) - val fullBlockCollisionShape = Lod1SolidBoxesCollisionShape( - overallBoundingBox = fullLodBoundingBox, - collisionPoints = fullBlockCollisionPoints, - solidBoxes = listOf(fullLodBoundingBox), - negativeBoxes = listOf(), - ) - - // Add default block states - run { - // region Add default solid block state - val solidBlockState = Lod1SolidBlockState( - collisionShape = fullBlockCollisionShape, - elasticity = DEFAULT_ELASTICITY.toFloat(), - friction = DEFAULT_FRICTION.toFloat(), - hardness = DEFAULT_HARDNESS.toFloat(), - lod1SolidBlockStateId = BlockTypeImpl.SOLID.toInt(), - ) - _solidBlockStates.add(solidBlockState) - _blockStateData.add(Triple(BlockTypeImpl.SOLID.toInt(), BlockTypeImpl.AIR.toInt(), BlockTypeImpl.SOLID.toInt())) - // endregion - - // region Add default water/lava liquid block states - val waterBlockState = Lod1LiquidBlockState( - boundingBox = fullLodBoundingBox, - density = 1000.0f, - dragCoefficient = 0.3f, - fluidVel = Vector3f(), - lod1LiquidBlockStateId = BlockTypeImpl.WATER.toInt(), - ) - - val lavaBlockState = Lod1LiquidBlockState( - boundingBox = fullLodBoundingBox, - density = 10000.0f, - dragCoefficient = 1.0f, - fluidVel = Vector3f(), - lod1LiquidBlockStateId = BlockTypeImpl.LAVA.toInt(), - ) - - _liquidBlockStates.add(waterBlockState) - _liquidBlockStates.add(lavaBlockState) - _blockStateData.add(Triple(BlockTypeImpl.AIR.toInt(), BlockTypeImpl.WATER.toInt(), BlockTypeImpl.WATER.toInt())) - _blockStateData.add(Triple(BlockTypeImpl.AIR.toInt(), BlockTypeImpl.LAVA.toInt(), BlockTypeImpl.LAVA.toInt())) - // endregion - } + val fullBlockCollisionShape = vsCore.newSolidStateBoxesShapeBuilder() + .addCollisionPoints(fullBlockCollisionPoints) + .addPositiveBox(fullLodBoundingBox) + .build() // A dummy world used to get the VoxelShape for each block state val dummyBlockGetter = object: BlockGetter { @@ -352,54 +295,44 @@ object MassDatapackResolver : BlockStateInfoProvider { StairBlockAccessor.getTopShapes() + StairBlockAccessor.getBottomShapes() + SlabBlockAccessor.getBottomAABB() + SlabBlockAccessor.getTopAABB() ) - // Setup initial conditions for future ids - var nextSolidId = 2 - var nextFluidId = 4 - var nextVoxelStateId = 4 - - val generatedCollisionShapesMap = HashMap() - val liquidMaterialToDensityMap = mapOf(Fluids.WATER to Pair(1000.0f, 0.3f), Fluids.LAVA to Pair(10000.0f, 1.0f), Fluids.FLOWING_WATER to Pair(1000.0f, 0.3f), Fluids.FLOWING_LAVA to Pair(10000.0f, 1.0f)) + val generatedCollisionShapesMap = HashMap() + val liquidMaterialToDensityMap = mapOf(Fluids.WATER to Pair(1000.0, 0.3), Fluids.LAVA to Pair(10000.0, 1.0), Fluids.FLOWING_WATER to Pair(1000.0, 0.3), Fluids.FLOWING_LAVA to Pair(10000.0, 1.0)) - val fluidStateToBlockTypeMap = HashMap>() + val fluidStateToBlockTypeMap = HashMap() // Get the id of the fluid state/create a new fluid state if necessary - fun getFluidState(fluidState: FluidState): Pair { + fun getFluidState(fluidState: FluidState): LiquidState { val cached = fluidStateToBlockTypeMap[fluidState] if (cached != null) return cached - val maxY = ((fluidState.ownHeight * 16.0).roundToInt() - 1).coerceIn(0, 15).toByte() - val fluidBox = LodBlockBoundingBox.createVSBoundingBox(0, 0, 0, 15, maxY, 15) - if (fluidState.type in liquidMaterialToDensityMap) { + val maxY = ((fluidState.ownHeight * 16.0).roundToInt() - 1).coerceIn(0, 15) + val fluidBox = AABBi(0, 0, 0, 15, maxY, 15) + return if (fluidState.type in liquidMaterialToDensityMap) { val (density, dragCoefficient) = liquidMaterialToDensityMap[fluidState.type]!! - val newFluidBlockState = Lod1LiquidBlockState( - boundingBox = fluidBox, - density = density, - dragCoefficient = dragCoefficient, - fluidVel = Vector3f(), - lod1LiquidBlockStateId = nextFluidId++, - ) - val stateId = nextVoxelStateId++ - _liquidBlockStates.add(newFluidBlockState) - _blockStateData.add(Triple(BlockTypeImpl.AIR.toInt(), newFluidBlockState.lod1LiquidBlockStateId, stateId)) - val blockTypeNew = BlockTypeImpl(stateId) - fluidStateToBlockTypeMap[fluidState] = newFluidBlockState.lod1LiquidBlockStateId to blockTypeNew - return newFluidBlockState.lod1LiquidBlockStateId to blockTypeNew + val newFluidBlockState = vsCore.newLiquidStateBuilder() + .boxShape(fluidBox) + .density(density) + .dragCoefficient(dragCoefficient) + .velocity(Vector3d()) + .build() + + newFluidBlockState } else { // Default - return BlockTypeImpl.WATER.toInt() to BlockTypeImpl.WATER + vsCore.blockTypes.waterState.liquidState!! } } blockStates.forEach { blockState: BlockState -> - val blockType: BlockType + val vsBlockState: VsBlockState if (blockState.isAir) { - blockType = vsCore.blockTypes.air + vsBlockState = vsCore.blockTypes.airState } else { - blockType = if (blockState.liquid()) { - getFluidState(blockState.fluidState).second + vsBlockState = if (blockState.liquid()) { + VsBlockState(null, getFluidState(blockState.fluidState)) } else if (blockState.isSolid) { val voxelShape = blockState.getShape(dummyBlockGetter, BlockPos.ZERO) - val collisionShape: Lod1SolidCollisionShape = if (voxelShapeToCollisionShapeMap.contains(voxelShape)) { + val collisionShape: SolidBlockShape = if (voxelShapeToCollisionShapeMap.contains(voxelShape)) { voxelShapeToCollisionShapeMap[voxelShape]!! } else if (generatedCollisionShapesMap.contains(voxelShape)) { if (generatedCollisionShapesMap[voxelShape] != null) { @@ -416,35 +349,36 @@ object MassDatapackResolver : BlockStateInfoProvider { val vsBlockStateInfo = map[BuiltInRegistries.BLOCK.getKey(blockState.block)] // Create new solid block state - val solidStateId = nextSolidId++ - val newSolidBlockState = Lod1SolidBlockState( - collisionShape = collisionShape, - elasticity = vsBlockStateInfo?.elasticity?.toFloat() ?: DEFAULT_ELASTICITY.toFloat(), - friction = vsBlockStateInfo?.friction?.toFloat() ?: DEFAULT_FRICTION.toFloat(), - hardness = DEFAULT_HARDNESS.toFloat(), - lod1SolidBlockStateId = solidStateId, - ) - _solidBlockStates.add(newSolidBlockState) - - // Create new voxel state - val blockStateId = nextVoxelStateId++ - - var fluidId = BlockTypeImpl.AIR.toInt() - if (!blockState.fluidState.isEmpty) { - fluidId = getFluidState(blockState.fluidState).first + val solidState = vsCore.newSolidStateBuilder() + .shape(collisionShape) + .elasticity(vsBlockStateInfo?.elasticity ?: DEFAULT_ELASTICITY) + .friction(vsBlockStateInfo?.friction ?: DEFAULT_FRICTION) + .hardness(DEFAULT_HARDNESS) + .build() + + val fluidState = if (!blockState.fluidState.isEmpty) { + getFluidState(blockState.fluidState) + } else { + null } - _blockStateData.add(Triple(solidStateId, fluidId, blockStateId)) - BlockTypeImpl(blockStateId) + VsBlockState(solidState, fluidState) } else { - vsCore.blockTypes.air + vsCore.blockTypes.airState } } - blockStateToId[blockState] = blockType + mcBlockStateToVs[blockState] = vsBlockState } registeredBlocks = true } + // TODO implement + private fun runRegisterBlockStateEvent() { + val event = RegisterBlockStateEventImpl() + ValkyrienSkiesMod.api.registerBlockStateEvent.emit(event) + mcBlockStateToVs.putAll(event.toRegister) + } + private val logger by logger() } 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 f8eb1f0fb..6889d8be9 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 @@ -13,13 +13,13 @@ import net.minecraft.world.phys.Vec3 import org.joml.Vector3f import org.valkyrienskies.core.api.ships.LoadedServerShip import org.valkyrienskies.core.api.ships.setAttachment -import org.valkyrienskies.core.impl.networking.simple.sendToServer import org.valkyrienskies.mod.api.SeatedControllingPlayer import org.valkyrienskies.mod.common.config.VSKeyBindings import org.valkyrienskies.mod.common.getShipManagingPos import org.valkyrienskies.mod.common.getShipObjectManagingPos import org.valkyrienskies.mod.common.isBlockInShipyard import org.valkyrienskies.mod.common.networking.PacketPlayerDriving +import org.valkyrienskies.mod.common.vsCore open class ShipMountingEntity(type: EntityType, level: Level) : Entity(type, level) { // Decides if this entity controls the ship it is in. @@ -100,7 +100,9 @@ open class ShipMountingEntity(type: EntityType, level: Level impulse.x = if (left == right) 0.0f else if (left) 1.0f else -1.0f impulse.y = if (up == down) 0.0f else if (up) 1.0f else -1.0f - PacketPlayerDriving(impulse, sprint, cruise).sendToServer() + with(vsCore.simplePacketNetworking) { + PacketPlayerDriving(impulse, sprint, cruise).sendToServer() + } } override fun getControllingPassenger(): LivingEntity? { 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 900e9c645..bdc1377f6 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,15 +1,14 @@ 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 -import org.valkyrienskies.core.impl.networking.simple.sendToClient 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 @@ -100,6 +99,8 @@ object VSEntityManager { } .toMap() - PacketSyncVSEntityTypes(entityTypes).sendToClient(player) + with(vsCore.simplePacketNetworking) { + PacketSyncVSEntityTypes(entityTypes).sendToClient(player) + } } } 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 65124d70f..fd7103297 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 @@ -7,7 +7,7 @@ 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.impl.util.events.EventEmitterImpl +import org.valkyrienskies.core.util.events.EventEmitterImpl object VSGameEvents { 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 4e245c9b6..db56b3466 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,31 +1,28 @@ 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 import org.valkyrienskies.core.api.ships.getAttachment import org.valkyrienskies.core.api.ships.setAttachment -import org.valkyrienskies.core.impl.networking.simple.register -import org.valkyrienskies.core.impl.networking.simple.registerClientHandler -import org.valkyrienskies.core.impl.networking.simple.registerServerHandler import org.valkyrienskies.mod.api.SeatedControllingPlayer import org.valkyrienskies.mod.common.entity.ShipMountingEntity import org.valkyrienskies.mod.common.entity.handling.VSEntityManager import org.valkyrienskies.mod.common.getShipObjectManagingPos import org.valkyrienskies.mod.common.util.MinecraftPlayer +import org.valkyrienskies.mod.common.vsCore object VSGamePackets { - fun register() { + fun register() = with(vsCore.simplePacketNetworking) { PacketPlayerDriving::class.register() PacketStopChunkUpdates::class.register() PacketRestartChunkUpdates::class.register() PacketSyncVSEntityTypes::class.register() } - fun registerHandlers() { + fun registerHandlers() = with(vsCore.simplePacketNetworking) { PacketPlayerDriving::class.registerServerHandler { driving, iPlayer -> val player = (iPlayer as MinecraftPlayer).player as ServerPlayer val seat = player.vehicle as? ShipMountingEntity 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 80997f52f..cef8435c0 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 @@ -13,8 +13,8 @@ import org.joml.primitives.AABBd import org.joml.primitives.AABBdc import org.valkyrienskies.core.api.ships.Ship import org.valkyrienskies.core.apigame.collision.ConvexPolygonc -import org.valkyrienskies.core.impl.collision.k.createPolygonFromAABB import org.valkyrienskies.core.util.extend +import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.getShipsIntersecting import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.vsCore @@ -110,7 +110,7 @@ object EntityShipCollisionUtils { val entityBoxWithMovement = entityBoundingBox.expandTowards(movement) val collidingPolygons: MutableList = ArrayList() val entityBoundingBoxExtended = entityBoundingBox.toJOML().extend(movement.toJOML()) - for (shipObject in world.shipObjectWorld.loadedShips.getIntersecting(entityBoundingBoxExtended)) { + for (shipObject in world.shipObjectWorld.loadedShips.getIntersecting(entityBoundingBoxExtended, world.dimensionId)) { val shipTransform = shipObject.transform val entityPolyInShipCoordinates: ConvexPolygonc = collider.createPolygonFromAABB( entityBoxWithMovement.toJOML(), @@ -125,7 +125,7 @@ object EntityShipCollisionUtils { world.getBlockCollisions(entity, entityBoundingBoxInShipCoordinates.toMinecraft()) shipBlockCollisionStream.forEach { voxelShape: VoxelShape -> voxelShape.forAllBoxes { minX, minY, minZ, maxX, maxY, maxZ -> - val shipPolygon: ConvexPolygonc = createPolygonFromAABB( + val shipPolygon: ConvexPolygonc = vsCore.entityPolygonCollider.createPolygonFromAABB( AABBd(minX, minY, minZ, maxX, maxY, maxZ), shipTransform.shipToWorld, shipObject.id diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt index 8081551a7..27ca1f1cb 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt @@ -18,12 +18,15 @@ import org.apache.commons.lang3.StringUtils import org.valkyrienskies.core.impl.config.SidedVSConfigClass import org.valkyrienskies.core.impl.config.VSConfigClass import org.valkyrienskies.core.impl.util.serialization.VSJacksonUtil +import org.valkyrienskies.mod.common.vsCore import java.util.Optional object VSClothConfig { @JvmStatic - fun createConfigScreenFor(parent: Screen, vararg configClasses: VSConfigClass): Screen { + fun createConfigScreenFor(parent: Screen, vararg configClassesJ: Class<*>): Screen { + val configClasses = configClassesJ.map(vsCore::getRegisteredConfigLegacy) + return ConfigBuilder.create().apply { parentScreen = parent @@ -240,7 +243,7 @@ object VSClothConfig { val newValue = try { mapper.readTree(str) } catch (ex: JsonProcessingException) { - return@setErrorSupplier Optional.of(Component.literal(ex.message)) + return@setErrorSupplier Optional.of(Component.literal(ex.message ?: "")) } getValidationMessageComponent(newValue) 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 58faea254..e7fcbca02 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 @@ -26,8 +26,7 @@ import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.RegistryObject import org.valkyrienskies.core.apigame.VSCoreFactory -import org.valkyrienskies.core.impl.config.VSConfigClass -import org.valkyrienskies.core.impl.config.VSCoreConfig +import org.valkyrienskies.core.impl.config_impl.VSCoreConfig import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.client.VSPhysicsEntityRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod @@ -105,8 +104,8 @@ class ValkyrienSkiesModForge { ConfigScreenHandler.ConfigScreenFactory { _, parent -> VSClothConfig.createConfigScreenFor( parent, - VSConfigClass.getRegisteredConfig(VSCoreConfig::class.java), - VSConfigClass.getRegisteredConfig(VSGameConfig::class.java) + VSCoreConfig::class.java, + VSGameConfig::class.java ) } } diff --git a/gradle.properties b/gradle.properties index 9e2c1f161..ea544ea80 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,7 +28,7 @@ createbigcannons_version= 0.5.2.a create_utilities_version=0.2.1+1.20.1 energy_version=2.3.0 -vs_core_version=1.1.0+b19b27c4a4 +vs_core_version=1.1.0+3a97aaf771 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually kotlin.stdlib.default.dependency=false From 43668c8368c9e0f0bd30d5fe02d3715595be2bc6 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 24 May 2024 20:25:52 -0400 Subject: [PATCH 123/156] initial work on api --- .../valkyrienskies/mod/api/ValkyrienSkies.kt | 20 ++++++++++++++ .../org/valkyrienskies/mod/api/VsApi.kt | 10 +++---- .../valkyrienskies/mod/common/VSGameUtils.kt | 11 +++----- .../mod/common/command/VSCommands.kt | 26 +++++++++---------- .../mod/common/entity/VSPhysicsEntity.kt | 4 +-- .../mod/common/world/RaycastUtils.kt | 10 ++++--- 6 files changed, 48 insertions(+), 33 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api/ValkyrienSkies.kt diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/ValkyrienSkies.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/ValkyrienSkies.kt new file mode 100644 index 000000000..5ef8f8264 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/ValkyrienSkies.kt @@ -0,0 +1,20 @@ +@file:JvmName("ValkyrienSkies") +package org.valkyrienskies.mod.api + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.ChunkPos +import net.minecraft.world.level.Level +import org.valkyrienskies.core.api.ships.LoadedShip +import org.valkyrienskies.core.api.ships.Ship + +val vsApi: VsApi @JvmName("getApi") get() = TODO() + +fun Level?.getShipManagingBlock(pos: BlockPos?) = vsApi.getShipManagingBlock(this, pos) +fun Level?.getShipManagingBlock(x: Int, y: Int, z: Int) = getShipManagingChunk(x shr 4, z shr 4) + +fun Level?.getLoadedShipManagingBlock(pos: BlockPos?): LoadedShip? = TODO() + +fun Level?.getDeadShipManagingBlock(pos: BlockPos?): Ship? = TODO() + +fun Level?.getShipManagingChunk(pos: ChunkPos?) = vsApi.getShipManagingChunk(this, pos) +fun Level?.getShipManagingChunk(chunkX: Int, chunkZ: Int) = vsApi.getShipManagingChunk(this, chunkX, chunkZ) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt index 61cb0c671..270bf4ebc 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt @@ -9,6 +9,7 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.world.entity.Entity import org.jetbrains.annotations.ApiStatus.* +import org.valkyrienskies.core.api.VsCoreApi import org.valkyrienskies.core.api.event.ListenableEvent import org.valkyrienskies.core.api.ships.* import org.valkyrienskies.mod.api.events.PostRenderShipEvent @@ -16,12 +17,7 @@ import org.valkyrienskies.mod.api.events.PreRenderShipEvent import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent @NonExtendable -interface VsApi { - - companion object { - @get:JvmStatic - val instance: VsApi get() = TODO() - } +interface VsApi : VsCoreApi { /** * This event gets called when it's time to register physics block states for Minecraft block states. @@ -55,4 +51,6 @@ interface VsApi { fun getShipManagingBlock(level: Level?, pos: BlockPos?): Ship? fun getShipManagingChunk(level: Level?, pos: ChunkPos?): Ship? + + fun getShipManagingChunk(level: Level?, chunkX: Int, chunkZ: Int): Ship? } 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 4b91b8b14..0f38c1c50 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -285,12 +285,7 @@ fun ServerLevel?.getShipObjectManagingPos(pos: Vector3dc) = private fun getShipManagingPosImpl(world: Level?, x: Int, z: Int): Ship? { return if (world != null && world.isChunkInShipyard(x, z)) { - val ship = world.shipObjectWorld.allShips.getByChunkPos(x, z, world.dimensionId) - if (ship != null && ship.chunkClaimDimension == world.dimensionId) { - ship - } else { - null - } + world.shipObjectWorld.allShips.getByChunkPos(x, z, world.dimensionId) } else { null } @@ -397,7 +392,7 @@ fun Level?.getWorldCoordinates(blockPos: BlockPos, pos: Vector3d): Vector3d { } fun Level.getShipsIntersecting(aabb: AABB): Iterable = getShipsIntersecting(aabb.toJOML()) -fun Level.getShipsIntersecting(aabb: AABBdc): Iterable = allShips.getIntersecting(aabb).filter { it.chunkClaimDimension == dimensionId } +fun Level.getShipsIntersecting(aabb: AABBdc): Iterable = allShips.getIntersecting(aabb, dimensionId) fun Level?.transformAabbToWorld(aabb: AABB): AABB = transformAabbToWorld(aabb.toJOML()).toMinecraft() fun Level?.transformAabbToWorld(aabb: AABBd) = this?.transformAabbToWorld(aabb, aabb) ?: aabb @@ -406,7 +401,7 @@ fun Level.transformAabbToWorld(aabb: AABBdc, dest: AABBd): AABBd { val ship2 = getShipManagingPos(aabb.maxX(), aabb.maxY(), aabb.maxZ()) // if both endpoints of the aabb are in the same ship, do the transform - if (ship1 == ship2 && ship1 != null && ship1.chunkClaimDimension == dimensionId) { + if (ship1 == ship2 && ship1 != null) { return aabb.transform(ship1.shipToWorld, dest) } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt index 63597f2db..24f40a10a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt @@ -62,7 +62,7 @@ object VSCommands { try { val r = ShipArgument.getShips(it, "ships").toList() as List vsCore.deleteShips(it.source.shipWorld as ServerShipWorld, r) - it.source.sendVSMessage(Component.translatable(DELETED_SHIPS_MESSAGE, r.size)) + it.source.sendVSMessage(translatable(DELETED_SHIPS_MESSAGE, r.size)) r.size } catch (e: Exception) { if (e !is CommandRuntimeException) LOGGER.throwing(e) @@ -87,7 +87,7 @@ object VSCommands { } it.source.sendVSMessage( - Component.translatable( + translatable( SET_SHIP_STATIC_SUCCESS_MESSAGE, r.size, if (isStatic) "true" else "false" ) ) @@ -117,7 +117,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - Component.translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) + translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -151,7 +151,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - Component.translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) + translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -191,7 +191,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - Component.translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) + translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -237,7 +237,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - Component.translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) + translatable(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -263,7 +263,7 @@ object VSCommands { val ship = sourceEntity.level().getShipManagingPos(rayTrace.blockPos) if (ship != null) { (it.source as VSCommandSource).sendVSMessage( - Component.translatable(GET_SHIP_SUCCESS_MESSAGE, ship.slug) + translatable(GET_SHIP_SUCCESS_MESSAGE, ship.slug) ) success = true } @@ -271,12 +271,12 @@ object VSCommands { if (success) { 1 } else { - (it.source as VSCommandSource).sendVSMessage(Component.translatable(GET_SHIP_FAIL_MESSAGE)) + (it.source as VSCommandSource).sendVSMessage(translatable(GET_SHIP_FAIL_MESSAGE)) 0 } } else { (it.source as VSCommandSource).sendVSMessage( - Component.translatable(GET_SHIP_ONLY_USABLE_BY_ENTITIES_MESSAGE) + translatable(GET_SHIP_ONLY_USABLE_BY_ENTITIES_MESSAGE) ) 0 } @@ -346,12 +346,12 @@ object VSCommands { ) ) - dispatcher.root.children.first { it.name == "teleport" }.apply { + dispatcher.root.children.firstOrNull { it.name == "teleport" }?.apply { addChild( argument("ships", ShipArgument.selectorOnly()).executes { val serverShips = ShipArgument.getShips(it, "ships").toList() as List val serverShip = serverShips.singleOrNull() ?: throw CommandRuntimeException( - Component.translatable(TELEPORT_FIRST_ARG_CAN_ONLY_INPUT_1_SHIP) + translatable(TELEPORT_FIRST_ARG_CAN_ONLY_INPUT_1_SHIP) ) val source = it.source as CommandSourceStack val shipPos = serverShip.transform.positionInWorld @@ -369,7 +369,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - Component.translatable(TELEPORTED_MULTIPLE_SHIPS_SUCCESS, serverShips.size) + translatable(TELEPORTED_MULTIPLE_SHIPS_SUCCESS, serverShips.size) ) serverShips.size } @@ -386,7 +386,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - Component.translatable(TELEPORTED_MULTIPLE_SHIPS_SUCCESS, serverShips.size) + translatable(TELEPORTED_MULTIPLE_SHIPS_SUCCESS, serverShips.size) ) serverShips.size } 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 879b890f7..9fa7dd50b 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 @@ -159,10 +159,10 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En super.load(compoundTag) } - override fun setLevelCallback(callback: EntityInLevelCallback?) { + override fun setLevelCallback(callback: EntityInLevelCallback) { super.setLevelCallback(callback) if (!this.level().isClientSide) { - val isNull = (callback == null) || callback == EntityInLevelCallback.NULL + val isNull = callback == EntityInLevelCallback.NULL if (!isNull) { // Try adding the rigid body of this entity from the world if (physicsEntityServer != null) { 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 83a1bdd3a..45ccfb945 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 @@ -18,8 +18,10 @@ import org.apache.logging.log4j.LogManager import org.joml.Vector3d import org.joml.primitives.AABBd import org.joml.primitives.AABBdc +import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.properties.ShipId import org.valkyrienskies.core.game.ships.ShipObjectClient +import org.valkyrienskies.mod.common.getShipsIntersecting import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toMinecraft @@ -52,13 +54,13 @@ fun Level.clipIncludeShips( // Iterate every ship, find do the raycast in ship space, // choose the raycast with the lowest distance to the start position. - for (ship in shipObjectWorld.loadedShips.getIntersecting(clipAABB)) { + for (ship in getShipsIntersecting(clipAABB)) { // Skip skipShip if (ship.id == skipShip) { continue } - val worldToShip = (ship as? ShipObjectClient)?.renderTransform?.worldToShipMatrix ?: ship.worldToShip - val shipToWorld = (ship as? ShipObjectClient)?.renderTransform?.shipToWorldMatrix ?: ship.shipToWorld + val worldToShip = (ship as? ClientShip)?.renderTransform?.worldToShip ?: ship.worldToShip + val shipToWorld = (ship as? ClientShip)?.renderTransform?.shipToWorld ?: ship.shipToWorld val shipStart = worldToShip.transformPosition(ctx.from.toJOML()).toMinecraft() val shipEnd = worldToShip.transformPosition(ctx.to.toJOML()).toMinecraft() @@ -223,7 +225,7 @@ fun Level.raytraceEntities( val start = Vector3d() val end = Vector3d() - shipObjectWorld.loadedShips.getIntersecting(origBoundingBoxM.toJOML()).forEach { + getShipsIntersecting(origBoundingBoxM.toJOML()).forEach { it.worldToShip.transformPosition(origStartVec, start) it.worldToShip.transformPosition(origEndVec, end) From bcda04a48246404c0efd7050e19cb6422be6f75c Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sat, 25 May 2024 21:16:10 -0400 Subject: [PATCH 124/156] compat: integrated dynamics (#851) --- .../valkyrienskies/mod/common/VSGameUtils.kt | 2 +- .../mod/util/VectorConversionsMC.kt | 4 ++ forge/build.gradle | 5 ++ .../MixinVoxelShapeComponents.java | 57 +++++++++++++++++++ .../valkyrienskies-forge.mixins.json | 1 + settings.gradle | 12 ++-- 6 files changed, 74 insertions(+), 7 deletions(-) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/integrateddynamics/MixinVoxelShapeComponents.java 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 7deaab3ea..cf8fb104d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -304,7 +304,7 @@ fun ClientLevel?.transformRenderAABBToWorld(pos: Position, aabb: AABB): AABB { return aabb } -fun Entity.getShipManaging(): Ship? = this.level().getShipManagingPos(this.position()) +fun Entity?.getShipManaging(): Ship? = this?.let { this.level().getShipManagingPos(this.position()) } // Level fun Level?.getShipManagingPos(chunkX: Int, chunkZ: Int) = 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 dbb47cbd0..0a9f1eb5a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/util/VectorConversionsMC.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/util/VectorConversionsMC.kt @@ -101,6 +101,10 @@ fun Matrix4dc.transform(v: Vector4f) = v.also { ) } +fun Matrix4dc.transformPosition(v: Vec3): Vec3 { + return transformPosition(v.toJOML()).toMinecraft() +} + // endregion // region Minecraft diff --git a/forge/build.gradle b/forge/build.gradle index 8b6268115..2330102dc 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -85,6 +85,11 @@ dependencies { // Modular Routers modCompileOnly("curse.maven:mr-250294:4696089") + // Integrated Dynamics + modCompileOnly("curse.maven:integrated-dynamics-236307:5297722") + modCompileOnly("curse.maven:cyclops-core-232758:5262063") + modCompileOnly("curse.maven:common-capabilities-247007:4987207") + // Add Kotlin for Forge (3.12.0) forgeRuntimeLibrary("maven.modrinth:kotlin-for-forge:${kotlin_version}") diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/integrateddynamics/MixinVoxelShapeComponents.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/integrateddynamics/MixinVoxelShapeComponents.java new file mode 100644 index 000000000..eac5d856f --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/integrateddynamics/MixinVoxelShapeComponents.java @@ -0,0 +1,57 @@ +package org.valkyrienskies.mod.forge.mixin.compat.integrateddynamics; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import javax.annotation.Nullable; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.Vec3; +import org.cyclops.integrateddynamics.core.block.BlockRayTraceResultComponent; +import org.cyclops.integrateddynamics.core.block.VoxelShapeComponents; +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.VectorConversionsMCKt; + +/** + * This fixes Integrated Dynamics blocks not working on ships. Integrated Dynamics uses a custom raytrace + * for its blocks which are smaller than a full cube in size. This ensures that those raytraces are done in the shipyard. + *

+ * Note: we already have mixins that do this for the vanilla clip method, but ID made its own clip method that does only one block. + * + * @see Issue #218 + */ +@Mixin(VoxelShapeComponents.class) +public class MixinVoxelShapeComponents { + + @WrapOperation( + method = "Lorg/cyclops/integrateddynamics/core/block/VoxelShapeComponents;rayTrace(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/entity/Entity;)Lorg/cyclops/integrateddynamics/core/block/BlockRayTraceResultComponent;", + remap = false, + at = @At( + value = "INVOKE", + target = "Lorg/cyclops/integrateddynamics/core/block/VoxelShapeComponents;clip(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/core/BlockPos;)Lorg/cyclops/integrateddynamics/core/block/BlockRayTraceResultComponent;", + remap = true + ) + ) + public BlockRayTraceResultComponent preRaytrace(final VoxelShapeComponents instance, final Vec3 startVec, final Vec3 endVec, + final BlockPos entry, final Operation original, final BlockPos pos, @Nullable final Entity entity) { + + // If we're raytracing from an entity (the player), and the player is looking at an Integrated Dynamics block + // in the shipyard, we transform the start and endpoints of the raytrace into the shipyard so that it works + // properly. + if (entity != null) { + final Ship ship = VSGameUtilsKt.getShipManagingPos(entity.getCommandSenderWorld(), pos); + if (ship != null) { + final Vec3 newStart = VectorConversionsMCKt.transformPosition(ship.getWorldToShip(), startVec); + final Vec3 newEnd = VectorConversionsMCKt.transformPosition(ship.getWorldToShip(), endVec); + + return original.call(instance, newStart, newEnd, pos); + } + } + + // otherwise just default to the original behavior + return original.call(instance, startVec, endVec, pos); + } + +} diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index c7b04283b..33be08ee7 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -8,6 +8,7 @@ "compat.create.MixinControlledContraptionEntity", "compat.create.client.trackOutlines.MixinTrackBlockOutline", "compat.immersivengineering.MixinBlockEntityInventory", + "compat.integrateddynamics.MixinVoxelShapeComponents", "compat.modular_routers.MixinRouterMenu", "compat.tfc.MixinTFCChunkGenerator", "compat.thermalexpansion.MixinTileCoFH", diff --git a/settings.gradle b/settings.gradle index e4f82deee..1de8c2a2a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -43,11 +43,11 @@ include("common") include("fabric") include("forge") -try { - def core = file("../vs-core") - if (core.isDirectory()) { - includeBuild(core) - } -} catch (SecurityException ignore) {} +//try { +// def core = file("../vs-core") +// if (core.isDirectory()) { +// includeBuild(core) +// } +//} catch (SecurityException ignore) {} rootProject.name = "valkyrienskies" From 70461ea373bde996d581c613100ebd2aecfb4672 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sun, 26 May 2024 18:26:51 -0400 Subject: [PATCH 125/156] housekeeping: update api --- .../org/valkyrienskies/mod/api_impl/events/VsApiImpl.kt | 4 ++++ .../main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 2 +- .../org/valkyrienskies/mod/common/util/DimensionIdProvider.kt | 2 +- gradle.properties | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VsApiImpl.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VsApiImpl.kt index bb683afbe..3749d133e 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VsApiImpl.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VsApiImpl.kt @@ -37,4 +37,8 @@ class VsApiImpl : VsApi { override fun getShipManagingChunk(level: Level?, pos: ChunkPos?): Ship? { return pos?.let { level?.getShipManagingPos(it) } } + + override fun getShipManagingChunk(level: Level?, chunkX: Int, chunkZ: Int): Ship? { + return level?.getShipManagingPos(chunkX, chunkZ) + } } 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 0f38c1c50..383548825 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -28,11 +28,11 @@ import org.valkyrienskies.core.api.ships.ServerShip import org.valkyrienskies.core.api.ships.Ship import org.valkyrienskies.core.api.util.functions.DoubleTernaryConsumer import org.valkyrienskies.core.api.world.LevelYRange +import org.valkyrienskies.core.api.world.properties.DimensionId import org.valkyrienskies.core.apigame.world.IPlayer import org.valkyrienskies.core.apigame.world.ServerShipWorldCore import org.valkyrienskies.core.apigame.world.ShipWorldCore import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate -import org.valkyrienskies.core.apigame.world.properties.DimensionId import org.valkyrienskies.core.game.ships.ShipObjectServer import org.valkyrienskies.core.impl.hooks.VSEvents.TickEndEvent import org.valkyrienskies.core.util.expand diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/DimensionIdProvider.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/DimensionIdProvider.kt index a9649fc70..2eb2df991 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/DimensionIdProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/DimensionIdProvider.kt @@ -1,6 +1,6 @@ package org.valkyrienskies.mod.common.util -import org.valkyrienskies.core.apigame.world.properties.DimensionId +import org.valkyrienskies.core.api.world.properties.DimensionId /** * Interface used to get the [DimensionId] from Minecraft [Level] objects diff --git a/gradle.properties b/gradle.properties index ea544ea80..0f40bb958 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,7 +28,7 @@ createbigcannons_version= 0.5.2.a create_utilities_version=0.2.1+1.20.1 energy_version=2.3.0 -vs_core_version=1.1.0+3a97aaf771 +vs_core_version=1.1.0+8e5c799a5d # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually kotlin.stdlib.default.dependency=false From 71078a60a4f38fb4dad2f241ff12df0250c5c2d7 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 28 May 2024 16:35:53 -0400 Subject: [PATCH 126/156] fix: fabric compile errors; update vs-core --- .../mod/fabric/compat/modmenu/ValkyrienModMenu.kt | 7 +++---- gradle.properties | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt index bdd81fbdf..9c31462e1 100644 --- a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt +++ b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt @@ -2,8 +2,7 @@ package org.valkyrienskies.mod.fabric.compat.modmenu import com.terraformersmc.modmenu.api.ConfigScreenFactory import com.terraformersmc.modmenu.api.ModMenuApi -import org.valkyrienskies.core.impl.config.VSConfigClass.Companion.getRegisteredConfig -import org.valkyrienskies.core.impl.config.VSCoreConfig +import org.valkyrienskies.core.impl.config_impl.VSCoreConfig import org.valkyrienskies.mod.common.config.VSGameConfig import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig @@ -12,8 +11,8 @@ class ValkyrienModMenu : ModMenuApi { return ConfigScreenFactory { parent -> VSClothConfig.createConfigScreenFor( parent, - getRegisteredConfig(VSCoreConfig::class.java), - getRegisteredConfig(VSGameConfig::class.java) + VSCoreConfig::class.java, + VSGameConfig::class.java ) } } diff --git a/gradle.properties b/gradle.properties index 0f40bb958..daa4f55c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,7 +28,7 @@ createbigcannons_version= 0.5.2.a create_utilities_version=0.2.1+1.20.1 energy_version=2.3.0 -vs_core_version=1.1.0+8e5c799a5d +vs_core_version=1.1.0+2c8004ed40 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually kotlin.stdlib.default.dependency=false From 6911bbe238de0dde753c29d5a20c5af1d04202cd Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 28 May 2024 18:12:43 -0400 Subject: [PATCH 127/156] fix: errors with latest version of vs-core --- .../mod/mixin/entity/MixinEntity.java | 5 ++--- .../mod/common/BlockStateInfoProvider.kt | 5 ----- .../mod/common/DefaultBlockStateInfoProvider.kt | 5 ----- .../valkyrienskies/mod/common/ValkyrienSkiesMod.kt | 3 --- .../mod/common/command/VSCommands.kt | 14 +------------- .../mod/common/entity/VSPhysicsEntity.kt | 5 ++--- fabric/build.gradle | 5 +++++ .../trackOutlines/MixinTrackBlockOutline.java | 10 +++++----- .../trackOutlines/MixinTrackBlockOutline.java | 10 +++++----- gradle.properties | 2 +- 10 files changed, 21 insertions(+), 43 deletions(-) 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 e8eb20a5d..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 @@ -31,7 +31,6 @@ import org.valkyrienskies.core.api.ships.LoadedShip; import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.core.api.ships.properties.ShipTransform; -import org.valkyrienskies.core.impl.game.ships.ShipObjectClient; import org.valkyrienskies.mod.common.entity.ShipMountedToData; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.EntityDraggingInformation; @@ -112,8 +111,8 @@ private void preGetEyePosition(final float partialTicks, final CallbackInfoRetur final LoadedShip shipMountedTo = shipMountedToData.getShipMountedTo(); final ShipTransform shipTransform; - if (shipMountedTo instanceof ShipObjectClient) { - shipTransform = ((ShipObjectClient) shipMountedTo).getRenderTransform(); + if (shipMountedTo instanceof ClientShip) { + shipTransform = ((ClientShip) shipMountedTo).getRenderTransform(); } else { shipTransform = shipMountedTo.getShipTransform(); } 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 1cdd6595e..0d85a7866 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -17,11 +17,6 @@ import org.valkyrienskies.core.apigame.world.chunks.BlockType import org.valkyrienskies.mod.common.block.WingBlock import org.valkyrienskies.mod.common.config.MassDatapackResolver import org.valkyrienskies.mod.common.hooks.VSGameEvents -import org.valkyrienskies.physics_api.Lod1BlockStateId -import org.valkyrienskies.physics_api.Lod1LiquidBlockStateId -import org.valkyrienskies.physics_api.Lod1SolidBlockStateId -import org.valkyrienskies.physics_api.voxel.Lod1LiquidBlockState -import org.valkyrienskies.physics_api.voxel.Lod1SolidBlockState import java.util.function.IntFunction // Other mods can then provide weights and types based on their added content diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt index d69962eae..231e37b7a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt @@ -4,11 +4,6 @@ import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.LiquidBlock import net.minecraft.world.level.block.state.BlockState import org.valkyrienskies.core.apigame.world.chunks.BlockType -import org.valkyrienskies.physics_api.Lod1BlockStateId -import org.valkyrienskies.physics_api.Lod1LiquidBlockStateId -import org.valkyrienskies.physics_api.Lod1SolidBlockStateId -import org.valkyrienskies.physics_api.voxel.Lod1LiquidBlockState -import org.valkyrienskies.physics_api.voxel.Lod1SolidBlockState object DefaultBlockStateInfoProvider : BlockStateInfoProvider { override val priority: Int diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt index 46d3d4d17..1803a2b34 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -14,10 +14,7 @@ import net.minecraft.world.level.block.entity.BlockEntityType import org.valkyrienskies.core.api.ships.setAttachment import org.valkyrienskies.core.apigame.VSCore import org.valkyrienskies.core.apigame.VSCoreClient -import org.valkyrienskies.core.impl.config.VSConfigClass -import org.valkyrienskies.core.impl.config_impl.VSCoreConfig import org.valkyrienskies.core.impl.hooks.VSEvents -import org.valkyrienskies.mod.api.VsApi import org.valkyrienskies.mod.api_impl.events.VsApiImpl import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.config.VSGameConfig diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt index 24f40a10a..7e45e84b8 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt @@ -3,7 +3,6 @@ package org.valkyrienskies.mod.common.command import com.mojang.brigadier.CommandDispatcher import com.mojang.brigadier.arguments.ArgumentType import com.mojang.brigadier.arguments.BoolArgumentType -import com.mojang.brigadier.arguments.DoubleArgumentType import com.mojang.brigadier.arguments.StringArgumentType import com.mojang.brigadier.builder.LiteralArgumentBuilder import com.mojang.brigadier.builder.RequiredArgumentBuilder @@ -13,7 +12,6 @@ import net.minecraft.commands.CommandSourceStack import net.minecraft.commands.arguments.EntityArgument import net.minecraft.commands.arguments.coordinates.BlockPosArgument import net.minecraft.commands.arguments.coordinates.Vec3Argument -import net.minecraft.network.chat.Component import net.minecraft.network.chat.Component.translatable import net.minecraft.world.entity.Entity import net.minecraft.world.phys.BlockHitResult @@ -23,12 +21,9 @@ import org.valkyrienskies.core.api.world.ServerShipWorld import org.valkyrienskies.core.api.world.ShipWorld import org.valkyrienskies.core.apigame.ShipTeleportData import org.valkyrienskies.core.impl.game.ShipTeleportDataImpl -import org.valkyrienskies.core.impl.game.ships.ShipData -import org.valkyrienskies.core.impl.game.ships.ShipObject import org.valkyrienskies.core.util.x import org.valkyrienskies.core.util.y import org.valkyrienskies.core.util.z -import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.getShipManagingPos import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toJOMLD @@ -77,14 +72,7 @@ object VSCommands { val r = ShipArgument.getShips(it, "ships").toList() as List val isStatic = BoolArgumentType.getBool(it, "is-static") r.forEach { ship -> - if (ship is ShipObject) { - // TODO: AAAAAAAAA THIS IS HORRIBLE how can the API support this? - (ship.shipData as ShipData).isStatic = isStatic - } else if (ship is ShipData) { - // TODO: AAAAAAAAA THIS IS HORRIBLE how can the API support this? - ship.isStatic = isStatic - } - + ship.isStatic = isStatic } it.source.sendVSMessage( translatable( 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 9fa7dd50b..0d8401c75 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 @@ -27,7 +27,6 @@ import org.valkyrienskies.core.apigame.world.ServerShipWorldCore import org.valkyrienskies.core.impl.game.ShipTeleportDataImpl import org.valkyrienskies.core.impl.game.ships.ShipInertiaDataImpl import org.valkyrienskies.core.impl.game.ships.ShipObjectClientWorld -import org.valkyrienskies.core.impl.game.ships.ShipObjectServerWorld import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl import org.valkyrienskies.core.impl.util.serialization.VSJacksonUtil import org.valkyrienskies.mod.common.dimensionId @@ -142,7 +141,7 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En } val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY) val oldPhysicsEntityData = getMapper().readValue(physicsEntityDataAsBytes) - val newShipId = (level().shipObjectWorld as ShipObjectServerWorld).allocateShipId(level().dimensionId) + val newShipId = (level().shipObjectWorld as ServerShipWorldCore).allocateShipId(level().dimensionId) val newPhysicsEntityData = oldPhysicsEntityData.copyPhysicsEntityDataWithNewId(newShipId) // Change the shipId to be something new setPhysicsEntityData(newPhysicsEntityData) @@ -199,7 +198,7 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En if (physicsEntityServerCopy != null) { val newPos = Vector3d(d, e, f) val teleportData = ShipTeleportDataImpl(newPos = newPos) - (this.level().shipObjectWorld as ShipObjectServerWorld).teleportPhysicsEntity(this.physicsEntityServer!!, teleportData) + (this.level().shipObjectWorld as ServerShipWorldCore).teleportPhysicsEntity(this.physicsEntityServer!!, teleportData) } else { physicsEntityData!!.transform = ShipTransformImpl.create( Vector3d(d, e, f), diff --git a/fabric/build.gradle b/fabric/build.gradle index 2e5490396..7d79522c7 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -67,6 +67,11 @@ dependencies { exclude group: "com.google.guava" } + def jacksonVersion = '2.14.0' + + + include("com.fasterxml:classmate:1.5.1") + implementation("com.fasterxml:classmate:1.5.1") // CC Restitched //modImplementation("curse.maven:cc-restitched-462672:3908334"){ // exclude module: "jsonschema.module.addon" diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java index f71208b95..83ad26a3a 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java @@ -24,8 +24,8 @@ 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.core.impl.game.ships.ShipObjectClient; import org.valkyrienskies.mod.common.VSClientGameUtils; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @@ -58,8 +58,8 @@ private static PoseStack redirectTransformStackTranslate(final PoseStack ms) { final Level level = Minecraft.getInstance().level; if (level != null && valkyrienskies$vec != null) { - final ShipObjectClient ship; - if ((ship = (ShipObjectClient) VSGameUtilsKt.getShipManagingPos(level, 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); @@ -117,8 +117,8 @@ private static void harvest(final LevelRenderer context, final Camera info, fina 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 ShipObjectClient ship; - if ((ship = (ShipObjectClient) VSGameUtilsKt.getShipManagingPos(level, + final ClientShip ship; + if ((ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, valkyrienskies$hitResult.getBlockPos())) != null) { final Vec3 camPos = valkyrienskies$info.getPosition(); VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), instance, diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java index be2aa2349..97c911ad6 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java @@ -22,8 +22,8 @@ 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.core.impl.game.ships.ShipObjectClient; import org.valkyrienskies.mod.common.VSClientGameUtils; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @@ -58,8 +58,8 @@ private static PoseStack redirectTransformStackTranslate(final PoseStack ms) { final Level level = Minecraft.getInstance().level; if (level != null && valkyrienskies$vec != null) { - final ShipObjectClient ship; - if ((ship = (ShipObjectClient) VSGameUtilsKt.getShipManagingPos(level, 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); @@ -115,8 +115,8 @@ private static void harvest(Block event, CallbackInfo ci) { 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 ShipObjectClient ship; - if ((ship = (ShipObjectClient) VSGameUtilsKt.getShipManagingPos(level, + final ClientShip ship; + if ((ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, valkyrienskies$hitResult.getBlockPos())) != null) { final Vec3 camPos = valkyrienskies$info.getPosition(); VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), instance, diff --git a/gradle.properties b/gradle.properties index daa4f55c9..a4bae6dd7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,7 +28,7 @@ createbigcannons_version= 0.5.2.a create_utilities_version=0.2.1+1.20.1 energy_version=2.3.0 -vs_core_version=1.1.0+2c8004ed40 +vs_core_version=1.1.0+233880a786 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually kotlin.stdlib.default.dependency=false From 2e6723d19a509bf439aef1b4a8acf6189acf100d Mon Sep 17 00:00:00 2001 From: Dokurai Date: Sat, 29 Jun 2024 07:27:18 +0300 Subject: [PATCH 128/156] Fix TFC compatibility issue (#833) --- .../mod/forge/mixin/compat/tfc/MixinTFCChunkGenerator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 index 16fc6dba0..a20e2602b 100644 --- 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 @@ -59,7 +59,7 @@ private void preCreateReferences( } @Inject(method = "m_214184_", at = @At("HEAD"), cancellable = true) - private void preGetBaseColumn(int i, int j, LevelHeightAccessor levelHeightAccessor, CallbackInfoReturnable cir) { + private void preGetBaseColumn(int i, int j, LevelHeightAccessor levelHeightAccessor, RandomState randomState, CallbackInfoReturnable cir) { if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(i, j)) { cir.setReturnValue(new NoiseColumn(0, new BlockState[0])); } From c06ad13c1ee815ca81ae9b2c89f64c8339381427 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Jun 2024 12:03:39 -0400 Subject: [PATCH 129/156] Remove DimensionId from getIntersecting calls, update vscore --- .../org/valkyrienskies/mod/mixin/client/MixinCamera.java | 1 - .../mod/mixin/server/world/MixinChunkMap.java | 1 - .../kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 6 +++--- 3 files changed, 3 insertions(+), 5 deletions(-) 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 5b908e493..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 @@ -27,7 +27,6 @@ import org.valkyrienskies.core.api.ships.properties.ShipTransform; import org.valkyrienskies.mod.client.IVSCamera; import org.valkyrienskies.mod.common.world.RaycastUtilsKt; -import org.joml.Vector3f; @Mixin(Camera.class) public abstract class MixinCamera implements IVSCamera { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java index dadf8a84d..590b3c56d 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinChunkMap.java @@ -6,7 +6,6 @@ import java.util.List; import java.util.Set; import java.util.function.Supplier; -import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; 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 d7cfc22d8..cf4b69a37 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -28,11 +28,11 @@ import org.valkyrienskies.core.api.ships.ServerShip import org.valkyrienskies.core.api.ships.Ship import org.valkyrienskies.core.api.util.functions.DoubleTernaryConsumer import org.valkyrienskies.core.api.world.LevelYRange -import org.valkyrienskies.core.api.world.properties.DimensionId import org.valkyrienskies.core.apigame.world.IPlayer import org.valkyrienskies.core.apigame.world.ServerShipWorldCore import org.valkyrienskies.core.apigame.world.ShipWorldCore import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate +import org.valkyrienskies.core.apigame.world.properties.DimensionId import org.valkyrienskies.core.game.ships.ShipObjectServer import org.valkyrienskies.core.impl.hooks.VSEvents.TickEndEvent import org.valkyrienskies.core.util.expand @@ -212,7 +212,7 @@ inline fun Level.transformToNearbyShipsAndWorld( cb(posInWorld.x(), posInWorld.y(), posInWorld.z()) } - for (nearbyShip in shipObjectWorld.allShips.getIntersecting(aabb, dimensionId)) { + for (nearbyShip in shipObjectWorld.allShips.getIntersecting(aabb)) { if (nearbyShip == currentShip) continue val posInShip = nearbyShip.worldToShip.transformPosition(posInWorld, temp0) cb(posInShip.x(), posInShip.y(), posInShip.z()) @@ -392,7 +392,7 @@ fun Level?.getWorldCoordinates(blockPos: BlockPos, pos: Vector3d): Vector3d { } fun Level.getShipsIntersecting(aabb: AABB): Iterable = getShipsIntersecting(aabb.toJOML()) -fun Level.getShipsIntersecting(aabb: AABBdc): Iterable = allShips.getIntersecting(aabb, dimensionId) +fun Level.getShipsIntersecting(aabb: AABBdc): Iterable = allShips.getIntersecting(aabb) fun Level?.transformAabbToWorld(aabb: AABB): AABB = transformAabbToWorld(aabb.toJOML()).toMinecraft() fun Level?.transformAabbToWorld(aabb: AABBd) = this?.transformAabbToWorld(aabb, aabb) ?: aabb From 2a68254c32b6b54a810b1999595b6a440bc9305e Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Jun 2024 12:04:50 -0400 Subject: [PATCH 130/156] forgor properties --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index a4bae6dd7..fd0f74256 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,7 +28,7 @@ createbigcannons_version= 0.5.2.a create_utilities_version=0.2.1+1.20.1 energy_version=2.3.0 -vs_core_version=1.1.0+233880a786 +vs_core_version=1.1.0+c366a39369 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually kotlin.stdlib.default.dependency=false From e21b52807b255305c65030e263a7e083eed4bdd8 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Jun 2024 12:29:59 -0400 Subject: [PATCH 131/156] fix: nvm, i cant read hash numbers --- common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt | 2 +- .../main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 4 ++-- gradle.properties | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt index 270bf4ebc..787296871 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt @@ -17,7 +17,7 @@ import org.valkyrienskies.mod.api.events.PreRenderShipEvent import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent @NonExtendable -interface VsApi : VsCoreApi { +interface VsApi : VSCoreApi { /** * This event gets called when it's time to register physics block states for Minecraft block states. 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 cf4b69a37..1049b9ec8 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -212,7 +212,7 @@ inline fun Level.transformToNearbyShipsAndWorld( cb(posInWorld.x(), posInWorld.y(), posInWorld.z()) } - for (nearbyShip in shipObjectWorld.allShips.getIntersecting(aabb)) { + for (nearbyShip in shipObjectWorld.allShips.getIntersecting(aabb, dimensionId)) { if (nearbyShip == currentShip) continue val posInShip = nearbyShip.worldToShip.transformPosition(posInWorld, temp0) cb(posInShip.x(), posInShip.y(), posInShip.z()) @@ -392,7 +392,7 @@ fun Level?.getWorldCoordinates(blockPos: BlockPos, pos: Vector3d): Vector3d { } fun Level.getShipsIntersecting(aabb: AABB): Iterable = getShipsIntersecting(aabb.toJOML()) -fun Level.getShipsIntersecting(aabb: AABBdc): Iterable = allShips.getIntersecting(aabb) +fun Level.getShipsIntersecting(aabb: AABBdc): Iterable = allShips.getIntersecting(aabb, dimensionId) fun Level?.transformAabbToWorld(aabb: AABB): AABB = transformAabbToWorld(aabb.toJOML()).toMinecraft() fun Level?.transformAabbToWorld(aabb: AABBd) = this?.transformAabbToWorld(aabb, aabb) ?: aabb diff --git a/gradle.properties b/gradle.properties index fd0f74256..c5c73d0a9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,7 +28,7 @@ createbigcannons_version= 0.5.2.a create_utilities_version=0.2.1+1.20.1 energy_version=2.3.0 -vs_core_version=1.1.0+c366a39369 +vs_core_version=1.1.0+da86725858 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually kotlin.stdlib.default.dependency=false From 156c780eeacd249f075ab6fb267a95ee098b06f5 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Jun 2024 12:47:42 -0400 Subject: [PATCH 132/156] weird compiler error --- common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt index 787296871..270bf4ebc 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/VsApi.kt @@ -17,7 +17,7 @@ import org.valkyrienskies.mod.api.events.PreRenderShipEvent import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent @NonExtendable -interface VsApi : VSCoreApi { +interface VsApi : VsCoreApi { /** * This event gets called when it's time to register physics block states for Minecraft block states. From a9348063d0831d3a8bf7433f05da3e8ea9880e4f Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Wed, 3 Jul 2024 20:40:53 +0200 Subject: [PATCH 133/156] Make mixin more sane for better compatibility --- .../client/renderer/MixinLevelRenderer.java | 59 ---------------- .../hit_outline/MixinLevelRenderer.java | 67 +++++++++++++++++++ .../valkyrienskies-common.mixins.json | 3 +- 3 files changed, 69 insertions(+), 60 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/hit_outline/MixinLevelRenderer.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java index 59776e28c..bc939442a 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/renderer/MixinLevelRenderer.java @@ -1,44 +1,13 @@ package org.valkyrienskies.mod.mixin.client.renderer; -import static org.valkyrienskies.mod.common.VSClientGameUtils.transformRenderWithShip; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.blaze3d.vertex.VertexConsumer; -import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.LevelRenderer; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.phys.Vec3; -import net.minecraft.world.phys.shapes.CollisionContext; -import net.minecraft.world.phys.shapes.VoxelShape; 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.Constant; -import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyConstant; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.mod.common.VSGameUtilsKt; @Mixin(LevelRenderer.class) public abstract class MixinLevelRenderer { - @Shadow - private ClientLevel level; - - @Unique private PoseStack matrixStack; - @Unique private Vec3 camera; - - @Shadow - private static void renderShape(final PoseStack matrixStack, final VertexConsumer vertexConsumer, - final VoxelShape voxelShape, final double d, final double e, final double f, final float red, final float green, - final float blue, final float alpha) { - throw new AssertionError(); - } - /** * @reason This mixin forces the game to always render block damage. */ @@ -52,34 +21,6 @@ private double disableBlockDamageDistanceCheck(final double originalBlockDamageD return Double.MAX_VALUE; } - /** - * @reason mojank developers who wrote this don't quite understand what a matrixstack is apparently - * @author Rubydesic - */ - @Inject(method = "renderHitOutline", at = @At("HEAD"), cancellable = true) - private void preRenderHitOutline(final PoseStack matrixStack, final VertexConsumer vertexConsumer, - final Entity entity, final double camX, final double camY, final double camZ, final BlockPos blockPos, - final BlockState blockState, final CallbackInfo ci) { - ci.cancel(); - final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(level, blockPos); - if (ship != null) { - matrixStack.pushPose(); - transformRenderWithShip(ship.getRenderTransform(), matrixStack, blockPos, camX, camY, camZ); - renderShape(matrixStack, vertexConsumer, - blockState.getShape(this.level, blockPos, CollisionContext.of(entity)), - 0d, 0d, 0d, 0.0F, 0.0F, 0.0F, 0.4F); - matrixStack.popPose(); - } else { - // vanilla - renderShape(matrixStack, vertexConsumer, - blockState.getShape(this.level, blockPos, CollisionContext.of(entity)), - (double) blockPos.getX() - camX, - (double) blockPos.getY() - camY, - (double) blockPos.getZ() - camZ, - 0.0F, 0.0F, 0.0F, 0.4F); - } - } - /** * This mixin makes block damage render on ships. diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/hit_outline/MixinLevelRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/hit_outline/MixinLevelRenderer.java new file mode 100644 index 000000000..f742b7a52 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/hit_outline/MixinLevelRenderer.java @@ -0,0 +1,67 @@ +package org.valkyrienskies.mod.mixin.feature.hit_outline; + +import static org.valkyrienskies.mod.common.VSClientGameUtils.transformRenderWithShip; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import javax.annotation.Nullable; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.VoxelShape; +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.At.Shift; +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.VSGameUtilsKt; + +@Mixin(LevelRenderer.class) +public class MixinLevelRenderer { + + @Shadow + @Nullable + private ClientLevel level; + + @Shadow + private static void renderShape(final PoseStack matrixStack, final VertexConsumer vertexConsumer, + final VoxelShape voxelShape, final double d, final double e, final double f, final float red, final float green, + final float blue, final float alpha) { + throw new AssertionError(); + } + + /** + * @reason mojank developers who wrote this don't quite understand what a matrixstack is apparently + */ + @Inject( + method = "renderHitOutline", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/client/renderer/LevelRenderer;renderShape(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/phys/shapes/VoxelShape;DDDFFFF)V", + shift = Shift.BEFORE + ), + cancellable = true + ) + private void preRenderShape(PoseStack matrixStack, VertexConsumer vertexConsumer, Entity entity, + double camX, double camY, double camZ, + BlockPos pos, BlockState state, + CallbackInfo ci + ) { + final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(this.level, pos); + if (ship != null) { + matrixStack.pushPose(); + transformRenderWithShip(ship.getRenderTransform(), matrixStack, pos, camX, camY, camZ); + renderShape(matrixStack, vertexConsumer, + state.getShape(this.level, pos, CollisionContext.of(entity)), + 0d, 0d, 0d, 0.0F, 0.0F, 0.0F, 0.4F); + matrixStack.popPose(); + ci.cancel(); + } + } + +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index e9c168279..9733c11fa 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -127,6 +127,7 @@ "feature.commands.MixinClientSuggestionProvider", "feature.fix_render_chunk_sorting.MixinRenderChunk", "feature.fluid_camera_fix.MixinCamera", + "feature.hit_outline.MixinLevelRenderer", "feature.render_blockentity_distance_check.MixinBlockEntityRenderDispatcher", "feature.render_leashes.MixinMobRenderer", "feature.render_pathfinding.MixinDebugRenderer", @@ -168,9 +169,9 @@ "mod_compat.flywheel.MixinInstancingEngine", "mod_compat.optifine.RenderChunkInfoAccessorOptifine", "mod_compat.optifine_vanilla.MixinLevelRenderer", + "mod_compat.sodium.MixinChunkTracker", "mod_compat.sodium.MixinRenderSectionManager", "mod_compat.sodium.MixinSodiumWorldRenderer", - "mod_compat.sodium.MixinChunkTracker", "mod_compat.sound_physics_remastered.MixinSoundPhysics", "mod_compat.vanilla_renderer.MixinLevelRendererVanilla", "mod_compat.vanilla_renderer.MixinViewAreaVanilla", From e5651dd6dbf7507755948d0593fa7b1fbadfc5e7 Mon Sep 17 00:00:00 2001 From: xiewuzhiying <92735961+xiewuzhiying@users.noreply.github.com> Date: Sun, 28 Jul 2024 17:25:59 +0800 Subject: [PATCH 134/156] Fix MixinTrackBlockOutline (#921) --- .../trackOutlines/MixinTrackBlockOutline.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java index 97c911ad6..de52ce15b 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java @@ -1,7 +1,7 @@ package org.valkyrienskies.mod.forge.mixin.compat.create.client.trackOutlines; +import com.llamalad7.mixinextras.sugar.Local; 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; @@ -21,14 +21,13 @@ 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, remap = false) +@Mixin(TrackBlockOutline.class) public class MixinTrackBlockOutline { @Unique private static Vec3 valkyrienskies$cameraVec3; @@ -39,12 +38,9 @@ public class MixinTrackBlockOutline { @Inject(method = "drawCurveSelection(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/phys/Vec3;)V", 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) { - + target = "Lcom/simibubi/create/content/trains/track/TrackBlockOutline$BezierPointSelection;angles()Lnet/minecraft/world/phys/Vec3;"), remap = false) + private static void harvestDrawCurveSelection(final PoseStack ms, final MultiBufferSource buffer, final Vec3 camera, final CallbackInfo ci, @Local + final BezierPointSelection result) { valkyrienskies$cameraVec3 = camera; valkyrienskies$vec = result.vec(); valkyrienskies$angles = result.angles(); @@ -53,7 +49,7 @@ private static void harvestDrawCurveSelection(final PoseStack ms, final MultiBuf @ModifyArg(method = "drawCurveSelection(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/phys/Vec3;)V", 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) + index = 1, remap = false) private static PoseStack redirectTransformStackTranslate(final PoseStack ms) { final Level level = Minecraft.getInstance().level; From 8142bb81ad657095d6449a247c86e06b447ffac8 Mon Sep 17 00:00:00 2001 From: m-doescode <80221594+m-doescode@users.noreply.github.com> Date: Thu, 15 Aug 2024 13:17:21 +0300 Subject: [PATCH 135/156] Fix #486 - when you log off on a ship and it moves, you should log on still in the ship, not in the middle of nowhere (#937) * Added basic implementation of teleporting disconnected players back onto ships * Removed print statements * Extracted MAX_ONBOARD_TICKS from magic number * Moved MAX_ONBOARD_TICKS to a config option, and added the ability for reconnected player teleportation to be disabled --------- Authored-by: m-doescode <80221594+m-doescode@users.noreply.github.co> --- .../MixinServerPlayer.java | 87 +++++++++++++++++++ .../mod/common/config/VSGameConfig.kt | 14 +++ .../valkyrienskies-common.mixins.json | 1 + 3 files changed, 102 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/teleport_reconnected_player_to_ship/MixinServerPlayer.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/teleport_reconnected_player_to_ship/MixinServerPlayer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/teleport_reconnected_player_to_ship/MixinServerPlayer.java new file mode 100644 index 000000000..903bd866c --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/teleport_reconnected_player_to_ship/MixinServerPlayer.java @@ -0,0 +1,87 @@ +package org.valkyrienskies.mod.mixin.feature.teleport_reconnected_player_to_ship; + +import com.mojang.authlib.GameProfile; +import javax.annotation.Nullable; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import org.joml.Vector3d; +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.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.config.VSGameConfig; +import org.valkyrienskies.mod.common.util.EntityDraggingInformation; +import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider; + +@Mixin(ServerPlayer.class) +public abstract class MixinServerPlayer extends Player { + + @Shadow + public abstract ServerLevel serverLevel(); + + public MixinServerPlayer(final Level level, final BlockPos blockPos, final float f, + final GameProfile gameProfile) { + super(level, blockPos, f, gameProfile); + throw new IllegalStateException("Unreachable"); + } + + @Inject(method = "readAdditionalSaveData", at = @At("RETURN")) + void teleportToShip(final CompoundTag compoundTag, final CallbackInfo ci) { + if (!VSGameConfig.SERVER.getTeleportReconnectedPlayers()) + return; + + if (!compoundTag.contains("LastShipId")) + return; // Player did not disconnect off of any ship + + final long lastShipId = compoundTag.getLong("LastShipId"); + + final Ship ship = VSGameUtilsKt.getShipObjectWorld(serverLevel()).getAllShips().getById(lastShipId); + // Don't teleport if the ship doesn't exist anymore + if (ship == null) + return; + + // Translate ship coords to world coords + final double x = compoundTag.getDouble("RelativeShipX"); + final double y = compoundTag.getDouble("RelativeShipY"); + final double z = compoundTag.getDouble("RelativeShipZ"); + + final Vector3d playerShipPosition = new Vector3d(x, y, z); + final Vector3d playerWorldPosition = ship.getShipToWorld().transformPosition(playerShipPosition); + + setPos(playerWorldPosition.x, playerWorldPosition.y, playerWorldPosition.z); + } + + @Inject(method = "addAdditionalSaveData", at = @At("RETURN")) + void rememberLastShip(final CompoundTag compoundTag, final CallbackInfo ci) { + final EntityDraggingInformation draggingInformation = ((IEntityDraggingInformationProvider) this).getDraggingInformation(); + + if (draggingInformation.getTicksSinceStoodOnShip() > VSGameConfig.SERVER.getMaxAirborneTicksForReconnectedPlayerTeleport()) + return; + + @Nullable final Long lastShipId = draggingInformation.getLastShipStoodOn(); + if (lastShipId == null) + return; + + final Ship ship = VSGameUtilsKt.getShipObjectWorld(serverLevel()).getAllShips().getById(lastShipId); + if (ship == null) + return; + + compoundTag.putLong("LastShipId", lastShipId); + + // Get position relative to ship + // (Technically, this grabs the position in the shipyard, but it works well enough...) + final Vector3d playerWorldPosition = new Vector3d(getX(), getY(), getZ()); + final Vector3d playerShipPosition = ship.getWorldToShip().transformPosition(playerWorldPosition); + + compoundTag.putDouble("RelativeShipX", playerShipPosition.x); + compoundTag.putDouble("RelativeShipY", playerShipPosition.y); + compoundTag.putDouble("RelativeShipZ", playerShipPosition.z); + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSGameConfig.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSGameConfig.kt index fe225d812..052bf504f 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSGameConfig.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSGameConfig.kt @@ -95,6 +95,20 @@ object VSGameConfig { ) var enableMovementChecks = false + @JsonSchema( + description = "If true, when a player disconnects, their position on the ship is saved such that " + + "if the ship is moved, when they reconnect they will be teleported to the same position in the ship " + + "as they left, instead of being left behind." + ) + var teleportReconnectedPlayers = true + + @JsonSchema( + description = "Determines how many airborne ticks after a player leaves the ground of a" + + "ship that they are still considered part of it when they disconnect, such that they will" + + "be teleported back to it after reconnecnting." + ) + var maxAirborneTicksForReconnectedPlayerTeleport = 4 + @JsonSchema( description = "If true, prevents water and other fluids from flowing out of the ship's bounding box." ) diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 9733c11fa..c7549fabc 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -48,6 +48,7 @@ "feature.shipyard_entities.MixinServerLevel", "feature.shipyard_entities.MixinTransientEntitySectionManager", "feature.spawn_player_on_ship.MixinServerGamePacketListenerImpl", + "feature.teleport_reconnected_player_to_ship.MixinServerPlayer", "feature.tick_ship_chunks.MixinChunkMap", "feature.world_border.MixinLevel", "feature.world_border.MixinWorldBorder", From ad53ee32ac929fba004880557d2238e41ae5e81f Mon Sep 17 00:00:00 2001 From: Coffee Date: Fri, 16 Aug 2024 07:53:35 +0100 Subject: [PATCH 136/156] Fix compatibility with Pehkui player scale (#927) --- .../mixin/feature/entity_collision/MixinEntity.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 89e61a69e..b38be9453 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 @@ -103,16 +103,18 @@ private void redirectSetVelocity(final MoverType moverType, final Vec3 movement, // Remove the component of [movementAdjustedForCollisions] that is parallel to [collisionResponseHorizontal] if (collisionResponseHorizontal.lengthSquared() > 1e-6) { + final Vec3 deltaMovement = getDeltaMovement(); + final Vector3dc collisionResponseHorizontalNormal = collisionResponseHorizontal.normalize(new Vector3d()); final double parallelHorizontalVelocityComponent = collisionResponseHorizontalNormal - .dot(movementAdjustedForCollisions.x, 0.0, movementAdjustedForCollisions.z); + .dot(deltaMovement.x, 0.0, deltaMovement.z); setDeltaMovement( - movementAdjustedForCollisions.x + deltaMovement.x - collisionResponseHorizontalNormal.x() * parallelHorizontalVelocityComponent, - movementAdjustedForCollisions.y, - movementAdjustedForCollisions.z + deltaMovement.y, + deltaMovement.z - collisionResponseHorizontalNormal.z() * parallelHorizontalVelocityComponent ); } From 369674108232400da42ed32f77de16c6cef84b32 Mon Sep 17 00:00:00 2001 From: FlamingAssembler <34496536+Endalion@users.noreply.github.com> Date: Thu, 22 Aug 2024 17:33:46 +0800 Subject: [PATCH 137/156] Fix wing position on world reload (#945) --- .../valkyrienskies/mod/mixin/server/world/MixinServerLevel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java index 3971c68fd..18c84104a 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java @@ -154,7 +154,7 @@ private boolean includeShipsInParticleDistanceCheck( for (int z = 0; z < 16; z++) { final BlockState blockState = chunkSection.getBlockState(x, y, z); final int posX = (chunkX << 4) + x; - final int posY = worldChunk.getMinBuildHeight() + y; + final int posY = worldChunk.getMinBuildHeight() + (sectionY << 4) + y; final int posZ = (chunkZ << 4) + z; if (blockState.getBlock() instanceof WingBlock) { mutableBlockPos.set(posX, posY, posZ); From a9ed0529b2ff76e35d4684b1c256f4ec3abcb763 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 6 Sep 2024 21:15:25 -0700 Subject: [PATCH 138/156] Increment version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index c5c73d0a9..f0d0f5877 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-120 -mod_version=2.3.0-beta.5 +mod_version=2.3.0-beta.6 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ From 17a8173359eb3cb19ab28b0fac0a6fd138ae1575 Mon Sep 17 00:00:00 2001 From: xiewuzhiying <92735961+xiewuzhiying@users.noreply.github.com> Date: Mon, 23 Sep 2024 12:27:15 +0800 Subject: [PATCH 139/156] fix teleport command can't teleport ships between two dimensions. (#908) --- .../mod/common/command/VSCommands.kt | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt index 7e45e84b8..85776aa59 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt @@ -24,6 +24,7 @@ import org.valkyrienskies.core.impl.game.ShipTeleportDataImpl import org.valkyrienskies.core.util.x import org.valkyrienskies.core.util.y import org.valkyrienskies.core.util.z +import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.getShipManagingPos import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toJOMLD @@ -96,8 +97,12 @@ object VSCommands { val r = ShipArgument.getShips(it, "ships").toList() as List val position = Vec3Argument.getVec3(it as CommandContext, "position") + val dimensionId = (it.source as CommandSourceStack).level.dimensionId val shipTeleportData: ShipTeleportData = - ShipTeleportDataImpl(newPos = position.toJOML()) + ShipTeleportDataImpl( + newPos = position.toJOML(), + newDimension = dimensionId + ) r.forEach { ship -> vsCore.teleportShip( (it as CommandContext).source.shipWorld as ServerShipWorld, @@ -125,12 +130,14 @@ object VSCommands { ) val source = it.source as CommandSourceStack + val dimensionId = (it.source as CommandSourceStack).level.dimensionId val shipTeleportData: ShipTeleportData = ShipTeleportDataImpl( newPos = position.toJOML(), newRot = eulerAngles.toEulerRotationFromMCEntity( source.rotation.x.toDouble(), source.rotation.y.toDouble(), - ) + ), + newDimension = dimensionId ) r.forEach { ship -> vsCore.teleportShip( @@ -164,13 +171,15 @@ object VSCommands { ) val source = it.source as CommandSourceStack + val dimensionId = (it.source as CommandSourceStack).level.dimensionId val shipTeleportData: ShipTeleportData = ShipTeleportDataImpl( newPos = position.toJOML(), newRot = eulerAngles.toEulerRotationFromMCEntity( source.rotation.x.toDouble(), source.rotation.y.toDouble(), ), - newVel = velocity.toVector3d(0.0, 0.0, 0.0) + newVel = velocity.toVector3d(0.0, 0.0, 0.0), + newDimension = dimensionId ) r.forEach { ship -> vsCore.teleportShip( @@ -209,6 +218,7 @@ object VSCommands { ) val source = it.source as CommandSourceStack + val dimensionId = (it.source as CommandSourceStack).level.dimensionId val shipTeleportData: ShipTeleportData = ShipTeleportDataImpl( newPos = position.toJOML(), @@ -216,7 +226,8 @@ object VSCommands { source.rotation.x.toDouble(), source.rotation.y.toDouble(), ), newVel = velocity.toVector3d(0.0, 0.0, 0.0), - newOmega = angularVelocity.toVector3d(0.0, 0.0, 0.0) + newOmega = angularVelocity.toVector3d(0.0, 0.0, 0.0), + newDimension = dimensionId ) r.forEach { ship -> vsCore.teleportShip( From 08344735729861157e394ad18bfc649f24830e8f Mon Sep 17 00:00:00 2001 From: alex_s168 <63254202+alex-s168@users.noreply.github.com> Date: Mon, 23 Sep 2024 06:28:52 +0200 Subject: [PATCH 140/156] EMF Compatibility (#958) * emf compat * fix server --- common/build.gradle | 4 +++ .../emf/MixinEMFAnimationEntityContext.java | 34 +++++++++++++++++++ .../mod_compat/etf/MixinBlockEntity.java | 21 ++++++++++++ .../valkyrienskies-common.mixins.json | 2 ++ 4 files changed, 61 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/emf/MixinEMFAnimationEntityContext.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/etf/MixinBlockEntity.java diff --git a/common/build.gradle b/common/build.gradle index 39472623e..fbfeb62d7 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -25,6 +25,10 @@ dependencies { modCompileOnly("curse.maven:ftb-teams-404468:4229138") modCompileOnly("curse.maven:ftb-chunks-314906:4229120") + // EMF compat + modCompileOnly("curse.maven:entity-model-features-844662:5696901") + modCompileOnly("curse.maven:entity-texture-features-fabric-568563:5697084") + //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}") diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/emf/MixinEMFAnimationEntityContext.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/emf/MixinEMFAnimationEntityContext.java new file mode 100644 index 000000000..e80c5579a --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/emf/MixinEMFAnimationEntityContext.java @@ -0,0 +1,34 @@ +package org.valkyrienskies.mod.mixin.mod_compat.emf; + +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.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import traben.entity_model_features.models.animation.EMFAnimationEntityContext; +import traben.entity_model_features.utils.EMFEntity; + +@Mixin(EMFAnimationEntityContext.class) +public class MixinEMFAnimationEntityContext { + @Shadow + private static EMFEntity IEMFEntity; + + @Inject( + at = @At("HEAD"), + method = "distanceOfEntityFrom", + cancellable = true + ) + private static void distanceOfEntityFrom(final BlockPos pos, final CallbackInfoReturnable cir) { + if (IEMFEntity != null) { + final var level = Minecraft.getInstance().level; + final var posW = VSGameUtilsKt.toWorldCoordinates(level, Vec3.atCenterOf(pos)); + final var entityW = VSGameUtilsKt.toWorldCoordinates(level, Vec3.atCenterOf(IEMFEntity.etf$getBlockPos())); + final var dist = posW.distanceTo(entityW); + cir.setReturnValue((int) dist); + } + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/etf/MixinBlockEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/etf/MixinBlockEntity.java new file mode 100644 index 000000000..c7e64422e --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/etf/MixinBlockEntity.java @@ -0,0 +1,21 @@ +package org.valkyrienskies.mod.mixin.mod_compat.etf; + +import net.minecraft.client.Minecraft; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import traben.entity_texture_features.utils.ETFEntity; + +@Mixin(value = BlockEntity.class, priority = 1200) +public abstract class MixinBlockEntity implements ETFEntity { + @Override + public float etf$distanceTo(final Entity entity) { + final var level = Minecraft.getInstance().level; + final var aW = VSGameUtilsKt.toWorldCoordinates(level, Vec3.atCenterOf(etf$getBlockPos())); + final var bW = VSGameUtilsKt.toWorldCoordinates(level, entity.position()); + final var dist = aW.distanceTo(bW); + return (float) dist; + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index c7549fabc..489e19601 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -177,6 +177,8 @@ "mod_compat.vanilla_renderer.MixinLevelRendererVanilla", "mod_compat.vanilla_renderer.MixinViewAreaVanilla", "mod_compat.vanilla_renderer.RenderChunkInfoAccessor", + "mod_compat.emf.MixinEMFAnimationEntityContext", + "mod_compat.etf.MixinBlockEntity", "realms.MixinRealmsConnect" ], "injectors": { From 52443a1e6bd450d5907d3c80e3021d23d2eeb40c Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 24 Sep 2024 05:08:37 -0700 Subject: [PATCH 141/156] Merge from 1.18.x/main --- README.md | 6 - common/build.gradle | 10 + .../mod/mixin/entity/MixinEntity.java | 5 +- .../MixinBlockItem.java | 47 +- .../feature/entity_collision/MixinEntity.java | 5 + .../MixinPersistentEntitySectionManager.java | 76 - .../bluemap/HiresTileModelAccessor.java | 15 + .../mixin/mod_compat/bluemap/MixinBmMap.java | 47 + .../bluemap/MixinHiresModelManager.java | 100 ++ .../mixin/mod_compat/bluemap/MixinWorld.java | 36 + .../accessors/ChuteBlockEntityAccessor.java | 16 + .../create/client/MixinDeployTool.java | 67 + .../create/client/MixinSchematicToolBase.java | 70 + .../client/MixinSchematicTransformation.java | 57 + .../MixinAbstractContraptionEntity.java | 16 +- .../MixinPitchOrientedContraptionEntity.java | 9 + .../MixinBlockEntityInstanceManager.java | 4 +- .../sodium/MixinRenderSectionManager.java | 10 + .../MixinLevelRendererVanilla.java | 21 + .../mixin/server/MinecraftServerAccessor.java | 13 + .../mixin/server/MixinMinecraftServer.java | 28 +- .../mixin/server/world/MixinServerLevel.java | 9 +- .../mixin/world/chunk/MixinLevelChunk.java | 6 +- .../mod_compat/bluemap/WorldDuck.java | 10 + .../org/valkyrienskies/mod/api/VsAPI.kt | 56 + .../mod/api/events/PostRenderShipEvent.kt | 6 + .../mod/api/events/PreRenderShipEvent.kt | 6 + .../mod/api/events/RegisterBlockStateEvent.kt | 25 + .../events/RegisterBlockStateEventImpl.kt | 36 + .../mod/api_impl/events/VSApiImpl.kt | 44 + .../mod/common/BlockStateInfoProvider.kt | 9 - .../common/DefaultBlockStateInfoProvider.kt | 22 +- .../valkyrienskies/mod/common/PlayerUtil.kt | 33 +- .../valkyrienskies/mod/common/VSGameUtils.kt | 25 +- .../mod/common/ValkyrienSkiesMod.kt | 5 +- .../mod/common/assembly/AssemblyUtil.kt | 147 ++ .../common/assembly/SeamlessChunksManager.kt | 15 +- .../mod/common/assembly/ShipAssembler.kt | 115 ++ .../mod/common/assembly/ShipAssembly.kt | 88 +- .../mod/common/command/ShipArgumentParser.kt | 10 +- .../mod/common/config/VSGameConfig.kt | 24 + .../mod/common/config/VSMassDataLoader.kt | 301 ++-- .../mod/common/entity/ShipMountingEntity.kt | 6 +- .../mod/common/entity/VSPhysicsEntity.kt | 5 +- .../common/entity/handling/VSEntityManager.kt | 7 +- .../mod/common/hooks/VSGameEvents.kt | 12 +- .../mod/common/networking/VSGamePackets.kt | 8 +- .../common/util/EntityShipCollisionUtils.kt | 3 +- .../valkyrienskies/mod/compat/LoadedMods.kt | 3 + .../mod/compat/Weather2Compat.kt | 73 + .../mod/compat/clothconfig/VSClothConfig.kt | 8 +- .../org/valkyrienskies/mod/util/McMathUtil.kt | 4 + .../assets/valkyrienskies/lang/ko_kr.json | 25 + .../valkyrienskies/vs_mass/1_18_blocks.json | 220 +-- .../data/valkyrienskies/vs_mass/1_19_blocks | 44 +- .../data/valkyrienskies/vs_mass/1_20_blocks | 48 +- .../valkyrienskies/vs_mass/computercraft.json | 24 +- .../vs_mass/crafting_stations.json | 34 +- .../data/valkyrienskies/vs_mass/ground.json | 94 +- .../data/valkyrienskies/vs_mass/masonry.json | 334 ++-- .../data/valkyrienskies/vs_mass/misc.json | 204 +-- .../data/valkyrienskies/vs_mass/plants.json | 30 +- .../vs_mass/redstone_components.json | 72 +- .../vs_mass/steelarmorblocks.json | 1486 +++++++++++++++++ .../data/valkyrienskies/vs_mass/wood.json | 122 +- .../valkyrienskies-common.mixins.json | 12 +- fabric/build.gradle | 8 + .../cc_restitched/MixinSpeakerPosition.java | 48 - .../cc_restitched/MixinSpeakerSound.java | 64 + .../mixin/compat/cc_restitched/README.MD | 2 +- .../compat/create/MixinChuteBlockEntity.java | 63 + .../create/client/MixinTrackBlockOutline.java | 134 ++ .../MixinPersistentEntitySectionManager.java | 58 + .../fabric/compat/modmenu/ValkyrienModMenu.kt | 7 +- .../valkyrienskies-fabric.mixins.json | 5 +- forge/build.gradle | 11 +- .../cc_tweaked/MixinSpeakerPosition.java | 47 - .../compat/cc_tweaked/MixinSpeakerSound.java | 64 + .../forge/mixin/compat/cc_tweaked/README.MD | 2 +- .../compat/create/MixinChuteBlockEntity.java | 63 + .../create/client/MixinTrackBlockOutline.java | 126 ++ .../mekanism/MixinRadiationManager.java | 31 + .../MixinPersistentEntitySectionManager.java | 58 + .../forge/common/ValkyrienSkiesModForge.kt | 7 +- .../valkyrienskies-forge.mixins.json | 7 +- gradle.properties | 2 +- 86 files changed, 4132 insertions(+), 1203 deletions(-) delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/HiresTileModelAccessor.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinBmMap.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinHiresModelManager.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinWorld.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/ChuteBlockEntityAccessor.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinDeployTool.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicToolBase.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicTransformation.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/server/MinecraftServerAccessor.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/bluemap/WorldDuck.java create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api/VsAPI.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api/events/PostRenderShipEvent.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api/events/PreRenderShipEvent.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api/events/RegisterBlockStateEvent.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/RegisterBlockStateEventImpl.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VSApiImpl.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/AssemblyUtil.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembler.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt create mode 100644 common/src/main/resources/assets/valkyrienskies/lang/ko_kr.json create mode 100644 common/src/main/resources/data/valkyrienskies/vs_mass/steelarmorblocks.json delete mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerSound.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinChuteBlockEntity.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinTrackBlockOutline.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java delete mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerSound.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinChuteBlockEntity.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinTrackBlockOutline.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mekanism/MixinRadiationManager.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java diff --git a/README.md b/README.md index 5592c99ca..f12a0854f 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,6 @@ You can download official releases of Valkyrien Skies from our [website](https:/ ## Development -Valkyrien Skies 2 source code is split between the code in this repository, and -the code in [vs-core](https://github.com/ValkyrienSkies/vs-core). - -The Minecraft version dependent code lives in this repository, and the version -independent code lives in [vs-core](https://github.com/ValkyrienSkies/vs-core). - ### IntelliJ 1. Clone the diff --git a/common/build.gradle b/common/build.gradle index 0964ac38e..5e2948337 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -17,6 +17,8 @@ dependencies { exclude module: "fastutil" } + implementation("org.valkyrienskies.core:api:${rootProject.vs_core_version}") + implementation("org.valkyrienskies.core:api-game:${rootProject.vs_core_version}") implementation("org.valkyrienskies.core:util:${rootProject.vs_core_version}") // FTB Stuffs @@ -24,6 +26,9 @@ dependencies { modCompileOnly("curse.maven:ftb-teams-404468:4229138") modCompileOnly("curse.maven:ftb-chunks-314906:4229120") + // Weather2 1.18 + // modCompileOnly("curse.maven:weather-storms-tornadoes-237746:4426524") + //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}") @@ -34,6 +39,11 @@ dependencies { //implementation("io.github.fabricators_of_create.Porting-Lib:Porting-Lib:$port_lib_version+$minecraft_version") modCompileOnly("maven.modrinth:create-big-cannons:${createbigcannons_version}") + modCompileOnly("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") + modCompileOnly("com.rbasamoyai:createbigcannons-fabric-${minecraft_version}:${createbigcannons_version}") + + //Bluemap fabric 1.19 + modCompileOnly("curse.maven:bluemap-406463:4474497") } architectury { 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 94b1c5eb3..7b5178cfc 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 @@ -31,7 +31,6 @@ import org.valkyrienskies.core.api.ships.LoadedShip; import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.core.api.ships.properties.ShipTransform; -import org.valkyrienskies.core.impl.game.ships.ShipObjectClient; import org.valkyrienskies.mod.common.entity.ShipMountedToData; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.EntityDraggingInformation; @@ -112,8 +111,8 @@ private void preGetEyePosition(final float partialTicks, final CallbackInfoRetur final LoadedShip shipMountedTo = shipMountedToData.getShipMountedTo(); final ShipTransform shipTransform; - if (shipMountedTo instanceof ShipObjectClient) { - shipTransform = ((ShipObjectClient) shipMountedTo).getRenderTransform(); + if (shipMountedTo instanceof ClientShip) { + shipTransform = ((ClientShip) shipMountedTo).getRenderTransform(); } else { shipTransform = shipMountedTo.getShipTransform(); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_placement_orientation/MixinBlockItem.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_placement_orientation/MixinBlockItem.java index c28c66239..4f5ba2397 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_placement_orientation/MixinBlockItem.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_placement_orientation/MixinBlockItem.java @@ -1,50 +1,37 @@ package org.valkyrienskies.mod.mixin.feature.block_placement_orientation; -import net.minecraft.world.InteractionResult; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import net.minecraft.world.item.BlockItem; import net.minecraft.world.item.context.BlockPlaceContext; +import net.minecraft.world.level.block.state.BlockState; 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.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import org.valkyrienskies.mod.common.PlayerUtil; @Mixin(BlockItem.class) public abstract class MixinBlockItem { - - @Inject( - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/item/BlockItem;getPlacementState(Lnet/minecraft/world/item/context/BlockPlaceContext;)Lnet/minecraft/world/level/block/state/BlockState;" - ), - method = "place", - locals = LocalCapture.CAPTURE_FAILHARD - ) - private void transformPlayerWhenPlacing(final BlockPlaceContext ignore, - final CallbackInfoReturnable cir, final BlockPlaceContext context) { - if (context == null || context.getPlayer() == null) { - return; - } - - PlayerUtil.transformPlayerTemporarily(context.getPlayer(), context.getLevel(), context.getClickedPos()); - } - @Inject( + @WrapOperation( at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/item/BlockItem;getPlacementState(Lnet/minecraft/world/item/context/BlockPlaceContext;)Lnet/minecraft/world/level/block/state/BlockState;", - shift = Shift.AFTER + target = "Lnet/minecraft/world/item/BlockItem;getPlacementState(Lnet/minecraft/world/item/context/BlockPlaceContext;)Lnet/minecraft/world/level/block/state/BlockState;" ), method = "place" ) - private void untransformPlayerAfterPlacing(final BlockPlaceContext context, - final CallbackInfoReturnable cir) { - if (context.getPlayer() == null) { - return; + private BlockState transformPlayerWhenPlacing( + final BlockItem _instance, final BlockPlaceContext _ctx, + final Operation original, final BlockPlaceContext ctx + ) { + if (ctx == null || ctx.getPlayer() == null) { + return null; } - PlayerUtil.untransformPlayer(context.getPlayer()); + return PlayerUtil.transformPlayerTemporarily( + ctx.getPlayer(), + ctx.getLevel(), + ctx.getClickedPos(), + () -> original.call(this, ctx) + ); } } 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 f4142f122..f6bbf72f1 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 @@ -116,6 +116,8 @@ private void redirectSetVelocity(final MoverType moverType, final Vec3 movement, - collisionResponseHorizontalNormal.z() * parallelHorizontalVelocityComponent ); } + // The rest of the move function (including tryCheckInsideBlocks) is skipped, so calling it here + tryCheckInsideBlocks(); // Cancel the original invocation of Entity.setVelocity(DDD)V to remove vanilla behavior callbackInfo.cancel(); } @@ -224,6 +226,9 @@ private void preSpawnSprintParticle(final CallbackInfo ci) { @Shadow public abstract void setDeltaMovement(double x, double y, double z); + @Shadow + protected abstract void tryCheckInsideBlocks(); + @Shadow protected abstract Vec3 collide(Vec3 vec3d); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java deleted file mode 100644 index 0f7068745..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java +++ /dev/null @@ -1,76 +0,0 @@ -package org.valkyrienskies.mod.mixin.feature.shipyard_entities; - -import it.unimi.dsi.fastutil.longs.Long2ObjectMap; -import it.unimi.dsi.fastutil.longs.LongOpenHashSet; -import it.unimi.dsi.fastutil.longs.LongSet; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.entity.EntitySectionStorage; -import net.minecraft.world.level.entity.PersistentEntitySectionManager; -import net.minecraft.world.level.entity.Visibility; -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.mod.mixinducks.world.OfLevel; - -@Mixin(PersistentEntitySectionManager.class) -public abstract class MixinPersistentEntitySectionManager implements OfLevel { - @Shadow - @Final - EntitySectionStorage sectionStorage; - - @Unique - private Level level; - - @Override - public Level getLevel() { - return level; - } - - @Override - public void setLevel(final Level level) { - this.level = level; - ((OfLevel) this.sectionStorage).setLevel(level); - } - - @Shadow - @Final - private LongSet chunksToUnload; - - @Shadow - @Final - private Long2ObjectMap chunkVisibility; - - @Shadow - private boolean processChunkUnload(final long l) { - throw new IllegalStateException("This should not be invoked"); - } - - /** - * This fixes this function randomly crashing. I'm not sure why but the removeIf() function is buggy - */ - @Inject( - method = "processUnloads", at = @At(value = "HEAD"), cancellable = true - ) - private void replaceProcessUnloads(final CallbackInfo ci) { - // I don't know why this crashes, try-catch please help me! - try { - final LongSet toRemove = new LongOpenHashSet(); - for (final long key : this.chunksToUnload) { - if (this.chunkVisibility.get(key) != Visibility.HIDDEN) { - toRemove.add(key); - } else if (this.processChunkUnload(key)) { - toRemove.add(key); - } - } - chunksToUnload.removeAll(toRemove); - } catch (final Exception e) { - e.printStackTrace(); - } - ci.cancel(); - } -} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/HiresTileModelAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/HiresTileModelAccessor.java new file mode 100644 index 000000000..f08d39ee1 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/HiresTileModelAccessor.java @@ -0,0 +1,15 @@ +package org.valkyrienskies.mod.mixin.mod_compat.bluemap; + +import de.bluecolored.bluemap.core.map.hires.HiresTileModel; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(HiresTileModel.class) +@Pseudo +public interface HiresTileModelAccessor { + + @Accessor("position") + double[] getPositions(); + +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinBmMap.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinBmMap.java new file mode 100644 index 000000000..6ec653ef7 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinBmMap.java @@ -0,0 +1,47 @@ +package org.valkyrienskies.mod.mixin.mod_compat.bluemap; + +import com.flowpowered.math.vector.Vector2i; +import de.bluecolored.bluemap.core.map.BmMap; +import de.bluecolored.bluemap.core.map.hires.HiresModelManager; +import de.bluecolored.bluemap.core.world.World; +import java.util.function.Predicate; +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.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.mixinducks.mod_compat.bluemap.WorldDuck; + +@Mixin(BmMap.class) +@Pseudo +public class MixinBmMap { + @Shadow + @Final + private World world; + + @Shadow + @Final + private HiresModelManager hiresModelManager; + + @Redirect( + method = "renderTile", + at = @At( + value = "INVOKE", + target = "Ljava/util/function/Predicate;test(Ljava/lang/Object;)Z" + ), + remap = false + ) + boolean skipShipyard(final Predicate predicate, final Object object) { + final Vector2i tilePos = (Vector2i) object; + final var level = ((WorldDuck) world).valkyrienskies$getCorrelatingLevel(); + final var grid = this.hiresModelManager.getTileGrid(); + final var x = grid.getCellMinX(tilePos.getX()) + 1; + final var z = grid.getCellMinY(tilePos.getY()) + 1; + + final var notShipyard = !VSGameUtilsKt.isBlockInShipyard(level, x, 0, z); + + return predicate.test(tilePos) && notShipyard; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinHiresModelManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinHiresModelManager.java new file mode 100644 index 000000000..0edc61f5a --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinHiresModelManager.java @@ -0,0 +1,100 @@ +package org.valkyrienskies.mod.mixin.mod_compat.bluemap; + +import com.flowpowered.math.vector.Vector3i; +import de.bluecolored.bluemap.core.map.TileMetaConsumer; +import de.bluecolored.bluemap.core.map.hires.HiresModelManager; +import de.bluecolored.bluemap.core.map.hires.HiresModelRenderer; +import de.bluecolored.bluemap.core.map.hires.HiresTileModel; +import de.bluecolored.bluemap.core.world.World; +import org.joml.Matrix4dc; +import org.joml.Vector3d; +import org.joml.Vector3dc; +import org.joml.primitives.AABBd; +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.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.mixinducks.mod_compat.bluemap.WorldDuck; + +@Pseudo +@Mixin(HiresModelManager.class) +public class MixinHiresModelManager { + + @Redirect( + remap = false, + method = "render", + at = @At(value = "INVOKE", target = "Lde/bluecolored/bluemap/core/map/hires/HiresModelRenderer;render(Lde/bluecolored/bluemap/core/world/World;Lcom/flowpowered/math/vector/Vector3i;Lcom/flowpowered/math/vector/Vector3i;Lde/bluecolored/bluemap/core/map/hires/HiresTileModel;Lde/bluecolored/bluemap/core/map/TileMetaConsumer;)V") + ) + void renderModel(final HiresModelRenderer instance, final World world, + final Vector3i min, final Vector3i max, + final HiresTileModel model, final TileMetaConsumer tmc + ) { + final var aabb = new AABBd( + min.getX(), min.getY(), min.getZ(), + max.getX(), max.getY(), max.getZ() + ); + + final var level = ((WorldDuck) world).valkyrienskies$getCorrelatingLevel(); + if (level == null) { + System.out.println("Valkyrien Skies x BlueMap: Could not find correlating level for bluemap world"); + return; + } + + //TODO we are begging the gods to not have race conditions here + final var ships = VSGameUtilsKt.getShipsIntersecting(level, aabb); + + var start = model.size(); + + for (final Ship ship : ships) { + if (!aabb.containsPoint(ship.getTransform().getPositionInWorld())) continue; + final var shipAABB = ship.getShipAABB(); + + assert shipAABB != null; + final var shipMin = new Vector3i(shipAABB.minX() - 1, shipAABB.minY() - 1, shipAABB.minZ() - 1); + final var shipMax = new Vector3i(shipAABB.maxX() + 1, shipAABB.maxY() + 1, shipAABB.maxZ() + 1); + + + // renders the ship with as origin shipMin.x, 0, shipMin.z + instance.render(world, shipMin, shipMax, model, tmc); + + final var preTranslation = new Vector3d( + shipMin.getX(), + 0, + shipMin.getZ() + ); + + final var postTranslation = new Vector3d( + -min.getX(), + 0, + -min.getZ() + ); + + valkyrienskies$transformModel(start, model.size(), model, preTranslation, postTranslation, ship.getTransform().getShipToWorld()); + + start = model.size(); + } + + + instance.render(world, min, max, model, tmc); + } + + @Unique + private void valkyrienskies$transformModel(final int start, final int end, final HiresTileModel model, final Vector3dc preTranslation, final Vector3dc postTranslation, final Matrix4dc transform) { + final var positions = ((HiresTileModelAccessor) model).getPositions(); + + for(int face = start; face < end; ++face) { + for(int i = 0; i < 3; ++i) { + final int index = face * 9 + i * 3; + final double x = positions[index] + preTranslation.x(); + final double y = positions[index + 1] + preTranslation.y(); + final double z = positions[index + 2] + preTranslation.z(); + positions[index] = (x * transform.m00()) + (y * transform.m10()) + (z * transform.m20()) + transform.m30() + postTranslation.x(); + positions[index + 1] = (x * transform.m01()) + (y * transform.m11()) + (z * transform.m21()) + transform.m31() + postTranslation.y(); + positions[index + 2] = (x * transform.m02()) + (y * transform.m12()) + (z * transform.m22()) + transform.m32() + postTranslation.z(); + } + } + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinWorld.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinWorld.java new file mode 100644 index 000000000..db7538349 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinWorld.java @@ -0,0 +1,36 @@ +package org.valkyrienskies.mod.mixin.mod_compat.bluemap; + +import de.bluecolored.bluemap.core.mca.MCAWorld; +import java.nio.file.Path; +import java.util.Objects; +import net.minecraft.world.level.Level; +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.valkyrienskies.mod.common.ValkyrienSkiesMod; +import org.valkyrienskies.mod.mixin.server.MinecraftServerAccessor; +import org.valkyrienskies.mod.mixinducks.mod_compat.bluemap.WorldDuck; + +@Mixin(MCAWorld.class) +@Pseudo +public class MixinWorld implements WorldDuck { + + @Shadow + @Final + private Path worldFolder; + + @Override + public Level valkyrienskies$getCorrelatingLevel() { + for (final var level : Objects.requireNonNull(ValkyrienSkiesMod.getCurrentServer()).getAllLevels()) { + final MinecraftServerAccessor accessor = (MinecraftServerAccessor) ValkyrienSkiesMod.getCurrentServer(); + + final Path path1 = accessor.getStorageSource().getDimensionPath(level.dimension()).toAbsolutePath().normalize(); + final Path path2 = this.worldFolder.toAbsolutePath().normalize(); + if (path1.equals(path2)) + return level; + } + + return null; + } +} 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 new file mode 100644 index 000000000..917b5c175 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/ChuteBlockEntityAccessor.java @@ -0,0 +1,16 @@ +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/client/MixinDeployTool.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinDeployTool.java new file mode 100644 index 000000000..f10487ac3 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinDeployTool.java @@ -0,0 +1,67 @@ +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/MixinSchematicToolBase.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicToolBase.java new file mode 100644 index 000000000..32a196e4e --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicToolBase.java @@ -0,0 +1,70 @@ +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 new file mode 100644 index 000000000..5c6d76c84 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSchematicTransformation.java @@ -0,0 +1,57 @@ +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/entity/MixinAbstractContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinAbstractContraptionEntity.java index 8f1282915..fb9a150e1 100644 --- 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 @@ -28,6 +28,7 @@ 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; @@ -44,10 +45,13 @@ 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; @@ -55,7 +59,7 @@ @Mixin(AbstractContraptionEntity.class) public abstract class MixinAbstractContraptionEntity extends Entity implements MixinAbstractContraptionEntityDuck, - ContraptionWingProvider, IEntityDraggingInformationProvider { + ContraptionWingProvider, IEntityDraggingInformationProvider, ShipMountedToDataProvider { public MixinAbstractContraptionEntity(EntityType entityType, Level level) { super(entityType, level); @@ -89,6 +93,16 @@ public StructureTransform getStructureTransform() { @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) { 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 index cd97ecbcc..fd88191d2 100644 --- 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 @@ -1,5 +1,7 @@ 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; @@ -48,4 +50,11 @@ protected void vsProcesssRiderPositionHook( } } } + + @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/MixinBlockEntityInstanceManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinBlockEntityInstanceManager.java index 86ad788fa..e3408c46f 100644 --- 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 @@ -48,6 +48,7 @@ public MixinBlockEntityInstanceManager(final MaterialManager materialManager) { 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( @@ -57,7 +58,8 @@ void preCreateRaw(final BlockEntity blockEntity, final CallbackInfoReturnable vs$createMaterialManager()); final Vector3i c = ship.getChunkClaim().getCenterBlockCoordinates(VSGameUtilsKt.getYRange(nullableLevel), new Vector3i()); - ((InstancingEngineAccessor) manager).setOriginCoordinate(new BlockPos(c.x, c.y, c.z)); + if (manager instanceof InstancingEngineAccessor) + ((InstancingEngineAccessor) manager).setOriginCoordinate(new BlockPos(c.x, c.y, c.z)); cir.setReturnValue(InstancedRenderRegistry.createInstance(manager, blockEntity)); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRenderSectionManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRenderSectionManager.java index dabb6f95e..2b9362767 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRenderSectionManager.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/sodium/MixinRenderSectionManager.java @@ -14,6 +14,8 @@ import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunkSection; import org.joml.primitives.AABBd; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -72,7 +74,15 @@ private void afterIterateChunks(final Camera camera, final Frustum frustum, fina final boolean spectator, final CallbackInfo ci) { for (final ClientShip ship : VSGameUtilsKt.getShipObjectWorld(Minecraft.getInstance()).getLoadedShips()) { ship.getActiveChunksSet().forEach((x, z) -> { + final LevelChunk levelChunk = world.getChunk(x, z); for (int y = world.getMinSection(); y < world.getMaxSection(); y++) { + // If the chunk section is empty then skip it + final LevelChunkSection levelChunkSection = levelChunk.getSection(y - world.getMinSection()); + if (levelChunkSection.hasOnlyAir()) { + continue; + } + // TODO: Add occlusion logic here? + final RenderSection section = getRenderSection(x, y, z); if (section == null) { 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 35a6afb25..2d4f7be96 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 @@ -25,8 +25,11 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Vec3i; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunkSection; import org.jetbrains.annotations.Nullable; import org.joml.Vector3dc; +import org.joml.primitives.AABBd; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -47,6 +50,7 @@ @Mixin(LevelRenderer.class) public abstract class MixinLevelRendererVanilla { + @Unique private final WeakHashMap> shipRenderChunks = new WeakHashMap<>(); @Shadow private ClientLevel level; @@ -120,11 +124,27 @@ private void addShipVisibleChunks( } shipObject.getActiveChunksSet().forEach((x, z) -> { + final LevelChunk levelChunk = level.getChunk(x, z); for (int y = level.getMinSection(); y < level.getMaxSection(); y++) { tempPos.set(x << 4, y << 4, z << 4); final ChunkRenderDispatcher.RenderChunk renderChunk = chunkStorageAccessor.callGetRenderChunkAt(tempPos); if (renderChunk != null) { + // If the chunk section is empty then skip it + final LevelChunkSection levelChunkSection = levelChunk.getSection(y - level.getMinSection()); + if (levelChunkSection.hasOnlyAir()) { + continue; + } + + // If the chunk isn't in the frustum then skip it + final AABBd b2 = new AABBd((x << 4) - 6e-1, (y << 4) - 6e-1, (z << 4) - 6e-1, + (x << 4) + 15.6, (y << 4) + 15.6, (z << 4) + 15.6) + .transform(shipObject.getRenderTransform().getShipToWorld()); + + if (!frustum.isVisible(VectorConversionsMCKt.toMinecraft(b2))) { + continue; + } + final LevelRenderer.RenderChunkInfo newChunkInfo; if (ValkyrienCommonMixinConfigPlugin.getVSRenderer() == VSRenderer.OPTIFINE) { newChunkInfo = @@ -199,6 +219,7 @@ private ObjectArrayList redirectRenderChunksInFrustum(final Lev return (ObjectArrayList) renderChunksGeneratedByVanilla; } + @Unique private void renderChunkLayer(final RenderType renderType, final PoseStack poseStack, final double d, final double e, final double f, final Matrix4f matrix4f, final ObjectList chunksToRender) { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/MinecraftServerAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/MinecraftServerAccessor.java new file mode 100644 index 000000000..3df35bbc3 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/MinecraftServerAccessor.java @@ -0,0 +1,13 @@ +package org.valkyrienskies.mod.mixin.server; + +import net.minecraft.server.MinecraftServer; +import net.minecraft.world.level.storage.LevelStorageSource; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(MinecraftServer.class) +public interface MinecraftServerAccessor { + + @Accessor("storageSource") + LevelStorageSource.LevelStorageAccess getStorageSource(); +} 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 fce1429bb..c5642f5f3 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 @@ -62,7 +62,10 @@ import org.valkyrienskies.mod.common.util.VSServerLevel; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.common.world.ChunkManagement; +import org.valkyrienskies.mod.compat.LoadedMods; +import org.valkyrienskies.mod.compat.Weather2Compat; import org.valkyrienskies.mod.util.KrunchSupport; +import org.valkyrienskies.mod.util.McMathUtilKt; @Mixin(MinecraftServer.class) public abstract class MixinMinecraftServer implements IShipObjectWorldServerProvider, GameServer { @@ -124,6 +127,14 @@ public VSPipeline getVsPipeline() { ) ) private void postCreateLevels(final CallbackInfo ci) { + // Register blocks + if (!MassDatapackResolver.INSTANCE.getRegisteredBlocks()) { + final List blockStateList = new ArrayList<>(Block.BLOCK_STATE_REGISTRY.size()); + Block.BLOCK_STATE_REGISTRY.forEach((blockStateList::add)); + MassDatapackResolver.INSTANCE.registerAllBlockStates(blockStateList); + ValkyrienSkiesMod.getVsCore().registerBlockStates(MassDatapackResolver.INSTANCE.getBlockStateData()); + } + // Load ship data from the world storage final ShipSavedData shipSavedData = overworld().getDataStorage() .computeIfAbsent(ShipSavedData::load, ShipSavedData.Companion::createEmpty, ShipSavedData.SAVED_DATA_ID); @@ -140,18 +151,6 @@ private void postCreateLevels(final CallbackInfo ci) { // Create ship world and VS Pipeline vsPipeline = shipSavedData.getPipeline(); - // Register blocks - if (!MassDatapackResolver.INSTANCE.getRegisteredBlocks()) { - final List blockStateList = new ArrayList<>(Block.BLOCK_STATE_REGISTRY.size()); - Block.BLOCK_STATE_REGISTRY.forEach((blockStateList::add)); - MassDatapackResolver.INSTANCE.registerAllBlockStates(blockStateList); - } - vsPipeline.registerBlocks( - MassDatapackResolver.INSTANCE.getSolidBlockStates(), - MassDatapackResolver.INSTANCE.getLiquidBlockStates(), - MassDatapackResolver.INSTANCE.getBlockStateData() - ); - KrunchSupport.INSTANCE.setKrunchSupported(!vsPipeline.isUsingDummyPhysics()); shipWorld = vsPipeline.getShipWorld(); @@ -161,7 +160,8 @@ private void postCreateLevels(final CallbackInfo ci) { getShipObjectWorld().addDimension( VSGameUtilsKt.getDimensionId(overworld()), - VSGameUtilsKt.getYRange(overworld()) + VSGameUtilsKt.getYRange(overworld()), + McMathUtilKt.getDEFAULT_WORLD_GRAVITY() ); } @@ -233,6 +233,8 @@ private void postTick(final CallbackInfo ci) { // Only drag entities after we have updated the ship positions for (final ServerLevel level : getAllLevels()) { EntityDragger.INSTANCE.dragEntitiesWithShips(level.getAllEntities()); + if (LoadedMods.getWeather2()) + Weather2Compat.INSTANCE.tick(level); } handleShipPortals(); diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java index 985ac3f04..4f707449b 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java @@ -57,6 +57,7 @@ import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.mixin.accessors.server.level.ChunkMapAccessor; import org.valkyrienskies.mod.mixin.accessors.server.level.DistanceManagerAccessor; +import org.valkyrienskies.mod.util.McMathUtilKt; @Mixin(ServerLevel.class) public abstract class MixinServerLevel implements IShipObjectWorldServerProvider, VSServerLevel { @@ -96,8 +97,11 @@ void onInit(final MinecraftServer minecraftServer, final Executor executor, // This only happens when overworld gets loaded on startup, we have a mixin in MixinMinecraftServer for this specific case if (getShipObjectWorld() != null) { - getShipObjectWorld().addDimension(VSGameUtilsKt.getDimensionId((ServerLevel) (Object) this), - VSGameUtilsKt.getYRange((ServerLevel) (Object) this)); + getShipObjectWorld().addDimension( + VSGameUtilsKt.getDimensionId((ServerLevel) (Object) this), + VSGameUtilsKt.getYRange((ServerLevel) (Object) this), + McMathUtilKt.getDEFAULT_WORLD_GRAVITY() + ); } } @@ -244,6 +248,7 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf VSGameUtilsKt.getDimensionId(self), voxelShapeUpdates ); + } @Override 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 ad158569f..c1b6d962c 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 @@ -33,6 +33,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.BlockStateInfo; +import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VSLevelChunk; @Mixin(LevelChunk.class) @@ -61,7 +62,10 @@ public MixinLevelChunk(final Ship ship) { public void postSetBlockState(final BlockPos pos, final BlockState state, final boolean moved, final CallbackInfoReturnable cir) { final BlockState prevState = cir.getReturnValue(); - BlockStateInfo.INSTANCE.onSetBlock(level, pos, prevState, state); + // This function is getting invoked by non-game threads for some reason. So use executeOrSchedule() to schedule + // onSetBlock() to be run on the next tick when this function is invoked by a non-game thread. + // See https://github.com/ValkyrienSkies/Valkyrien-Skies-2/issues/913 for more info. + VSGameUtilsKt.executeOrSchedule(level, () -> BlockStateInfo.INSTANCE.onSetBlock(level, pos, prevState, state)); } @Shadow 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 new file mode 100644 index 000000000..162811d5f --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/bluemap/WorldDuck.java @@ -0,0 +1,10 @@ +package org.valkyrienskies.mod.mixinducks.mod_compat.bluemap; + +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.level.Level; + +public interface WorldDuck { + + Level valkyrienskies$getCorrelatingLevel(); + +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/VsAPI.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/VsAPI.kt new file mode 100644 index 000000000..270bf4ebc --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/VsAPI.kt @@ -0,0 +1,56 @@ +package org.valkyrienskies.mod.api + +import net.minecraft.client.gui.screens.Screen +import net.minecraft.client.multiplayer.ClientLevel +import net.minecraft.core.BlockPos +import net.minecraft.world.level.ChunkPos +import net.minecraft.world.level.Level +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.entity.Entity + +import org.jetbrains.annotations.ApiStatus.* +import org.valkyrienskies.core.api.VsCoreApi +import org.valkyrienskies.core.api.event.ListenableEvent +import org.valkyrienskies.core.api.ships.* +import org.valkyrienskies.mod.api.events.PostRenderShipEvent +import org.valkyrienskies.mod.api.events.PreRenderShipEvent +import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent + +@NonExtendable +interface VsApi : VsCoreApi { + + /** + * This event gets called when it's time to register physics block states for Minecraft block states. + */ + @get:Experimental + val registerBlockStateEvent: ListenableEvent + + @get:Experimental + val preRenderShipEvent: ListenableEvent + + @get:Experimental + val postRenderShipEvent: ListenableEvent + + fun isShipMountingEntity(entity: Entity): Boolean + + @Deprecated(message = "The legacy VS config system will be replaced soon. " + + "Migrate to another config library, or the new system when it's released. ") + fun createConfigScreenLegacy(parent: Screen, vararg configs: Class<*>): Screen + + /** + * Get the ship with the chunk claim that contains [pos], if it exists. + * + * If either parameter is null, this will return null. + * + * @param level The [Level] to look for the ship in. If [level] is a + * [ServerLevel], this will return a [ServerShip]. If [level] is a + * [ClientLevel], this will return a [ClientShip]. + * + * @param pos A block position in the Shipyard + */ + fun getShipManagingBlock(level: Level?, pos: BlockPos?): Ship? + + fun getShipManagingChunk(level: Level?, pos: ChunkPos?): Ship? + + fun getShipManagingChunk(level: Level?, chunkX: Int, chunkZ: Int): Ship? +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PostRenderShipEvent.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PostRenderShipEvent.kt new file mode 100644 index 000000000..33bbd6de3 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PostRenderShipEvent.kt @@ -0,0 +1,6 @@ +package org.valkyrienskies.mod.api.events + +import org.jetbrains.annotations.ApiStatus.Experimental + +@Experimental +interface PostRenderShipEvent diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PreRenderShipEvent.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PreRenderShipEvent.kt new file mode 100644 index 000000000..2d99dbf51 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/PreRenderShipEvent.kt @@ -0,0 +1,6 @@ +package org.valkyrienskies.mod.api.events + +import org.jetbrains.annotations.ApiStatus.Experimental + +@Experimental +interface PreRenderShipEvent diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/events/RegisterBlockStateEvent.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/RegisterBlockStateEvent.kt new file mode 100644 index 000000000..12800615b --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api/events/RegisterBlockStateEvent.kt @@ -0,0 +1,25 @@ +package org.valkyrienskies.mod.api.events + +import net.minecraft.world.level.block.state.BlockState +import org.jetbrains.annotations.ApiStatus.Experimental +import org.valkyrienskies.core.api.physics.blockstates.LiquidState +import org.valkyrienskies.core.api.physics.blockstates.SolidState + +@Experimental +interface RegisterBlockStateEvent { + + fun newLiquidStateBuilder(): LiquidState.Builder + fun buildLiquidState(block: LiquidState.Builder.() -> Unit): LiquidState + fun newSolidStateBuilder(): SolidState.Builder + fun buildSolidState(block: SolidState.Builder.() -> Unit): SolidState + + fun register(state: BlockState, solidState: SolidState) + fun register(state: BlockState, liquidState: LiquidState) + + /** + * Registers the Minecraft [state] to be represented by [LiquidState] and [SolidState] in the same block. + * This is useful for e.g., a waterlogged chest, where the [liquidState] would be water and the [solidState] would + * be the chest shape. + */ + fun register(state: BlockState, liquidState: LiquidState, solidState: SolidState) +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/RegisterBlockStateEventImpl.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/RegisterBlockStateEventImpl.kt new file mode 100644 index 000000000..683019ebe --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/RegisterBlockStateEventImpl.kt @@ -0,0 +1,36 @@ +package org.valkyrienskies.mod.api_impl.events + +import net.minecraft.world.level.block.state.BlockState +import org.valkyrienskies.core.api.physics.blockstates.LiquidState +import org.valkyrienskies.core.api.physics.blockstates.SolidState +import org.valkyrienskies.core.apigame.physics.blockstates.VsBlockState +import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent +import org.valkyrienskies.mod.common.ValkyrienSkiesMod.vsCore + +class RegisterBlockStateEventImpl : RegisterBlockStateEvent { + val toRegister = mutableListOf>() + + override fun newLiquidStateBuilder(): LiquidState.Builder = + vsCore.newLiquidStateBuilder() + + override fun buildLiquidState(block: LiquidState.Builder.() -> Unit): LiquidState = + vsCore.newLiquidStateBuilder().apply(block).build() + + override fun newSolidStateBuilder(): SolidState.Builder = + vsCore.newSolidStateBuilder() + + override fun buildSolidState(block: SolidState.Builder.() -> Unit): SolidState = + vsCore.newSolidStateBuilder().apply(block).build() + + override fun register(state: BlockState, solidState: SolidState) { + toRegister.add(Pair(state, VsBlockState(solidState, null))) + } + + override fun register(state: BlockState, liquidState: LiquidState) { + toRegister.add(Pair(state, VsBlockState(null, liquidState))) + } + + override fun register(state: BlockState, liquidState: LiquidState, solidState: SolidState) { + toRegister.add(Pair(state, VsBlockState(solidState, liquidState))) + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VSApiImpl.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VSApiImpl.kt new file mode 100644 index 000000000..3749d133e --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VSApiImpl.kt @@ -0,0 +1,44 @@ +package org.valkyrienskies.mod.api_impl.events + +import net.minecraft.client.gui.screens.Screen +import net.minecraft.core.BlockPos +import net.minecraft.world.entity.Entity +import net.minecraft.world.level.ChunkPos +import net.minecraft.world.level.Level +import org.valkyrienskies.core.api.ships.Ship +import org.valkyrienskies.core.util.events.EventEmitterImpl +import org.valkyrienskies.mod.api.VsApi +import org.valkyrienskies.mod.api.events.PostRenderShipEvent +import org.valkyrienskies.mod.api.events.PreRenderShipEvent +import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent +import org.valkyrienskies.mod.common.entity.ShipMountingEntity +import org.valkyrienskies.mod.common.getShipManagingPos +import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig + +class VsApiImpl : VsApi { + + override val registerBlockStateEvent = EventEmitterImpl() + override val preRenderShipEvent = EventEmitterImpl() + override val postRenderShipEvent = EventEmitterImpl() + + override fun isShipMountingEntity(entity: Entity): Boolean { + return entity is ShipMountingEntity + } + + override fun createConfigScreenLegacy(parent: Screen, vararg configs: Class<*>): Screen { + return VSClothConfig.createConfigScreenFor(parent, *configs) + } + + + override fun getShipManagingBlock(level: Level?, pos: BlockPos?): Ship? { + return pos?.let { level?.getShipManagingPos(it) } + } + + override fun getShipManagingChunk(level: Level?, pos: ChunkPos?): Ship? { + return pos?.let { level?.getShipManagingPos(it) } + } + + override fun getShipManagingChunk(level: Level?, chunkX: Int, chunkZ: Int): Ship? { + return level?.getShipManagingPos(chunkX, chunkZ) + } +} 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 4a6ce7419..129d47e3a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -17,11 +17,6 @@ import org.valkyrienskies.core.apigame.world.chunks.BlockType import org.valkyrienskies.mod.common.block.WingBlock import org.valkyrienskies.mod.common.config.MassDatapackResolver import org.valkyrienskies.mod.common.hooks.VSGameEvents -import org.valkyrienskies.physics_api.Lod1BlockStateId -import org.valkyrienskies.physics_api.Lod1LiquidBlockStateId -import org.valkyrienskies.physics_api.Lod1SolidBlockStateId -import org.valkyrienskies.physics_api.voxel.Lod1LiquidBlockState -import org.valkyrienskies.physics_api.voxel.Lod1SolidBlockState import java.util.function.IntFunction // Other mods can then provide weights and types based on their added content @@ -35,10 +30,6 @@ interface BlockStateInfoProvider { // Get the id of the block state fun getBlockStateType(blockState: BlockState): BlockType? - - val solidBlockStates: List - val liquidBlockStates: List - val blockStateData: List> } object BlockStateInfo { diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt index 373b4254c..fc8ebaf03 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt @@ -1,23 +1,13 @@ package org.valkyrienskies.mod.common +import net.minecraft.world.level.block.Blocks +import net.minecraft.world.level.block.LiquidBlock import net.minecraft.world.level.block.state.BlockState -import net.minecraft.world.level.material.Material import org.valkyrienskies.core.apigame.world.chunks.BlockType -import org.valkyrienskies.physics_api.Lod1BlockStateId -import org.valkyrienskies.physics_api.Lod1LiquidBlockStateId -import org.valkyrienskies.physics_api.Lod1SolidBlockStateId -import org.valkyrienskies.physics_api.voxel.Lod1LiquidBlockState -import org.valkyrienskies.physics_api.voxel.Lod1SolidBlockState object DefaultBlockStateInfoProvider : BlockStateInfoProvider { override val priority: Int get() = Int.MIN_VALUE - override val solidBlockStates: List - get() = TODO() - override val liquidBlockStates: List - get() = TODO() - override val blockStateData: List> - get() = TODO() override fun getBlockStateMass(blockState: BlockState): Double { if (blockState.isAir) return 0.0 @@ -28,9 +18,9 @@ object DefaultBlockStateInfoProvider : BlockStateInfoProvider { override fun getBlockStateType(blockState: BlockState): BlockType { if (blockState.isAir) return vsCore.blockTypes.air - val blockMaterial = blockState.material - if (blockMaterial.isLiquid) - return if (blockMaterial == Material.LAVA) vsCore.blockTypes.lava else vsCore.blockTypes.water - return if (blockMaterial.isSolid) vsCore.blockTypes.solid else vsCore.blockTypes.air + val block = blockState.block + if (block is LiquidBlock) + return if (block == Blocks.LAVA) vsCore.blockTypes.lava else vsCore.blockTypes.water + return if (blockState.material.isSolid) vsCore.blockTypes.solid else vsCore.blockTypes.air } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt index ce0890a0b..a246a2bb7 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/PlayerUtil.kt @@ -25,28 +25,23 @@ object PlayerUtil { @JvmStatic fun transformPlayerTemporarily(player: Player, ship: LoadedShip?) { - if (player.level.isBlockInShipyard(player.x, player.y, player.z)) { - // player is already in shipyard - return - } + if (ship == null) return + // player is already in shipyard + if (player.level.isBlockInShipyard(player.x, player.y, player.z)) return prevPosInfo[player] = TempPlayerPosInfo(player.yRot, player.yHeadRot, player.xRot, player.position()) - if (ship != null) { - val shipMatrix = ship.worldToShip - val direction = shipMatrix.transformDirection( - player.lookAngle.toJOML() - ) - val position = shipMatrix.transformPosition( - player.position().toJOML() - ) - val yaw = -atan2(direction.x, direction.z) - val pitch = -atan2(direction.y, sqrt((direction.x * direction.x) + (direction.z * direction.z))) - player.yRot = (yaw * (180 / Math.PI)).toFloat() - player.yHeadRot = player.yRot - player.xRot = (pitch * (180 / Math.PI)).toFloat() - (player as EntityAccessor).setPosNoUpdates(position.toMinecraft()) - } + val shipMatrix = ship.worldToShip + + val direction = shipMatrix.transformDirection(player.lookAngle.toJOML()) + val position = shipMatrix.transformPosition(player.position().toJOML()) + val yaw = -atan2(direction.x, direction.z) + val pitch = -atan2(direction.y, sqrt((direction.x * direction.x) + (direction.z * direction.z))) + + player.yRot = (yaw * (180 / Math.PI)).toFloat() + player.yHeadRot = player.yRot + player.xRot = (pitch * (180 / Math.PI)).toFloat() + (player as EntityAccessor).setPosNoUpdates(position.toMinecraft()) } @JvmStatic 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 9368ad3fd..8c4160db7 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -10,6 +10,7 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.server.MinecraftServer import net.minecraft.server.level.ServerChunkCache import net.minecraft.server.level.ServerLevel +import net.minecraft.util.thread.BlockableEventLoop import net.minecraft.world.entity.Entity import net.minecraft.world.entity.player.Player import net.minecraft.world.level.ChunkPos @@ -208,7 +209,7 @@ inline fun Level?.transformToNearbyShipsAndWorld( cb(posInWorld.x(), posInWorld.y(), posInWorld.z()) } - for (nearbyShip in shipObjectWorld.allShips.getIntersecting(aabb)) { + for (nearbyShip in shipObjectWorld.allShips.getIntersecting(aabb, this!!.dimensionId)) { if (nearbyShip == currentShip) continue val posInShip = nearbyShip.worldToShip.transformPosition(posInWorld, temp0) cb(posInShip.x(), posInShip.y(), posInShip.z()) @@ -393,8 +394,7 @@ fun Level?.getWorldCoordinates(blockPos: BlockPos, pos: Vector3d): Vector3d { } fun Level.getShipsIntersecting(aabb: AABB): Iterable = getShipsIntersecting(aabb.toJOML()) -fun Level.getShipsIntersecting(aabb: AABBdc): Iterable = allShips.getIntersecting(aabb).filter { it.chunkClaimDimension == dimensionId } - +fun Level.getShipsIntersecting(aabb: AABBdc): Iterable = allShips.getIntersecting(aabb, dimensionId) fun Level?.transformAabbToWorld(aabb: AABB): AABB = transformAabbToWorld(aabb.toJOML()).toMinecraft() fun Level?.transformAabbToWorld(aabb: AABBd) = this?.transformAabbToWorld(aabb, aabb) ?: aabb fun Level.transformAabbToWorld(aabb: AABBdc, dest: AABBd): AABBd { @@ -409,6 +409,25 @@ fun Level.transformAabbToWorld(aabb: AABBdc, dest: AABBd): AABBd { return dest.set(aabb) } +/** + * Execute [runnable] immediately iff the thread invoking this is the same as the game thread. + * Otherwise, schedule [runnable] to run on the next tick. + */ +fun Level.executeOrSchedule(runnable: Runnable) { + val blockableEventLoop: BlockableEventLoop = if (!this.isClientSide) { + this.server!! as BlockableEventLoop + } else { + Minecraft.getInstance() + } + if (blockableEventLoop.isSameThread) { + // For some reason MinecraftServer wants to schedule even when it's the same thread, so we need to add our own + // logic + runnable.run() + } else { + blockableEventLoop.execute(runnable) + } +} + fun getShipMountedToData(passenger: Entity, partialTicks: Float? = null): ShipMountedToData? { val vehicle = passenger.vehicle ?: return null if (vehicle is ShipMountedToDataProvider) { diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt index 6dac43e54..f5f20b0b7 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -8,8 +8,6 @@ import net.minecraft.world.level.block.entity.BlockEntityType import org.valkyrienskies.core.api.ships.setAttachment import org.valkyrienskies.core.apigame.VSCore import org.valkyrienskies.core.apigame.VSCoreClient -import org.valkyrienskies.core.impl.config.VSConfigClass -import org.valkyrienskies.core.impl.config.VSCoreConfig import org.valkyrienskies.core.impl.hooks.VSEvents import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.config.VSGameConfig @@ -50,8 +48,7 @@ object ValkyrienSkiesMod { VSGamePackets.register() VSGamePackets.registerHandlers() - VSConfigClass.registerConfig("vs_core", VSCoreConfig::class.java) - VSConfigClass.registerConfig("vs", VSGameConfig::class.java) + core.registerConfigLegacy("vs", VSGameConfig::class.java) VSEvents.ShipLoadEvent.on { event -> event.ship.setAttachment(GameTickForceApplier()) } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/AssemblyUtil.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/AssemblyUtil.kt new file mode 100644 index 000000000..78199a624 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/AssemblyUtil.kt @@ -0,0 +1,147 @@ +package org.valkyrienskies.mod.common.assembly + +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction +import net.minecraft.nbt.CompoundTag +import net.minecraft.util.Mth +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.Blocks +import net.minecraft.world.level.block.state.BlockState +import net.minecraft.world.level.chunk.LevelChunk +import net.minecraft.world.ticks.ScheduledTick +import org.joml.Vector3d +import org.joml.Vector3i + +private val AIR = Blocks.AIR.defaultBlockState() +object AssemblyUtil { + + fun setBlock(level: Level, pos: BlockPos, state: BlockState?) { + val chunk = level.getChunk(pos) as LevelChunk + val section = chunk.getSection(chunk.getSectionIndex(pos.y)) + val oldState = level.getBlockState(pos) + section.setBlockState(pos.x and 15, pos.y and 15, pos.z and 15, state) + ShipAssembler.triggerBlockChange(level, pos, oldState, state) + } + + fun removeBlock(level: Level, pos: BlockPos) { + level.removeBlockEntity(pos) + setBlock(level, pos, Blocks.AIR.defaultBlockState()) + } + + fun copyBlock(level: Level, from: BlockPos?, to: BlockPos) { + val state = level.getBlockState(from) + val blockentity = level.getBlockEntity(from) + setBlock(level, to, state) + + // Transfer pending schedule-ticks + if (level.blockTicks.hasScheduledTick(from, state.block)) { + level.blockTicks.schedule(ScheduledTick(state.block, to, 0, 0)) + } + + // Transfer block-entity data + if (state.hasBlockEntity() && blockentity != null) { + val data: CompoundTag = blockentity.saveWithId() + level.setBlockEntity(blockentity) + val newBlockentity = level.getBlockEntity(to) + newBlockentity?.load(data) + } + } + + fun updateBlock(level: Level, fromPos: BlockPos, toPos: BlockPos, toState: BlockState) { + + // 75 = flag 1 (block update) & flag 2 (send to clients) + flag 8 (force rerenders) + val flags = 11 + + //updateNeighbourShapes recurses through nearby blocks, recursionLeft is the limit + val recursionLeft = 511 + + level.setBlocksDirty(fromPos, toState, AIR) + level.sendBlockUpdated(fromPos, toState, AIR, flags) + level.blockUpdated(fromPos, AIR.block) + // This handles the update for neighboring blocks in worldspace + AIR.updateIndirectNeighbourShapes(level, fromPos, flags, recursionLeft - 1) + AIR.updateNeighbourShapes(level, fromPos, flags, recursionLeft) + AIR.updateIndirectNeighbourShapes(level, fromPos, flags, recursionLeft) + //This updates lighting for blocks in worldspace + level.chunkSource.lightEngine.checkBlock(fromPos) + + level.setBlocksDirty(toPos, AIR, toState) + level.sendBlockUpdated(toPos, AIR, toState, flags) + level.blockUpdated(toPos, toState.block) + if (!level.isClientSide && toState.hasAnalogOutputSignal()) { + level.updateNeighbourForOutputSignal(toPos, toState.block) + } + //This updates lighting for blocks in shipspace + level.chunkSource.lightEngine.checkBlock(toPos) + } + + fun toBlockPos(x: Double, y: Double, z: Double): BlockPos { + return BlockPos(Mth.floor(x), Math.floor(y).toInt(), Math.floor(z).toInt()) + } + + fun toBlockPos(vec: Vector3d): BlockPos { + return toBlockPos(vec.x, vec.y, vec.z) + } + + fun getVecDirection(v: Vector3i): Direction { + var axis = Direction.Axis.X + if (v.y() != 0) axis = Direction.Axis.Y + if (v.z() != 0) axis = Direction.Axis.Z + val direction = if (v.x + v.y + v.z > 0) Direction.AxisDirection.POSITIVE else Direction.AxisDirection.NEGATIVE + return Direction.fromAxisAndDirection(axis, direction) + } + + fun getMinCorner(pos1: BlockPos, pos2: BlockPos): BlockPos { + return BlockPos( + Math.min(pos1.x, pos2.x), + Math.min(pos1.y, pos2.y), + Math.min(pos1.z, pos2.z) + ) + } + + fun getMaxCorner(pos1: BlockPos, pos2: BlockPos): BlockPos { + return BlockPos( + Math.max(pos1.x, pos2.x), + Math.max(pos1.y, pos2.y), + Math.max(pos1.z, pos2.z) + ) + } + + fun getMiddle(pos1: BlockPos, pos2: BlockPos): Vector3i { + val middleX = Math.min(pos1.x, pos2.x).toDouble() + (Math.max(pos1.x, pos2.x) - Math.min( + pos1.x, + pos2.x + ) + 1) / 2 + val middleY = Math.min(pos1.y, pos2.y).toDouble() + (Math.max(pos1.y, pos2.y) - Math.min( + pos1.y, + pos2.y + ) + 1) / 2 + val middleZ = Math.min(pos1.z, pos2.z).toDouble() + (Math.max(pos1.z, pos2.z) - Math.min( + pos1.z, + pos2.z + ) + 1) / 2 + return Vector3i(middleX.toInt(), middleY.toInt(), middleZ.toInt()) + } + + fun getMiddle(pos1: Vector3d, pos2: Vector3d): Vector3d { + val middleX = Math.min(pos1.x, pos2.x) + (Math.max(pos1.x, pos2.x) - Math.min( + pos1.x, + pos2.x + )) / 2.0 + val middleY = Math.min(pos1.y, pos2.y) + (Math.max(pos1.y, pos2.y) - Math.min( + pos1.y, + pos2.y + )) / 2.0 + val middleZ = Math.min(pos1.z, pos2.z) + (Math.max(pos1.z, pos2.z) - Math.min( + pos1.z, + pos2.z + )) / 2.0 + return Vector3d(middleX, middleY, middleZ) + } + + + + + +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SeamlessChunksManager.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SeamlessChunksManager.kt index bb8aac7ab..f79def783 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SeamlessChunksManager.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SeamlessChunksManager.kt @@ -12,7 +12,6 @@ import net.minecraft.world.level.ChunkPos import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.properties.ChunkClaim import org.valkyrienskies.core.impl.hooks.VSEvents.ShipLoadEventClient -import org.valkyrienskies.core.impl.networking.simple.registerClientHandler import org.valkyrienskies.core.util.pollUntilEmpty import org.valkyrienskies.mod.common.getShipManagingPos import org.valkyrienskies.mod.common.isChunkInShipyard @@ -44,12 +43,14 @@ class SeamlessChunksManager(private val listener: ClientPacketListener) { private val stalledChunks = LongOpenHashSet() init { - PacketStopChunkUpdates::class.registerClientHandler { (chunks) -> - chunks.forEach { stalledChunks.add(it.toMinecraft().toLong()) } - } - PacketRestartChunkUpdates::class.registerClientHandler { packet -> - Minecraft.getInstance().execute { - onRestartUpdates(packet) + with(vsCore.simplePacketNetworking) { + PacketStopChunkUpdates::class.registerClientHandler { (chunks) -> + chunks.forEach { stalledChunks.add(it.toMinecraft().toLong()) } + } + PacketRestartChunkUpdates::class.registerClientHandler { packet -> + Minecraft.getInstance().execute { + onRestartUpdates(packet) + } } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembler.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembler.kt new file mode 100644 index 000000000..7ee1c79b1 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembler.kt @@ -0,0 +1,115 @@ +package org.valkyrienskies.mod.common.assembly + +import net.minecraft.core.BlockPos +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Blocks +import net.minecraft.world.level.block.state.BlockState +import org.joml.Vector3d +import org.joml.Vector3i +import org.joml.Vector3ic +import org.valkyrienskies.core.api.ships.ServerShip +import org.valkyrienskies.core.api.ships.Ship +import org.valkyrienskies.core.impl.game.ShipTeleportDataImpl +import org.valkyrienskies.mod.common.BlockStateInfo.onSetBlock +import org.valkyrienskies.mod.common.dimensionId +import org.valkyrienskies.mod.common.getShipObjectManagingPos +import org.valkyrienskies.mod.common.shipObjectWorld + +object ShipAssembler { + + fun triggerBlockChange(level: Level?, pos: BlockPos?, prevState: BlockState?, newState: BlockState?) { + onSetBlock(level!!, pos!!, prevState!!, newState!!) + } + + fun isValidShipBlock(state: BlockState?): Boolean { + if (state != null) { + //return !state.tags.anyMatch { it== VsShipAssemblerTags.FORBIDDEN_ASSEMBLE } + return !state.isAir + } + return true + } + + + fun assembleToShip(level: Level, blocks: List, removeOriginal: Boolean, scale: Double): ServerShip { + assert(level is ServerLevel) { "Can't manage contraptions on client side!" } + val sLevel: ServerLevel = level as ServerLevel + if (blocks.isEmpty()) { + throw IllegalArgumentException() + } + + val existingShip = sLevel.getShipObjectManagingPos(blocks.find { !sLevel.getBlockState(it).isAir } ?: throw IllegalArgumentException()) + + var structureCornerMin: BlockPos = blocks[0] + var structureCornerMax: BlockPos = blocks[0] + var hasSolids = false + + // Calculate bounds of the area containing all blocks adn check for solids and invalid blocks + for (itPos in blocks) { + if (isValidShipBlock(level.getBlockState(itPos))) { + structureCornerMin = AssemblyUtil.getMinCorner(structureCornerMin, itPos) + structureCornerMax = AssemblyUtil.getMaxCorner(structureCornerMax, itPos) + hasSolids = true + } + } + if (!hasSolids) throw IllegalArgumentException("No solid blocks found in the structure") + val contraptionOGPos: Vector3ic = AssemblyUtil.getMiddle(structureCornerMin, structureCornerMax) + // Create new contraption at center of bounds + val contraptionWorldPos: Vector3i = if (existingShip != null) { + val doubleVer = existingShip.shipToWorld.transformPosition(Vector3d(contraptionOGPos)).floor() + Vector3i(doubleVer.x.toInt(), doubleVer.y.toInt(), doubleVer.z.toInt()) + } else { + Vector3i(contraptionOGPos) + } + //val contraptionPosition = ContraptionPosition(Quaterniond(Vec3d(0.0, 1.0, 1.0), 0.0), contraptionWorldPos, null) + + val newShip: Ship = (level as ServerLevel).server.shipObjectWorld + .createNewShipAtBlock(contraptionWorldPos, false, scale, level.dimensionId) + + // Stone for safety reasons + + val contraptionShipPos = newShip.worldToShip.transformPosition(Vector3d(contraptionWorldPos.x.toDouble(),contraptionWorldPos.y.toDouble(),contraptionWorldPos.z.toDouble())) + val contraptionBlockPos = BlockPos(contraptionShipPos.x.toInt(),contraptionShipPos.y.toInt(),contraptionShipPos.z.toInt()) + + + // Copy blocks and check if the center block got replaced (is default a stone block) + var centerBlockReplaced = false + for (itPos in blocks) { + if (isValidShipBlock(level.getBlockState(itPos))) { + val relative: BlockPos = itPos.subtract( BlockPos(contraptionOGPos.x(),contraptionOGPos.y(),contraptionOGPos.z())) + val shipPos: BlockPos = contraptionBlockPos.offset(relative) + AssemblyUtil.copyBlock(level, itPos, shipPos) + if (relative == BlockPos.ZERO) centerBlockReplaced = true + } + } + + // If center block got not replaced, remove the stone block + if (!centerBlockReplaced) { + level.setBlock(contraptionBlockPos, Blocks.AIR.defaultBlockState(), 3) + } + + // Remove original blocks + if (removeOriginal) { + for (itPos in blocks) { + if (isValidShipBlock(level.getBlockState(itPos))) { + AssemblyUtil.removeBlock(level, itPos) + } + } + } + + // Trigger updates on both contraptions + for (itPos in blocks) { + val relative: BlockPos = itPos.subtract(BlockPos(contraptionOGPos.x(),contraptionOGPos.y(),contraptionOGPos.z())) + val shipPos: BlockPos = contraptionBlockPos.offset(relative) + AssemblyUtil.updateBlock(level,itPos,shipPos,level.getBlockState(shipPos)) + } + + + sLevel.server.shipObjectWorld + .teleportShip(newShip as ServerShip, ShipTeleportDataImpl(Vector3d(contraptionWorldPos.x.toDouble(),contraptionWorldPos.y.toDouble(),contraptionWorldPos.z.toDouble()))) + + return newShip as ServerShip + } + + +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt index 8df8aea74..b3ea1c640 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembly.kt @@ -5,10 +5,9 @@ import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.ChunkPos import org.joml.Vector3d import org.valkyrienskies.core.api.ships.ServerShip -import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet import org.valkyrienskies.core.impl.game.ships.ShipData import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl -import org.valkyrienskies.core.impl.networking.simple.sendToClient +import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.executeIf import org.valkyrienskies.mod.common.isTickingChunk @@ -16,93 +15,20 @@ import org.valkyrienskies.mod.common.networking.PacketRestartChunkUpdates import org.valkyrienskies.mod.common.networking.PacketStopChunkUpdates import org.valkyrienskies.mod.common.playerWrapper import org.valkyrienskies.mod.common.shipObjectWorld +import org.valkyrienskies.mod.common.util.toBlockPos import org.valkyrienskies.mod.common.util.toJOML +import org.valkyrienskies.mod.common.vsCore import org.valkyrienskies.mod.util.relocateBlock import org.valkyrienskies.mod.util.updateBlock +@Deprecated("Use ShipAssembler.assembleToShip instead") fun createNewShipWithBlocks( centerBlock: BlockPos, blocks: DenseBlockPosSet, level: ServerLevel ): ServerShip { if (blocks.isEmpty()) throw IllegalArgumentException() - val ship = level.shipObjectWorld.createNewShipAtBlock(centerBlock.toJOML(), false, 1.0, level.dimensionId) - - val shipChunkX = ship.chunkClaim.xMiddle - val shipChunkZ = ship.chunkClaim.zMiddle - - val worldChunkX = centerBlock.x shr 4 - val worldChunkZ = centerBlock.z shr 4 - - val deltaX = worldChunkX - shipChunkX - val deltaZ = worldChunkZ - shipChunkZ - - val chunksToBeUpdated = mutableMapOf>() - blocks.forEachChunk { x, _, z, _ -> - val sourcePos = ChunkPos(x, z) - val destPos = ChunkPos(x - deltaX, z - deltaZ) - chunksToBeUpdated[sourcePos] = Pair(sourcePos, destPos) - } - val chunkPairs = chunksToBeUpdated.values.toList() - val chunkPoses = chunkPairs.flatMap { it.toList() } - val chunkPosesJOML = chunkPoses.map { it.toJOML() } - - // Send a list of all the chunks that we plan on updating to players, so that they - // defer all updates until assembly is finished - level.players().forEach { player -> - PacketStopChunkUpdates(chunkPosesJOML).sendToClient(player.playerWrapper) - } - - // Use relocateBlock to copy all the blocks into the ship - blocks.forEachChunk { chunkX, chunkY, chunkZ, chunk -> - val sourceChunk = level.getChunk(chunkX, chunkZ) - val destChunk = level.getChunk(chunkX - deltaX, chunkZ - deltaZ) - - chunk.forEach { x, y, z -> - val fromPos = BlockPos((sourceChunk.pos.x shl 4) + x, (chunkY shl 4) + y, (sourceChunk.pos.z shl 4) + z) - val toPos = BlockPos((destChunk.pos.x shl 4) + x, (chunkY shl 4) + y, (destChunk.pos.z shl 4) + z) - - relocateBlock(sourceChunk, fromPos, destChunk, toPos, false, ship) - } - } - - // Use updateBlock to update blocks after copying - blocks.forEachChunk { chunkX, chunkY, chunkZ, chunk -> - val sourceChunk = level.getChunk(chunkX, chunkZ) - val destChunk = level.getChunk(chunkX - deltaX, chunkZ - deltaZ) - - chunk.forEach { x, y, z -> - val fromPos = BlockPos((sourceChunk.pos.x shl 4) + x, (chunkY shl 4) + y, (sourceChunk.pos.z shl 4) + z) - val toPos = BlockPos((destChunk.pos.x shl 4) + x, (chunkY shl 4) + y, (destChunk.pos.z shl 4) + z) - - updateBlock(destChunk.level, fromPos, toPos, destChunk.getBlockState(toPos)) - } - } - - // Calculate the position of the block that the player clicked after it has been assembled - val centerInShip = Vector3d( - ((shipChunkX shl 4) + (centerBlock.x and 15)).toDouble(), - centerBlock.y.toDouble(), - ((shipChunkZ shl 4) + (centerBlock.z and 15)).toDouble() - ) - - // The ship's position has shifted from the center block since we assembled the ship, compensate for that - val centerBlockPosInWorld = ship.inertiaData.centerOfMassInShip.sub(centerInShip, Vector3d()) - .add(ship.transform.positionInWorld) - - // Put the ship into the compensated position, so that all the assembled blocks stay in the same place - // TODO: AAAAAAAAA THIS IS HORRIBLE how can the API support this? - (ship as ShipData).transform = (ship.transform as ShipTransformImpl).copy(positionInWorld = centerBlockPosInWorld) - - level.server.executeIf( - // This condition will return true if all modified chunks have been both loaded AND - // chunk update packets were sent to players - { chunkPoses.all(level::isTickingChunk) } - ) { - // Once all the chunk updates are sent to players, we can tell them to restart chunk updates - level.players().forEach { player -> - PacketRestartChunkUpdates(chunkPosesJOML).sendToClient(player.playerWrapper) - } - } + val blockList: MutableList = mutableListOf() - return ship + blocks.toList().forEach { blockList.add(it.toBlockPos()) } + return ShipAssembler.assembleToShip(level, blockList, true, 1.0) } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentParser.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentParser.kt index 00adb0621..857d01523 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentParser.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentParser.kt @@ -138,8 +138,14 @@ class ShipArgumentParser(private val source: VSCommandSource?, private var selec .filter { it.startsWith(builder.remaining) } .forEach { builder.suggest(it) } } - "limit" -> {} + "id" -> + suggest { builder, source -> + source.shipWorld.allShips + .map { it.id.toString() } + .filter { it.startsWith(builder.remaining) } + .forEach { builder.suggest(it) } + } else -> throw ERROR_UNKNOWN_OPTION.create(option) } @@ -155,7 +161,7 @@ class ShipArgumentParser(private val source: VSCommandSource?, private var selec this.slug = slug } - + "id" -> id = reader.readLong() "limit" -> limit = reader.readInt() else -> throw ERROR_UNKNOWN_OPTION.create(option) } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSGameConfig.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSGameConfig.kt index fe225d812..ebf47e73d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSGameConfig.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSGameConfig.kt @@ -72,6 +72,30 @@ object VSGameConfig { var canTurtlesLeaveScaledShips = false } + val Weather2 = WEATHER2() + + class WEATHER2 { + @JsonSchema( + description = "How much Weather 2's wind affects VS ships" + ) + var windMultiplier = 0.0001f + + @JsonSchema( + description = "The maximum velocity a VS ship can travel because of wind" + ) + var windMaxVel = 20.0f + + @JsonSchema( + description = "In what range storms affect VS ships" + ) + var stormRange = 150.0 + + @JsonSchema( + description = "Storm effect dampening on VS ships" + ) + var stormDampening = 0.0f + } + @JsonSchema( description = "By default, the vanilla server prevents block interacts past a certain distance " + "to prevent cheat clients from breaking blocks halfway across the map. " + 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 a40f37daf..6ec62527c 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 @@ -17,32 +17,25 @@ import net.minecraft.world.level.block.entity.BlockEntity import net.minecraft.world.level.block.state.BlockState import net.minecraft.world.level.material.FluidState import net.minecraft.world.level.material.Fluids -import net.minecraft.world.level.material.Material import net.minecraft.world.phys.shapes.VoxelShape -import org.joml.Vector3f -import org.joml.Vector3i +import org.joml.Vector3d +import org.joml.primitives.AABBi +import org.joml.primitives.AABBic +import org.valkyrienskies.core.api.physics.blockstates.BoxesBlockShape +import org.valkyrienskies.core.api.physics.blockstates.CollisionPoint +import org.valkyrienskies.core.api.physics.blockstates.LiquidState +import org.valkyrienskies.core.api.physics.blockstates.SolidBlockShape +import org.valkyrienskies.core.apigame.physics.blockstates.VsBlockState import org.valkyrienskies.core.apigame.world.chunks.BlockType import org.valkyrienskies.core.game.VSBlockType -import org.valkyrienskies.core.impl.collision.Lod1SolidShapeUtils -import org.valkyrienskies.core.impl.game.BlockTypeImpl import org.valkyrienskies.mod.common.BlockStateInfoProvider +import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.hooks.VSGameEvents import org.valkyrienskies.mod.common.vsCore import org.valkyrienskies.mod.mixin.accessors.world.level.block.SlabBlockAccessor import org.valkyrienskies.mod.mixin.accessors.world.level.block.StairBlockAccessor import org.valkyrienskies.mod.util.logger -import org.valkyrienskies.physics_api.Lod1BlockStateId -import org.valkyrienskies.physics_api.Lod1LiquidBlockStateId -import org.valkyrienskies.physics_api.Lod1SolidBlockStateId -import org.valkyrienskies.physics_api.voxel.CollisionPoint -import org.valkyrienskies.physics_api.voxel.Lod1LiquidBlockState -import org.valkyrienskies.physics_api.voxel.Lod1SolidBlockState -import org.valkyrienskies.physics_api.voxel.Lod1SolidBoxesCollisionShape -import org.valkyrienskies.physics_api.voxel.Lod1SolidCollisionShape -import org.valkyrienskies.physics_api.voxel.LodBlockBoundingBox import java.util.Optional -import kotlin.math.max -import kotlin.math.min import kotlin.math.roundToInt private data class VSBlockStateInfo( @@ -56,10 +49,9 @@ private data class VSBlockStateInfo( object MassDatapackResolver : BlockStateInfoProvider { private val map = hashMapOf() - private val _solidBlockStates: MutableList = ArrayList() - private val _liquidBlockStates: MutableList = ArrayList() - private val _blockStateData: MutableList> = ArrayList() - private val blockStateToId: MutableMap = HashMap() + private val mcBlockStateToVs: MutableMap = HashMap() + + val blockStateData: Collection = mcBlockStateToVs.values val loader get() = VSMassDataLoader() @@ -74,19 +66,14 @@ object MassDatapackResolver : BlockStateInfoProvider { override fun getBlockStateMass(blockState: BlockState): Double? = map[Registry.BLOCK.getKey(blockState.block)]?.mass - override fun getBlockStateType(blockState: BlockState): VSBlockType? = - blockStateToId[blockState]!! + override fun getBlockStateType(blockState: BlockState): BlockType? { + val vsState = mcBlockStateToVs[blockState] ?: return null + return vsCore.blockTypes.getType(vsState) + } var registeredBlocks = false private set - override val solidBlockStates: List - get() = _solidBlockStates - override val liquidBlockStates: List - get() = _liquidBlockStates - override val blockStateData: List> - get() = _blockStateData - class VSMassDataLoader : SimpleJsonResourceReloadListener(Gson(), "vs_mass") { private val tags = mutableListOf() @@ -160,7 +147,7 @@ object MassDatapackResolver : BlockStateInfoProvider { val friction = element.asJsonObject["friction"]?.asDouble ?: DEFAULT_FRICTION val elasticity = element.asJsonObject["elasticity"]?.asDouble ?: DEFAULT_ELASTICITY - val priority = element.asJsonObject["priority"]?.asInt ?: 100 + val priority = element.asJsonObject["priority"]?.asInt ?: decideDefaultPriority(origin) if (tag != null) { addToBeAddedTags(VSBlockStateInfo(ResourceLocation(tag), priority, weight, friction, elasticity, null)) @@ -173,38 +160,45 @@ object MassDatapackResolver : BlockStateInfoProvider { } } - private fun generateStairCollisionShapes(stairShapes: Array): Map { + fun decideDefaultPriority(resourceLocation: ResourceLocation) = when { + resourceLocation.namespace.equals(ValkyrienSkiesMod.MOD_ID) -> 1000 + resourceLocation.namespace.equals("custom") -> 50 + else -> 100 + } + + + private fun generateStairCollisionShapes(stairShapes: Array): Map { val testPoints = listOf( - CollisionPoint(Vector3f(.25f, .25f, .25f), .25f), - CollisionPoint(Vector3f(.25f, .25f, .75f), .25f), - CollisionPoint(Vector3f(.25f, .75f, .25f), .25f), - CollisionPoint(Vector3f(.25f, .75f, .75f), .25f), - CollisionPoint(Vector3f(.75f, .25f, .25f), .25f), - CollisionPoint(Vector3f(.75f, .25f, .75f), .25f), - CollisionPoint(Vector3f(.75f, .75f, .25f), .25f), - CollisionPoint(Vector3f(.75f, .75f, .75f), .25f), + CollisionPoint(.25f, .25f, .25f, .25f), + CollisionPoint(.25f, .25f, .75f, .25f), + CollisionPoint(.25f, .75f, .25f, .25f), + CollisionPoint(.25f, .75f, .75f, .25f), + CollisionPoint(.75f, .25f, .25f, .25f), + CollisionPoint(.75f, .25f, .75f, .25f), + CollisionPoint(.75f, .75f, .25f, .25f), + CollisionPoint(.75f, .75f, .75f, .25f), ) val testBoxes = listOf( - LodBlockBoundingBox.createVSBoundingBox(0, 0, 0, 7, 7, 7), - LodBlockBoundingBox.createVSBoundingBox(0, 0, 8, 7, 7, 15), - LodBlockBoundingBox.createVSBoundingBox(0, 8, 0, 7, 15, 7), - LodBlockBoundingBox.createVSBoundingBox(0, 8, 8, 7, 15, 15), - LodBlockBoundingBox.createVSBoundingBox(8, 0, 0, 15, 7, 7), - LodBlockBoundingBox.createVSBoundingBox(8, 0, 8, 15, 7, 15), - LodBlockBoundingBox.createVSBoundingBox(8, 8, 0, 15, 15, 7), - LodBlockBoundingBox.createVSBoundingBox(8, 8, 8, 15, 15, 15), + AABBi(0, 0, 0, 7, 7, 7), + AABBi(0, 0, 8, 7, 7, 15), + AABBi(0, 8, 0, 7, 15, 7), + AABBi(0, 8, 8, 7, 15, 15), + AABBi(8, 0, 0, 15, 7, 7), + AABBi(8, 0, 8, 15, 7, 15), + AABBi(8, 8, 0, 15, 15, 7), + AABBi(8, 8, 8, 15, 15, 15), ) - val map: MutableMap = HashMap() + val map: MutableMap = HashMap() stairShapes.forEach { stairShape -> val points: MutableList = ArrayList() - val positiveBoxes: MutableList = ArrayList() - val negativeBoxes: MutableList = ArrayList() + val positiveBoxes: MutableList = ArrayList() + val negativeBoxes: MutableList = ArrayList() testPoints.forEachIndexed { index, testPoint -> var added = false stairShape.forAllBoxes { minX, minY, minZ, maxX, maxY, maxZ -> - if (testPoint.pos.x() in minX .. maxX && testPoint.pos.y() in minY .. maxY && testPoint.pos.z() in minZ .. maxZ) { + if (testPoint.x in minX .. maxX && testPoint.y in minY .. maxY && testPoint.z in minZ .. maxZ) { points.add(testPoint) added = true return@forAllBoxes @@ -216,52 +210,39 @@ object MassDatapackResolver : BlockStateInfoProvider { negativeBoxes.add(testBoxes[index]) } } - val minTotalAABB = Vector3i(positiveBoxes[0].minX.toInt(), positiveBoxes[0].minY.toInt(), positiveBoxes[0].minZ.toInt()) - val maxTotalAABB = Vector3i(positiveBoxes[0].maxX.toInt(), positiveBoxes[0].maxY.toInt(), positiveBoxes[0].maxZ.toInt()) - for (i in 1 until positiveBoxes.size) { - minTotalAABB.x = min(minTotalAABB.x, positiveBoxes[i].minX.toInt()) - minTotalAABB.y = min(minTotalAABB.y, positiveBoxes[i].minY.toInt()) - minTotalAABB.z = min(minTotalAABB.z, positiveBoxes[i].minZ.toInt()) - maxTotalAABB.x = max(maxTotalAABB.x, positiveBoxes[i].maxX.toInt()) - maxTotalAABB.y = max(maxTotalAABB.y, positiveBoxes[i].maxY.toInt()) - maxTotalAABB.z = max(maxTotalAABB.z, positiveBoxes[i].maxZ.toInt()) - } - val overallBox = LodBlockBoundingBox.createVSBoundingBox( - minTotalAABB.x.toByte(), minTotalAABB.y.toByte(), minTotalAABB.z.toByte(), maxTotalAABB.x.toByte(), - maxTotalAABB.y.toByte(), maxTotalAABB.z.toByte() - ) - val collisionShape = Lod1SolidBoxesCollisionShape( - overallBoundingBox = overallBox, - collisionPoints = points, - solidBoxes = Lod1SolidShapeUtils.mergeBoxes(positiveBoxes), - negativeBoxes = Lod1SolidShapeUtils.mergeBoxes(negativeBoxes), - ) + + val collisionShape = vsCore.newSolidStateBoxesShapeBuilder() + .addCollisionPoints(points) + .addPositiveBoxes(vsCore.solidShapeUtils.mergeBoxes(positiveBoxes)) + .addNegativeBoxes(vsCore.solidShapeUtils.mergeBoxes(negativeBoxes)) + .build() + map[stairShape] = collisionShape } return map } - private fun generateShapeFromVoxel(voxelShape: VoxelShape): Lod1SolidBoxesCollisionShape? { - val posBoxes = ArrayList() + private fun generateShapeFromVoxel(voxelShape: VoxelShape): BoxesBlockShape? { + val posBoxes = ArrayList() var failed = false var maxBoxesToTest = 20 voxelShape.forAllBoxes { minX, minY, minZ, maxX, maxY, maxZ -> if (failed) { return@forAllBoxes } - val lodMinX = (minX * 16).roundToInt().toByte() - val lodMinY = (minY * 16).roundToInt().toByte() - val lodMinZ = (minZ * 16).roundToInt().toByte() - val lodMaxX = ((maxX * 16).roundToInt() - 1).toByte() - val lodMaxY = ((maxY * 16).roundToInt() - 1).toByte() - val lodMaxZ = ((maxZ * 16).roundToInt() - 1).toByte() + val lodMinX = (minX * 16).roundToInt() + val lodMinY = (minY * 16).roundToInt() + val lodMinZ = (minZ * 16).roundToInt() + val lodMaxX = ((maxX * 16).roundToInt() - 1) + val lodMaxY = ((maxY * 16).roundToInt() - 1) + val lodMaxZ = ((maxZ * 16).roundToInt() - 1) if (lodMinX !in 0..15 || lodMinY !in 0..15 || lodMinZ !in 0..15 || lodMaxX !in 0..15 || lodMaxY !in 0..15 || lodMaxZ !in 0..15) { // Out of range failed = true return@forAllBoxes } else { posBoxes.add( - LodBlockBoundingBox.createVSBoundingBox(lodMinX, lodMinY, lodMinZ, lodMaxX, lodMaxY, lodMaxZ) + AABBi(lodMinX, lodMinY, lodMinZ, lodMaxX, lodMaxY, lodMaxZ) ) } if (maxBoxesToTest == 0) { @@ -271,68 +252,33 @@ object MassDatapackResolver : BlockStateInfoProvider { } } return if (!failed) { - Lod1SolidShapeUtils.generateShapeFromBoxes(posBoxes) + try { + vsCore.solidShapeUtils.generateShapeFromBoxes(posBoxes) + } catch (ex: IllegalArgumentException) { + println("WTF ERROR WHILE PROCESSING $voxelShape") + null + } } else { null } } fun registerAllBlockStates(blockStates: Iterable) { - val fullLodBoundingBox = LodBlockBoundingBox.createVSBoundingBox(0, 0, 0, 15, 15, 15) + val fullLodBoundingBox = AABBi(0, 0, 0, 15, 15, 15) val fullBlockCollisionPoints = listOf( - CollisionPoint(Vector3f(.25f, .25f, .25f), .25f), - CollisionPoint(Vector3f(.25f, .25f, .75f), .25f), - CollisionPoint(Vector3f(.25f, .75f, .25f), .25f), - CollisionPoint(Vector3f(.25f, .75f, .75f), .25f), - CollisionPoint(Vector3f(.75f, .25f, .25f), .25f), - CollisionPoint(Vector3f(.75f, .25f, .75f), .25f), - CollisionPoint(Vector3f(.75f, .75f, .25f), .25f), - CollisionPoint(Vector3f(.75f, .75f, .75f), .25f), - ) - val fullBlockCollisionShape = Lod1SolidBoxesCollisionShape( - overallBoundingBox = fullLodBoundingBox, - collisionPoints = fullBlockCollisionPoints, - solidBoxes = listOf(fullLodBoundingBox), - negativeBoxes = listOf(), + CollisionPoint(.25f, .25f, .25f, .25f), + CollisionPoint(.25f, .25f, .75f, .25f), + CollisionPoint(.25f, .75f, .25f, .25f), + CollisionPoint(.25f, .75f, .75f, .25f), + CollisionPoint(.75f, .25f, .25f, .25f), + CollisionPoint(.75f, .25f, .75f, .25f), + CollisionPoint(.75f, .75f, .25f, .25f), + CollisionPoint(.75f, .75f, .75f, .25f), ) - - // Add default block states - run { - // region Add default solid block state - val solidBlockState = Lod1SolidBlockState( - collisionShape = fullBlockCollisionShape, - elasticity = DEFAULT_ELASTICITY.toFloat(), - friction = DEFAULT_FRICTION.toFloat(), - hardness = DEFAULT_HARDNESS.toFloat(), - lod1SolidBlockStateId = BlockTypeImpl.SOLID.toInt(), - ) - _solidBlockStates.add(solidBlockState) - _blockStateData.add(Triple(BlockTypeImpl.SOLID.toInt(), BlockTypeImpl.AIR.toInt(), BlockTypeImpl.SOLID.toInt())) - // endregion - - // region Add default water/lava liquid block states - val waterBlockState = Lod1LiquidBlockState( - boundingBox = fullLodBoundingBox, - density = 1000.0f, - dragCoefficient = 0.3f, - fluidVel = Vector3f(), - lod1LiquidBlockStateId = BlockTypeImpl.WATER.toInt(), - ) - - val lavaBlockState = Lod1LiquidBlockState( - boundingBox = fullLodBoundingBox, - density = 10000.0f, - dragCoefficient = 1.0f, - fluidVel = Vector3f(), - lod1LiquidBlockStateId = BlockTypeImpl.LAVA.toInt(), - ) - - _liquidBlockStates.add(waterBlockState) - _liquidBlockStates.add(lavaBlockState) - _blockStateData.add(Triple(BlockTypeImpl.AIR.toInt(), BlockTypeImpl.WATER.toInt(), BlockTypeImpl.WATER.toInt())) - _blockStateData.add(Triple(BlockTypeImpl.AIR.toInt(), BlockTypeImpl.LAVA.toInt(), BlockTypeImpl.LAVA.toInt())) - // endregion - } + val fullBlockCollisionShape = vsCore.newSolidStateBoxesShapeBuilder() + .addCollisionPoints(fullBlockCollisionPoints) + .addPositiveBox(fullLodBoundingBox) + .build() // A dummy world used to get the VoxelShape for each block state val dummyBlockGetter = object: BlockGetter { @@ -352,55 +298,46 @@ object MassDatapackResolver : BlockStateInfoProvider { StairBlockAccessor.getTopShapes() + StairBlockAccessor.getBottomShapes() + SlabBlockAccessor.getBottomAABB() + SlabBlockAccessor.getTopAABB() ) - // Setup initial conditions for future ids - var nextSolidId = 2 - var nextFluidId = 4 - var nextVoxelStateId = 4 + val generatedCollisionShapesMap = HashMap() + val liquidMaterialToDensityMap = mapOf(Fluids.WATER to Pair(1000.0, 0.3), Fluids.LAVA to Pair(10000.0, 1.0), Fluids.FLOWING_WATER to Pair(1000.0, 0.3), Fluids.FLOWING_LAVA to Pair(10000.0, 1.0)) - val generatedCollisionShapesMap = HashMap() - val liquidMaterialToDensityMap = mapOf(Fluids.WATER to Pair(1000.0f, 0.3f), Fluids.LAVA to Pair(10000.0f, 1.0f), Fluids.FLOWING_WATER to Pair(1000.0f, 0.3f), Fluids.FLOWING_LAVA to Pair(10000.0f, 1.0f)) - - val fluidStateToBlockTypeMap = HashMap>() + val fluidStateToBlockTypeMap = HashMap() // Get the id of the fluid state/create a new fluid state if necessary - fun getFluidState(fluidState: FluidState): Pair { + // Get the id of the fluid state/create a new fluid state if necessary + fun getFluidState(fluidState: FluidState): LiquidState { val cached = fluidStateToBlockTypeMap[fluidState] if (cached != null) return cached - val maxY = ((fluidState.ownHeight * 16.0).roundToInt() - 1).coerceIn(0, 15).toByte() - val fluidBox = LodBlockBoundingBox.createVSBoundingBox(0, 0, 0, 15, maxY, 15) - if (fluidState.type in liquidMaterialToDensityMap) { + val maxY = ((fluidState.ownHeight * 16.0).roundToInt() - 1).coerceIn(0, 15) + val fluidBox = AABBi(0, 0, 0, 15, maxY, 15) + return if (fluidState.type in liquidMaterialToDensityMap) { val (density, dragCoefficient) = liquidMaterialToDensityMap[fluidState.type]!! - val newFluidBlockState = Lod1LiquidBlockState( - boundingBox = fluidBox, - density = density, - dragCoefficient = dragCoefficient, - fluidVel = Vector3f(), - lod1LiquidBlockStateId = nextFluidId++, - ) - val stateId = nextVoxelStateId++ - _liquidBlockStates.add(newFluidBlockState) - _blockStateData.add(Triple(BlockTypeImpl.AIR.toInt(), newFluidBlockState.lod1LiquidBlockStateId, stateId)) - val blockTypeNew = BlockTypeImpl(stateId) - fluidStateToBlockTypeMap[fluidState] = newFluidBlockState.lod1LiquidBlockStateId to blockTypeNew - return newFluidBlockState.lod1LiquidBlockStateId to blockTypeNew + val newFluidBlockState = vsCore.newLiquidStateBuilder() + .boxShape(fluidBox) + .density(density) + .dragCoefficient(dragCoefficient) + .velocity(Vector3d()) + .build() + + newFluidBlockState } else { // Default - return BlockTypeImpl.WATER.toInt() to BlockTypeImpl.WATER + vsCore.blockTypes.waterState.liquidState!! } } blockStates.forEach { blockState: BlockState -> - val blockType: BlockType + val vsBlockState: VsBlockState if (blockState.isAir) { - blockType = vsCore.blockTypes.air + vsBlockState = vsCore.blockTypes.airState } else { val blockMaterial = blockState.material - blockType = if (blockMaterial.isLiquid) { - getFluidState(blockState.fluidState).second + vsBlockState = if (blockMaterial.isLiquid) { + VsBlockState(null, getFluidState(blockState.fluidState)) } else if (blockMaterial.isSolid) { val voxelShape = blockState.getShape(dummyBlockGetter, BlockPos.ZERO) - val collisionShape: Lod1SolidCollisionShape = if (voxelShapeToCollisionShapeMap.contains(voxelShape)) { + val collisionShape: SolidBlockShape = if (voxelShapeToCollisionShapeMap.contains(voxelShape)) { voxelShapeToCollisionShapeMap[voxelShape]!! } else if (generatedCollisionShapesMap.contains(voxelShape)) { if (generatedCollisionShapesMap[voxelShape] != null) { @@ -417,31 +354,25 @@ object MassDatapackResolver : BlockStateInfoProvider { val vsBlockStateInfo = map[Registry.BLOCK.getKey(blockState.block)] // Create new solid block state - val solidStateId = nextSolidId++ - val newSolidBlockState = Lod1SolidBlockState( - collisionShape = collisionShape, - elasticity = vsBlockStateInfo?.elasticity?.toFloat() ?: DEFAULT_ELASTICITY.toFloat(), - friction = vsBlockStateInfo?.friction?.toFloat() ?: DEFAULT_FRICTION.toFloat(), - hardness = DEFAULT_HARDNESS.toFloat(), - lod1SolidBlockStateId = solidStateId, - ) - _solidBlockStates.add(newSolidBlockState) - - // Create new voxel state - val blockStateId = nextVoxelStateId++ - - var fluidId = BlockTypeImpl.AIR.toInt() - if (!blockState.fluidState.isEmpty) { - fluidId = getFluidState(blockState.fluidState).first + val solidState = vsCore.newSolidStateBuilder() + .shape(collisionShape) + .elasticity(vsBlockStateInfo?.elasticity ?: DEFAULT_ELASTICITY) + .friction(vsBlockStateInfo?.friction ?: DEFAULT_FRICTION) + .hardness(DEFAULT_HARDNESS) + .build() + + val fluidState = if (!blockState.fluidState.isEmpty) { + getFluidState(blockState.fluidState) + } else { + null } - _blockStateData.add(Triple(solidStateId, fluidId, blockStateId)) - BlockTypeImpl(blockStateId) + VsBlockState(solidState, fluidState) } else { - vsCore.blockTypes.air + vsCore.blockTypes.airState } } - blockStateToId[blockState] = blockType + mcBlockStateToVs[blockState] = vsBlockState } registeredBlocks = true 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 fb62268ca..34da4e64b 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 @@ -12,13 +12,13 @@ import net.minecraft.world.phys.Vec3 import org.joml.Vector3f import org.valkyrienskies.core.api.ships.LoadedServerShip import org.valkyrienskies.core.api.ships.setAttachment -import org.valkyrienskies.core.impl.networking.simple.sendToServer import org.valkyrienskies.mod.api.SeatedControllingPlayer import org.valkyrienskies.mod.common.config.VSKeyBindings import org.valkyrienskies.mod.common.getShipManagingPos import org.valkyrienskies.mod.common.getShipObjectManagingPos import org.valkyrienskies.mod.common.isBlockInShipyard import org.valkyrienskies.mod.common.networking.PacketPlayerDriving +import org.valkyrienskies.mod.common.vsCore open class ShipMountingEntity(type: EntityType, level: Level) : Entity(type, level) { // Decides if this entity controls the ship it is in. @@ -96,7 +96,9 @@ open class ShipMountingEntity(type: EntityType, level: Level impulse.x = if (left == right) 0.0f else if (left) 1.0f else -1.0f impulse.y = if (up == down) 0.0f else if (up) 1.0f else -1.0f - PacketPlayerDriving(impulse, sprint, cruise).sendToServer() + with(vsCore.simplePacketNetworking) { + PacketPlayerDriving(impulse, sprint, cruise).sendToServer() + } } override fun getControllingPassenger(): Entity? { 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 b636d67ff..9adbc52d4 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 @@ -26,7 +26,6 @@ import org.valkyrienskies.core.apigame.world.ServerShipWorldCore import org.valkyrienskies.core.impl.game.ShipTeleportDataImpl import org.valkyrienskies.core.impl.game.ships.ShipInertiaDataImpl import org.valkyrienskies.core.impl.game.ships.ShipObjectClientWorld -import org.valkyrienskies.core.impl.game.ships.ShipObjectServerWorld import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl import org.valkyrienskies.core.impl.util.serialization.VSJacksonUtil import org.valkyrienskies.mod.common.dimensionId @@ -141,7 +140,7 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En } val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY) val oldPhysicsEntityData = getMapper().readValue(physicsEntityDataAsBytes) - val newShipId = (level.shipObjectWorld as ShipObjectServerWorld).allocateShipId(level.dimensionId) + val newShipId = (level.shipObjectWorld as ServerShipWorldCore).allocateShipId(level.dimensionId) val newPhysicsEntityData = oldPhysicsEntityData.copyPhysicsEntityDataWithNewId(newShipId) // Change the shipId to be something new setPhysicsEntityData(newPhysicsEntityData) @@ -198,7 +197,7 @@ open class VSPhysicsEntity(type: EntityType, level: Level) : En if (physicsEntityServerCopy != null) { val newPos = Vector3d(d, e, f) val teleportData = ShipTeleportDataImpl(newPos = newPos) - (this.level.shipObjectWorld as ShipObjectServerWorld).teleportPhysicsEntity(this.physicsEntityServer!!, teleportData) + (this.level.shipObjectWorld as ServerShipWorldCore).teleportPhysicsEntity(this.physicsEntityServer!!, teleportData) } else { physicsEntityData!!.transform = ShipTransformImpl.create( Vector3d(d, e, f), 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 8a45a3a62..f7ac714cc 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 @@ -5,10 +5,10 @@ import net.minecraft.core.Registry import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType -import org.valkyrienskies.core.impl.networking.simple.sendToClient 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 @@ -98,7 +98,8 @@ object VSEntityManager { i to namedEntityHandlers[handler].toString() } .toMap() - - PacketSyncVSEntityTypes(entityTypes).sendToClient(player) + with (vsCore.simplePacketNetworking) { + PacketSyncVSEntityTypes(entityTypes).sendToClient(player) + } } } 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 fd3a1ccaf..6a5608cc3 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 @@ -7,7 +7,9 @@ import net.minecraft.client.renderer.LevelRenderer import net.minecraft.client.renderer.LevelRenderer.RenderChunkInfo import net.minecraft.client.renderer.RenderType import org.valkyrienskies.core.api.ships.ClientShip -import org.valkyrienskies.core.impl.util.events.EventEmitterImpl +import org.valkyrienskies.core.api.ships.properties.ShipId +import org.valkyrienskies.core.util.events.EventEmitterImpl +import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet object VSGameEvents { @@ -18,6 +20,8 @@ object VSGameEvents { val postRenderShip = EventEmitterImpl() val shipsStartRendering = EventEmitterImpl() + val shipSplit = EventEmitterImpl() + data class ShipStartRenderEvent( val renderer: LevelRenderer, val renderType: RenderType, @@ -35,5 +39,11 @@ object VSGameEvents { val ship: ClientShip, val chunks: ObjectList ) + + data class ShipSplitEvent( + val ship: ShipId, + val newShip: ShipId, + val blocks: DenseBlockPosSet + ) } 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 7c1efeb1b..4be65f6eb 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 @@ -6,25 +6,23 @@ import net.minecraft.server.level.ServerPlayer import org.valkyrienskies.core.api.ships.LoadedServerShip import org.valkyrienskies.core.api.ships.getAttachment import org.valkyrienskies.core.api.ships.setAttachment -import org.valkyrienskies.core.impl.networking.simple.register -import org.valkyrienskies.core.impl.networking.simple.registerClientHandler -import org.valkyrienskies.core.impl.networking.simple.registerServerHandler import org.valkyrienskies.mod.api.SeatedControllingPlayer import org.valkyrienskies.mod.common.entity.ShipMountingEntity import org.valkyrienskies.mod.common.entity.handling.VSEntityManager import org.valkyrienskies.mod.common.getShipObjectManagingPos import org.valkyrienskies.mod.common.util.MinecraftPlayer +import org.valkyrienskies.mod.common.vsCore object VSGamePackets { - fun register() { + fun register() = with(vsCore.simplePacketNetworking) { PacketPlayerDriving::class.register() PacketStopChunkUpdates::class.register() PacketRestartChunkUpdates::class.register() PacketSyncVSEntityTypes::class.register() } - fun registerHandlers() { + fun registerHandlers() = with(vsCore.simplePacketNetworking) { PacketPlayerDriving::class.registerServerHandler { driving, iPlayer -> val player = (iPlayer as MinecraftPlayer).player as ServerPlayer val seat = player.vehicle as? ShipMountingEntity 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 89b3128f8..4b4109ae1 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 @@ -13,7 +13,6 @@ import org.joml.primitives.AABBd import org.joml.primitives.AABBdc import org.valkyrienskies.core.api.ships.Ship import org.valkyrienskies.core.apigame.collision.ConvexPolygonc -import org.valkyrienskies.core.impl.collision.k.createPolygonFromAABB import org.valkyrienskies.core.util.extend import org.valkyrienskies.mod.common.getShipsIntersecting import org.valkyrienskies.mod.common.shipObjectWorld @@ -125,7 +124,7 @@ object EntityShipCollisionUtils { world.getBlockCollisions(entity, entityBoundingBoxInShipCoordinates.toMinecraft()) shipBlockCollisionStream.forEach { voxelShape: VoxelShape -> voxelShape.forAllBoxes { minX, minY, minZ, maxX, maxY, maxZ -> - val shipPolygon: ConvexPolygonc = createPolygonFromAABB( + val shipPolygon: ConvexPolygonc = vsCore.entityPolygonCollider.createPolygonFromAABB( AABBd(minX, minY, minZ, maxX, maxY, maxZ), shipTransform.shipToWorld, shipObject.id diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/LoadedMods.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/LoadedMods.kt index 6d3e0cd9c..995539262 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/LoadedMods.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/LoadedMods.kt @@ -8,6 +8,9 @@ object LoadedMods { @JvmStatic val iris by CompatInfo("net.coderbot.iris.Iris") + @JvmStatic + val weather2 by CompatInfo("weather2.Weather") + class CompatInfo(private val className: String) : ReadOnlyProperty { private var isLoaded: Boolean? = null diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt new file mode 100644 index 000000000..975b461e8 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt @@ -0,0 +1,73 @@ +package org.valkyrienskies.mod.compat + +import net.minecraft.server.level.ServerLevel +import org.joml.Vector3d +import org.valkyrienskies.core.api.ships.getAttachment +import org.valkyrienskies.mod.common.config.VSGameConfig +import org.valkyrienskies.mod.common.shipObjectWorld +import org.valkyrienskies.mod.common.util.GameTickForceApplier +import org.valkyrienskies.mod.common.util.toMinecraft +import weather2.ServerTickHandler +import weather2.weathersystem.storm.StormObject + +object Weather2Compat { + fun tick(level: ServerLevel) { + val mgr = ServerTickHandler + .getWeatherManagerFor(level.dimension()) + + val windMult = VSGameConfig.SERVER.Weather2.windMultiplier + val windMax = VSGameConfig.SERVER.Weather2.windMaxVel + val stormDampen = 1.0f - VSGameConfig.SERVER.Weather2.stormDampening + val stormRange = VSGameConfig.SERVER.Weather2.stormRange + + val vec = Vector3d() + level.shipObjectWorld.loadedShips.forEach { ship -> + val forces = ship.getAttachment()!! + + val com = ship.inertiaData.centerOfMassInShip + + ship.shipToWorld.transformPosition(com, vec) + val pos = vec.toMinecraft() + + val motion = ship.velocity.toMinecraft() + + val mass = ship.inertiaData.mass + + var forcePlusMotion = mgr.windManager.applyWindForceImpl( + pos, + motion, + mass.toFloat(), + windMult, + windMax + ) + + fun applyForcePlusMotion() { + vec.x = forcePlusMotion.x + vec.y = forcePlusMotion.y + vec.z = forcePlusMotion.z + + vec.sub(ship.velocity) + vec.mul(mass) + + forces.applyInvariantForceToPos(vec, com) + } + + applyForcePlusMotion() + + mgr.getStormsAround(pos, stormRange).forEach { + if (it is StormObject) { + runCatching { // prevent Cannot read field "listLayers" because "this.tornadoFunnelSimple" is null at weather2.weathersystem.storm.StormObject.spinObject(StormObject.java:2503) + forcePlusMotion = it.spinObject( + pos, + forcePlusMotion, + false, + stormDampen + ) + + applyForcePlusMotion() + } + } + } + } + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt index 8081551a7..64fe9da9b 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt @@ -16,14 +16,16 @@ import net.minecraft.client.gui.screens.Screen import net.minecraft.network.chat.Component import org.apache.commons.lang3.StringUtils import org.valkyrienskies.core.impl.config.SidedVSConfigClass -import org.valkyrienskies.core.impl.config.VSConfigClass import org.valkyrienskies.core.impl.util.serialization.VSJacksonUtil +import org.valkyrienskies.mod.common.vsCore import java.util.Optional object VSClothConfig { @JvmStatic - fun createConfigScreenFor(parent: Screen, vararg configClasses: VSConfigClass): Screen { + fun createConfigScreenFor(parent: Screen, vararg configClassesJ: Class<*>): Screen { + val configClasses = configClassesJ.map(vsCore::getRegisteredConfigLegacy) + return ConfigBuilder.create().apply { parentScreen = parent @@ -240,7 +242,7 @@ object VSClothConfig { val newValue = try { mapper.readTree(str) } catch (ex: JsonProcessingException) { - return@setErrorSupplier Optional.of(Component.literal(ex.message)) + return@setErrorSupplier Optional.of(Component.literal(ex.message ?: "")) } getValidationMessageComponent(newValue) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/util/McMathUtil.kt b/common/src/main/kotlin/org/valkyrienskies/mod/util/McMathUtil.kt index 507aea658..43968e4f7 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/util/McMathUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/util/McMathUtil.kt @@ -1,6 +1,8 @@ package org.valkyrienskies.mod.util import net.minecraft.world.phys.AABB +import org.joml.Vector3d +import org.joml.Vector3dc fun AABB.scale(scale: Double): AABB { val sizeX = (this.xsize * scale) / 2 @@ -15,3 +17,5 @@ fun AABB.scale(scale: Double): AABB { this.center.z + sizeZ ) } + +val DEFAULT_WORLD_GRAVITY: Vector3dc = Vector3d(0.0, -10.0, 0.0) diff --git a/common/src/main/resources/assets/valkyrienskies/lang/ko_kr.json b/common/src/main/resources/assets/valkyrienskies/lang/ko_kr.json new file mode 100644 index 000000000..d391ddadc --- /dev/null +++ b/common/src/main/resources/assets/valkyrienskies/lang/ko_kr.json @@ -0,0 +1,25 @@ +{ + "key.valkyrienskies.ship_cruise": "크루즈", + "key.valkyrienskies.ship_down": "하강", + "category.valkyrienskies.driving": "운전", + "block.valkyrienskies.test_chair": "디버그 의자", + "block.valkyrienskies.test_hinge": "디버그 힌지", + "block.valkyrienskies.test_flap": "디버그 플랩", + "block.valkyrienskies.test_wing": "디버그 날개", + "item.valkyrienskies.ship_creator": "선박 생성기", + "item.valkyrienskies.ship_creator_smaller": "소형 선박 생성기", + "item.valkyrienskies.physics_entity_creator": "물리 엔티티 생성기", + "argument.valkyrienskies.ship.no_found": "선박을 찾을 수 없음", + "argument.valkyrienskies.ship.multiple_found": "여러 선박을 찾음", + "command.valkyrienskies.delete.success": "%d척의 선박을 삭제했습니다!", + "command.valkyrienskies.set_static.success": "%d척의 선박을 is-static=%s로 설정했습니다!", + "command.valkyrienskies.teleport.success": "%d척의 선박을 %s(으)로 이동했습니다!", + "command.valkyrienskies.teleport.multiple_ship_success": "%d척의 선박을 이동했습니다!", + "command.valkyrienskies.mc_teleport.can_only_teleport_to_one_ship": "정확히 1척의 선박으로만 이동할 수 있습니다", + "command.valkyrienskies.get_ship.success": "슬러그가 %s인 선박을 찾았습니다", + "command.valkyrienskies.get_ship.fail": "선박을 찾을 수 없습니다", + "command.valkyrienskies.get_ship.only_usable_by_entities": "/vs get-ship은 엔티티에 의해서만 실행될 수 있습니다!", + "tooltip.valkyrienskies.mass": "질량", + "command.valkyrienskies.scale.success": "%d척의 선박을 크기를 조절했습니다!", + "itemGroup.valkyrienSkies": "Valkyrien Skies" +} diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/1_18_blocks.json b/common/src/main/resources/data/valkyrienskies/vs_mass/1_18_blocks.json index 023e8219b..0f5308bb4 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/1_18_blocks.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/1_18_blocks.json @@ -5,548 +5,548 @@ }, { "block": "minecraft:rooted_dirt", - "mass": 1100.0, + "mass": 110.0, "friction": 0.7 }, { "block": "minecraft:calcite", - "mass": 2700.0, + "mass": 270.0, "friction": 0.5 }, { "block": "minecraft:dripstone_block", - "mass": 2700.0, + "mass": 270.0, "friction": 0.5 }, { "block": "minecraft:pointed_dripstone", - "mass": 1900.0, + "mass": 190.0, "friction": 0.5 }, { "block": "minecraft:tuff", - "mass": 1800.0, + "mass": 180.0, "friction": 0.7 }, { "block": "minecraft:budding_amethyst", - "mass": 2650.0, + "mass": 265.0, "friction": 1.0 }, { "block": "minecraft:amethyst_block", - "mass": 2650.0, + "mass": 265.0, "friction": 1.0 }, { "block": "minecraft:small_amethyst_bud", - "mass": 100.0, + "mass": 10.0, "friction": 0.7 }, { "block": "minecraft:medium_amethyst_bud", - "mass": 300.0, + "mass": 30.0, "friction": 0.8 }, { "block": "minecraft:large_amethyst_bud", - "mass": 600.0, + "mass": 60.0, "friction": 0.9 }, { "block": "minecraft:azalea", - "mass": 120.0, + "mass": 12.0, "elasticity": 0.1 }, { "block": "minecraft:flowering_azalea", - "mass": 120.0, + "mass": 12.0, "elasticity": 0.1 }, { "block": "minecraft:hanging_roots", - "mass": 4.0 + "mass": 0.40 }, { "block": "minecraft:big_dripleaf", - "mass": 8.0, + "mass": 0.80, "friction": 0.3, "elasticity": 0.3 }, { "block": "minecraft:big_dripleaf_stem", - "mass": 4.0 + "mass": 0.40 }, { "block": "minecraft:small_dripleaf", - "mass": 3.0 + "mass": 0.30 }, { "block": "minecraft:glow_lichen", - "mass": 1.0 + "mass": 0.10 }, { "block": "minecraft:cave_vines", - "mass": 20.0 + "mass": 2.0 }, { "block": "minecraft:cave_vines_plant", - "mass": 20.0 + "mass": 2.0 }, { "block": "minecraft:spore_blossom", - "mass": 12.0 + "mass": 1.20 }, { "block": "minecraft:moss_block", - "mass": 250.0, + "mass": 25.0, "friction": 0.5, "elasticity": 0.05 }, { "block": "minecraft:moss_carpet", - "mass": 15.0, + "mass": 1.5, "friction": 0.5 }, { "block": "minecraft:lightning_rod", - "mass": 1800.0, + "mass": 180.0, "friction": 0.2 }, { "block": "minecraft:copper_block", - "mass": 8960.0, + "mass": 900.0, "friction": 0.2 }, { "block": "minecraft:exposed_copper", - "mass": 8960.0, + "mass": 900.0, "friction": 0.25 }, { "block": "minecraft:weathered_copper", - "mass": 8960.0, + "mass": 900.0, "friction": 0.3 }, { "block": "minecraft:oxidized_copper", - "mass": 8960.0, + "mass": 900.0, "friction": 0.35 }, { "block": "minecraft:waxed_copper_block", - "mass": 8960.0, + "mass": 900.0, "friction": 0.15 }, { "block": "minecraft:waxed_exposed_copper", - "mass": 8960.0, + "mass": 900.0, "friction": 0.2 }, { "block": "minecraft:waxed_weathered_copper", - "mass": 8960.0, + "mass": 900.0, "friction": 0.25 }, { "block": "minecraft:waxed_oxidized_copper", - "mass": 8960.0, + "mass": 900.0, "friction": 0.3 }, { "block": "minecraft:cut_copper", - "mass": 2240.0, + "mass": 225.0, "friction": 0.2 }, { "block": "minecraft:exposed_cut_copper", - "mass": 2240.0, + "mass": 225.0, "friction": 0.25 }, { "block": "minecraft:weathered_cut_copper", - "mass": 2240.0, + "mass": 225.0, "friction": 0.3 }, { "block": "minecraft:oxidized_cut_copper", - "mass": 2240.0, + "mass": 225.0, "friction": 0.35 }, { "block": "minecraft:waxed_cut_copper", - "mass": 2240.0, + "mass": 225.0, "friction": 0.15 }, { "block": "minecraft:waxed_exposed_cut_copper", - "mass": 2240.0, + "mass": 225.0, "friction": 0.2 }, { "block": "minecraft:waxed_weathered_cut_copper", - "mass": 2240.0, + "mass": 225.0, "friction": 0.25 }, { "block": "minecraft:waxed_oxidized_cut_copper", - "mass": 2240.0, + "mass": 225.0, "friction": 0.3 }, { "block": "minecraft:cut_copper_slab", - "mass": 1120.0, + "mass": 112.5, "friction": 0.2 }, { "block": "minecraft:exposed_cut_copper_slab", - "mass": 1120.0, + "mass": 112.5, "friction": 0.25 }, { "block": "minecraft:weathered_cut_copper_slab", - "mass": 1120.0, + "mass": 112.5, "friction": 0.3 }, { "block": "minecraft:oxidized_cut_copper_slab", - "mass": 1120.0, + "mass": 112.5, "friction": 0.35 }, { "block": "minecraft:waxed_cut_copper_slab", - "mass": 1120.0, + "mass": 112.5, "friction": 0.15 }, { "block": "minecraft:waxed_exposed_cut_copper_slab", - "mass": 1120.0, + "mass": 112.5, "friction": 0.2 }, { "block": "minecraft:waxed_weathered_cut_copper_slab", - "mass": 1120.0, + "mass": 112.5, "friction": 0.25 }, { "block": "minecraft:waxed_oxidized_cut_copper_slab", - "mass": 1120.0, + "mass": 112.5, "friction": 0.3 }, { "block": "minecraft:cut_copper_stairs", - "mass": 1680.0, + "mass": 168.75, "friction": 0.2 }, { "block": "minecraft:exposed_cut_copper_stairs", - "mass": 1680.0, + "mass": 168.75, "friction": 0.25 }, { "block": "minecraft:weathered_cut_copper_stairs", - "mass": 1680.0, + "mass": 168.75, "friction": 0.3 }, { "block": "minecraft:oxidized_cut_copper_stairs", - "mass": 1680.0, + "mass": 168.75, "friction": 0.35 }, { "block": "minecraft:waxed_cut_copper_stairs", - "mass": 1680.0, + "mass": 168.75, "friction": 0.15 }, { "block": "minecraft:waxed_exposed_cut_copper_stairs", - "mass": 1680.0, + "mass": 168.75, "friction": 0.2 }, { "block": "minecraft:waxed_weathered_cut_copper_stairs", - "mass": 1680.0, + "mass": 168.75, "friction": 0.25 }, { "block": "minecraft:waxed_oxidized_cut_copper_stairs", - "mass": 1680.0, + "mass": 168.75, "friction": 0.3 }, { "block": "minecraft:raw_copper_block", - "mass": 8960.0, + "mass": 900.0, "friction": 0.8 }, { "block": "minecraft:raw_iron_block", - "mass": 7840.0, + "mass": 785.0, "friction": 0.8 }, { "block": "minecraft:raw_gold_block", - "mass": 19280.0, + "mass": 1930.0, "friction": 0.8 }, { "block": "minecraft:candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:white_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:orange_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:magenta_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:light_blue_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:yellow_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:lime_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:pink_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:gray_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:light_gray_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:cyan_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:purple_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:blue_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:brown_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:green_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:red_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:black_candle", - "mass": 2.0, + "mass": 0.2, "friction": 0.1 }, { "block": "minecraft:deepslate", - "mass": 2900.0, + "mass": 290.0, "friction": 0.5 }, { "block": "minecraft:infested_deepslate", - "mass": 2900.0, + "mass": 290.0, "friction": 0.5 }, { "block": "minecraft:cobbled_deepslate", - "mass": 2720.0, + "mass": 275.0, "friction": 0.8 }, { "block": "minecraft:chiseled_deepslate", - "mass": 2720.0, + "mass": 275.0, "friction": 0.6 }, { "block": "minecraft:polished_deepslate", - "mass": 2720.0, + "mass": 275.0, "friction": 0.35 }, { "block": "minecraft:deepslate_bricks", - "mass": 2720.0, + "mass": 275.0, "friction": 0.5 }, { "block": "minecraft:cracked_deepslate_bricks", - "mass": 2720.0, + "mass": 275.0, "friction": 0.6 }, { "block": "minecraft:deepslate_tiles", - "mass": 2720.0, + "mass": 275.0, "friction": 0.6 }, { "block": "minecraft:cracked_deepslate_tiles", - "mass": 2720.0, + "mass": 275.0, "friction": 0.7 }, { "block": "minecraft:cobbled_deepslate_slab", - "mass": 1360.0, + "mass": 137.5, "friction": 0.8 }, { "block": "minecraft:polished_deepslate_slab", - "mass": 1360.0, + "mass": 137.5, "friction": 0.35 }, { "block": "minecraft:deepslate_brick_slab", - "mass": 1360.0, + "mass": 137.5, "friction": 0.5 }, { "block": "minecraft:deepslate_tile_slab", - "mass": 1360.0, + "mass": 137.5, "friction": 0.6 }, { "block": "minecraft:cobbled_deepslate_stairs", - "mass": 2040.0, + "mass": 206.25, "friction": 0.8 }, { "block": "minecraft:polished_deepslate_stairs", - "mass": 2040.0, + "mass": 206.25, "friction": 0.35 }, { "block": "minecraft:deepslate_brick_stairs", - "mass": 2040.0, + "mass": 206.25, "friction": 0.5 }, { "block": "minecraft:deepslate_tile_stairs", - "mass": 2040.0, + "mass": 206.25, "friction": 0.6 }, { "block": "minecraft:cobbled_deepslate_wall", - "mass": 1360.0, + "mass": 135.0, "friction": 0.8 }, { "block": "minecraft:polished_deepslate_wall", - "mass": 1360.0, + "mass": 135.0, "friction": 0.45 }, { "block": "minecraft:deepslate_brick_wall", - "mass": 1360.0, + "mass": 135.0, "friction": 0.5 }, { "block": "minecraft:deepslate_tile_wall", - "mass": 1360.0, + "mass": 135.0, "friction": 0.6 }, { "block": "minecraft:copper_ore", - "mass": 3260.0, + "mass": 325.0, "friction": 0.6 }, { "block": "minecraft:deepslate_copper_ore", - "mass": 3510.0, + "mass": 355.0, "friction": 0.5 }, { "block": "minecraft:deepslate_coal_ore", - "mass": 2715.0, + "mass": 271.5, "friction": 0.5 }, { "block": "minecraft:deepslate_lapis_ore", - "mass": 2950.0, + "mass": 295.0, "friction": 0.5 }, { "block": "minecraft:deepslate_iron_ore", - "mass": 3430.0, + "mass": 345.0, "friction": 0.5 }, { "block": "minecraft:deepslate_gold_ore", - "mass": 4700.0, + "mass": 470.0, "friction": 0.5 }, { "block": "minecraft:deepslate_redstone_ore", - "mass": 2225.0, + "mass": 222.5, "friction": 0.5 }, { "block": "minecraft:deepslate_diamond_ore", - "mass": 2950.0, + "mass": 295.0, "friction": 0.5 }, { "block": "minecraft:deepslate_emerald_ore", - "mass": 2855.0, + "mass": 285.5, "friction": 0.5 }, { "block": "minecraft:powder_snow", - "mass": 120.0, + "mass": 12.0, "friction": 0.3 }, { "block": "minecraft:sculk_sensor", - "mass": 200.0, + "mass": 25.0, "friction": 0.2, "elasticity": 0.3 }, { "block": "minecraft:smooth_basalt", - "mass": 3010.0, + "mass": 300.0, "friction": 0.35 }, { "block": "minecraft:tinted_glass", - "mass": 2200.0, + "mass": 220.0, "friction": 0.2 }, { "tag": "minecraft:candle_cakes", - "mass": 702.0, + "mass": 70.0, "friction": 0.1 } ] diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/1_19_blocks b/common/src/main/resources/data/valkyrienskies/vs_mass/1_19_blocks index cee29a304..987e68011 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/1_19_blocks +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/1_19_blocks @@ -1,19 +1,19 @@ [ { "block": "minecraft:pearlescent_froglight", - "mass": 3200.0, + "mass": 320.0, "friction": 0.07, "elasticity": 0.8 }, { "block": "minecraft:verdant_froglight", - "mass": 3200.0, + "mass": 320.0, "friction": 0.07, "elasticity": 0.8 }, { "block": "minecraft:ochre_froglight", - "mass": 3200.0, + "mass": 320.0, "friction": 0.07, "elasticity": 0.8 }, @@ -24,37 +24,37 @@ }, { "block": "minecraft:mangrove_log", - "mass": 900.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:stripped_mangrove_log", - "mass": 900.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:mangrove_wood", - "mass": 900.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:stripped_mangrove_wood", - "mass": 900.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:mangrove_planks", - "mass": 600.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:mangrove_slab", - "mass": 300.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:mangrove_stairs", - "mass": 450.0, + "mass": 75.0, "friction": 0.5 }, { @@ -68,64 +68,64 @@ }, { "block": "minecraft:muddy_mangrove_roots", - "mass": 1800.0, + "mass": 150.0, "friction": 0.8 }, { "block": "minecraft:mud", - "mass": 1800.0, + "mass": 100.0, "friction": 0.9 }, { "block": "minecraft:packed_mud", - "mass": 1450.0, + "mass": 150.0, "friction": 0.7 }, { "block": "minecraft:mud_bricks", - "mass": 1450.0, + "mass": 150.0, "friction": 0.7 }, { "block": "minecraft:mud_brick_wall", - "mass": 725.0, + "mass": 125.0, "friction": 0.7 }, { "block": "minecraft:mud_brick_slab", - "mass": 725.0, + "mass": 75.0, "friction": 0.7 }, { "block": "minecraft:mud_brick_stairs", - "mass": 1035.0, + "mass": 112.5, "friction": 0.7 }, { "block": "minecraft:reinforced_deepslate", - "mass": 3400.0, + "mass": 400.0, "friction": 0.7 }, { "block": "minecraft:sculk", - "mass": 400.0, + "mass": 25.0, "friction": 0.2, "elasticity": 0.3 }, { "block": "minecraft:sculk_catalyst", - "mass": 600.0, + "mass": 50.0, "friction": 0.2 }, { "block": "minecraft:sculk_shrieker", - "mass": 200.0, + "mass": 50.0, "friction": 0.2, "elasticity": 0.3 }, { "block": "minecraft:sculk_vein", - "mass": 8.0, + "mass": 5.0, "friction": 0.2, "elasticity": 0.03 } diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/1_20_blocks b/common/src/main/resources/data/valkyrienskies/vs_mass/1_20_blocks index 4a443127c..44b4d056f 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/1_20_blocks +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/1_20_blocks @@ -6,120 +6,120 @@ }, { "block": "minecraft:bamboo_block", - "mass": 150.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:stripped_bamboo_block", - "mass": 150.0, + "mass": 200.0, "friction": 0.4 }, { "block": "minecraft:bamboo_planks", - "mass": 100.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:bamboo_mosaic", - "mass": 100.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:bamboo_mosaic_slab", - "mass": 50.0, + "mass": 25.0, "friction": 0.5 }, { "block": "minecraft:bamboo_slab", - "mass": 50.0, + "mass": 25.0, "friction": 0.5 }, { "block": "minecraft:bamboo_stairs", - "mass": 75.0, + "mass": 37.5, "friction": 0.5 }, { "block": "minecraft:bamboo_mosaic_stairs", - "mass": 75.0, + "mass": 37.5, "friction": 0.5 }, { "block": "minecraft:calibrated_sculk_sensor", - "mass": 230.0, + "mass": 25.0, "friction": 0.9, "elasticity": 0.3 }, { "block": "minecraft:cherry_wood", - "mass": 640.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:cherry_log", - "mass": 640.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:stripped_cherry_wood", - "mass": 640.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:stripped_cherry_log", - "mass": 640.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:cherry_planks", - "mass": 425.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:cherry_slab", - "mass": 210.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:cherry_stairs", - "mass": 315.0, + "mass": 75.0, "friction": 0.5 }, { "block": "minecraft:chiseled_bookshelf", - "mass": 650.0, + "mass": 150.0, "friction": 0.5 }, { "block": "minecraft:decorated_pot", - "mass": 250.0, + "mass": 25.0, "friction": 0.35 }, { "block": "minecraft:piglin_head", - "mass": 5.0 + "mass": 0.5 }, { "block": "minecraft:piglin_wall_head", - "mass": 5.0 + "mass": 0.5 }, { "block": "minecraft:pink_petals", - "mass": 1.0 + "mass": 0.1 }, { "block": "minecraft:sniffer_egg", - "mass": 980.0, + "mass": 95.0, "friction": 0.1 }, { "block": "minecraft:suspicious_sand", - "mass": 1565.0, + "mass": 150.0, "friction": 0.4 }, { "block": "minecraft:suspicious_gravel", - "mass": 1685.0, + "mass": 150.0, "friction": 0.7 }, { diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/computercraft.json b/common/src/main/resources/data/valkyrienskies/vs_mass/computercraft.json index 6a794f7b3..673dc0955 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/computercraft.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/computercraft.json @@ -1,50 +1,50 @@ [ { "block": "computercraft:computer_advanced", - "mass": 15395.0 + "mass": 1535.0 }, { "block": "computercraft:turtle_advanced", - "mass": 15795.0 + "mass": 1575.0 }, { "block": "computercraft:monitor_advanced", - "mass": 15245.0 + "mass": 1525.0 }, { "block": "computercraft:wireless_modem_advanced", - "mass": 15250.0 + "mass": 1525.0 }, { "block": "computercraft:computer_normal", - "mass": 3150 + "mass": 315.0 }, { "block": "computercraft:turtle_normal", - "mass": 3600.0 + "mass": 360.0 }, { "block": "computercraft:monitor_normal", - "mass": 3200.0 + "mass": 320.0 }, { "block": "computercraft:wired_modem_full", - "mass": 3300.0 + "mass": 330.0 }, { "block": "computercraft:cable", - "mass": 160.0 + "mass": 15.0 }, { "block": "computercraft:printer", - "mass": 3150.0 + "mass": 315.0 }, { "block": "computercraft:speaker", - "mass": 4350.0 + "mass": 435.0 }, { "block": "computercraft:disk_drive", - "mass": 3300.0 + "mass": 330.0 } ] diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/crafting_stations.json b/common/src/main/resources/data/valkyrienskies/vs_mass/crafting_stations.json index a3c014bf8..5d17a2f47 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/crafting_stations.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/crafting_stations.json @@ -1,83 +1,83 @@ [ { "block": "minecraft:crafting_table", - "mass": 800.0, + "mass": 80.0, "friction": 0.6 }, { "block": "minecraft:furnace", - "mass": 2800.0, + "mass": 280.0, "friction": 0.5 }, { "block": "minecraft:blast_furnace", - "mass": 3000.0, + "mass": 300.0, "friction": 0.5 }, { "block": "minecraft:smoker", - "mass": 2800.0, + "mass": 280.0, "friction": 0.5 }, { "block": "minecraft:stonecutter", - "mass": 2000.0, + "mass": 200.0, "friction": 0.5 }, { "tag": "minecraft:campfires", - "mass": 600.0 + "mass": 60.0 }, { "block": "minecraft:enchanting_table", - "mass": 1600.0 + "mass": 160.0 }, { "tag": "minecraft:anvil", - "mass": 7000.0, + "mass": 700.0, "friction": 0.2 }, { "block": "minecraft:cauldron", - "mass": 5400.0, + "mass": 540.0, "friction": 0.2 }, { "block": "minecraft:water_cauldron", - "mass": 5900.0, + "mass": 590.0, "friction": 0.2 }, { "block": "minecraft:brewing_stand", - "mass": 800.0 + "mass": 80.0 }, { "block": "minecraft:grindstone", - "mass": 1500.0, + "mass": 150.0, "friction": 0.2 }, { "block": "minecraft:fletching_table", - "mass": 900.0, + "mass": 90.0, "friction": 0.6 }, { "block": "minecraft:smithing_table", - "mass": 1800.0, + "mass": 180.0, "friction": 0.6 }, { "block": "minecraft:loom", - "mass": 400.0 + "mass": 40.0 }, { "block": "minecraft:cartography_table", - "mass": 800.0, + "mass": 80.0, "friction": 0.5 }, { "block": "minecraft:composter", - "mass": 700.0, + "mass": 70.0, "friction": 0.5 } ] diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/ground.json b/common/src/main/resources/data/valkyrienskies/vs_mass/ground.json index 139a148a2..5212bc2f1 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/ground.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/ground.json @@ -1,237 +1,237 @@ [ { "block": "minecraft:dirt", - "mass": 1220.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:coarse_dirt", - "mass": 1500.0, + "mass": 150.0, "friction": 0.7 }, { "block": "minecraft:dirt_path", - "mass": 1200.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:farmland", - "mass": 1220.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:grass", - "mass": 1300.0, + "mass": 125.0, "friction": 0.5 }, { "block": "minecraft:clay", - "mass": 1700.0, + "mass": 150.0, "friction": 0.4 }, { "block": "minecraft:gravel", - "mass": 1680.0, + "mass": 150.0, "friction": 0.7 }, { "block": "minecraft:mycelium", - "mass": 1300.0, + "mass": 125.0, "friction": 0.5 }, { "tag": "minecraft:nylium", - "mass": 1180.0, + "mass": 125.0, "friction": 0.5 }, { "block": "minecraft:podzol", - "mass": 1300.0, + "mass": 125.0, "friction": 0.6 }, { "tag": "minecraft:sand", - "mass": 1560.0, + "mass": 150.0, "friction": 0.4 }, { "block": "minecraft:soul_sand", - "mass": 1000.0, + "mass": 100.0, "friction": 0.9 }, { "block": "minecraft:soul_soil", - "mass": 900.0, + "mass": 100.0, "friction": 0.8 }, { "block": "minecraft:andesite", - "mass": 2770.0, + "mass": 275.0, "friction": 0.6 }, { "block": "minecraft:basalt", - "mass": 3010.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:smooth_basalt", - "mass": 3010.0, + "mass": 300.0, "friction": 0.5 }, { "block": "minecraft:blackstone", - "mass": 3400.0, + "mass": 350.0, "friction": 0.7 }, { "block": "minecraft:cobblestone", - "mass": 2480.0, + "mass": 250.0, "friction": 0.8 }, { "block": "minecraft:mossy_cobblestone", - "mass": 2600.0, + "mass": 250.0, "friction": 0.8 }, { "block": "minecraft:diorite", - "mass": 2900.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:end_stone", - "mass": 2800.0, + "mass": 100.0, "friction": 0.6 }, { "block": "minecraft:glowstone", - "mass": 1000.0, + "mass": 100.0, "friction": 0.7 }, { "block": "minecraft:granite", - "mass": 2700.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:magma_block", - "mass": 3200.0, + "mass": 300.0, "friction": 0.4 }, { "block": "minecraft:netherrack", - "mass": 1100.0, + "mass": 100.0, "friction": 0.4 }, { "block": "minecraft:obsidian", - "mass": 2350.0, + "mass": 500.0, "friction": 0.8 }, { "block": "minecraft:crying_obsidian", - "mass": 2350.0, + "mass": 500.0, "friction": 0.8 }, { "block": "minecraft:sandstone", - "mass": 2300.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:red_sandstone", - "mass": 2300.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:stone", - "mass": 2600.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:white_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:orange_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:magenta_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:light_blue_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:yellow_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:lime_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:pink_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:gray_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:light_gray_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:cyan_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:purple_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:blue_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:brown_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:green_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:red_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 }, { "block": "minecraft:black_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.6 } ] diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/masonry.json b/common/src/main/resources/data/valkyrienskies/vs_mass/masonry.json index a2a151ed6..5ed1d1585 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/masonry.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/masonry.json @@ -1,837 +1,837 @@ [ { "block": "minecraft:stone_slab", - "mass": 1300.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:cut_red_sandstone", - "mass": 2300.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:cut_sandstone", - "mass": 2300.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:smooth_stone_slab", - "mass": 1300.0, + "mass": 125.0, "friction": 0.4 }, { "block": "minecraft:granite_slab", - "mass": 1350.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:polished_granite_slab", - "mass": 1350.0, + "mass": 125.0, "friction": 0.4 }, { "block": "minecraft:diorite_slab", - "mass": 1450.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:polished_diorite_slab", - "mass": 1450.0, + "mass": 125.0, "friction": 0.4 }, { "block": "minecraft:andesite_slab", - "mass": 1385.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:polished_andesite_slab", - "mass": 1385.0, + "mass": 125.0, "friction": 0.4 }, { "block": "minecraft:cobblestone_slab", - "mass": 1240.0, + "mass": 125.0, "friction": 0.8 }, { "block": "minecraft:mossy_cobblestone_slab", - "mass": 1300.0, + "mass": 125.0, "friction": 0.8 }, { "block": "minecraft:stone_brick_slab", - "mass": 1300.0, + "mass": 125.0, "friction": 0.5 }, { "block": "minecraft:mossy_stone_brick_slab", - "mass": 1300.0, + "mass": 125.0, "friction": 0.3 }, { "block": "minecraft:brick_slab", - "mass": 950.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:end_stone_brick_slab", - "mass": 1400.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:nether_brick_slab", - "mass": 950.0, + "mass": 50.0, "friction": 0.6 }, { "block": "minecraft:red_nether_brick_slab", - "mass": 950.0, + "mass": 50.0, "friction": 0.6 }, { "block": "minecraft:sandstone_slab", - "mass": 1150.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:cut_sandstone_slab", - "mass": 1150.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:smooth_sandstone_slab", - "mass": 1150.0, + "mass": 125.0, "friction": 0.5 }, { "block": "minecraft:red_sandstone_slab", - "mass": 1150.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:cut_red_sandstone_slab", - "mass": 1150.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:smooth_red_sandstone_slab", - "mass": 1150.0, + "mass": 125.0, "friction": 0.5 }, { "block": "minecraft:quartz_slab", - "mass": 1160.0, + "mass": 150.0, "friction": 0.5 }, { "block": "minecraft:smooth_quartz_slab", - "mass": 1160.0, + "mass": 150.0, "friction": 0.3 }, { "block": "minecraft:purpur_slab", - "mass": 60.0, + "mass": 50.0, "friction": 0.6 }, { "block": "minecraft:prismarine_slab", - "mass": 1000.0, + "mass": 150.0, "friction": 0.8 }, { "block": "minecraft:prismarine_brick_slab", - "mass": 1600.0, + "mass": 150.0, "friction": 0.5 }, { "block": "minecraft:dark_prismarine_slab", - "mass": 1600.0, + "mass": 150.0, "friction": 0.6 }, { "block": "minecraft:blackstone_slab", - "mass": 1700.0, + "mass": 175.0, "friction": 0.7 }, { "block": "minecraft:polished_blackstone_slab", - "mass": 1700.0, + "mass": 175.0, "friction": 0.5 }, { "block": "minecraft:polished_blackstone_brick_slab", - "mass": 1700.0, + "mass": 175.0, "friction": 0.5 }, { "block": "minecraft:stone_stairs", - "mass": 1950.0, + "mass": 187.5, "friction": 0.6 }, { "block": "minecraft:granite_stairs", - "mass": 2025.0, + "mass": 187.5, "friction": 0.6 }, { "block": "minecraft:polished_granite_stairs", - "mass": 2025.0, + "mass": 187.5, "friction": 0.5 }, { "block": "minecraft:diorite_stairs", - "mass": 2175.0, + "mass": 187.5, "friction": 0.6 }, { "block": "minecraft:polished_diorite_stairs", - "mass": 2175.0, + "mass": 187.5, "friction": 0.5 }, { "block": "minecraft:andesite_stairs", - "mass": 2080.0, + "mass": 187.5, "friction": 0.6 }, { "block": "minecraft:polished_andesite_stairs", - "mass": 2080.0, + "mass": 187.5, "friction": 0.5 }, { "block": "minecraft:cobblestone_stairs", - "mass": 1860.0, + "mass": 187.5, "friction": 0.8 }, { "block": "minecraft:mossy_cobblestone_stairs", - "mass": 1950.0, + "mass": 187.5, "friction": 0.8 }, { "block": "minecraft:stone_brick_stairs", - "mass": 1950.0, + "mass": 187.5, "friction": 0.5 }, { "block": "minecraft:mossy_stone_brick_stairs", - "mass": 1950.0, + "mass": 187.5, "friction": 0.3 }, { "block": "minecraft:brick_stairs", - "mass": 1425.0, + "mass": 187.5, "friction": 0.6 }, { "block": "minecraft:end_stone_brick_stairs", - "mass": 2100.0, + "mass": 75.0, "friction": 0.5 }, { "block": "minecraft:nether_brick_stairs", - "mass": 1425.0, + "mass": 75.0, "friction": 0.6 }, { "block": "minecraft:red_nether_brick_stairs", - "mass": 1425.0, + "mass": 75.0, "friction": 0.6 }, { "block": "minecraft:sandstone_stairs", - "mass": 1725.0, + "mass": 187.5, "friction": 0.6 }, { "block": "minecraft:smooth_sandstone_stairs", - "mass": 1725.0, + "mass": 187.5, "friction": 0.5 }, { "block": "minecraft:red_sandstone_stairs", - "mass": 1725.0, + "mass": 187.5, "friction": 0.6 }, { "block": "minecraft:smooth_red_sandstone_stairs", - "mass": 1725.0, + "mass": 187.5, "friction": 0.5 }, { "block": "minecraft:quartz_stairs", - "mass": 1740.0, + "mass": 225.0, "friction": 0.5 }, { "block": "minecraft:smooth_quartz_stairs", - "mass": 1740.0, + "mass": 225.0, "friction": 0.3 }, { "block": "minecraft:purpur_stairs", - "mass": 90.0, + "mass": 75.0, "friction": 0.6 }, { "block": "minecraft:prismarine_stairs", - "mass": 1500.0, + "mass": 225.0, "friction": 0.8 }, { "block": "minecraft:prismarine_brick_stairs", - "mass": 2400.0, + "mass": 225.0, "friction": 0.5 }, { "block": "minecraft:dark_prismarine_stairs", - "mass": 2400.0, + "mass": 225.0, "friction": 0.6 }, { "block": "minecraft:blackstone_stairs", - "mass": 2550.0, + "mass": 262.5, "friction": 0.7 }, { "block": "minecraft:polished_blackstone_stairs", - "mass": 2550.0, + "mass": 262.5, "friction": 0.5 }, { "block": "minecraft:polished_blackstone_brick_stairs", - "mass": 2550.0, + "mass": 262.5, "friction": 0.4 }, { "block": "minecraft:granite_wall", - "mass": 1350.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:diorite_wall", - "mass": 1450.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:andesite_wall", - "mass": 1385.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:cobblestone_wall", - "mass": 1240.0, + "mass": 125.0, "friction": 0.8 }, { "block": "minecraft:mossy_cobblestone_wall", - "mass": 1300.0, + "mass": 125.0, "friction": 0.8 }, { "block": "minecraft:stone_brick_wall", - "mass": 1300.0, + "mass": 125.0, "friction": 0.5 }, { "block": "minecraft:mossy_stone_brick_wall", - "mass": 1300.0, + "mass": 125.0, "friction": 0.3 }, { "block": "minecraft:brick_wall", - "mass": 950.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:end_stone_brick_wall", - "mass": 1400.0, + "mass": 75.0, "friction": 0.5 }, { "block": "minecraft:nether_brick_wall", - "mass": 950.0, + "mass": 75.0, "friction": 0.6 }, { "block": "minecraft:red_nether_brick_wall", - "mass": 950.0, + "mass": 75.0, "friction": 0.6 }, { "block": "minecraft:sandstone_wall", - "mass": 1150.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:red_sandstone_wall", - "mass": 1150.0, + "mass": 125.0, "friction": 0.6 }, { "block": "minecraft:prismarine_wall", - "mass": 1000.0, + "mass": 100.0, "friction": 0.8 }, { "block": "minecraft:blackstone_wall", - "mass": 1700.0, + "mass": 125.0, "friction": 0.7 }, { "block": "minecraft:polished_blackstone_wall", - "mass": 1700.0, + "mass": 125.0, "friction": 0.5 }, { "block": "minecraft:polished_blackstone_brick_wall", - "mass": 1700.0, + "mass": 125.0, "friction": 0.4 }, { "block": "minecraft:polished_granite", - "mass": 2700.0, + "mass": 250.0, "friction": 0.4 }, { "block": "minecraft:polished_diorite", - "mass": 2900.0, + "mass": 250.0, "friction": 0.4 }, { "block": "minecraft:polished_andesite", - "mass": 2770.0, + "mass": 250.0, "friction": 0.4 }, { "block": "minecraft:polished_basalt", - "mass": 3010.0, + "mass": 250.0, "friction": 0.4 }, { "block": "minecraft:polished_blackstone", - "mass": 3400.0, + "mass": 250.0, "friction": 0.5 }, { "block": "minecraft:polished_blackstone_bricks", - "mass": 3400.0, + "mass": 250.0, "friction": 0.4 }, { "block": "minecraft:smooth_quartz", - "mass": 2320.0, + "mass": 300.0, "friction": 0.3 }, { "block": "minecraft:smooth_sandstone", - "mass": 2300.0, + "mass": 250.0, "friction": 0.5 }, { "block": "minecraft:smooth_red_sandstone", - "mass": 2300.0, + "mass": 250.0, "friction": 0.4 }, { "block": "minecraft:smooth_stone", - "mass": 2600.0, + "mass": 250.0, "friction": 0.4 }, { "block": "minecraft:cracked_stone_bricks", - "mass": 2600.0, + "mass": 250.0, "friction": 0.7 }, { "block": "minecraft:cracked_nether_bricks", - "mass": 1900.0, + "mass": 100.0, "friction": 0.7 }, { "block": "minecraft:cracked_polished_blackstone_bricks", - "mass": 3400.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:chiseled_sandstone", - "mass": 2300.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:chiseled_stone_bricks", - "mass": 2600.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:chiseled_nether_bricks", - "mass": 1900.0, + "mass": 100.0, "friction": 0.6 }, { "block": "minecraft:chiseled_quartz_block", - "mass": 2320.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:chiseled_red_sandstone", - "mass": 2300.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:chiseled_polished_blackstone", - "mass": 3400.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:quartz_pillar", - "mass": 2320.0, + "mass": 300.0, "friction": 0.5 }, { "block": "minecraft:purpur_pillar", - "mass": 120.0, + "mass": 100.0, "friction": 0.6 }, { "block": "minecraft:purpur_block", - "mass": 120.0, + "mass": 100.0, "friction": 0.6 }, { "block": "minecraft:quartz_block", - "mass": 2320.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:mossy_stone_bricks", - "mass": 2600.0, + "mass": 250.0, "friction": 0.3 }, { "block": "minecraft:gilded_blackstone", - "mass": 3800.0, + "mass": 300.0, "friction": 0.7 }, { "block": "minecraft:nether_brick_fence", - "mass": 380.0, + "mass": 50.0, "friction": 0.6 }, { "block": "minecraft:bricks", - "mass": 1900.0, + "mass": 250.0, "friction": 0.6 }, { "block": "minecraft:stone_bricks", - "mass": 2600.0, + "mass": 250.0, "friction": 0.5 }, { "block": "minecraft:nether_bricks", - "mass": 1900.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:red_nether_bricks", - "mass": 1900.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:end_stone_bricks", - "mass": 2800.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:quartz_bricks", - "mass": 2320.0, + "mass": 300.0, "friction": 0.5 }, { "block": "minecraft:prismarine", - "mass": 2000.0, + "mass": 300.0, "friction": 0.8 }, { "block": "minecraft:prismarine_bricks", - "mass": 3200.0, + "mass": 300.0, "friction": 0.5 }, { "block": "minecraft:dark_prismarine", - "mass": 3200.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:white_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:orange_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:magenta_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:light_blue_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:yellow_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:lime_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:pink_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:gray_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:light_gray_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:cyan_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:purple_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:blue_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:brown_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:green_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:red_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:black_glazed_terracotta", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:white_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:orange_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:magenta_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:light_blue_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:yellow_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:lime_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:pink_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:gray_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:light_gray_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:cyan_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:purple_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:blue_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:brown_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:green_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:red_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:black_concrete_powder", - "mass": 2360.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:white_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:orange_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:magenta_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:light_blue_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:yellow_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:lime_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:pink_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:gray_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:light_gray_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:cyan_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:purple_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:blue_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:brown_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:green_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:red_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:black_concrete", - "mass": 2360.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:infested_stone", - "mass": 2600.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:infested_cobblestone", - "mass": 2600.0, + "mass": 300.0, "friction": 0.8 }, { "block": "minecraft:infested_stone_bricks", - "mass": 2600.0, + "mass": 300.0, "friction": 0.5 }, { "block": "minecraft:infested_cracked_stone_bricks", - "mass": 2600.0, + "mass": 300.0, "friction": 0.6 }, { "block": "minecraft:infested_mossy_stone_bricks", - "mass": 2600.0, + "mass": 300.0, "friction": 0.3 }, { "block": "minecraft:infested_chiseled_stone_bricks", - "mass": 2600.0, + "mass": 300.0, "friction": 0.6 } ] diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json b/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json index c964b8257..7c91c380f 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json @@ -34,92 +34,92 @@ }, { "block": "minecraft:gold_block", - "mass": 19280.0, + "mass": 1930.0, "friction": 0.2 }, { "block": "minecraft:iron_block", - "mass": 7840.0, + "mass": 785.0, "friction": 0.2 }, { "block": "minecraft:diamond_block", - "mass": 3520.0, + "mass": 300.0, "friction": 0.1 }, { "block": "minecraft:emerald_block", - "mass": 2670.0, + "mass": 250.0, "friction": 0.1 }, { "block": "minecraft:coal_block", - "mass": 1400.0, + "mass": 150.0, "friction": 0.7 }, { "block": "minecraft:netherite_block", - "mass": 89680.0, + "mass": 8968.0, "friction": 0.2 }, { "block": "minecraft:lapis_block", - "mass": 2750.0, + "mass": 275.0, "friction": 0.5 }, { "block": "minecraft:coal_ore", - "mass": 2465.0, + "mass": 245.0, "friction": 0.6 }, { "block": "minecraft:diamond_ore", - "mass": 2700.0, + "mass": 270.0, "friction": 0.6 }, { "block": "minecraft:emerald_ore", - "mass": 2605.0, + "mass": 260.0, "friction": 0.6 }, { "block": "minecraft:ancient_debris", - "mass": 3140.0, + "mass": 315.0, "friction": 0.8 }, { "block": "minecraft:iron_ore", - "mass": 3180.0, + "mass": 315.0, "friction": 0.6 }, { "block": "minecraft:gold_ore", - "mass": 4450.0, + "mass": 445.0, "friction": 0.6 }, { "block": "minecraft:lapis_ore", - "mass": 2700.0, + "mass": 270.0, "friction": 0.6 }, { "block": "minecraft:redstone_ore", - "mass": 1975.0, + "mass": 195.0, "friction": 0.6 }, { "block": "minecraft:nether_quartz_ore", - "mass": 1405.0, + "mass": 150.0, "friction": 0.4 }, { "block": "minecraft:nether_gold_ore", - "mass": 2210.0, + "mass": 225.0, "friction": 0.4 }, { "block": "minecraft:bone_block", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { @@ -129,23 +129,23 @@ }, { "block": "minecraft:hay_block", - "mass": 200.0, + "mass": 20.0, "friction": 0.6, "elasticity": 0.3 }, { "block": "minecraft:carved_pumpkin", - "mass": 100.0, + "mass": 10.0, "friction": 0.3 }, { "block": "minecraft:jack_o_lantern", - "mass": 105.0, + "mass": 10.0, "friction": 0.3 }, { "block": "minecraft:beacon", - "mass": 930.0, + "mass": 400.0, "friction": 0.2 }, { @@ -154,39 +154,39 @@ }, { "block": "minecraft:sponge", - "mass": 170.0, + "mass": 175.0, "friction": 0.6, "elasticity": 0.2 }, { "block": "minecraft:wet_sponge", - "mass": 1050.0, + "mass": 200.0, "friction": 0.3, "elasticity": 0.6 }, { "block": "minecraft:torch", - "mass": 5.0 + "mass": 0.5 }, { "block": "minecraft:wall_torch", - "mass": 5.0 + "mass": 0.5 }, { "block": "minecraft:soul_torch", - "mass": 5.0 + "mass": 0.5 }, { "block": "minecraft:soul_wall_torch", - "mass": 5.0 + "mass": 0.5 }, { "block": "minecraft:lantern", - "mass": 25.0 + "mass": 2.5 }, { "block": "minecraft:soul_lantern", - "mass": 25.0 + "mass": 2.5 }, { "block": "minecraft:end_rod", @@ -195,210 +195,210 @@ }, { "block": "minecraft:sea_lantern", - "mass": 2500.0, + "mass": 250.0, "friction": 0.2 }, { "block": "minecraft:glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:white_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:orange_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:magenta_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:light_blue_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:yellow_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:lime_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:pink_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:gray_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:light_gray_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:cyan_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:purple_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:blue_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:brown_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:green_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:red_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:black_stained_glass", - "mass": 2000.0, + "mass": 200.0, "friction": 0.2 }, { "block": "minecraft:glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:white_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:orange_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:magenta_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:light_blue_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:yellow_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:lime_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:pink_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:gray_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:light_gray_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:cyan_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:purple_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:blue_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:brown_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:green_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:red_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:black_stained_glass_pane", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "tag": "minecraft:beds", - "mass": 125.0, + "mass": 25.0, "friction": 0.6, "elasticity": 0.5 }, { "tag": "minecraft:carpets", - "mass": 20.0, + "mass": 2.0, "friction": 0.6, "elasticity": 0.05 }, { "tag": "minecraft:wool", - "mass": 450.0, + "mass": 50.0, "friction": 0.6, "elasticity": 0.5 }, { "block": "minecraft:bookshelf", - "mass": 650.0, + "mass": 150.0, "friction": 0.5 }, { "block": "minecraft:chest", - "mass": 400.0, + "mass": 100.0, "friction": 0.4 }, { "block": "minecraft:barrel", - "mass": 375.0, + "mass": 125.0, "friction": 0.4 }, { @@ -407,87 +407,87 @@ }, { "tag": "minecraft:fences", - "mass": 40.0 + "mass": 50.0 }, { "block": "minecraft:snow", - "mass": 25.0, + "mass": 2.5, "friction": 0.2 }, { "block": "minecraft:snow_block", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:ice", - "mass": 830.0, + "mass": 125.0, "friction": 0.05 }, { "block": "minecraft:packed_ice", - "mass": 875.0, + "mass": 250.0, "friction": 0.02 }, { "block": "minecraft:blue_ice", - "mass": 920.0, + "mass": 400.0, "friction": 0.0 }, { "block": "minecraft:jukebox", - "mass": 800.0, + "mass": 80.0, "friction": 0.6 }, { "block": "minecraft:iron_bars", - "mass": 250.0, + "mass": 25.0, "friction": 0.2 }, { "block": "minecraft:chain", - "mass": 50.0, + "mass": 5.0, "friction": 0.7 }, { "block": "minecraft:dragon_egg", - "mass": 1400.0, + "mass": 500.0, "friction": 0.8 }, { "block": "minecraft:end_portal_frame", - "mass": 3000.0, + "mass": 300.0, "friction": 0.4 }, { "block": "minecraft:ender_chest", - "mass": 800.0, + "mass": 100.0, "friction": 0.4 }, { "block": "minecraft:slime_block", - "mass": 1100.0, + "mass": 200.0, "friction": 1.0, "elasticity": 1.0 }, { "block": "minecraft:honey_block", - "mass": 1400.0, + "mass": 200.0, "friction": 1.0 }, { "block": "minecraft:honeycomb_block", - "mass": 900.0, + "mass": 150.0, "friction": 0.8 }, { "block": "minecraft:bee_nest", - "mass": 400.0, + "mass": 150.0, "friction": 0.5 }, { "block": "minecraft:beehive", - "mass": 450.0, + "mass": 150.0, "friction": 0.4 }, { @@ -500,31 +500,31 @@ }, { "block": "minecraft:dried_kelp_block", - "mass": 1000.0, + "mass": 100.0, "friction": 0.6, "elasticity": 0.3 }, { "tag": "minecraft:signs", - "mass": 10.0 + "mass": 5.0 }, { "tag": "minecraft:flower_pots", - "mass": 30.0 + "mass": 5.0 }, { "block": "minecraft:cake", - "mass": 700.0, + "mass": 5.0, "friction": 0.1 }, { "block": "minecraft:skeleton_skull", - "mass": 2.0, + "mass": 2.5, "friction": 0.2 }, { "block": "minecraft:wither_skeleton_skull", - "mass": 2.0, + "mass": 2.5, "friction": 0.2 }, { @@ -541,16 +541,16 @@ }, { "block": "minecraft:dragon_head", - "mass": 40.0 + "mass": 7.5 }, { "block": "minecraft:skeleton_wall_skull", - "mass": 2.0, + "mass": 2.5, "friction": 0.2 }, { "block": "minecraft:wither_skeleton_wall_skull", - "mass": 2.0, + "mass": 2.5, "friction": 0.2 }, { @@ -567,25 +567,25 @@ }, { "block": "minecraft:dragon_wall_head", - "mass": 40.0 + "mass": 7.5 }, { "block": "minecraft:lodestone", - "mass": 4450.0, + "mass": 445.0, "friction": 0.5 }, { "block": "minecraft:bell", - "mass": 1000.0, + "mass": 100.0, "friction": 0.2 }, { "block": "minecraft:respawn_anchor", - "mass": 2000.0, + "mass": 200.0, "friction": 0.7 }, { "tag": "minecraft:banners", - "mass": 30.0 + "mass": 3.0 } ] diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/plants.json b/common/src/main/resources/data/valkyrienskies/vs_mass/plants.json index 9ae1a5cf2..820e6a091 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/plants.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/plants.json @@ -5,7 +5,7 @@ }, { "tag": "minecraft:leaves", - "mass": 200.0, + "mass": 20.0, "elasticity": 0.15 }, { @@ -95,32 +95,32 @@ }, { "tag": "minecraft:coral_blocks", - "mass": 1500.0, + "mass": 15.0, "friction": 0.7 }, { "block": "minecraft:dead_tube_coral_block", - "mass": 1500.0, + "mass": 15.0, "friction": 0.7 }, { "block": "minecraft:dead_brain_coral_block", - "mass": 1500.0, + "mass": 15.0, "friction": 0.7 }, { "block": "minecraft:dead_bubble_coral_block", - "mass": 1500.0, + "mass": 15.0, "friction": 0.7 }, { "block": "minecraft:dead_fire_coral_block", - "mass": 1500.0, + "mass": 15.0, "friction": 0.7 }, { "block": "minecraft:dead_horn_coral_block", - "mass": 1500.0, + "mass": 15.0, "friction": 0.7 }, { @@ -209,7 +209,7 @@ }, { "block": "minecraft:cactus", - "mass": 600.0 + "mass": 60.0 }, { "block": "minecraft:melon_stem", @@ -221,7 +221,7 @@ }, { "block": "minecraft:melon", - "mass": 600.0, + "mass": 100.0, "friction": 0.2 }, { @@ -234,7 +234,7 @@ }, { "block": "minecraft:pumpkin", - "mass": 600.0, + "mass": 100.0, "friction": 0.3 }, { @@ -279,12 +279,12 @@ }, { "tag": "minecraft:wart_blocks", - "mass": 600.0, + "mass": 60.0, "elasticity": 0.1 }, { "block": "minecraft:shroomlight", - "mass": 800.0 + "mass": 80.0 }, { "block": "minecraft:chorus_plant", @@ -298,19 +298,19 @@ }, { "block": "minecraft:brown_mushroom_block", - "mass": 400.0, + "mass": 40.0, "friction": 0.2, "elasticity": 0.1 }, { "block": "minecraft:red_mushroom_block", - "mass": 400.0, + "mass": 40.0, "friction": 0.2, "elasticity": 0.1 }, { "block": "minecraft:mushroom_stem", - "mass": 600.0, + "mass": 60.0, "friction": 0.2, "elasticity": 0.1 }, diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/redstone_components.json b/common/src/main/resources/data/valkyrienskies/vs_mass/redstone_components.json index 65540b04b..e44ff1b7a 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/redstone_components.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/redstone_components.json @@ -1,51 +1,51 @@ [ { "block": "minecraft:redstone_wire", - "mass": 5.0 + "mass": 0.5 }, { "block": "minecraft:dispenser", - "mass": 2800.0, + "mass": 250.0, "friction": 0.5 }, { "block": "minecraft:dropper", - "mass": 2800.0, + "mass": 250.0, "friction": 0.5 }, { "block": "minecraft:note_block", - "mass": 1200.0, + "mass": 100.0, "friction": 0.6 }, { "block": "minecraft:detector_rail", - "mass": 380.0, + "mass": 100.0, "friction": 0.7 }, { "block": "minecraft:powered_rail", - "mass": 800.0, + "mass": 150.0, "friction": 0.7 }, { "block": "minecraft:rail", - "mass": 330.0, + "mass": 100.0, "friction": 0.7 }, { "block": "minecraft:activator_rail", - "mass": 330.0, + "mass": 100.0, "friction": 0.7 }, { "block": "minecraft:piston", - "mass": 2800.0, + "mass": 250.0, "friction": 0.5 }, { "block": "minecraft:sticky_piston", - "mass": 2800.0, + "mass": 250.0, "friction": 0.5 }, { @@ -60,51 +60,51 @@ }, { "block": "minecraft:tnt", - "mass": 1200.0 + "mass": 125.0 }, { "block": "minecraft:lever", - "mass": 10.0 + "mass": 5.0 }, { "tag": "minecraft:wooden_pressure_plates", - "mass": 10.0 + "mass": 5.0 }, { "block": "minecraft:stone_pressure_plate", - "mass": 130.0 + "mass": 10.0 }, { "block": "minecraft:polished_blackstone_pressure_plate", - "mass": 170.0 + "mass": 10.0 }, { "block": "minecraft:light_weighted_pressure_plate", - "mass": 800.0 + "mass": 50.0 }, { "block": "minecraft:heavy_weighted_pressure_plate", - "mass": 350.0 + "mass": 100.0 }, { "block": "minecraft:redstone_torch", - "mass": 5.0 + "mass": 0.5 }, { "tag": "minecraft:wooden_buttons", - "mass": 2.0 + "mass": 0.25 }, { "block": "minecraft:stone_button", - "mass": 26.0 + "mass": 0.5 }, { "block": "minecraft:polished_blackstone_button", - "mass": 34.0 + "mass": 0.5 }, { "block": "minecraft:tripwire_hook", - "mass": 80.0 + "mass": 0.5 }, { "block": "minecraft:tripwire", @@ -112,22 +112,22 @@ }, { "block": "minecraft:daylight_detector", - "mass": 1200.0, + "mass": 125.0, "friction": 0.2 }, { "block": "minecraft:redstone_block", - "mass": 1350.0, + "mass": 250.0, "friction": 0.4 }, { "block": "minecraft:observer", - "mass": 2800.0, + "mass": 250.0, "friction": 0.5 }, { "block": "minecraft:target", - "mass": 200.0, + "mass": 100.0, "elasticity": 0.3 }, { @@ -136,36 +136,36 @@ }, { "block": "minecraft:trapped_chest", - "mass": 480.0 + "mass": 150.0 }, { "block": "minecraft:redstone_lamp", - "mass": 1200.0, + "mass": 100.0, "friction": 0.2 }, { "block": "minecraft:comparator", - "mass": 250.0, + "mass": 25.0, "friction": 0.3 }, { "block": "minecraft:repeater", - "mass": 250.0, + "mass": 25.0, "friction": 0.3 }, { "block": "minecraft:hopper", - "mass": 3800.0, + "mass": 100.0, "friction": 0.3 }, { "tag": "minecraft:shulker_boxes", - "mass": 800.0, + "mass": 50.0, "friction": 0.1 }, { "tag": "minecraft:fence_gates", - "mass": 20.0 + "mass": 5.0 }, { "tag": "minecraft:wooden_doors", @@ -173,16 +173,16 @@ }, { "block": "minecraft:iron_door", - "mass": 1000.0, + "mass": 75.0, "friction": 0.35 }, { "tag": "minecraft:wooden_trapdoors", - "mass": 25.0 + "mass": 50.0 }, { "block": "minecraft:iron_trapdoor", - "mass": 1000.0, + "mass": 100.0, "friction": 0.35 } ] diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/steelarmorblocks.json b/common/src/main/resources/data/valkyrienskies/vs_mass/steelarmorblocks.json new file mode 100644 index 000000000..d1b599284 --- /dev/null +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/steelarmorblocks.json @@ -0,0 +1,1486 @@ +[ + { + "block": "s_a_b:doublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:steelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:hardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:lightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:steelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:lightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:steelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:lightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:steelarmorstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:steelwl", + "mass": 1176.0 + }, + { + "block": "s_a_b:armorwl", + "mass": 4312.0 + }, + { + "block": "s_a_b:sandbag", + "mass": 624.0 + }, + { + "block": "s_a_b:blacksteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:redsteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:greensteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:bluesteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:cyansteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:brownsteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:graysteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:whitesteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:lightgraysteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:lightbluesteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:magentasteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:yellowsteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:pinksteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:purplesteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:orangesteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:limesteelblock", + "mass": 1176.0 + }, + { + "block": "s_a_b:blackhardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:redhardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:greenhardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:bluehardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:cyanhardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:brownhardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:grayhardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:lightgrayhardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:lightbluehardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:magentahardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:yellowhardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:pinkhardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:purplehardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:orangehardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:limehardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:whitehardsteelblock", + "mass": 4312.0 + }, + { + "block": "s_a_b:blacklightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:redlightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:greenlightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:bluelightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:cyanlightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:brownlightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:graylightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:lightgraylightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:lightbluelightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:magentalightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:yellowlightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:pinklightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:purplelightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:orangelightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:limelightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:whitelightsteelblock", + "mass": 392.0 + }, + { + "block": "s_a_b:blackdoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:reddoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:greendoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:bluedoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:cyandoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:browndoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:graydoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:lightgraydoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:lightbluedoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:magentadoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:yellowdoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:pinkdoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:purpledoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:orangedoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:limedoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:whitedoublesteelblock", + "mass": 2744.0 + }, + { + "block": "s_a_b:blacklightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:redlightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:greenlightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:bluelightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:cyanlightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:brownlightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:graylightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:lightgraylightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:lightbluelightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:magentalightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:yellowlightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:pinklightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:purplelightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:orangelightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:limelightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:whitelightsteelvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:blacksteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:redsteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:greensteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:bluesteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:cyansteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:brownsteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:graysteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:lightgraysteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:lightbluesteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:magentasteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:yellowsteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:pinksteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:purplesteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:orangesteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:limesteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:whitesteelvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:blacklightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:redlightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:greenlightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:bluelightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:cyanlightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:brownlightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:graylightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:lightgraylightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:lightbluelightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:magentalightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:yellowlightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:pinklightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:purplelightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:orangelightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:limelightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:whitelightsteelslab", + "mass": 196.0 + }, + { + "block": "s_a_b:blacksteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:redsteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:greensteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:bluesteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:cyansteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:brownsteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:graysteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:lightgraysteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:lightbluesteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:magentasteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:yellowsteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:pinksteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:purplesteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:orangesteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:limesteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:whitesteelslab", + "mass": 588.0 + }, + { + "block": "s_a_b:blacklightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:redlightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:greenlightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:bluelightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:cyanlightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:brownlightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:graylightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:lightgraylightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:lightbluelightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:magentalightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:yellowlightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:pinklightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:purplelightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:orangelightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:limelightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:whitelightsteelstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:blacksteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:redsteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:greensteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:bluesteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:cyansteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:brownsteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:graysteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:lightgraysteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:lightbluesteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:magentasteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:yellowsteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:pinksteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:purplesteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:orangesteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:limesteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:whitesteelstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:steelblockcolored_29", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelblockcolored_31", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelblockcolored_32", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelblockcolored_33", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelblockcoloredparade", + "mass": 1176.0 + }, + { + "block": "s_a_b:doublesteelblockcolored_29", + "mass": 2744.0 + }, + { + "block": "s_a_b:doublesteelblockcolored_31", + "mass": 2744.0 + }, + { + "block": "s_a_b:doublesteelblockcolored_32", + "mass": 2744.0 + }, + { + "block": "s_a_b:doublesteelblockcolored_33", + "mass": 2744.0 + }, + { + "block": "s_a_b:doublesteelblockcoloredparade", + "mass": 2744.0 + }, + { + "block": "s_a_b:lightsteelblockcolored_29", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelblockcolored_31", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelblockcolored_32", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelblockcolored_33", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelblockcoloredparade", + "mass": 392.0 + }, + { + "block": "s_a_b:hardsteelblockcolored_29", + "mass": 4312.0 + }, + { + "block": "s_a_b:hardsteelblockcolored_31", + "mass": 4312.0 + }, + { + "block": "s_a_b:hardsteelblockcolored_32", + "mass": 4312.0 + }, + { + "block": "s_a_b:hardsteelblockcolored_33", + "mass": 4312.0 + }, + { + "block": "s_a_b:hardsteelblockcoloredparade", + "mass": 4312.0 + }, + { + "block": "s_a_b:steelvslabcolored_29", + "mass": 588.0 + }, + { + "block": "s_a_b:steelvslabcolored_31", + "mass": 588.0 + }, + { + "block": "s_a_b:steelvslabcolored_32", + "mass": 588.0 + }, + { + "block": "s_a_b:steelvslabcolored_33", + "mass": 588.0 + }, + { + "block": "s_a_b:steelvslabcoloredparade", + "mass": 588.0 + }, + { + "block": "s_a_b:lightsteelvslabcolored_29", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelvslabcolored_31", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelvslabcolored_32", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelvslabcolored_33", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelvslabcoloredparade", + "mass": 196.0 + }, + { + "block": "s_a_b:steelslabcolored_29", + "mass": 588.0 + }, + { + "block": "s_a_b:steelslabcolored_31", + "mass": 588.0 + }, + { + "block": "s_a_b:steelslabcolored_32", + "mass": 588.0 + }, + { + "block": "s_a_b:steelslabcolored_33", + "mass": 588.0 + }, + { + "block": "s_a_b:steelslabcoloredparade", + "mass": 588.0 + }, + { + "block": "s_a_b:lightsteelslabcolored_29", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelslabcolored_31", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelslabcolored_32", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelslabcolored_33", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelslabcoloredparade", + "mass": 196.0 + }, + { + "block": "s_a_b:steelstairscolored_29", + "mass": 882.0 + }, + { + "block": "s_a_b:steelstairscolored_31", + "mass": 882.0 + }, + { + "block": "s_a_b:steelstairscolored_32", + "mass": 882.0 + }, + { + "block": "s_a_b:steelstairscolored_33", + "mass": 882.0 + }, + { + "block": "s_a_b:steelstairscoloredparade", + "mass": 882.0 + }, + { + "block": "s_a_b:lightsteelstairscolored_29", + "mass": 294.0 + }, + { + "block": "s_a_b:lghtsteelstairscolored_31", + "mass": 294.0 + }, + { + "block": "s_a_b:lghtsteelstairscolored_32", + "mass": 294.0 + }, + { + "block": "s_a_b:lghtsteelstairscolored_33", + "mass": 294.0 + }, + { + "block": "s_a_b:lghtsteelstairscoloredparade", + "mass": 3234.0 + }, + { + "block": "s_a_b:doublesteelblockshipbottom", + "mass": 2744.0 + }, + { + "block": "s_a_b:steelblockshipbottom", + "mass": 1176.0 + }, + { + "block": "s_a_b:hardsteelblockshipbottom", + "mass": 4312.0 + }, + { + "block": "s_a_b:lightsteelblockshipbottom", + "mass": 392.0 + }, + { + "block": "s_a_b:doublesteelblock_4bo", + "mass": 2744.0 + }, + { + "block": "s_a_b:steelblock_4bo", + "mass": 1176.0 + }, + { + "block": "s_a_b:hardsteelblock_4bo", + "mass": 4312.0 + }, + { + "block": "s_a_b:lightsteelblock_4bo", + "mass": 392.0 + }, + { + "block": "s_a_b:doublesteelblockgelb", + "mass": 2744.0 + }, + { + "block": "s_a_b:steelblockgelb", + "mass": 1176.0 + }, + { + "block": "s_a_b:hardsteelblockgelb", + "mass": 4312.0 + }, + { + "block": "s_a_b:lightsteelblockgelb", + "mass": 392.0 + }, + { + "block": "s_a_b:doublesteelblockpanzergrau", + "mass": 2744.0 + }, + { + "block": "s_a_b:steelblockpanzergrau", + "mass": 1176.0 + }, + { + "block": "s_a_b:hardsteelblockpanzergrau", + "mass": 4312.0 + }, + { + "block": "s_a_b:lightsteelblockpanzergrau", + "mass": 392.0 + }, + { + "block": "s_a_b:doublesteelblockrotbraun", + "mass": 2744.0 + }, + { + "block": "s_a_b:steelblockrotbraun", + "mass": 1176.0 + }, + { + "block": "s_a_b:hardsteelblockrotbraun", + "mass": 4312.0 + }, + { + "block": "s_a_b:lightsteelblockrotbraun", + "mass": 392.0 + }, + { + "block": "s_a_b:steelslabshipbottom", + "mass": 588.0 + }, + { + "block": "s_a_b:steelvslabshipbottom", + "mass": 588.0 + }, + { + "block": "s_a_b:steelstairsshipbottom", + "mass": 882.0 + }, + { + "block": "s_a_b:lightsteelslabshipbottom", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelvslabshipbottom", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelstairsshipbottom", + "mass": 294.0 + }, + { + "block": "s_a_b:steelslab_4bo", + "mass": 588.0 + }, + { + "block": "s_a_b:steelvslab_4bo", + "mass": 588.0 + }, + { + "block": "s_a_b:steelstairs_4bo", + "mass": 882.0 + }, + { + "block": "s_a_b:lightsteelslab_4bo", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelvslab_4bo", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelstairs_4bo", + "mass": 294.0 + }, + { + "block": "s_a_b:steelslabgelb", + "mass": 588.0 + }, + { + "block": "s_a_b:steelvslabgelb", + "mass": 588.0 + }, + { + "block": "s_a_b:steelstairsgelb", + "mass": 882.0 + }, + { + "block": "s_a_b:lightsteelslabgelb", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelvslabgelb", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelstairsgelb", + "mass": 294.0 + }, + { + "block": "s_a_b:steelslabpanzergrau", + "mass": 588.0 + }, + { + "block": "s_a_b:steelvslabpanzergrau", + "mass": 588.0 + }, + { + "block": "s_a_b:steelstairspanzergrau", + "mass": 882.0 + }, + { + "block": "s_a_b:lightsteelslabpanzergrau", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelvslabpanzergrau", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelstairspanzergrau", + "mass": 294.0 + }, + { + "block": "s_a_b:steelslabrotbraun", + "mass": 588.0 + }, + { + "block": "s_a_b:steelvslabrotbraun", + "mass": 588.0 + }, + { + "block": "s_a_b:steelstairsrotbraun", + "mass": 882.0 + }, + { + "block": "s_a_b:lightsteelslabrotbraun", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelvslabrotbraun", + "mass": 196.0 + }, + { + "block": "s_a_b:lightsteelstairsrotbraun", + "mass": 294.0 + }, + { + "block": "s_a_b:steelwl_29", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelwl_31", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelwl_32", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelwl_33", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelwlblack", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelwlgray", + "mass": 1176.0 + }, + { + "block": "s_a_b:lightwl_29", + "mass": 392.0 + }, + { + "block": "s_a_b:lightwl_31", + "mass": 392.0 + }, + { + "block": "s_a_b:lightwl_32", + "mass": 392.0 + }, + { + "block": "s_a_b:lightwl_33", + "mass": 392.0 + }, + { + "block": "s_a_b:lightwlblack", + "mass": 392.0 + }, + { + "block": "s_a_b:lightwlgray", + "mass": 392.0 + }, + { + "block": "s_a_b:armorwl_29", + "mass": 4312.0 + }, + { + "block": "s_a_b:armorwl_31", + "mass": 4312.0 + }, + { + "block": "s_a_b:armorwl_32", + "mass": 4312.0 + }, + { + "block": "s_a_b:armorwl_33", + "mass": 4312.0 + }, + { + "block": "s_a_b:armorwlblack", + "mass": 4312.0 + }, + { + "block": "s_a_b:armorwlgray", + "mass": 4312.0 + }, + { + "block": "s_a_b:lightsteelblockcamoplains", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelcamoforest", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelcamosnow", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelcamodesert", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelcamomesa", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelcamoswamp", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelcamojungle", + "mass": 392.0 + }, + { + "block": "s_a_b:lightsteelcamotaiga", + "mass": 392.0 + }, + { + "block": "s_a_b:steelblockcamoplains", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelblockcamoforest", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelblockcamosnow", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelblockcamodesert", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelblockcamomesa", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelblockcamoswamp", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelblockcamojungle", + "mass": 1176.0 + }, + { + "block": "s_a_b:steelblockcamotaiga", + "mass": 1176.0 + }, + { + "block": "s_a_b:doublesteelblockcamoplains", + "mass": 2744.0 + }, + { + "block": "s_a_b:doublesteelblockcamoforest", + "mass": 2744.0 + }, + { + "block": "s_a_b:doublesteelblockcamosnow", + "mass": 2744.0 + }, + { + "block": "s_a_b:doublesteelblockcamodesert", + "mass": 2744.0 + }, + { + "block": "s_a_b:doublesteelblockcamomesa", + "mass": 2744.0 + }, + { + "block": "s_a_b:doublesteelblockcamoswamp", + "mass": 2744.0 + }, + { + "block": "s_a_b:doublesteelblockcamojungle", + "mass": 2744.0 + }, + { + "block": "s_a_b:doublesteelblockcamotaiga", + "mass": 2744.0 + }, + { + "block": "s_a_b:hardsteelblockcamoplains", + "mass": 4312.0 + }, + { + "block": "s_a_b:hardsteelblockcamoforest", + "mass": 4312.0 + }, + { + "block": "s_a_b:hardsteelblockcamosnow", + "mass": 4312.0 + }, + { + "block": "s_a_b:hardsteelblockcamodesert", + "mass": 4312.0 + }, + { + "block": "s_a_b:hardsteelblockcamomesa", + "mass": 4312.0 + }, + { + "block": "s_a_b:hardsteelblockcamoswamp", + "mass": 4312.0 + }, + { + "block": "s_a_b:hardsteelblockcamojungle", + "mass": 4312.0 + }, + { + "block": "s_a_b:hardsteelblockcamotaiga", + "mass": 4312.0 + }, + { + "block": "s_a_b:iightsteelcamoplainsslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamoplainsvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamoplainsstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:iightsteelcamoforestslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamoforestvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamoforeststairs", + "mass": 294.0 + }, + { + "block": "s_a_b:iightsteelcamosnowslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamosnowvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamosnowstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:iightsteelcamodesertslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamodesertvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamodesertstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:iightsteelcamomesaslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamomesavslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamomesastairs", + "mass": 294.0 + }, + { + "block": "s_a_b:iightsteelcamoswampslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamoswampvslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamoswampstairs", + "mass": 294.0 + }, + { + "block": "s_a_b:iightsteelcamojungleslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamojunglevslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamojunglestairs", + "mass": 294.0 + }, + { + "block": "s_a_b:iightsteelcamotaigaslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamotaigavslab", + "mass": 196.0 + }, + { + "block": "s_a_b:iightsteelcamotaigastairs", + "mass": 294.0 + }, + { + "block": "s_a_b:steelcamoplainsslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamoplainsvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamoplainsstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:steelcamoforestslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamoforestvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamoforeststairs", + "mass": 882.0 + }, + { + "block": "s_a_b:steelcamosnowslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamosnowvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamosnowstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:steelcamodesertslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamodesertvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamodesertstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:steelcamomesaslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamomesavslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamomesastairs", + "mass": 882.0 + }, + { + "block": "s_a_b:steelcamoswampslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamoswampvslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamoswampstairs", + "mass": 882.0 + }, + { + "block": "s_a_b:steelcamojungleslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamojunglevslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamojunglestairs", + "mass": 882.0 + }, + { + "block": "s_a_b:steelcamotaigaslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamotaigavslab", + "mass": 588.0 + }, + { + "block": "s_a_b:steelcamotaigastairs", + "mass": 882.0 + } +] diff --git a/common/src/main/resources/data/valkyrienskies/vs_mass/wood.json b/common/src/main/resources/data/valkyrienskies/vs_mass/wood.json index f1f037988..2c859b451 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/wood.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/wood.json @@ -1,302 +1,302 @@ [ { "block": "minecraft:oak_wood", - "mass": 900.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:oak_log", - "mass": 900.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:stripped_oak_wood", - "mass": 900.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:stripped_oak_log", - "mass": 900.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:oak_planks", - "mass": 600.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:oak_slab", - "mass": 300.0, + "mass": 50.0, "friction": 0.5 }, { - "block": "minecraft:oak_slab", - "mass": 450.0, + "block": "minecraft:oak_stairs", + "mass": 75.0, "friction": 0.5 }, { "block": "minecraft:spruce_wood", - "mass": 780.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:spruce_log", - "mass": 780.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:stripped_spruce_wood", - "mass": 780.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:stripped_spruce_log", - "mass": 780.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:spruce_planks", - "mass": 480.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:spruce_slab", - "mass": 240.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:spruce_stairs", - "mass": 360.0, + "mass": 75.0, "friction": 0.5 }, { "block": "minecraft:birch_wood", - "mass": 770.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:birch_log", - "mass": 770.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:stripped_birch_wood", - "mass": 770.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:stripped_birch_log", - "mass": 770.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:birch_planks", - "mass": 510.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:birch_slab", - "mass": 255.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:birch_stairs", - "mass": 380.0, + "mass": 75.0, "friction": 0.5 }, { "block": "minecraft:jungle_wood", - "mass": 850.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:jungle_log", - "mass": 850.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:stripped_jungle_wood", - "mass": 850.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:stripped_jungle_log", - "mass": 850.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:jungle_planks", - "mass": 500.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:jungle_slab", - "mass": 250.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:jungle_stairs", - "mass": 375.0, + "mass": 75.0, "friction": 0.5 }, { "block": "minecraft:acacia_wood", - "mass": 770.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:acacia_log", - "mass": 770.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:stripped_acacia_wood", - "mass": 770.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:stripped_acacia_log", - "mass": 770.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:acacia_planks", - "mass": 550.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:acacia_slab", - "mass": 275.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:acacia_stairs", - "mass": 410.0, + "mass": 75.0, "friction": 0.5 }, { "block": "minecraft:dark_oak_wood", - "mass": 800.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:dark_oak_log", - "mass": 800.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:stripped_dark_oak_wood", - "mass": 800.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:stripped_dark_oak_log", - "mass": 800.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:dark_oak_planks", - "mass": 650.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:dark_oak_slab", - "mass": 325.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:dark_oak_stairs", - "mass": 485.0, + "mass": 75.0, "friction": 0.5 }, { "block": "minecraft:warped_hyphae", - "mass": 980.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:warped_stem", - "mass": 980.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:stripped_warped_hyphae", - "mass": 980.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:stripped_warped_stem", - "mass": 980.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:warped_planks", - "mass": 910.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:warped_slab", - "mass": 455.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:warped_stairs", - "mass": 680.0, + "mass": 75.0, "friction": 0.5 }, { "block": "minecraft:crimson_hyphae", - "mass": 980.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:crimson_stem", - "mass": 980.0, + "mass": 400.0, "friction": 0.6 }, { "block": "minecraft:stripped_crimson_hyphae", - "mass": 980.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:stripped_crimson_stem", - "mass": 980.0, + "mass": 400.0, "friction": 0.4 }, { "block": "minecraft:crimson_planks", - "mass": 910.0, + "mass": 100.0, "friction": 0.5 }, { "block": "minecraft:crimson_slab", - "mass": 455.0, + "mass": 50.0, "friction": 0.5 }, { "block": "minecraft:crimson_stairs", - "mass": 680.0, + "mass": 750.0, "friction": 0.5 }, { "tag": "minecraft:logs", - "mass": 800.0, + "mass": 400.0, "friction": 0.6 }, { "tag": "minecraft:planks", - "mass": 700.0, + "mass": 100.0, "friction": 0.5 }, { "tag": "minecraft:wooden_stairs", - "mass": 525.0, + "mass": 75.0, "friction": 0.5 }, { "tag": "minecraft:wooden_slabs", - "mass": 350.0, + "mass": 50.0, "friction": 0.5 } ] diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index f6a391bc7..2b0fc4659 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -44,13 +44,16 @@ "feature.shipyard_entities.MixinEntity", "feature.shipyard_entities.MixinEntitySection", "feature.shipyard_entities.MixinEntitySectionStorage", - "feature.shipyard_entities.MixinPersistentEntitySectionManager", "feature.shipyard_entities.MixinServerLevel", "feature.shipyard_entities.MixinTransientEntitySectionManager", "feature.spawn_player_on_ship.MixinServerGamePacketListenerImpl", "feature.tick_ship_chunks.MixinChunkMap", "feature.world_border.MixinLevel", "feature.world_border.MixinWorldBorder", + "mod_compat.bluemap.HiresTileModelAccessor", + "mod_compat.bluemap.MixinBmMap", + "mod_compat.bluemap.MixinHiresModelManager", + "mod_compat.bluemap.MixinWorld", "mod_compat.create.IMixinDeployerHandler", "mod_compat.create.IMixinDeployerMovementBehaviour", "mod_compat.create.MixinAirCurrent", @@ -61,6 +64,7 @@ "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", @@ -89,6 +93,7 @@ "mod_compat.create_big_cannons.MixinPitchOrientedContraptionEntity", "mod_compat.ftb_chunks.MixinClaimedChunkManager", "mod_compat.reachentityattributes.MixinReachEntityAttributes", + "server.MinecraftServerAccessor", "server.MixinMinecraftServer", "server.MixinPlayerList", "server.command.MixinCommands", @@ -159,9 +164,12 @@ "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.create.client.trackOutlines.MixinTrackBlockOutline", - "mod_compat.create.client.MixinValueBox", "mod_compat.flywheel.InstancingEngineAccessor", "mod_compat.flywheel.MixinBlockEntityInstanceManager", "mod_compat.flywheel.MixinInstanceManager", diff --git a/fabric/build.gradle b/fabric/build.gradle index ff5d98e89..28c9639ae 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -59,8 +59,16 @@ dependencies { exclude module: "fastutil" exclude module: "kotlin-stdlib-jdk8" // Don't shade kotlin-stdlib-jdk8, even though vs-core depends on it exclude module: "jsonschema.module.addon" + + exclude group: "com.google.guava" } + def jacksonVersion = '2.14.0' + + + include("com.fasterxml:classmate:1.5.1") + implementation("com.fasterxml:classmate:1.5.1") + // CC Restitchedget modImplementation("maven.modrinth:cc-restitched:${cc_restitched_version}") diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java deleted file mode 100644 index f58bb2ae4..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java +++ /dev/null @@ -1,48 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; - -import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.api.ships.LoadedShip; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Pseudo -@Mixin(SpeakerPosition.class) -public abstract class MixinSpeakerPosition { - @Shadow - public abstract Level level(); - - @Inject(method = "position", at = @At("RETURN"), remap = false, cancellable = true) - public void ValkyrienSkies2$position(final CallbackInfoReturnable cir) { - final Vec3 pos = cir.getReturnValue(); - final LoadedShip ship = VSGameUtilsKt.getShipObjectManagingPos(level(), pos.x, pos.y, pos.z); - if (ship != null) { - cir.setReturnValue(VSGameUtilsKt.toWorldCoordinates(level(), pos)); - } - } - - @Redirect( - method = "withinDistance", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" - ) - ) - public double ValkyrienSkies$distanceToSqr(final Vec3 instance, final Vec3 d) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(level(), instance); - if (ship != null) { - return VSGameUtilsKt.squaredDistanceBetweenInclShips(level(), instance.x, instance.y, instance.z, d.x, d.y, - d.z); - } - - return instance.distanceToSqr(d); - } -} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerSound.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerSound.java new file mode 100644 index 000000000..1244e4b49 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerSound.java @@ -0,0 +1,64 @@ +package org.valkyrienskies.mod.fabric.mixin.compat.cc_restitched; + +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.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) { + super(arg, arg2); + } + + @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/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/README.MD b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/README.MD index 04360e4e0..86cfc1995 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/README.MD +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/README.MD @@ -1,6 +1,6 @@ Minimal ComputerCraft Compatibility Mixins -- MixinSpeakerPosition +- 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 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 new file mode 100644 index 000000000..75dc5f991 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinChuteBlockEntity.java @@ -0,0 +1,63 @@ +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/client/MixinTrackBlockOutline.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinTrackBlockOutline.java new file mode 100644 index 000000000..535f54ba1 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinTrackBlockOutline.java @@ -0,0 +1,134 @@ +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/shipyard_entities/MixinPersistentEntitySectionManager.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java new file mode 100644 index 000000000..3a98256bb --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java @@ -0,0 +1,58 @@ +package org.valkyrienskies.mod.fabric.mixin.feature.shipyard_entities; + +import java.util.function.LongPredicate; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.entity.EntitySectionStorage; +import net.minecraft.world.level.entity.PersistentEntitySectionManager; +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.ModifyArg; +import org.valkyrienskies.mod.mixinducks.world.OfLevel; + +@Mixin(PersistentEntitySectionManager.class) +public abstract class MixinPersistentEntitySectionManager implements OfLevel { + @Shadow + @Final + EntitySectionStorage sectionStorage; + + @Unique + private Level valkyrienskies$level; + + @Override + public Level getLevel() { + return valkyrienskies$level; + } + + @Override + public void setLevel(final Level level) { + this.valkyrienskies$level = level; + ((OfLevel) this.sectionStorage).setLevel(level); + } + + /** + * This fixes this function randomly crashing. I'm not sure why but the removeIf() function is buggy + */ + @ModifyArg( + method = "processUnloads", + at = @At( + target = "Lit/unimi/dsi/fastutil/longs/LongSet;removeIf(Ljava/uti l/function/LongPredicate;)Z", + value = "INVOKE" + ) + ) + private LongPredicate processUnloads_catchException( + final LongPredicate par1 + ) { + return (l) -> { + try { + return par1.test(l); + } catch (final Exception e) { + e.printStackTrace(); + return false; + } + }; + } +} diff --git a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt index bdd81fbdf..9c31462e1 100644 --- a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt +++ b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/compat/modmenu/ValkyrienModMenu.kt @@ -2,8 +2,7 @@ package org.valkyrienskies.mod.fabric.compat.modmenu import com.terraformersmc.modmenu.api.ConfigScreenFactory import com.terraformersmc.modmenu.api.ModMenuApi -import org.valkyrienskies.core.impl.config.VSConfigClass.Companion.getRegisteredConfig -import org.valkyrienskies.core.impl.config.VSCoreConfig +import org.valkyrienskies.core.impl.config_impl.VSCoreConfig import org.valkyrienskies.mod.common.config.VSGameConfig import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig @@ -12,8 +11,8 @@ class ValkyrienModMenu : ModMenuApi { return ConfigScreenFactory { parent -> VSClothConfig.createConfigScreenFor( parent, - getRegisteredConfig(VSCoreConfig::class.java), - getRegisteredConfig(VSGameConfig::class.java) + VSCoreConfig::class.java, + VSGameConfig::class.java ) } } diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index c646cb2f7..de0571ea6 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -3,20 +3,23 @@ "package": "org.valkyrienskies.mod.fabric.mixin", "compatibilityLevel": "JAVA_8", "mixins": [ - "compat.cc_restitched.MixinSpeakerPosition", "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", "world.level.block.FireMixin", "server.network.MixinServerPlayerGameMode", "server.network.MixinServerGamePacketListenerImpl" ], "client": [ + "compat.cc_restitched.MixinSpeakerSound", "compat.create.client.MixinContraptionHandlerClient", "compat.create.client.MixinContraptionRenderInfo", "compat.create.client.MixinCullingBlockEntityIterator", diff --git a/forge/build.gradle b/forge/build.gradle index c533cc67f..80d4ee261 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -51,8 +51,8 @@ configurations { } dependencies { - implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:0.2.0")) - implementation(include("io.github.llamalad7:mixinextras-forge:0.2.0")) + implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.5")) + implementation(include("io.github.llamalad7:mixinextras-forge:0.3.5")) forge "net.minecraftforge:forge:${rootProject.forge_version}" @@ -72,6 +72,10 @@ dependencies { 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}") @@ -81,6 +85,9 @@ dependencies { // Modular Routers modCompileOnly("curse.maven:mr-250294:4695682") + // Mekanism + modCompileOnly ("curse.maven:mekanism-268560:4644795") + // Add Kotlin for Forge (3.12.0) forgeRuntimeLibrary("maven.modrinth:kotlin-for-forge:${kotlin_version}") diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java deleted file mode 100644 index fa6304a8a..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.cc_tweaked; - -import dan200.computercraft.shared.peripheral.speaker.SpeakerPosition; -import net.minecraft.world.level.Level; -import net.minecraft.world.phys.Vec3; -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.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Pseudo -@Mixin(SpeakerPosition.class) -public abstract class MixinSpeakerPosition { - @Shadow - public abstract Level level(); - - @Inject(method = "position", at = @At("RETURN"), remap = false, cancellable = true) - public void ValkyrienSkies2$position(final CallbackInfoReturnable cir) { - final Vec3 pos = cir.getReturnValue(); - final Ship ship = VSGameUtilsKt.getShipObjectManagingPos(level(), pos.x, pos.y, pos.z); - if (ship != null) { - cir.setReturnValue(VSGameUtilsKt.toWorldCoordinates(level(), pos)); - } - } - - @Redirect( - method = "withinDistance", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D" - ) - ) - public double ValkyrienSkies$distanceToSqr(final Vec3 instance, final Vec3 d) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(level(), instance); - if (ship != null) { - return VSGameUtilsKt.squaredDistanceBetweenInclShips(level(), instance.x, instance.y, instance.z, d.x, d.y, - d.z); - } - - return instance.distanceToSqr(d); - } -} 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 new file mode 100644 index 000000000..3a3fa4244 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerSound.java @@ -0,0 +1,64 @@ +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.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) { + super(arg, arg2); + } + + @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/README.MD b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/README.MD index 04360e4e0..86cfc1995 100644 --- 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 @@ -1,6 +1,6 @@ Minimal ComputerCraft Compatibility Mixins -- MixinSpeakerPosition +- 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 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 new file mode 100644 index 000000000..21e60e3ca --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinChuteBlockEntity.java @@ -0,0 +1,63 @@ +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/client/MixinTrackBlockOutline.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinTrackBlockOutline.java new file mode 100644 index 000000000..599b00336 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinTrackBlockOutline.java @@ -0,0 +1,126 @@ +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.DrawSelectionEvent; +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, remap = false) +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(DrawSelectionEvent.HighlightBlock 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 new file mode 100644 index 000000000..229a7d65f --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mekanism/MixinRadiationManager.java @@ -0,0 +1,31 @@ +package org.valkyrienskies.mod.forge.mixin.compat.mekanism; + +import java.util.Objects; +import mekanism.api.Coord4D; +import mekanism.common.lib.radiation.RadiationManager; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceKey; +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.ModifyVariable; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.ValkyrienSkiesMod; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(RadiationManager.class) +public class MixinRadiationManager { + @ModifyVariable(remap = false, ordinal = 0, method = "radiate(Lmekanism/api/Coord4D;D)V", at = @At("HEAD"), argsOnly = true) + private Coord4D MixinDumpRadiation(final Coord4D coord4D) { + final ResourceKey resourceKey = coord4D.dimension; + final Level level = Objects.requireNonNull(ValkyrienSkiesMod.getCurrentServer()).getLevel(resourceKey); + final Ship ship = VSGameUtilsKt.getShipManagingPos(level, coord4D.getPos()); + if (ship == null){ + return coord4D; + }else{ + return new Coord4D(new BlockPos( + VectorConversionsMCKt.toMinecraft(VSGameUtilsKt.toWorldCoordinates(ship, coord4D.getPos()))), coord4D.dimension); + } + } +} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java new file mode 100644 index 000000000..bda6225c3 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java @@ -0,0 +1,58 @@ +package org.valkyrienskies.mod.forge.mixin.feature.shipyard_entities; + +import it.unimi.dsi.fastutil.longs.LongPredicate; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.entity.EntitySectionStorage; +import net.minecraft.world.level.entity.PersistentEntitySectionManager; +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.ModifyArg; +import org.valkyrienskies.mod.mixinducks.world.OfLevel; + +@Mixin(PersistentEntitySectionManager.class) +public abstract class MixinPersistentEntitySectionManager implements OfLevel { + @Shadow + @Final + EntitySectionStorage sectionStorage; + + @Unique + private Level valkyrienskies$level; + + @Override + public Level getLevel() { + return valkyrienskies$level; + } + + @Override + public void setLevel(final Level level) { + this.valkyrienskies$level = level; + ((OfLevel) this.sectionStorage).setLevel(level); + } + + /** + * This fixes this function randomly crashing. I'm not sure why but the removeIf() function is buggy + */ + @ModifyArg( + method = "processUnloads", + at = @At( + target = "Lit/unimi/dsi/fastutil/longs/LongSet;removeIf(Lit/unimi/dsi/fastutil/longs/LongPredicate;)Z", + value = "INVOKE" + ) + ) + private LongPredicate processUnloads_catchException( + final LongPredicate par1 + ) { + return (l) -> { + try { + return par1.test(l); + } catch (final Exception e) { + e.printStackTrace(); + return false; + } + }; + } +} 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 921640ec3..0903f3d7e 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 @@ -26,8 +26,7 @@ import net.minecraftforge.registries.DeferredRegister import net.minecraftforge.registries.ForgeRegistries import net.minecraftforge.registries.RegistryObject import org.valkyrienskies.core.apigame.VSCoreFactory -import org.valkyrienskies.core.impl.config.VSConfigClass -import org.valkyrienskies.core.impl.config.VSCoreConfig +import org.valkyrienskies.core.impl.config_impl.VSCoreConfig import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.client.VSPhysicsEntityRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod @@ -104,8 +103,8 @@ class ValkyrienSkiesModForge { ConfigScreenHandler.ConfigScreenFactory { _, parent -> VSClothConfig.createConfigScreenFor( parent, - VSConfigClass.getRegisteredConfig(VSCoreConfig::class.java), - VSConfigClass.getRegisteredConfig(VSGameConfig::class.java) + VSCoreConfig::class.java, + VSGameConfig::class.java ) } } diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index de7ebfc2e..9c4d726a9 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -3,28 +3,33 @@ "package": "org.valkyrienskies.mod.forge.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ - "compat.cc_tweaked.MixinSpeakerPosition", "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.modular_routers.MixinContainerModularRouter", "compat.tfc.MixinTFCChunkGenerator", "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", "compat.modular_routers.MixinRouterMenu", "feature.forge_interact.MixinIForgePlayer", "feature.water_in_ships_entity.MixinEntity", + "feature.shipyard_entities.MixinPersistentEntitySectionManager", "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" diff --git a/gradle.properties b/gradle.properties index b34061fed..688ed12a2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,7 +26,7 @@ flywheel_version_fabric=0.6.9-6 # https://modrinth.com/mod/create-big-cannons/version/ createbigcannons_version= 0.5.2.a -vs_core_version=1.1.0+b19b27c4a4 +vs_core_version=1.1.0+cf7b0d3c5b # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually kotlin.stdlib.default.dependency=false From 6be3966b78ffe7c9e9eee5f9a84b1962454c18b0 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Wed, 25 Sep 2024 23:22:44 -0700 Subject: [PATCH 142/156] Well the fabric work --- common/build.gradle | 3 +- .../trackOutlines/MixinTrackBlockOutline.java | 134 ------------------ .../mod/common/command/VSCommands.kt | 14 +- .../mod/compat/Weather2Compat.kt | 7 +- .../valkyrienskies-common.mixins.json | 1 - .../cc_restitched/MixinSpeakerSound.java | 5 +- gradle.properties | 2 +- 7 files changed, 12 insertions(+), 154 deletions(-) delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java diff --git a/common/build.gradle b/common/build.gradle index 5e2948337..9a179885f 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -39,8 +39,7 @@ dependencies { //implementation("io.github.fabricators_of_create.Porting-Lib:Porting-Lib:$port_lib_version+$minecraft_version") modCompileOnly("maven.modrinth:create-big-cannons:${createbigcannons_version}") - modCompileOnly("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") - modCompileOnly("com.rbasamoyai:createbigcannons-fabric-${minecraft_version}:${createbigcannons_version}") + // modCompileOnly("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") //Bluemap fabric 1.19 modCompileOnly("curse.maven:bluemap-406463:4474497") diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java deleted file mode 100644 index 83141fca5..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines/MixinTrackBlockOutline.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client.trackOutlines; - -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.Ship; -import org.valkyrienskies.core.impl.game.ships.ShipObjectClient; -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 ShipObjectClient ship; - if ((ship = (ShipObjectClient) 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 ShipObjectClient ship; - if ((ship = (ShipObjectClient) 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/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt index 1fc4a2968..0d3ca88dd 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt @@ -3,7 +3,6 @@ package org.valkyrienskies.mod.common.command import com.mojang.brigadier.CommandDispatcher import com.mojang.brigadier.arguments.ArgumentType import com.mojang.brigadier.arguments.BoolArgumentType -import com.mojang.brigadier.arguments.DoubleArgumentType import com.mojang.brigadier.arguments.StringArgumentType import com.mojang.brigadier.builder.LiteralArgumentBuilder import com.mojang.brigadier.builder.RequiredArgumentBuilder @@ -14,7 +13,6 @@ import net.minecraft.commands.arguments.EntityArgument import net.minecraft.commands.arguments.coordinates.BlockPosArgument import net.minecraft.commands.arguments.coordinates.Vec3Argument import net.minecraft.network.chat.Component -import net.minecraft.network.chat.Component.translatable import net.minecraft.world.entity.Entity import net.minecraft.world.phys.BlockHitResult import org.joml.Vector3d @@ -23,12 +21,9 @@ import org.valkyrienskies.core.api.world.ServerShipWorld import org.valkyrienskies.core.api.world.ShipWorld import org.valkyrienskies.core.apigame.ShipTeleportData import org.valkyrienskies.core.impl.game.ShipTeleportDataImpl -import org.valkyrienskies.core.impl.game.ships.ShipData -import org.valkyrienskies.core.impl.game.ships.ShipObject import org.valkyrienskies.core.util.x import org.valkyrienskies.core.util.y import org.valkyrienskies.core.util.z -import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.getShipManagingPos import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toJOMLD @@ -77,14 +72,7 @@ object VSCommands { val r = ShipArgument.getShips(it, "ships").toList() as List val isStatic = BoolArgumentType.getBool(it, "is-static") r.forEach { ship -> - if (ship is ShipObject) { - // TODO: AAAAAAAAA THIS IS HORRIBLE how can the API support this? - (ship.shipData as ShipData).isStatic = isStatic - } else if (ship is ShipData) { - // TODO: AAAAAAAAA THIS IS HORRIBLE how can the API support this? - ship.isStatic = isStatic - } - + ship.isStatic = isStatic } it.source.sendVSMessage( Component.translatable( diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt index 975b461e8..43e827abc 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt @@ -1,6 +1,7 @@ package org.valkyrienskies.mod.compat import net.minecraft.server.level.ServerLevel +/* import org.joml.Vector3d import org.valkyrienskies.core.api.ships.getAttachment import org.valkyrienskies.mod.common.config.VSGameConfig @@ -8,10 +9,13 @@ import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.GameTickForceApplier import org.valkyrienskies.mod.common.util.toMinecraft import weather2.ServerTickHandler -import weather2.weathersystem.storm.StormObject +import weather2.weathersystem.storm.StormObject= + */ object Weather2Compat { + // Weather mod is not on 1.19.2, so it must be disabled! fun tick(level: ServerLevel) { + /* val mgr = ServerTickHandler .getWeatherManagerFor(level.dimension()) @@ -69,5 +73,6 @@ object Weather2Compat { } } } + */ } } diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 2b0fc4659..08c5f8bb8 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -169,7 +169,6 @@ "mod_compat.create.client.MixinSchematicTransformation", "mod_compat.create.client.MixinValueBox", "mod_compat.create.client.trackOutlines.MixinBigOutlines", - "mod_compat.create.client.trackOutlines.MixinTrackBlockOutline", "mod_compat.flywheel.InstancingEngineAccessor", "mod_compat.flywheel.MixinBlockEntityInstanceManager", "mod_compat.flywheel.MixinInstanceManager", diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerSound.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerSound.java index 1244e4b49..fe62b1155 100644 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerSound.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerSound.java @@ -5,6 +5,7 @@ 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; @@ -23,8 +24,8 @@ public abstract class MixinSpeakerSound extends AbstractSoundInstance implements @Unique private SpeakerPosition speakerPosition; @Unique private Ship ship; - protected MixinSpeakerSound(ResourceLocation arg, SoundSource arg2) { - super(arg, arg2); + protected MixinSpeakerSound(ResourceLocation arg, SoundSource arg2, RandomSource arg3) { + super(arg, arg2, arg3); } @Inject( diff --git a/gradle.properties b/gradle.properties index 688ed12a2..6de3bbe7d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,7 +24,7 @@ create_fabric_version=0.5.1-c-build.1160+mc1.19.2 flywheel_version_fabric=0.6.9-6 # https://modrinth.com/mod/create-big-cannons/version/ -createbigcannons_version= 0.5.2.a +createbigcannons_version=0.5.2.a vs_core_version=1.1.0+cf7b0d3c5b # Prevent kotlin from autoincluding stdlib as a dependency, which breaks From c372f079544dd6b86e6727466d2ff7c7877f5a8b Mon Sep 17 00:00:00 2001 From: StewStrong Date: Wed, 25 Sep 2024 23:46:44 -0700 Subject: [PATCH 143/156] Got forge working --- .../mod/forge/mixin/compat/cc_tweaked/MixinSpeakerSound.java | 5 +++-- .../mixin/compat/create/client/MixinTrackBlockOutline.java | 4 ++-- forge/src/main/resources/valkyrienskies-forge.mixins.json | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) 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 index 3a3fa4244..907ec7493 100644 --- 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 @@ -5,6 +5,7 @@ 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; @@ -23,8 +24,8 @@ public abstract class MixinSpeakerSound extends AbstractSoundInstance implements @Unique private SpeakerPosition speakerPosition; @Unique private Ship ship; - protected MixinSpeakerSound(ResourceLocation arg, SoundSource arg2) { - super(arg, arg2); + protected MixinSpeakerSound(ResourceLocation arg, SoundSource arg2, RandomSource arg3) { + super(arg, arg2, arg3); } @Inject( 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 index 599b00336..38cc2b6ed 100644 --- 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 @@ -11,7 +11,7 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.Vec3; -import net.minecraftforge.client.event.DrawSelectionEvent; +import net.minecraftforge.client.event.RenderHighlightEvent; import org.joml.Quaterniond; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Mixin; @@ -99,7 +99,7 @@ private static BlockPos modIsWithinBounds(final BlockPos blockPos) { } @Inject(method = "drawCustomBlockSelection", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V")) - private static void harvest(DrawSelectionEvent.HighlightBlock event, CallbackInfo ci) { + private static void harvest(RenderHighlightEvent.Block event, CallbackInfo ci) { valkyrienskies$info = event.getCamera(); valkyrienskies$hitResult = (BlockHitResult) event.getTarget(); } diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 9c4d726a9..296d3d29f 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -12,7 +12,6 @@ "compat.create.MixinControlledContraptionEntity", "compat.immersivengineering.MixinBlockEntityInventory", "compat.mekanism.MixinRadiationManager", - "compat.modular_routers.MixinContainerModularRouter", "compat.tfc.MixinTFCChunkGenerator", "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", From b03bf63c61b4d468ece7a6a0864a7b5fc9b5deb1 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 26 Sep 2024 21:42:39 -0700 Subject: [PATCH 144/156] Ok it builds now, but needs manual testing --- .../bluemap/HiresTileModelAccessor.java | 6 ++--- .../bluemap/MixinHiresModelManager.java | 25 +++++++++++-------- .../mixin/mod_compat/bluemap/MixinWorld.java | 2 +- .../MixinAbstractContraptionEntity.java | 2 +- .../MixinPitchOrientedContraptionEntity.java | 2 +- fabric/gradle.properties | 2 +- .../create/client/MixinTrackBlockOutline.java | 4 +-- forge/gradle.properties | 2 +- .../create/client/MixinTrackBlockOutline.java | 4 +-- .../mekanism/MixinRadiationManager.java | 2 +- 10 files changed, 28 insertions(+), 23 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/HiresTileModelAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/HiresTileModelAccessor.java index f08d39ee1..ff9e50702 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/HiresTileModelAccessor.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/HiresTileModelAccessor.java @@ -1,15 +1,15 @@ package org.valkyrienskies.mod.mixin.mod_compat.bluemap; -import de.bluecolored.bluemap.core.map.hires.HiresTileModel; +import de.bluecolored.bluemap.core.map.hires.TileModel; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.gen.Accessor; -@Mixin(HiresTileModel.class) +@Mixin(TileModel.class) @Pseudo public interface HiresTileModelAccessor { @Accessor("position") - double[] getPositions(); + float[] getPositions(); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinHiresModelManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinHiresModelManager.java index 0edc61f5a..ecd14c2a0 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinHiresModelManager.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinHiresModelManager.java @@ -4,7 +4,7 @@ import de.bluecolored.bluemap.core.map.TileMetaConsumer; import de.bluecolored.bluemap.core.map.hires.HiresModelManager; import de.bluecolored.bluemap.core.map.hires.HiresModelRenderer; -import de.bluecolored.bluemap.core.map.hires.HiresTileModel; +import de.bluecolored.bluemap.core.map.hires.TileModel; import de.bluecolored.bluemap.core.world.World; import org.joml.Matrix4dc; import org.joml.Vector3d; @@ -26,11 +26,11 @@ public class MixinHiresModelManager { @Redirect( remap = false, method = "render", - at = @At(value = "INVOKE", target = "Lde/bluecolored/bluemap/core/map/hires/HiresModelRenderer;render(Lde/bluecolored/bluemap/core/world/World;Lcom/flowpowered/math/vector/Vector3i;Lcom/flowpowered/math/vector/Vector3i;Lde/bluecolored/bluemap/core/map/hires/HiresTileModel;Lde/bluecolored/bluemap/core/map/TileMetaConsumer;)V") + at = @At(value = "INVOKE", target = "Lde/bluecolored/bluemap/core/map/hires/HiresModelRenderer;render(Lde/bluecolored/bluemap/core/world/World;Lcom/flowpowered/math/vector/Vector3i;Lcom/flowpowered/math/vector/Vector3i;Lde/bluecolored/bluemap/core/map/hires/TileModel;Lde/bluecolored/bluemap/core/map/TileMetaConsumer;)V") ) void renderModel(final HiresModelRenderer instance, final World world, final Vector3i min, final Vector3i max, - final HiresTileModel model, final TileMetaConsumer tmc + final TileModel model, final TileMetaConsumer tmc ) { final var aabb = new AABBd( min.getX(), min.getY(), min.getZ(), @@ -82,18 +82,23 @@ void renderModel(final HiresModelRenderer instance, final World world, } @Unique - private void valkyrienskies$transformModel(final int start, final int end, final HiresTileModel model, final Vector3dc preTranslation, final Vector3dc postTranslation, final Matrix4dc transform) { + private void valkyrienskies$transformModel(final int start, final int end, final TileModel model, final Vector3dc preTranslation, final Vector3dc postTranslation, final Matrix4dc transform) { final var positions = ((HiresTileModelAccessor) model).getPositions(); for(int face = start; face < end; ++face) { for(int i = 0; i < 3; ++i) { final int index = face * 9 + i * 3; - final double x = positions[index] + preTranslation.x(); - final double y = positions[index + 1] + preTranslation.y(); - final double z = positions[index + 2] + preTranslation.z(); - positions[index] = (x * transform.m00()) + (y * transform.m10()) + (z * transform.m20()) + transform.m30() + postTranslation.x(); - positions[index + 1] = (x * transform.m01()) + (y * transform.m11()) + (z * transform.m21()) + transform.m31() + postTranslation.y(); - positions[index + 2] = (x * transform.m02()) + (y * transform.m12()) + (z * transform.m22()) + transform.m32() + postTranslation.z(); + final double x = ((double) positions[index]) + preTranslation.x(); + final double y = ((double) positions[index + 1]) + preTranslation.y(); + final double z = ((double) positions[index + 2]) + preTranslation.z(); + + final double newX = (x * transform.m00()) + (y * transform.m10()) + (z * transform.m20()) + transform.m30() + postTranslation.x(); + final double newY = (x * transform.m01()) + (y * transform.m11()) + (z * transform.m21()) + transform.m31() + postTranslation.y(); + final double newZ = (x * transform.m02()) + (y * transform.m12()) + (z * transform.m22()) + transform.m32() + postTranslation.z(); + + positions[index] = (float) newX; + positions[index + 1] = (float) newY; + positions[index + 2] = (float) newZ; } } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinWorld.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinWorld.java index db7538349..d8e332abd 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinWorld.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/bluemap/MixinWorld.java @@ -1,6 +1,6 @@ package org.valkyrienskies.mod.mixin.mod_compat.bluemap; -import de.bluecolored.bluemap.core.mca.MCAWorld; +import de.bluecolored.bluemap.core.world.mca.MCAWorld; import java.nio.file.Path; import java.util.Objects; import net.minecraft.world.level.Level; 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 index bd0c50537..5639ab068 100644 --- 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 @@ -96,7 +96,7 @@ public StructureTransform getStructureTransform() { @Nullable @Override public ShipMountedToData provideShipMountedToData(@NotNull final Entity passenger, @Nullable final Float partialTicks) { - final LoadedShip shipObjectEntityMountedTo = VSGameUtilsKt.getShipObjectManagingPos(passenger.level, toJOML(this.position())); + final LoadedShip shipObjectEntityMountedTo = VSGameUtilsKt.getShipObjectManagingPos(passenger.level(), toJOML(this.position())); if (shipObjectEntityMountedTo == null) return null; final Vector3dc mountedPosInShip = toJOML(this.getPassengerPosition(passenger, partialTicks == null ? 1 : partialTicks)); 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 index 66195ea48..a23ad73d5 100644 --- 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 @@ -53,7 +53,7 @@ protected void vsProcesssRiderPositionHook( @Inject(method="getPassengerPosition", at = @At("RETURN"), cancellable = true, remap = false) protected void vsGetPassengerPosition(Entity passenger, float partialTicks, CallbackInfoReturnable cir) { - if (VSGameUtilsKt.getShipObjectManagingPos(passenger.level, toJOML(this.position())) != null) { + if (VSGameUtilsKt.getShipObjectManagingPos(passenger.level(), toJOML(this.position())) != null) { cir.setReturnValue(cir.getReturnValue().add(0,0.1,0)); } } diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 441c691ec..a47ab01a3 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -26,7 +26,7 @@ no_indium_version=1.1.0+1.20 sodium_version = mc1.20.1-0.5.8 # https://modrinth.com/mod/cc-tweaked/version/Zoo9N9Dv -cc_tweaked_version = 1.113.1 +cc_tweaked_version = 1.113.1-fabric kotlin_fabric_version = 1.10.10+kotlin.1.9.10 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 index 535f54ba1..10f63988f 100644 --- 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 @@ -77,7 +77,7 @@ private static PoseStack redirectTransformStackTranslate(final PoseStack ms) { ms.translate(worldVec.x - valkyrienskies$cameraVec3.x, worldVec.y - valkyrienskies$cameraVec3.y, worldVec.z - valkyrienskies$cameraVec3.z); - ms.mulPose(VectorConversionsMCKt.toMinecraft(rotation)); + ms.mulPose(VectorConversionsMCKt.toFloat(rotation)); ms.translate(-.5, -.125f, -.5); } } @@ -96,7 +96,7 @@ private static BlockPos modIsWithinBounds(final BlockPos blockPos) { if (level != null) { final Ship ship; if ((ship = VSGameUtilsKt.getShipManagingPos(level, blockPos)) != null) { - return new BlockPos(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld() + return BlockPos.containing(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld() .transformPosition(VectorConversionsMCKt.toJOMLD(blockPos)))); } } diff --git a/forge/gradle.properties b/forge/gradle.properties index 5471ecadc..99ddb0120 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -10,7 +10,7 @@ cloth_config_version = 11.1.106 create_version = 0.5.1.e-22 flywheel_version = 0.6.10-7 registrate_version = MC1.20-1.3.3 -cc_tweaked_version = 1.109.0 +cc_tweaked_version = 1.109.0-forge #Extra # https://modrinth.com/mod/tis3d/version/MC1.19.2-forge-1.7.4 tis3d_version = MC1.20.1-forge-1.7.5 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 index 38cc2b6ed..aeaddd5f8 100644 --- 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 @@ -72,7 +72,7 @@ private static PoseStack redirectTransformStackTranslate(final PoseStack ms) { ms.translate(worldVec.x - valkyrienskies$cameraVec3.x, worldVec.y - valkyrienskies$cameraVec3.y, worldVec.z - valkyrienskies$cameraVec3.z); - ms.mulPose(VectorConversionsMCKt.toMinecraft(rotation)); + ms.mulPose(VectorConversionsMCKt.toFloat(rotation)); ms.translate(-.5, -.125f, -.5); } } @@ -91,7 +91,7 @@ private static BlockPos modIsWithinBounds(final BlockPos blockPos) { if (level != null) { final Ship ship; if ((ship = VSGameUtilsKt.getShipManagingPos(level, blockPos)) != null) { - return new BlockPos(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld() + return BlockPos.containing(VectorConversionsMCKt.toMinecraft(ship.getShipToWorld() .transformPosition(VectorConversionsMCKt.toJOMLD(blockPos)))); } } 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); } } From 8d1bb401d4351b6307130239229d83adda0fc441 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 26 Sep 2024 22:23:48 -0700 Subject: [PATCH 145/156] It do run now tho :running: --- fabric/build.gradle | 10 +- .../trackOutlines/MixinTrackBlockOutline.java | 134 ------------------ .../valkyrienskies-fabric.mixins.json | 1 - forge/build.gradle | 6 +- .../trackOutlines/MixinTrackBlockOutline.java | 128 ----------------- .../valkyrienskies-forge.mixins.json | 1 - 6 files changed, 10 insertions(+), 270 deletions(-) delete mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java delete mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java diff --git a/fabric/build.gradle b/fabric/build.gradle index 0656e9102..e009120ce 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -72,13 +72,13 @@ dependencies { include("com.fasterxml:classmate:1.5.1") implementation("com.fasterxml:classmate:1.5.1") - // CC Restitched - //modImplementation("curse.maven:cc-restitched-462672:3908334"){ - // exclude module: "jsonschema.module.addon" - //} // CC Restitched - modImplementation("maven.modrinth:cc-tweaked:${cc_tweaked_version}") + modCompileOnly("maven.modrinth:cc-tweaked:${cc_tweaked_version}") + + // EMF compat + modImplementation("curse.maven:entity-model-features-844662:5696901") + modImplementation("curse.maven:entity-texture-features-fabric-568563:5697084") // Create compat modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java deleted file mode 100644 index 83ad26a3a..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java +++ /dev/null @@ -1,134 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create.client.trackOutlines; - -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.toFloat(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 BlockPos.containing(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/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 5683e9c76..a94f08387 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -7,7 +7,6 @@ "compat.create.MixinBlocks", "compat.create.MixinChuteBlockEntity", "compat.create.MixinControlledContraptionEntity", - "compat.create.client.trackOutlines.MixinTrackBlockOutline", "compat.create.client.MixinTrackBlockOutline", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", diff --git a/forge/build.gradle b/forge/build.gradle index f0c093699..e07ddb2c9 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -74,11 +74,15 @@ dependencies { // Weather2 1.20.1 modImplementation("curse.maven:weather-storms-tornadoes-237746:5244118") - modImplementation("curse.maven:coroutil-237749:5010129") + modImplementation("curse.maven:coroutil-237749:5096038") // CC Tweaked modCompileOnly("maven.modrinth:cc-tweaked:${cc_tweaked_version}") + // EMF compat + modImplementation("curse.maven:entity-model-features-844662:5696899") + modImplementation("curse.maven:entity-texture-features-fabric-568563:5697083") + modCompileOnly("maven.modrinth:create-utilities:0.2.0+1.20.1") modImplementation("teamreborn:energy:${energy_version}") { transitive = false diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java deleted file mode 100644 index de52ce15b..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/trackOutlines/MixinTrackBlockOutline.java +++ /dev/null @@ -1,128 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create.client.trackOutlines; - -import com.llamalad7.mixinextras.sugar.Local; -import com.mojang.blaze3d.vertex.PoseStack; -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.Block; -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.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(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/phys/Vec3;)V", - at = @At(value = "INVOKE", - target = "Lcom/simibubi/create/content/trains/track/TrackBlockOutline$BezierPointSelection;angles()Lnet/minecraft/world/phys/Vec3;"), remap = false) - private static void harvestDrawCurveSelection(final PoseStack ms, final MultiBufferSource buffer, final Vec3 camera, final CallbackInfo ci, @Local - final BezierPointSelection result) { - valkyrienskies$cameraVec3 = camera; - valkyrienskies$vec = result.vec(); - valkyrienskies$angles = result.angles(); - } - - @ModifyArg(method = "drawCurveSelection(Lcom/mojang/blaze3d/vertex/PoseStack;Lnet/minecraft/client/renderer/MultiBufferSource;Lnet/minecraft/world/phys/Vec3;)V", - 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.toFloat(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 BlockPos.containing(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(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/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index aaec6d70f..07125e96e 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -7,7 +7,6 @@ "compat.create.MixinBlocks", "compat.create.MixinChuteBlockEntity", "compat.create.MixinControlledContraptionEntity", - "compat.create.client.trackOutlines.MixinTrackBlockOutline", "compat.immersivengineering.MixinBlockEntityInventory", "compat.integrateddynamics.MixinVoxelShapeComponents", "compat.modular_routers.MixinRouterMenu", From edf7675870e9671cf06d7ad6eb723131b48ff0ea Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 26 Sep 2024 22:42:37 -0700 Subject: [PATCH 146/156] Re-enabled Weather2Compat --- .../valkyrienskies/mod/compat/Weather2Compat.kt | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt index 43e827abc..aa2ddb782 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt @@ -1,7 +1,6 @@ package org.valkyrienskies.mod.compat import net.minecraft.server.level.ServerLevel -/* import org.joml.Vector3d import org.valkyrienskies.core.api.ships.getAttachment import org.valkyrienskies.mod.common.config.VSGameConfig @@ -9,13 +8,10 @@ import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.GameTickForceApplier import org.valkyrienskies.mod.common.util.toMinecraft import weather2.ServerTickHandler -import weather2.weathersystem.storm.StormObject= - */ +import weather2.weathersystem.storm.StormObject object Weather2Compat { - // Weather mod is not on 1.19.2, so it must be disabled! fun tick(level: ServerLevel) { - /* val mgr = ServerTickHandler .getWeatherManagerFor(level.dimension()) @@ -42,7 +38,8 @@ object Weather2Compat { motion, mass.toFloat(), windMult, - windMax + windMax, + true, ) fun applyForcePlusMotion() { @@ -65,7 +62,10 @@ object Weather2Compat { pos, forcePlusMotion, false, - stormDampen + stormDampen, + stormDampen, + false, + 0.0f, ) applyForcePlusMotion() @@ -73,6 +73,5 @@ object Weather2Compat { } } } - */ } } From ffeeee68b87f27039bf5d08ef5afab823f0405fc Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Fri, 27 Sep 2024 01:07:41 -0700 Subject: [PATCH 147/156] Delete common/src/main/kotlin/org/valkyrienskies/mod/api/VsAPI.kt --- .../org/valkyrienskies/mod/api/VsAPI.kt | 56 ------------------- 1 file changed, 56 deletions(-) delete mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api/VsAPI.kt diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api/VsAPI.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api/VsAPI.kt deleted file mode 100644 index 270bf4ebc..000000000 --- a/common/src/main/kotlin/org/valkyrienskies/mod/api/VsAPI.kt +++ /dev/null @@ -1,56 +0,0 @@ -package org.valkyrienskies.mod.api - -import net.minecraft.client.gui.screens.Screen -import net.minecraft.client.multiplayer.ClientLevel -import net.minecraft.core.BlockPos -import net.minecraft.world.level.ChunkPos -import net.minecraft.world.level.Level -import net.minecraft.server.level.ServerLevel -import net.minecraft.world.entity.Entity - -import org.jetbrains.annotations.ApiStatus.* -import org.valkyrienskies.core.api.VsCoreApi -import org.valkyrienskies.core.api.event.ListenableEvent -import org.valkyrienskies.core.api.ships.* -import org.valkyrienskies.mod.api.events.PostRenderShipEvent -import org.valkyrienskies.mod.api.events.PreRenderShipEvent -import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent - -@NonExtendable -interface VsApi : VsCoreApi { - - /** - * This event gets called when it's time to register physics block states for Minecraft block states. - */ - @get:Experimental - val registerBlockStateEvent: ListenableEvent - - @get:Experimental - val preRenderShipEvent: ListenableEvent - - @get:Experimental - val postRenderShipEvent: ListenableEvent - - fun isShipMountingEntity(entity: Entity): Boolean - - @Deprecated(message = "The legacy VS config system will be replaced soon. " + - "Migrate to another config library, or the new system when it's released. ") - fun createConfigScreenLegacy(parent: Screen, vararg configs: Class<*>): Screen - - /** - * Get the ship with the chunk claim that contains [pos], if it exists. - * - * If either parameter is null, this will return null. - * - * @param level The [Level] to look for the ship in. If [level] is a - * [ServerLevel], this will return a [ServerShip]. If [level] is a - * [ClientLevel], this will return a [ClientShip]. - * - * @param pos A block position in the Shipyard - */ - fun getShipManagingBlock(level: Level?, pos: BlockPos?): Ship? - - fun getShipManagingChunk(level: Level?, pos: ChunkPos?): Ship? - - fun getShipManagingChunk(level: Level?, chunkX: Int, chunkZ: Int): Ship? -} From b48dab2bdb66cc85ff26350f69fc65b6f1751c61 Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Fri, 27 Sep 2024 01:08:27 -0700 Subject: [PATCH 148/156] Delete common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VSApiImpl.kt --- .../mod/api_impl/events/VSApiImpl.kt | 44 ------------------- 1 file changed, 44 deletions(-) delete mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VSApiImpl.kt diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VSApiImpl.kt b/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VSApiImpl.kt deleted file mode 100644 index 3749d133e..000000000 --- a/common/src/main/kotlin/org/valkyrienskies/mod/api_impl/events/VSApiImpl.kt +++ /dev/null @@ -1,44 +0,0 @@ -package org.valkyrienskies.mod.api_impl.events - -import net.minecraft.client.gui.screens.Screen -import net.minecraft.core.BlockPos -import net.minecraft.world.entity.Entity -import net.minecraft.world.level.ChunkPos -import net.minecraft.world.level.Level -import org.valkyrienskies.core.api.ships.Ship -import org.valkyrienskies.core.util.events.EventEmitterImpl -import org.valkyrienskies.mod.api.VsApi -import org.valkyrienskies.mod.api.events.PostRenderShipEvent -import org.valkyrienskies.mod.api.events.PreRenderShipEvent -import org.valkyrienskies.mod.api.events.RegisterBlockStateEvent -import org.valkyrienskies.mod.common.entity.ShipMountingEntity -import org.valkyrienskies.mod.common.getShipManagingPos -import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig - -class VsApiImpl : VsApi { - - override val registerBlockStateEvent = EventEmitterImpl() - override val preRenderShipEvent = EventEmitterImpl() - override val postRenderShipEvent = EventEmitterImpl() - - override fun isShipMountingEntity(entity: Entity): Boolean { - return entity is ShipMountingEntity - } - - override fun createConfigScreenLegacy(parent: Screen, vararg configs: Class<*>): Screen { - return VSClothConfig.createConfigScreenFor(parent, *configs) - } - - - override fun getShipManagingBlock(level: Level?, pos: BlockPos?): Ship? { - return pos?.let { level?.getShipManagingPos(it) } - } - - override fun getShipManagingChunk(level: Level?, pos: ChunkPos?): Ship? { - return pos?.let { level?.getShipManagingPos(it) } - } - - override fun getShipManagingChunk(level: Level?, chunkX: Int, chunkZ: Int): Ship? { - return level?.getShipManagingPos(chunkX, chunkZ) - } -} From fe1b77de29ee87d7f580863b601a375b62f0416a Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 27 Sep 2024 01:53:50 -0700 Subject: [PATCH 149/156] Made EMF and ETF compileOnly so that servers can run --- .../mod/mixin/ValkyrienCommonMixinConfigPlugin.java | 6 ++++++ fabric/build.gradle | 4 ++-- forge/build.gradle | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) 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 8baef82ba..5e7d3d55a 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java @@ -83,6 +83,12 @@ public boolean shouldApplyMixin(final String s, final String mixinClassName) { return false; } } + // Only load this mixin when ETF is installed + if (mixinClassName.equals("org.valkyrienskies.mod.mixin.mod_compat.etf.MixinBlockEntity")) { + if (!classExists("traben.entity_texture_features.utils.ETFEntity")) { + return false; + } + } return true; } diff --git a/fabric/build.gradle b/fabric/build.gradle index e009120ce..da7bdc668 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -77,8 +77,8 @@ dependencies { modCompileOnly("maven.modrinth:cc-tweaked:${cc_tweaked_version}") // EMF compat - modImplementation("curse.maven:entity-model-features-844662:5696901") - modImplementation("curse.maven:entity-texture-features-fabric-568563:5697084") + modCompileOnly("curse.maven:entity-model-features-844662:5696901") + modCompileOnly("curse.maven:entity-texture-features-fabric-568563:5697084") // Create compat modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { diff --git a/forge/build.gradle b/forge/build.gradle index e07ddb2c9..91998b061 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -80,8 +80,8 @@ dependencies { modCompileOnly("maven.modrinth:cc-tweaked:${cc_tweaked_version}") // EMF compat - modImplementation("curse.maven:entity-model-features-844662:5696899") - modImplementation("curse.maven:entity-texture-features-fabric-568563:5697083") + modCompileOnly("curse.maven:entity-model-features-844662:5696899") + modCompileOnly("curse.maven:entity-texture-features-fabric-568563:5697083") modCompileOnly("maven.modrinth:create-utilities:0.2.0+1.20.1") modImplementation("teamreborn:energy:${energy_version}") { From 5beb174ba23d1a0d8a62306d2b11c77841fb0de3 Mon Sep 17 00:00:00 2001 From: Ictoan42 <62564272+Ictoan42@users.noreply.github.com> Date: Fri, 27 Sep 2024 09:16:21 +0000 Subject: [PATCH 150/156] Twilight Forest compatibility (#963) * Compat fix for twilight forest * Add mixins to prevent structure generation --------- Co-authored-by: StewStrong <83003027+StewStrong@users.noreply.github.com> --- build.gradle | 1 + forge/build.gradle | 3 + forge/gradle.properties | 3 + .../ChunkGeneratorTwilightMixin.java | 79 +++++++++++++++++++ .../mixin/compat/twilightforest/README.MD | 7 ++ .../valkyrienskies-forge.mixins.json | 1 + 6 files changed, 94 insertions(+) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/ChunkGeneratorTwilightMixin.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/README.MD diff --git a/build.gradle b/build.gradle index 0a5ab5923..26fcc2f63 100644 --- a/build.gradle +++ b/build.gradle @@ -109,6 +109,7 @@ subprojects { name = 'tterrag maven' url = 'https://maven.tterrag.com/' } + maven { url = "https://modmaven.dev/" } // Twilight Forest maven { url = "https://api.modrinth.com/maven" } // LazyDFU, Suggestion Tweaker, Create Big Cannons maven { url = "https://maven.shedaniel.me/" } // Cloth Config, REI maven { url "https://maven.architectury.dev/" } diff --git a/forge/build.gradle b/forge/build.gradle index 91998b061..bd1df6b35 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -67,6 +67,9 @@ dependencies { //modCompileOnly("curse.maven:rubidium-574856:4024781") modCompileOnly("maven.modrinth:embeddium:${embeddium_version}") + // Twilight Forest + modImplementation("teamtwilight:twilightforest:${twilightforest_version}:universal") + // Create compat modImplementation("com.simibubi.create:create-${minecraft_version}:${create_version}:slim") { transitive = false } modImplementation("com.jozufozu.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}") diff --git a/forge/gradle.properties b/forge/gradle.properties index 99ddb0120..fba90cc92 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -10,6 +10,9 @@ cloth_config_version = 11.1.106 create_version = 0.5.1.e-22 flywheel_version = 0.6.10-7 registrate_version = MC1.20-1.3.3 + +# https://modmaven.dev/teamtwilight/twilightforest/ +twilightforest_version = 4.3.2145 cc_tweaked_version = 1.109.0-forge #Extra # https://modrinth.com/mod/tis3d/version/MC1.19.2-forge-1.7.4 diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/ChunkGeneratorTwilightMixin.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/ChunkGeneratorTwilightMixin.java new file mode 100644 index 000000000..4a2502a3f --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/ChunkGeneratorTwilightMixin.java @@ -0,0 +1,79 @@ +package org.valkyrienskies.mod.forge.mixin.compat.twilightforest; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Holder; +import net.minecraft.core.HolderSet; +import net.minecraft.core.RegistryAccess; +import net.minecraft.server.level.ServerLevel; +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.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkGeneratorStructureState; +import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; +import net.minecraft.world.level.levelgen.NoiseSettings; +import net.minecraft.world.level.levelgen.RandomState; +import net.minecraft.world.level.levelgen.blending.Blender; +import net.minecraft.world.level.levelgen.structure.Structure; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; +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.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.valkyrienskies.mod.common.VS2ChunkAllocator; +import twilightforest.world.components.chunkgenerators.ChunkGeneratorTwilight; + +@Mixin(ChunkGeneratorTwilight.class) +public class ChunkGeneratorTwilightMixin { + @Shadow + @Final + protected Holder noiseGeneratorSettings; + + @Inject(method = "getBaseColumn", at = @At("HEAD"), cancellable = true) + private void preGetBaseColumn(int x, int y, LevelHeightAccessor level, RandomState random, CallbackInfoReturnable cir) { + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(x, y)) { + final NoiseSettings ns = this.noiseGeneratorSettings.value().noiseSettings(); + final int k = Math.max(ns.minY(), level.getMinBuildHeight()); + cir.setReturnValue(new NoiseColumn(k, new BlockState[0])); + } + } + + @Inject(method = "buildSurface", at = @At("HEAD"), cancellable = true) + private void preBuildSurface(WorldGenRegion world, StructureManager manager, RandomState random, ChunkAccess chunk, CallbackInfo ci) { + final ChunkPos chunkPos = chunk.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + ci.cancel(); + } + } + + @Inject(method = "fillFromNoise", at = @At("HEAD"), cancellable = true) + private void preFillFromNoise(Executor executor, Blender blender, RandomState random, StructureManager structureManager, ChunkAccess chunk, CallbackInfoReturnable> cir) { + final ChunkPos chunkPos = chunk.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + cir.setReturnValue(CompletableFuture.completedFuture(chunk)); + } + } + + @Inject(method = "createStructures", at = @At("HEAD"), cancellable = true) + private void preCreateStructures(RegistryAccess access, ChunkGeneratorStructureState state, StructureManager manager, ChunkAccess chunk, StructureTemplateManager templateManager, CallbackInfo ci) { + final ChunkPos chunkPos = chunk.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + ci.cancel(); + } + } + + @Inject(method = "findNearestMapStructure", at = @At("HEAD"), cancellable = true) + private void preFindNearestMapStructure(ServerLevel level, HolderSet targetStructures, BlockPos pos, int searchRadius, boolean skipKnownStructures, CallbackInfoReturnable cir) { + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(pos.getX() >> 4, pos.getZ() >> 4)) { + cir.setReturnValue(null); + } + } +} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/README.MD b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/README.MD new file mode 100644 index 000000000..0c5ecd121 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/twilightforest/README.MD @@ -0,0 +1,7 @@ +Just a smidgen of compatibility code for twilight forest + +- ChunkGeneratorTwilightMixin + - Fixes world generation not being cancelled within the shipyard in the + twilight forest. TF uses its own ChunkGenerator implementation but it has + all the same methods as the vanilla NoiseBasedChunkGenerator so the same + mixins work. diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 07125e96e..f98e1c0fe 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -14,6 +14,7 @@ "compat.tfc.MixinTFCChunkGenerator", "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", + "compat.twilightforest.ChunkGeneratorTwilightMixin", "feature.forge_interact.MixinIForgePlayer", "feature.water_in_ships_entity.MixinEntity", "feature.shipyard_entities.MixinPersistentEntitySectionManager", From 875c06a78bb02d1a3d9b84737f689017a5aa6fc3 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 28 May 2024 18:40:30 -0400 Subject: [PATCH 151/156] bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 95ebb7266..0e501bc88 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.20.1 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-120 -mod_version=2.3.0-beta.6 +mod_version=2.5.0-beta.1 maven_group=org.valkyrienskies.mod # https://www.curseforge.com/minecraft/mc-mods/architectury-api/files/ From 8be78004d5481b6f56e2a4773452747956d779f3 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 27 Sep 2024 21:28:15 -0400 Subject: [PATCH 152/156] Add Immersive Portals compatibility --- build.gradle | 1 + common/build.gradle | 4 + common/gradle.properties | 1 + .../ValkyrienCommonMixinConfigPlugin.java | 14 ++ .../client/world/MixinClientChunkCache.java | 14 +- .../MixinIpNewChunkTrackingGraph.java | 62 ++++++++ .../MixinMyBuiltChunkStorage.java | 139 ++++++++++++++++++ .../MixinVisibleSectionDiscovery.java | 36 +++++ .../mod_compat/immersive_portals/README.md | 1 + .../optifine_vanilla/MixinLevelRenderer.java | 5 +- .../MixinLevelRendererVanilla.java | 45 +++--- .../render/LevelRendererVanillaDuck.java | 9 ++ .../valkyrienskies/mod/compat/LoadedMods.kt | 3 + .../valkyrienskies-common.mixins.json | 13 +- fabric/build.gradle | 4 + fabric/gradle.properties | 1 + forge/build.gradle | 1 + .../mixin/ValkyrienSkiesForgeMixinPlugin.java | 63 ++++++++ .../mixinbooster/MixinIForgePlayer.java | 59 ++++++++ .../forge/mixin/compat/mixinbooster/README.md | 4 + .../valkyrienskies-forge.mixins.json | 6 +- 21 files changed, 449 insertions(+), 36 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinIpNewChunkTrackingGraph.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinMyBuiltChunkStorage.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinVisibleSectionDiscovery.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/README.md create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/client/render/LevelRendererVanillaDuck.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/ValkyrienSkiesForgeMixinPlugin.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mixinbooster/MixinIForgePlayer.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mixinbooster/README.md diff --git a/build.gradle b/build.gradle index 26fcc2f63..39adb1e01 100644 --- a/build.gradle +++ b/build.gradle @@ -119,6 +119,7 @@ subprojects { maven { url = "https://maven.tterrag.com/" } // Registrate, Forge Create and Flywheel maven { url = "https://maven.cafeteria.dev/releases" } // Fake Player API maven { url = "https://maven.jamieswhiteshirt.com/libs-release" } // Reach Entity Attributes + maven { url = "https://jitpack.io"} } maven { name = "Valkyrien Skies Internal" diff --git a/common/build.gradle b/common/build.gradle index 7f8f55e72..e8e216ed8 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -47,6 +47,10 @@ dependencies { //Bluemap fabric 1.20.1 modCompileOnly("curse.maven:bluemap-406463:5555756") + + modCompileOnly("com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:${immptl_version}") + modCompileOnly("com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:${immptl_version}") + modCompileOnly("com.github.iPortalTeam.ImmersivePortalsMod:build:${immptl_version}") } architectury { diff --git a/common/gradle.properties b/common/gradle.properties index a61644dcc..7069609b8 100644 --- a/common/gradle.properties +++ b/common/gradle.properties @@ -7,3 +7,4 @@ cloth_config_version = 11.1.106 # https://modrinth.com/mod/sodium/versions sodium_version = mc1.20.1-0.5.8 +immptl_version=v3.3.9-mc1.20.1 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 5e7d3d55a..c102db6e3 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/ValkyrienCommonMixinConfigPlugin.java @@ -8,6 +8,7 @@ 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.LoadedMods; import org.valkyrienskies.mod.compat.VSRenderer; /** @@ -59,6 +60,17 @@ public String getRefMapperConfig() { @Override public boolean shouldApplyMixin(final String s, final String mixinClassName) { final VSRenderer renderer = getVSRenderer(); + + if (mixinClassName.contains("org.valkyrienskies.mod.mixin.mod_compat.immersive_portals")) { + return LoadedMods.getImmersivePortals(); // Only load this mixin if immersive portals is present + } + if ( + mixinClassName.equals("org.valkyrienskies.mod.mixin.client.world.MixinClientChunkCache") || + mixinClassName.equals("org.valkyrienskies.mod.mixin.mod_compat.vanilla_renderer.MixinViewAreaVanilla") + ) { + return !LoadedMods.getImmersivePortals(); // Only load this if immersive portals is NOT present + } + if (mixinClassName.contains("org.valkyrienskies.mod.mixin.mod_compat.sodium")) { return renderer == VSRenderer.SODIUM; } @@ -74,6 +86,7 @@ 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")) { @@ -83,6 +96,7 @@ public boolean shouldApplyMixin(final String s, final String mixinClassName) { return false; } } + // Only load this mixin when ETF is installed if (mixinClassName.equals("org.valkyrienskies.mod.mixin.mod_compat.etf.MixinBlockEntity")) { if (!classExists("traben.entity_texture_features.utils.ETFEntity")) { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientChunkCache.java b/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientChunkCache.java index 28a764996..d76bd4d57 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientChunkCache.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/client/world/MixinClientChunkCache.java @@ -79,13 +79,15 @@ private void preLoadChunkFromPacket(final int x, final int z, @Inject(method = "drop", at = @At("HEAD"), cancellable = true) public void preUnload(final int chunkX, final int chunkZ, final CallbackInfo ci) { - vs$shipChunks.remove(ChunkPos.asLong(chunkX, chunkZ)); - if (ValkyrienCommonMixinConfigPlugin.getVSRenderer() != VSRenderer.SODIUM) { - ((IVSViewAreaMethods) ((LevelRendererAccessor) ((ClientLevelAccessor) level).getLevelRenderer()).getViewArea()) - .unloadChunk(chunkX, chunkZ); + if (VSGameUtilsKt.isChunkInShipyard(level, chunkX, chunkZ)) { + vs$shipChunks.remove(ChunkPos.asLong(chunkX, chunkZ)); + if (ValkyrienCommonMixinConfigPlugin.getVSRenderer() != VSRenderer.SODIUM) { + ((IVSViewAreaMethods) ((LevelRendererAccessor) ((ClientLevelAccessor) level).getLevelRenderer()).getViewArea()) + .unloadChunk(chunkX, chunkZ); + } + SodiumCompat.onChunkRemoved(this.level, chunkX, chunkZ); + ci.cancel(); } - SodiumCompat.onChunkRemoved(this.level, chunkX, chunkZ); - ci.cancel(); } @Inject( diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinIpNewChunkTrackingGraph.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinIpNewChunkTrackingGraph.java new file mode 100644 index 000000000..d4855139f --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinIpNewChunkTrackingGraph.java @@ -0,0 +1,62 @@ +package org.valkyrienskies.mod.mixin.mod_compat.immersive_portals; + +import com.llamalad7.mixinextras.sugar.Local; +import net.minecraft.server.level.ServerLevel; +import org.joml.primitives.AABBd; +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 qouteall.imm_ptl.core.chunk_loading.ChunkLoader; +import qouteall.imm_ptl.core.chunk_loading.ChunkLoader.ChunkPosConsumer; +import qouteall.imm_ptl.core.chunk_loading.NewChunkTrackingGraph; + +/** + * This mixin ensures that ship chunks are sent to players + */ +@Mixin(NewChunkTrackingGraph.class) +public class MixinIpNewChunkTrackingGraph { + + @Redirect( + method = "updateForPlayer", + at = @At(value = "INVOKE", + target = "Lqouteall/imm_ptl/core/chunk_loading/ChunkLoader;foreachChunkPos(Lqouteall/imm_ptl/core/chunk_loading/ChunkLoader$ChunkPosConsumer;)V") + ) + private static void addShipChunks(final ChunkLoader instance, final ChunkPosConsumer func, @Local final ServerLevel world) { + // region original function + for (int dx = -instance.radius; dx <= instance.radius; dx++) { + for (int dz = -instance.radius; dz <= instance.radius; dz++) { + func.consume( + instance.center.dimension, + instance.center.x + dx, + instance.center.z + dz, + Math.max(Math.abs(dx), Math.abs(dz)) + ); + } + } + // endregion + + // region inject ships + final AABBd box = new AABBd( + (instance.center.x - instance.radius) << 4, + world.getMinBuildHeight(), + (instance.center.z - instance.radius) << 4, + (instance.center.x + instance.radius) << 4, + world.getMaxBuildHeight(), + (instance.center.z + instance.radius) << 4 + ); + for (final Ship ship : VSGameUtilsKt.getShipsIntersecting(world, box)) { + ship.getActiveChunksSet().forEach((x, z) -> { + func.consume( + instance.center.dimension, + x, + z, + 1 // todo: change this? + ); + }); + } + // endregion + } + +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinMyBuiltChunkStorage.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinMyBuiltChunkStorage.java new file mode 100644 index 000000000..a5b7d5d4e --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinMyBuiltChunkStorage.java @@ -0,0 +1,139 @@ +package org.valkyrienskies.mod.mixin.mod_compat.immersive_portals; + +import it.unimi.dsi.fastutil.longs.Long2ObjectMap; +import it.unimi.dsi.fastutil.longs.Long2ObjectMap.Entry; +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import net.minecraft.client.renderer.LevelRenderer; +import net.minecraft.client.renderer.ViewArea; +import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher; +import net.minecraft.client.renderer.chunk.ChunkRenderDispatcher.RenderChunk; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.Level; +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.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.mixinducks.client.render.IVSViewAreaMethods; +import qouteall.imm_ptl.core.render.MyBuiltChunkStorage; + +/** + * Reimplementation of {@link org.valkyrienskies.mod.mixin.mod_compat.vanilla_renderer.MixinViewAreaVanilla} for immersive portals + */ +@Mixin(MyBuiltChunkStorage.class) +public class MixinMyBuiltChunkStorage extends ViewArea implements IVSViewAreaMethods { + + // Maps chunk position to an array of BuiltChunk, indexed by the y value. + @Unique + private final Long2ObjectMap vs$shipRenderChunks = + new Long2ObjectOpenHashMap<>(); + // This creates render chunks + @Unique + private ChunkRenderDispatcher vs$chunkBuilder; + + public MixinMyBuiltChunkStorage(final ChunkRenderDispatcher chunkRenderDispatcher, final Level level, final int i, + final LevelRenderer levelRenderer) { + super(chunkRenderDispatcher, level, i, levelRenderer); + } + + /** + * This mixin stores the [chunkBuilder] object from the constructor. It is used to create new render chunks. + */ + @Inject(method = "", at = @At("TAIL")) + private void postInit(final ChunkRenderDispatcher chunkBuilder, final Level world, final int viewDistance, + final LevelRenderer worldRenderer, final CallbackInfo callbackInfo) { + + this.vs$chunkBuilder = chunkBuilder; + } + + /** + * This mixin creates render chunks for ship chunks. + */ + @Inject(method = "setDirty", at = @At("HEAD"), cancellable = true) + private void preScheduleRebuild(final int x, final int y, final int z, final boolean important, + final CallbackInfo callbackInfo) { + + final int yIndex = y - level.getMinSection(); + + if (yIndex < 0 || yIndex >= chunkGridSizeY) { + return; // Weird, but just ignore it + } + + if (VSGameUtilsKt.isChunkInShipyard(level, x, z)) { + final long chunkPosAsLong = ChunkPos.asLong(x, z); + final ChunkRenderDispatcher.RenderChunk[] renderChunksArray = + vs$shipRenderChunks.computeIfAbsent(chunkPosAsLong, + k -> new ChunkRenderDispatcher.RenderChunk[chunkGridSizeY]); + + if (renderChunksArray[yIndex] == null) { + final ChunkRenderDispatcher.RenderChunk builtChunk = + vs$chunkBuilder.new RenderChunk(0, x << 4, y << 4, z << 4); + renderChunksArray[yIndex] = builtChunk; + } + + renderChunksArray[yIndex].setDirty(important); + + callbackInfo.cancel(); + } + } + + /** + * This mixin allows {@link ViewArea} to return the render chunks for ships. + */ + @Inject(method = "getRenderChunkAt", at = @At("HEAD"), cancellable = true) + private void preGetRenderedChunk(final BlockPos pos, + final CallbackInfoReturnable callbackInfoReturnable) { + 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 + } + + if (VSGameUtilsKt.isChunkInShipyard(level, chunkX, chunkZ)) { + final long chunkPosAsLong = ChunkPos.asLong(chunkX, chunkZ); + final ChunkRenderDispatcher.RenderChunk[] renderChunksArray = vs$shipRenderChunks.get(chunkPosAsLong); + if (renderChunksArray == null) { + callbackInfoReturnable.setReturnValue(null); + return; + } + final ChunkRenderDispatcher.RenderChunk renderChunk = renderChunksArray[chunkY]; + callbackInfoReturnable.setReturnValue(renderChunk); + } + } + + @Override + public void unloadChunk(final int chunkX, final int chunkZ) { + if (VSGameUtilsKt.isChunkInShipyard(level, chunkX, chunkZ)) { + final ChunkRenderDispatcher.RenderChunk[] chunks = + vs$shipRenderChunks.remove(ChunkPos.asLong(chunkX, chunkZ)); + if (chunks != null) { + for (final ChunkRenderDispatcher.RenderChunk chunk : chunks) { + if (chunk != null) { + chunk.releaseBuffers(); + } + } + } + } + } + + /** + * Clear VS ship render chunks so that we don't leak memory + */ + @Inject(method = "releaseAllBuffers", at = @At("HEAD")) + private void postReleaseAllBuffers(final CallbackInfo ci) { + for (final Entry entry : vs$shipRenderChunks.long2ObjectEntrySet()) { + for (final ChunkRenderDispatcher.RenderChunk renderChunk : entry.getValue()) { + if (renderChunk != null) { + renderChunk.releaseBuffers(); + } + } + } + vs$shipRenderChunks.clear(); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinVisibleSectionDiscovery.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinVisibleSectionDiscovery.java new file mode 100644 index 000000000..93ab0cec1 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/MixinVisibleSectionDiscovery.java @@ -0,0 +1,36 @@ +package org.valkyrienskies.mod.mixin.mod_compat.immersive_portals; + +import it.unimi.dsi.fastutil.objects.ObjectArrayList; +import net.minecraft.client.Camera; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.renderer.LevelRenderer.RenderChunkInfo; +import net.minecraft.client.renderer.culling.Frustum; +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.client.render.LevelRendererVanillaDuck; +import qouteall.imm_ptl.core.render.MyBuiltChunkStorage; +import qouteall.imm_ptl.core.render.VisibleSectionDiscovery; + +/** + * Calls vs$addShipVisibleChunks, since immersive portals injects and cancels a callback preventing + * MixinLevelRendererVanilla from calling it at the right time. + */ +@Mixin(VisibleSectionDiscovery.class) +public class MixinVisibleSectionDiscovery { + + @Inject( + method = "discoverVisibleSections", + at = @At("RETURN") + ) + private static void onDiscoverVisibleSections(ClientLevel world, MyBuiltChunkStorage builtChunks_, Camera camera, + Frustum frustum, ObjectArrayList resultHolder_, CallbackInfo ci) { + + if (!(Minecraft.getInstance().levelRenderer instanceof final LevelRendererVanillaDuck renderer)) return; + + renderer.vs$addShipVisibleChunks(frustum); + + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/README.md b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/README.md new file mode 100644 index 000000000..fc6027ad3 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/immersive_portals/README.md @@ -0,0 +1 @@ +These mixins add compatibility with the Immersive Portals mod 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 8e58f1908..0d258f636 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 @@ -48,7 +48,10 @@ public abstract class MixinLevelRenderer { ) ) private void afterRefresh(final CallbackInfo ci) { - ((ClientChunkCacheDuck) this.level.getChunkSource()).vs$getShipChunks().forEach((pos, chunk) -> { + // This can happen when immersive portals is installed + if (!(this.level.getChunkSource() instanceof final ClientChunkCacheDuck chunks)) return; + + chunks.vs$getShipChunks().forEach((pos, chunk) -> { for (int y = level.getMinSection(); y < level.getMaxSection(); y++) { viewArea.setDirty(ChunkPos.getX(pos), y, ChunkPos.getZ(pos), false); } 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 d6da16c66..a2c9d07f2 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 @@ -11,6 +11,7 @@ import it.unimi.dsi.fastutil.objects.ObjectList; import java.util.ListIterator; import java.util.WeakHashMap; +import net.minecraft.client.Camera; import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.LevelRenderer; @@ -32,6 +33,7 @@ import org.joml.primitives.AABBd; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; @@ -47,16 +49,20 @@ import org.valkyrienskies.mod.mixin.ValkyrienCommonMixinConfigPlugin; import org.valkyrienskies.mod.mixin.accessors.client.render.ViewAreaAccessor; import org.valkyrienskies.mod.mixin.mod_compat.optifine.RenderChunkInfoAccessorOptifine; +import org.valkyrienskies.mod.mixinducks.client.render.LevelRendererVanillaDuck; -@Mixin(LevelRenderer.class) -public abstract class MixinLevelRendererVanilla { +@Mixin(value = LevelRenderer.class, priority = 999) +public abstract class MixinLevelRendererVanilla implements LevelRendererVanillaDuck { @Unique - private final WeakHashMap> shipRenderChunks = new WeakHashMap<>(); + private final WeakHashMap> shipRenderChunks = new WeakHashMap<>(); @Shadow private ClientLevel level; + @Shadow @Final + @Mutable private ObjectArrayList renderChunksInFrustum; + @Shadow private @Nullable ViewArea viewArea; @Shadow @@ -64,7 +70,7 @@ public abstract class MixinLevelRendererVanilla { private Minecraft minecraft; @Unique - private ObjectList renderChunksGeneratedByVanilla = new ObjectArrayList<>(); + private ObjectArrayList renderChunksGeneratedByVanilla = new ObjectArrayList<>(); /** * Fix the distance to render chunks, so that MC doesn't think ship chunks are too far away @@ -105,14 +111,16 @@ private boolean needsFrustumUpdate(final boolean needsFrustumUpdate) { * Add ship render chunks to [renderChunks] */ @Inject( - method = "applyFrustum", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/util/profiling/ProfilerFiller;pop()V" - ) + method = "setupRender", + at = @At("RETURN") ) - private void addShipVisibleChunks( - final Frustum frustum, final CallbackInfo ci) { + private void preSetupRender(final Camera camera, final Frustum frustum, final boolean bl, final boolean bl2, final CallbackInfo ci) { + // This mixin never gets called for IP dimensions, instead we'll call it manually + vs$addShipVisibleChunks(frustum); + } + + @Override + public void vs$addShipVisibleChunks(final Frustum frustum) { renderChunksGeneratedByVanilla = new ObjectArrayList<>(renderChunksInFrustum); final BlockPos.MutableBlockPos tempPos = new BlockPos.MutableBlockPos(); @@ -177,13 +185,16 @@ private void clearShipChunks(final CallbackInfo ci) { value = "INVOKE", target = "Lnet/minecraft/client/renderer/LevelRenderer;renderChunkLayer(Lnet/minecraft/client/renderer/RenderType;Lcom/mojang/blaze3d/vertex/PoseStack;DDDLorg/joml/Matrix4f;)V" ), - method = "*" + method = "renderLevel" ) private void redirectRenderChunkLayer(final LevelRenderer receiver, final RenderType renderType, final PoseStack poseStack, final double camX, final double camY, final double camZ, final Matrix4f matrix4f, final Operation renderChunkLayer) { + final var originalRenderChunks = renderChunksInFrustum; + renderChunksInFrustum = renderChunksGeneratedByVanilla; renderChunkLayer.call(receiver, renderType, poseStack, camX, camY, camZ, matrix4f); + renderChunksInFrustum = originalRenderChunks; VSGameEvents.INSTANCE.getShipsStartRendering().emit(new VSGameEvents.ShipStartRenderEvent( receiver, renderType, poseStack, camX, camY, camZ, matrix4f @@ -208,16 +219,6 @@ private void redirectRenderChunkLayer(final LevelRenderer receiver, }); } - @Redirect( - at = @At( - value = "FIELD", - target = "Lnet/minecraft/client/renderer/LevelRenderer;renderChunksInFrustum:Lit/unimi/dsi/fastutil/objects/ObjectArrayList;" - ), - method = "renderChunkLayer" - ) - private ObjectArrayList redirectRenderChunksInFrustum(final LevelRenderer instance) { - return (ObjectArrayList) renderChunksGeneratedByVanilla; - } @Unique private void renderChunkLayer(final RenderType renderType, final PoseStack poseStack, final double d, diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/client/render/LevelRendererVanillaDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/client/render/LevelRendererVanillaDuck.java new file mode 100644 index 000000000..564f520bb --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/client/render/LevelRendererVanillaDuck.java @@ -0,0 +1,9 @@ +package org.valkyrienskies.mod.mixinducks.client.render; + +import net.minecraft.client.renderer.culling.Frustum; + +public interface LevelRendererVanillaDuck { + + void vs$addShipVisibleChunks(final Frustum frustum); + +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/LoadedMods.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/LoadedMods.kt index 995539262..3a70fb9c6 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/LoadedMods.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/LoadedMods.kt @@ -11,6 +11,9 @@ object LoadedMods { @JvmStatic val weather2 by CompatInfo("weather2.Weather") + @JvmStatic + val immersivePortals by CompatInfo("qouteall.imm_ptl.core.IPModMain") + class CompatInfo(private val className: String) : ReadOnlyProperty { private var isLoaded: Boolean? = null diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index f633e45ff..4fda08e41 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -93,6 +93,7 @@ "mod_compat.create.pr.MixinSeatBlock", "mod_compat.create_big_cannons.MixinPitchOrientedContraptionEntity", "mod_compat.create_utilities.MixinVoidLinkBehaviour", + "mod_compat.immersive_portals.MixinIpNewChunkTrackingGraph", "mod_compat.reachentityattributes.MixinReachEntityAttributes", "server.MinecraftServerAccessor", "server.MixinMinecraftServer", @@ -155,6 +156,7 @@ "mod_compat.create.client.MixinCogwheelBlockItemHitOnShaft", "mod_compat.create.client.MixinContraptionRenderDispatcher", "mod_compat.create.client.MixinContraptionRenderInfo", + "mod_compat.create.client.MixinDeployTool", "mod_compat.create.client.MixinElevatorControlsHandler", "mod_compat.create.client.MixinFilteringRenderer", "mod_compat.create.client.MixinGhostBlockRenderer", @@ -163,19 +165,22 @@ "mod_compat.create.client.MixinMultiplePlacementHelpers", "mod_compat.create.client.MixinOutline", "mod_compat.create.client.MixinPlacementHelpers", + "mod_compat.create.client.MixinSchematicToolBase", + "mod_compat.create.client.MixinSchematicTransformation", "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.emf.MixinEMFAnimationEntityContext", + "mod_compat.etf.MixinBlockEntity", "mod_compat.flywheel.InstancingEngineAccessor", "mod_compat.flywheel.MixinBlockEntityInstanceManager", "mod_compat.flywheel.MixinInstanceManager", "mod_compat.flywheel.MixinInstanceWorld", "mod_compat.flywheel.MixinInstancingEngine", + "mod_compat.immersive_portals.MixinMyBuiltChunkStorage", + "mod_compat.immersive_portals.MixinVisibleSectionDiscovery", "mod_compat.optifine.RenderChunkInfoAccessorOptifine", "mod_compat.optifine_vanilla.MixinLevelRenderer", "mod_compat.sodium.MixinChunkTracker", @@ -185,8 +190,6 @@ "mod_compat.vanilla_renderer.MixinLevelRendererVanilla", "mod_compat.vanilla_renderer.MixinViewAreaVanilla", "mod_compat.vanilla_renderer.RenderChunkInfoAccessor", - "mod_compat.emf.MixinEMFAnimationEntityContext", - "mod_compat.etf.MixinBlockEntity", "realms.MixinRealmsConnect" ], "injectors": { diff --git a/fabric/build.gradle b/fabric/build.gradle index da7bdc668..ca1017bcb 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -96,6 +96,10 @@ dependencies { modCompileOnly("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") modCompileOnly("dev.cafeteria:fake-player-api:${fake_player_api_version}") modCompileOnly("io.github.tropheusj:milk-lib:${milk_lib_version}") + + modCompileOnly("com.github.iPortalTeam.ImmersivePortalsMod:imm_ptl_core:${immptl_version}") + modCompileOnly("com.github.iPortalTeam.ImmersivePortalsMod:q_misc_util:${immptl_version}") + modCompileOnly("com.github.iPortalTeam.ImmersivePortalsMod:build:${immptl_version}") } // Copy the VS common access widener to the generated resources folder diff --git a/fabric/gradle.properties b/fabric/gradle.properties index a47ab01a3..9ad47341d 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -38,3 +38,4 @@ modmenu_version = 7.1.0 # https://linkie.shedaniel.me/dependencies?loader=fabric&version=1.19.2 cloth_config_version = 11.1.106 +immptl_version=v3.3.9-mc1.20.1 diff --git a/forge/build.gradle b/forge/build.gradle index bd1df6b35..b51c33772 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -53,6 +53,7 @@ configurations { dependencies { implementation(annotationProcessor("io.github.llamalad7:mixinextras-common:0.3.5")) implementation(include("io.github.llamalad7:mixinextras-forge:0.3.5")) + annotationProcessor("net.fabricmc:sponge-mixin:0.12.5+mixin.0.8.5") // use fabric mixin so we can write interface injectors (conditionally loaded if mixinbooster is enabled) forge "net.minecraftforge:forge:${rootProject.forge_version}" diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/ValkyrienSkiesForgeMixinPlugin.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/ValkyrienSkiesForgeMixinPlugin.java new file mode 100644 index 000000000..0bd0e2bad --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/ValkyrienSkiesForgeMixinPlugin.java @@ -0,0 +1,63 @@ +package org.valkyrienskies.mod.forge.mixin; + +import java.util.List; +import java.util.Set; +import org.objectweb.asm.tree.ClassNode; +import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin; +import org.spongepowered.asm.mixin.extensibility.IMixinInfo; + +public class ValkyrienSkiesForgeMixinPlugin implements IMixinConfigPlugin { + + private static boolean classExists(final String className) { + try { + Class.forName(className, false, ValkyrienSkiesForgeMixinPlugin.class.getClassLoader()); + return true; + } catch (final ClassNotFoundException ex) { + return false; + } + } + + @Override + public void onLoad(final String s) { + + } + + @Override + public String getRefMapperConfig() { + return ""; + } + + @Override + public boolean shouldApplyMixin(final String s, final String mixinClassName) { + final boolean isMixinBoosterLoaded = classExists("io.github.steelwoolmc.mixintransmog.MixinModlauncherRemapper"); + + if (mixinClassName.contains("org.valkyrienskies.mod.forge.mixin.compat.mixinbooster")) { + return isMixinBoosterLoaded; // Load only if mixinbooster is enabled + } + if (mixinClassName.equals("org.valkyrienskies.mod.forge.mixin.feature.forge_interact.MixinIForgePlayer")) { + return !isMixinBoosterLoaded; // Load only if mixinbooster is not enabled + } + + return true; + } + + @Override + public void acceptTargets(final Set set, final Set set1) { + + } + + @Override + public List getMixins() { + return List.of(); + } + + @Override + public void preApply(final String s, final ClassNode classNode, final String s1, final IMixinInfo iMixinInfo) { + + } + + @Override + public void postApply(final String s, final ClassNode classNode, final String s1, final IMixinInfo iMixinInfo) { + + } +} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mixinbooster/MixinIForgePlayer.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mixinbooster/MixinIForgePlayer.java new file mode 100644 index 000000000..50d46f2c9 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mixinbooster/MixinIForgePlayer.java @@ -0,0 +1,59 @@ +package org.valkyrienskies.mod.forge.mixin.compat.mixinbooster; + +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; +import java.util.Optional; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.common.extensions.IForgePlayer; +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.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.config.VSGameConfig; + +/** + * A variant of {@link org.valkyrienskies.mod.forge.mixin.feature.forge_interact.MixinIForgePlayer} that uses + * injectors to be more compatible with other mods + */ +@Mixin(IForgePlayer.class) +@Pseudo +public interface MixinIForgePlayer { + + @Shadow + Player self(); + + /** + * Include ships in server-side distance check when player interacts with a block. + * + * @return + */ + @ModifyExpressionValue( + method = "canReach(Lnet/minecraft/core/BlockPos;D)Z", + at = @At(value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;atCenterOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;") + ) + default Vec3 replacePosition(final Vec3 original) { + return VSGameUtilsKt.toWorldCoordinates(self().level(), original); + } + + @Inject( + method = "isCloseEnough(Lnet/minecraft/world/entity/Entity;D)Z", + at = @At(value = "HEAD"), + cancellable = true, + remap = false + ) + default void preIsCloseEnough(final Entity entity, final double distance, final CallbackInfoReturnable cir) { + if (VSGameConfig.SERVER.getEnableInteractDistanceChecks() && + VSGameUtilsKt.isBlockInShipyard(entity.level(), entity.blockPosition())) { + final Vec3 eye = this.self().getEyePosition(); + final Vec3 targetCenter = entity.getPosition(1.0F).add(0.0, entity.getBbHeight() / 2.0F, 0.0); + final Optional hit = entity.getBoundingBox().clip(eye, targetCenter); + hit.ifPresent(vec3 -> cir.setReturnValue(VSGameUtilsKt.squaredDistanceBetweenInclShips(this.self().level(), + vec3.x, vec3.y, vec3.z, eye.x, eye.y, eye.z))); + } + } +} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mixinbooster/README.md b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mixinbooster/README.md new file mode 100644 index 000000000..872df9c85 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mixinbooster/README.md @@ -0,0 +1,4 @@ +Contains variants of mixins that only work with fabric mixin +(i.e. mixinbooster installed). These mixins are conditionally enabled only if +mixinbooster is installed by the ValkyrienSkiesForgeMixinPlugin. Otherwise, +less compatible variants are used. diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index f98e1c0fe..129b12639 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -2,6 +2,7 @@ "required": true, "package": "org.valkyrienskies.mod.forge.mixin", "compatibilityLevel": "JAVA_17", + "plugin": "org.valkyrienskies.mod.forge.mixin.ValkyrienSkiesForgeMixinPlugin", "mixins": [ "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", @@ -9,15 +10,16 @@ "compat.create.MixinControlledContraptionEntity", "compat.immersivengineering.MixinBlockEntityInventory", "compat.integrateddynamics.MixinVoxelShapeComponents", - "compat.modular_routers.MixinRouterMenu", "compat.mekanism.MixinRadiationManager", + "compat.mixinbooster.MixinIForgePlayer", + "compat.modular_routers.MixinRouterMenu", "compat.tfc.MixinTFCChunkGenerator", "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", "compat.twilightforest.ChunkGeneratorTwilightMixin", "feature.forge_interact.MixinIForgePlayer", - "feature.water_in_ships_entity.MixinEntity", "feature.shipyard_entities.MixinPersistentEntitySectionManager", + "feature.water_in_ships_entity.MixinEntity", "world.level.block.FireMixin" ], "client": [ From 500230d35ac3be3ded81b764926a672a3aa0da63 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 27 Sep 2024 22:39:45 -0400 Subject: [PATCH 153/156] Fix Sinytra Connector Extras --- .../client/renderer/MixinGameRenderer.java | 14 +++----------- .../valkyrienskies/mod/common/VSGameUtils.kt | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 11 deletions(-) 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 ab7aebbd2..0afd14a9d 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 @@ -94,23 +94,15 @@ 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 vec3, final Operation original) { + return VSGameUtilsKt.squaredDistanceBetweenInclShips(this.minecraft.level, instance, vec3, original); } @Inject(method = "render", at = @At("HEAD")) 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 4e8525774..6fcc20fc5 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.common +import com.llamalad7.mixinextras.injector.wrapoperation.Operation import net.minecraft.client.Minecraft import net.minecraft.client.multiplayer.ClientLevel import net.minecraft.core.BlockPos @@ -124,6 +125,24 @@ val Player.playerWrapper get() = (this as PlayerDuck).vs_getPlayer() fun Entity.squaredDistanceToInclShips(x: Double, y: Double, z: Double) = level().squaredDistanceBetweenInclShips(x, y, z, this.x, this.y, this.z) +/** + * Meant to be used with @WrapOperation to replace distance checks in a compatible way + */ +fun Level?.squaredDistanceBetweenInclShips( + v1: Vec3, + v2: Vec3, + originalDistance: Operation? +): Double { + if (originalDistance == null) { + return squaredDistanceBetweenInclShips(v1.x, v1.y, v1.z, v2.x, v2.y, v2.z) // fast path + } + + val inWorldV1 = toWorldCoordinates(v1) + val inWorldV2 = toWorldCoordinates(v2) + + return originalDistance.call(inWorldV1, inWorldV2) +} + /** * Calculates the squared distance between to points. * x1/y1/z1 are transformed into world coordinates if they are on a ship From ca9fc89aec61dc386e22b47bba8e54d16b60ca2d Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 27 Sep 2024 23:02:07 -0400 Subject: [PATCH 154/156] Remove duplicated CurseMaven repo --- build.gradle | 6 ------ 1 file changed, 6 deletions(-) diff --git a/build.gradle b/build.gradle index 39adb1e01..b3da12d7f 100644 --- a/build.gradle +++ b/build.gradle @@ -87,12 +87,6 @@ subprojects { } catch (UnknownDomainObjectException ignore) {} mavenCentral() - maven { - url "https://cursemaven.com" - content { - includeModule "curse.maven", "kotlinforforge-351264" - } - } if (!project.block_external_repositories) { mavenLocal() maven { From a81efdff0276468492b3e6fa0b2b7836ba1193dd Mon Sep 17 00:00:00 2001 From: alex_s168 <63254202+alex-s168@users.noreply.github.com> Date: Sat, 28 Sep 2024 09:28:53 +0200 Subject: [PATCH 155/156] a (#971) --- .../mod/compat/Weather2Compat.kt | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt index aa2ddb782..816c3e920 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt @@ -56,20 +56,18 @@ object Weather2Compat { applyForcePlusMotion() mgr.getStormsAround(pos, stormRange).forEach { - if (it is StormObject) { - runCatching { // prevent Cannot read field "listLayers" because "this.tornadoFunnelSimple" is null at weather2.weathersystem.storm.StormObject.spinObject(StormObject.java:2503) - forcePlusMotion = it.spinObject( - pos, - forcePlusMotion, - false, - stormDampen, - stormDampen, - false, - 0.0f, - ) + if (it is StormObject && it.tornadoFunnelSimple != null) { + forcePlusMotion = it.spinObject( + pos, + forcePlusMotion, + false, + stormDampen, + stormDampen, + true, + 0.0f, + ) - applyForcePlusMotion() - } + applyForcePlusMotion() } } } From 14fe81bd167c66e7de1ed0752e65abc3a0431be3 Mon Sep 17 00:00:00 2001 From: xiewuzhiying Date: Mon, 30 Sep 2024 00:10:01 +0800 Subject: [PATCH 156/156] small fix --- .../mixin/compat/create/client/MixinTrackBlockOutline.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 index aeaddd5f8..4e1318a7b 100644 --- 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 @@ -85,7 +85,8 @@ private static PoseStack redirectTransformStackTranslate(final PoseStack ms) { 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")) + target = "Lnet/minecraft/world/level/border/WorldBorder;isWithinBounds(Lnet/minecraft/core/BlockPos;)Z"), + remap = true) private static BlockPos modIsWithinBounds(final BlockPos blockPos) { final Level level = Minecraft.getInstance().level; if (level != null) { @@ -98,7 +99,7 @@ private static BlockPos modIsWithinBounds(final BlockPos blockPos) { return blockPos; } - @Inject(method = "drawCustomBlockSelection", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V")) + @Inject(method = "drawCustomBlockSelection", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V"), remap = true) private static void harvest(RenderHighlightEvent.Block event, CallbackInfo ci) { valkyrienskies$info = event.getCamera(); valkyrienskies$hitResult = (BlockHitResult) event.getTarget();