From 4b581016757f32763b6dcdac4407e524b4debdd5 Mon Sep 17 00:00:00 2001 From: AlphaMode Date: Sun, 6 Nov 2022 22:49:37 -0600 Subject: [PATCH 001/437] 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/437] 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 98ff6a64d831a2c981a566a758ae6b30edbc5ef9 Mon Sep 17 00:00:00 2001 From: TechTastic <74630543+TechTastic@users.noreply.github.com> Date: Thu, 29 Dec 2022 04:19:27 -0600 Subject: [PATCH 003/437] [1.18.2] Minimum ComputerCraft Compatibility Code (#265) * Initial Commit Added Config Option for Turtles leaving Scaled Ships Added CCT and CCR to their respective build.gradle files Added README.MD to both Forge and Fabric * Initial Commit CC:R Fabric Added MixinSpeakerPosition - Fix Speakers playing sounds in Shipyard instead of Worldspace Added MixinTurtleBrain - If Turtle is on a ship, target position is outside of ship's VoxelAABB, and ship is not scaled, Turtle leaves ship Added MixinTurtleMoveCommand - Turtles can not enter a position where a ship is located - Turtles can not leave a ship's ActiveChunkSet Added MixinWirelessNetwork - FIx Modems not being able to communicate to/from ships * Added ComputerCraft mass file * Forge Added MixinSpeakerPosition Added MixinTurtleMoveCommand Added MixinTurtleBrain Added MixinWirelessNetwork Updated CCT * Final Commit Edited both README.MD files to reflect the Mixins in place * Both ------------------------- Edited MixinTurtleMoveCommand to use ChunkClaim instead of IActiveChunkSet * Both ---------------------- Edited MixinTurtleBrain to replace deprecated method getShipVoxelAABB() with getShipAABB() * Both ---------------------- Edited MixinTurtleBrain to replace deprecated method getShipTransform() with getTransform() Edited MixinTurtleMoveCommand to remove unused method isShipScaled() --- .../mod/common/config/VSGameConfig.kt | 10 ++ .../valkyrienskies/vs_mass/computercraft.json | 50 ++++++++ fabric/build.gradle | 13 ++ .../cc_restitched/MixinSpeakerPosition.java | 48 ++++++++ .../cc_restitched/MixinTurtleBrain.java | 115 +++++++++++++++++ .../cc_restitched/MixinTurtleMoveCommand.java | 57 +++++++++ .../cc_restitched/MixinWirelessNetwork.java | 46 +++++++ .../mixin/compat/cc_restitched/README.MD | 15 +++ .../valkyrienskies-fabric.mixins.json | 4 + forge/build.gradle | 13 ++ .../cc_tweaked/MixinSpeakerPosition.java | 47 +++++++ .../compat/cc_tweaked/MixinTurtleBrain.java | 116 ++++++++++++++++++ .../cc_tweaked/MixinTurtleMoveCommand.java | 57 +++++++++ .../cc_tweaked/MixinWirelessNetwork.java | 41 +++++++ .../forge/mixin/compat/cc_tweaked/README.MD | 15 +++ .../valkyrienskies-forge.mixins.json | 4 + 16 files changed, 651 insertions(+) create mode 100644 common/src/main/resources/data/valkyrienskies/vs_mass/computercraft.json create 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/MixinTurtleBrain.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/README.MD create 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/MixinTurtleBrain.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinTurtleMoveCommand.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinWirelessNetwork.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/README.MD 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 69a52a43d..980835f05 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 @@ -19,6 +19,16 @@ object VSGameConfig { } class Server { + val ComputerCraft = COMPUTERCRAFT() + + class COMPUTERCRAFT { + @JsonSchema( + description = "Turtles leaving scaled up/down ship may cause issues" + + "Enable/Disable Turtles Leaving Scaled Ships?" + ) + var canTurtlesLeaveScaledShips = false + } + @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/resources/data/valkyrienskies/vs_mass/computercraft.json b/common/src/main/resources/data/valkyrienskies/vs_mass/computercraft.json new file mode 100644 index 000000000..6a794f7b3 --- /dev/null +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/computercraft.json @@ -0,0 +1,50 @@ +[ + { + "block": "computercraft:computer_advanced", + "mass": 15395.0 + }, + { + "block": "computercraft:turtle_advanced", + "mass": 15795.0 + }, + { + "block": "computercraft:monitor_advanced", + "mass": 15245.0 + }, + { + "block": "computercraft:wireless_modem_advanced", + "mass": 15250.0 + }, + { + "block": "computercraft:computer_normal", + "mass": 3150 + }, + { + "block": "computercraft:turtle_normal", + "mass": 3600.0 + }, + { + "block": "computercraft:monitor_normal", + "mass": 3200.0 + }, + { + "block": "computercraft:wired_modem_full", + "mass": 3300.0 + }, + { + "block": "computercraft:cable", + "mass": 160.0 + }, + { + "block": "computercraft:printer", + "mass": 3150.0 + }, + { + "block": "computercraft:speaker", + "mass": 4350.0 + }, + { + "block": "computercraft:disk_drive", + "mass": 3300.0 + } +] diff --git a/fabric/build.gradle b/fabric/build.gradle index 96ed19138..2ba36139c 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -24,6 +24,16 @@ loom { accessWidenerPath = project(":common").loom.accessWidenerPath } +repositories { + // CC Restitched + maven { + url "https://cursemaven.com" + content { + includeGroup "curse.maven" + } + } +} + dependencies { include(annotationProcessor(implementation("com.github.LlamaLad7:MixinExtras:0.1.1"))) @@ -58,6 +68,9 @@ dependencies { exclude module: "fastutil" exclude module: "kotlin-stdlib-jdk8" // Don't shade kotlin-stdlib-jdk8, even though vs-core depends on it } + + // CC Restitched + modCompileOnly("curse.maven:cc-restitched-462672:3838648") } // Copy the VS common access widener to the generated resources folder 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 new file mode 100644 index 000000000..f58bb2ae4 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerPosition.java @@ -0,0 +1,48 @@ +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 new file mode 100644 index 000000000..654235c89 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleBrain.java @@ -0,0 +1,115 @@ +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; +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 + ) + private BlockPos ValkyrienSkies2$teleportToBlockPos(final BlockPos pos) { + final TileTurtle 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 = new BlockPos(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 new file mode 100644 index 000000000..7e44efd49 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinTurtleMoveCommand.java @@ -0,0 +1,57 @@ +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 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"), 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/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 new file mode 100644 index 000000000..62dbb0c1c --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinWirelessNetwork.java @@ -0,0 +1,46 @@ +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.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 IPacketReceiver shipReceiver; + private static IPacketSender 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(final IPacketReceiver receiver, final Packet packet, + final double range, + final boolean interdimensional, final CallbackInfo ci) { + shipReceiver = receiver; + shipSender = packet.sender(); + } +} 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 new file mode 100644 index 000000000..04360e4e0 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/README.MD @@ -0,0 +1,15 @@ +Minimal ComputerCraft Compatibility Mixins + +- MixinSpeakerPosition + - Fixes Speakers on Ships not playing sounds in worldspace but in Shipyard +- MixinTurtleBrain + - Fails Movement if the turtle is in worldspace and the target position is a + ship (returns "ship") + - Fails Movement if the turtle is on ship and the target position is outside + a ship's ActiveChunkSet (returns "out of ship") +- MixinTurtleMoveCommand + - Allows a Turtle to Leave Ships if the target position is outside of ship's + VoxelAABB and ship is not scaled up or down +- MixinWirelessNetwork + - Fixes Modems not being able to communicate from/to ships despite being + within range diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index c1e700183..53e2cb6b0 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -4,6 +4,10 @@ "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.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", "world.level.block.FireMixin" diff --git a/forge/build.gradle b/forge/build.gradle index 8c07ec8d5..8d734ce23 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -50,6 +50,16 @@ configurations { shadowCommon.extendsFrom core } +repositories { + // CC Tweaked + maven { + url "https://cursemaven.com" + content { + includeGroup "curse.maven" + } + } +} + dependencies { include(forgeRuntimeLibrary(annotationProcessor(implementation("com.github.LlamaLad7:MixinExtras:0.1.1")))) @@ -70,6 +80,9 @@ dependencies { modImplementation("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_version}") modImplementation("com.tterrag.registrate:Registrate:${registrate_version}") + // CC Tweaked + modCompileOnly("curse.maven:cc-tweaked-282001:4061947") + // Add Kotlin for Forge. forgeRuntimeLibrary('curse.maven:kotlinforforge-351264:3925887') 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 new file mode 100644 index 000000000..fa6304a8a --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinSpeakerPosition.java @@ -0,0 +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); + } +} 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 new file mode 100644 index 000000000..a5ca0bd71 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinTurtleBrain.java @@ -0,0 +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; + } +} 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 new file mode 100644 index 000000000..4798d7249 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinTurtleMoveCommand.java @@ -0,0 +1,57 @@ +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 new file mode 100644 index 000000000..f623cc254 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/MixinWirelessNetwork.java @@ -0,0 +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(); + } +} 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 new file mode 100644 index 000000000..04360e4e0 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/cc_tweaked/README.MD @@ -0,0 +1,15 @@ +Minimal ComputerCraft Compatibility Mixins + +- MixinSpeakerPosition + - Fixes Speakers on Ships not playing sounds in worldspace but in Shipyard +- MixinTurtleBrain + - Fails Movement if the turtle is in worldspace and the target position is a + ship (returns "ship") + - Fails Movement if the turtle is on ship and the target position is outside + a ship's ActiveChunkSet (returns "out of ship") +- MixinTurtleMoveCommand + - Allows a Turtle to Leave Ships if the target position is outside of ship's + VoxelAABB and ship is not scaled up or down +- MixinWirelessNetwork + - Fixes Modems not being able to communicate from/to ships despite being + within range diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index b48014501..5786e6c53 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -4,6 +4,10 @@ "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.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", "compat.create.MixinCrushingWheelBlock", From 98168db48d30f26e273b862c1e1540fe7dd06b08 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Thu, 29 Dec 2022 05:45:33 -0700 Subject: [PATCH 004/437] Removed maven repos --- fabric/build.gradle | 10 ---------- forge/build.gradle | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 2ba36139c..f3250db8a 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -24,16 +24,6 @@ loom { accessWidenerPath = project(":common").loom.accessWidenerPath } -repositories { - // CC Restitched - maven { - url "https://cursemaven.com" - content { - includeGroup "curse.maven" - } - } -} - dependencies { include(annotationProcessor(implementation("com.github.LlamaLad7:MixinExtras:0.1.1"))) diff --git a/forge/build.gradle b/forge/build.gradle index 8d734ce23..f8b1c54d0 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -50,16 +50,6 @@ configurations { shadowCommon.extendsFrom core } -repositories { - // CC Tweaked - maven { - url "https://cursemaven.com" - content { - includeGroup "curse.maven" - } - } -} - dependencies { include(forgeRuntimeLibrary(annotationProcessor(implementation("com.github.LlamaLad7:MixinExtras:0.1.1")))) From 64b2c086e894c46d28550a00f30e9730c3f9c483 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Thu, 29 Dec 2022 19:49:30 +0100 Subject: [PATCH 005/437] Changing MixinEntity making an inject more normal. --- .../shipyard_entities/MixinEntity.java | 47 ++++++------------- 1 file changed, 14 insertions(+), 33 deletions(-) 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 87d79847d..85a54c807 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 @@ -7,13 +7,11 @@ import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; 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; 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.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; @@ -22,6 +20,9 @@ @Mixin(Entity.class) public abstract class MixinEntity { + @Shadow + public abstract void setPosRaw(double d, double e, double f); + @Shadow public abstract void positionRider(Entity entity); @@ -66,49 +67,29 @@ private void beforeTeleportTo(final double d, final double e, final double f, fi } @Unique - private static Vector3dc tempVec = null; + private boolean isModifyingSetPos = false; /** * @author ewoudje * @reason use vs2 entity handler to handle this method */ - @Inject(method = "setPosRaw", at = @At(value = "HEAD")) + @Inject(method = "setPosRaw", at = @At(value = "HEAD"), cancellable = true) private void handlePosSet(final double x, final double y, final double z, final CallbackInfo ci) { + if (isModifyingSetPos) { + return; + } + final Vector3d pos = new Vector3d(x, y, z); final Ship ship; if ((ship = VSGameUtilsKt.getShipObjectManagingPos(level, pos)) != null) { - tempVec = VSEntityManager.INSTANCE.getHandler(Entity.class.cast(this)) + final var result = VSEntityManager.INSTANCE.getHandler(Entity.class.cast(this)) .onEntityMove(Entity.class.cast(this), ship, pos); - } else { - tempVec = null; - } - } - @ModifyVariable(method = "setPosRaw", at = @At(value = "HEAD"), ordinal = 0, argsOnly = true) - private double setX(final double x) { - if (tempVec != null) { - return tempVec.x(); - } else { - return x; - } - } - - @ModifyVariable(method = "setPosRaw", at = @At(value = "HEAD"), ordinal = 1, argsOnly = true) - private double setY(final double y) { - if (tempVec != null) { - return tempVec.y(); - } else { - return y; - } - } - - @ModifyVariable(method = "setPosRaw", at = @At(value = "HEAD"), ordinal = 2, argsOnly = true) - private double setZ(final double z) { - if (tempVec != null) { - return tempVec.z(); - } else { - return z; + isModifyingSetPos = true; + setPosRaw(result.x(), result.y(), result.z()); + isModifyingSetPos = false; + ci.cancel(); } } From 4ed0dd48650ad89b1e2eba15a048fc652b0d279b Mon Sep 17 00:00:00 2001 From: TechTastic <74630543+TechTastic@users.noreply.github.com> Date: Tue, 3 Jan 2023 16:10:35 -0600 Subject: [PATCH 006/437] [1.18.2] FTB Chunks Compatibility (#291) * Added MixinClaimedChunkManager to pass Shipyard positions to worldspace to be tested against Edited build.gradle:common to add FTB Chunks, Utilities, and Teams, as well as the CurseMaven repository Edited valkyrienskies-common.mixins.json to add MixinClaimedChunkManager * Edited MixinClaimedChunkManager to add a check for build height to allow ships to fly over claimed chunks * Edited MixinClaimedChunkManager to use the actual position * Fixed Crash Edited MixinClaimedChunkManager to change the position passed to the newly created ChunkDimPos instance for getChunk * Re-added build height check to allow ships to fly over claims without falling under claim's protection * Added a new Config Segment for FTB Chunks with 2 Config Options to disable ships being protected and to disable ships being protected above/below build height * remove maven repo Co-authored-by: Rubydesic --- common/build.gradle | 5 ++ .../ftb_chunks/MixinClaimedChunkManager.java | 62 +++++++++++++++++++ .../mod/common/config/VSGameConfig.kt | 14 +++++ .../valkyrienskies-common.mixins.json | 1 + 4 files changed, 82 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/ftb_chunks/MixinClaimedChunkManager.java diff --git a/common/build.gradle b/common/build.gradle index 58cfc8c64..49e2132b4 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -15,6 +15,11 @@ dependencies { exclude module: "netty-buffer" exclude module: "fastutil" } + + // FTB Stuffs + modCompileOnly("curse.maven:ftb-util-404465:4210935") + modCompileOnly("curse.maven:ftb-teams-404468:4229138") + modCompileOnly("curse.maven:ftb-chunks-314906:4229120") } architectury { 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 new file mode 100644 index 000000000..b04b52d04 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/ftb_chunks/MixinClaimedChunkManager.java @@ -0,0 +1,62 @@ +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; +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.ModifyArg; +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(ClaimedChunkManager.class) +public abstract class MixinClaimedChunkManager { + @Unique + private Entity entity = null; + + @ModifyVariable(method = "protect", at = @At("HEAD"), name = "entity", remap = false) + private Entity ValkyrienSkies$entity(final Entity entity) { + this.entity = entity; + return entity; + } + + @ModifyArg( + method = "protect", + at = @At( + value = "INVOKE", + target = "Ldev/ftb/mods/ftblibrary/math/ChunkDimPos;(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)V" + ) + ) + private BlockPos ValkyrienSkies$newChunkDimPos(final BlockPos pos) { + if (entity == null && !VSGameConfig.SERVER.getFTBChunks().getShipsProtectedByClaims()) { + return pos; + } + + final Level level = entity.level; + + final Ship ship = VSGameUtilsKt.getShipManagingPos(level, pos); + if (ship == null) { + return pos; + } + + final Vector3d vec = ship.getShipToWorld().transformPosition(new Vector3d(pos.getX(), pos.getY(), pos.getZ())); + final BlockPos newPos = new BlockPos(VectorConversionsMCKt.toMinecraft(vec)); + + if ( + (newPos.getY() > level.getMaxBuildHeight() || newPos.getY() < level.getMinBuildHeight()) && + !VSGameConfig.SERVER.getFTBChunks().getShipsProtectionOutOfBuildHeight() + ) { + return pos; + } + + return newPos; + } +} 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 980835f05..2c176cce6 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 @@ -19,6 +19,20 @@ object VSGameConfig { } class Server { + val FTBChunks = FTBCHUNKS() + + class FTBCHUNKS { + @JsonSchema( + description = "Are Ships protected by FTB Chunk Claims?" + ) + var shipsProtectedByClaims = true + + @JsonSchema( + description = "Are ships protected outside of build height (max and min)?" + ) + var shipsProtectionOutOfBuildHeight = false + } + val ComputerCraft = COMPUTERCRAFT() class COMPUTERCRAFT { diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 0fddd4649..fa2bc3a76 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -41,6 +41,7 @@ "feature.water_in_ships_entity.MixinEntity", "feature.world_border.MixinLevel", "feature.world_border.MixinWorldBorder", + "mod_compat.ftb_chunks.MixinClaimedChunkManager", "mod_compat.sodium.MixinChunkTracker", "mod_compat.sodium.MixinRegionChunkRenderer", "mod_compat.sodium.MixinRenderSectionManager", From 387fda158922481988d918d439199976fdc8ce4e Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins <31552479+FluffyJenkins@users.noreply.github.com> Date: Thu, 5 Jan 2023 00:35:10 +0000 Subject: [PATCH 007/437] Added Create Seat entity into VS_Entities (#296) --- common/src/main/resources/data/create/vs_entities/seat.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 common/src/main/resources/data/create/vs_entities/seat.json diff --git a/common/src/main/resources/data/create/vs_entities/seat.json b/common/src/main/resources/data/create/vs_entities/seat.json new file mode 100644 index 000000000..9e6377c34 --- /dev/null +++ b/common/src/main/resources/data/create/vs_entities/seat.json @@ -0,0 +1,3 @@ +{ + "handler": "valkyrienskies:shipyard" +} From 5246271eeffe94a0d8c991a19ded47c047469e97 Mon Sep 17 00:00:00 2001 From: AlphaMode Date: Fri, 6 Jan 2023 15:09:17 -0600 Subject: [PATCH 008/437] 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 171d840b0d6146494d357836fd62bdd7a042b140 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sat, 7 Jan 2023 01:30:24 -0500 Subject: [PATCH 009/437] fix: null check --- .../mixin/mod_compat/ftb_chunks/MixinClaimedChunkManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b04b52d04..43f3bd67d 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 @@ -36,7 +36,7 @@ public abstract class MixinClaimedChunkManager { ) ) private BlockPos ValkyrienSkies$newChunkDimPos(final BlockPos pos) { - if (entity == null && !VSGameConfig.SERVER.getFTBChunks().getShipsProtectedByClaims()) { + if (entity == null || !VSGameConfig.SERVER.getFTBChunks().getShipsProtectedByClaims()) { return pos; } From cbbdfa92a4d943d209ff9b8ba2408a3a82918b47 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sat, 7 Jan 2023 01:33:44 -0500 Subject: [PATCH 010/437] fix: structurize crash (#293) --- .../MixinBlockEntityRenderDispatcher.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_blockentity_distance_check/MixinBlockEntityRenderDispatcher.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_blockentity_distance_check/MixinBlockEntityRenderDispatcher.java index d06e8d9c6..b57119725 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_blockentity_distance_check/MixinBlockEntityRenderDispatcher.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/render_blockentity_distance_check/MixinBlockEntityRenderDispatcher.java @@ -3,7 +3,6 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import net.minecraft.client.Camera; -import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher; import net.minecraft.client.renderer.blockentity.BlockEntityRenderer; import net.minecraft.core.BlockPos; @@ -15,6 +14,7 @@ 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.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; /** @@ -48,9 +48,9 @@ private boolean isTileEntityInRenderRange(final BlockEnt // If by default was false, then check if this BlockEntity belongs to a ship final BlockPos bePos = blockEntity.getBlockPos(); - final ClientShip shipObject = VSGameUtilsKt.getShipObjectManagingPos((ClientLevel) level, bePos); - if (shipObject != null) { - final Matrix4dc m = shipObject.getRenderTransform().getShipToWorldMatrix(); + final Ship nullableShip = VSGameUtilsKt.getShipObjectManagingPos(level, bePos); + if (nullableShip instanceof ClientShip ship) { + final Matrix4dc m = ship.getRenderTransform().getShipToWorld(); return new Vec3( m.m00() * bePos.getX() + m.m10() * bePos.getY() + m.m20() * bePos.getZ() + m.m30(), From 10e7afa04f45c5c1c1565f122131b6ddb8d657f2 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sat, 7 Jan 2023 01:38:39 -0500 Subject: [PATCH 011/437] housekeeping: update gradle plugins --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 18ae52bb2..c3e75eec8 100644 --- a/build.gradle +++ b/build.gradle @@ -7,9 +7,9 @@ buildscript { plugins { // Needed for Forge+Fabric - id "architectury-plugin" version "3.4-SNAPSHOT" - id "dev.architectury.loom" version "0.12.0-SNAPSHOT" apply false - id 'io.github.juuxel.loom-quiltflower' version '1.7.1' apply false + id "architectury-plugin" version "3.4.143" + id "dev.architectury.loom" version "1.0.306" 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 // Kotlin linter From 8b2875532723e6a1b3b2ff4e3dad152772f3e45f Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sat, 7 Jan 2023 02:25:15 -0500 Subject: [PATCH 012/437] fix: add javax annotations to gradle --- build.gradle | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.gradle b/build.gradle index c3e75eec8..ce4468f11 100644 --- a/build.gradle +++ b/build.gradle @@ -99,6 +99,8 @@ subprojects { minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" // The following line declares the mojmap mappings, you may use other mappings as well mappings loom.officialMojangMappings() + + compileOnly("com.google.code.findbugs:jsr305:3.0.2") } // configure checkstyle From 183b8ab075abdd9e37ed59e618edf195dbfd0982 Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins <31552479+FluffyJenkins@users.noreply.github.com> Date: Sun, 8 Jan 2023 00:54:54 +0000 Subject: [PATCH 013/437] Unfloored position components in getOnPos related parts of the entity_collsion mixin (#305) --- .../feature/entity_collision/MixinEntity.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 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 79a56eb96..d862f68d3 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 @@ -133,7 +133,7 @@ private BlockPos getPosStandingOnFromShips(final Vector3dc blockPosInGlobal) { final Iterable intersectingShips = VSGameUtilsKt.getShipsIntersecting(level, testAABB); for (final Ship ship : intersectingShips) { final Vector3dc blockPosInLocal = - ship.getShipTransform().getWorldToShipMatrix().transformPosition(blockPosInGlobal, new Vector3d()); + ship.getTransform().getWorldToShip().transformPosition(blockPosInGlobal, new Vector3d()); final BlockPos blockPos = new BlockPos( Math.floor(blockPosInLocal.x()), Math.floor(blockPosInLocal.y()), Math.floor(blockPosInLocal.z()) ); @@ -142,7 +142,7 @@ private BlockPos getPosStandingOnFromShips(final Vector3dc blockPosInGlobal) { return blockPos; } else { // Check the block below as well, in the cases of fences - final Vector3dc blockPosInLocal2 = ship.getShipTransform().getWorldToShipMatrix() + final Vector3dc blockPosInLocal2 = ship.getTransform().getWorldToShip() .transformPosition( new Vector3d(blockPosInGlobal.x(), blockPosInGlobal.y() - 1.0, blockPosInGlobal.z())); final BlockPos blockPos2 = new BlockPos( @@ -160,9 +160,9 @@ private BlockPos getPosStandingOnFromShips(final Vector3dc blockPosInGlobal) { @Inject(method = "getBlockPosBelowThatAffectsMyMovement", at = @At("HEAD"), cancellable = true) private void preGetBlockPosBelowThatAffectsMyMovement(final CallbackInfoReturnable cir) { final Vector3dc blockPosInGlobal = new Vector3d( - Math.floor(position.x) + 0.5, - Math.floor(getBoundingBox().minY - 0.5) + 0.5, - Math.floor(position.z) + 0.5 + position.x, + getBoundingBox().minY - 0.5, + position.z ); final BlockPos blockPosStandingOnFromShip = getPosStandingOnFromShips(blockPosInGlobal); if (blockPosStandingOnFromShip != null) { @@ -177,9 +177,9 @@ private void preGetBlockPosBelowThatAffectsMyMovement(final CallbackInfoReturnab @Inject(method = "getOnPos", at = @At("HEAD"), cancellable = true) private void preGetOnPos(final CallbackInfoReturnable cir) { final Vector3dc blockPosInGlobal = new Vector3d( - Math.floor(position.x) + 0.5, - Math.floor(position.y - 0.2) + 0.5, - Math.floor(position.z) + 0.5 + position.x, + position.y - 0.2, + position.z ); final BlockPos blockPosStandingOnFromShip = getPosStandingOnFromShips(blockPosInGlobal); if (blockPosStandingOnFromShip != null) { @@ -190,9 +190,9 @@ private void preGetOnPos(final CallbackInfoReturnable cir) { @Inject(method = "spawnSprintParticle", at = @At("HEAD"), cancellable = true) private void preSpawnSprintParticle(final CallbackInfo ci) { final Vector3dc blockPosInGlobal = new Vector3d( - Math.floor(position.x) + 0.5, - Math.floor(position.y - 0.2) + 0.5, - Math.floor(position.z) + 0.5 + position.x, + position.y - 0.2, + position.z ); final BlockPos blockPosStandingOnFromShip = getPosStandingOnFromShips(blockPosInGlobal); if (blockPosStandingOnFromShip != null) { From 32dcacb129eb423b039a0b5fbfda4cfb17f8dc08 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sat, 7 Jan 2023 16:45:48 -0500 Subject: [PATCH 014/437] housekeeping: refactor moveEntityFromShipyardToWorld --- .../entity/handling/WorldEntityHandler.kt | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) 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 0f62988c1..599fbd9a8 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 @@ -57,19 +57,18 @@ object WorldEntityHandler : VSEntityHandler { entity.yo = entity.y entity.zo = entity.z - val shipVelocity = Vector3d().add(ship.velocity) - .add( - newPos.sub(ship.shipTransform.shipPositionInWorldCoordinates, Vector3d()) - .cross(ship.omega) - ).mul(0.05) // Tick velocity - - entity.deltaMovement = - ship.shipTransform.transformDirectionNoScalingFromShipToWorld(entity.deltaMovement.toJOML(), Vector3d()) - .add(shipVelocity) - .toMinecraft() - - val direction = - ship.shipTransform.transformDirectionNoScalingFromShipToWorld(entity.lookAngle.toJOML(), Vector3d()) + val newPosInShipLocal = Vector3d(newPos).sub(ship.transform.positionInWorld) + val shipVelocity = Vector3d(ship.velocity) // ship linear velocity + .add(Vector3d(ship.omega).cross(newPosInShipLocal)) // angular velocity + .mul(0.05) // Tick velocity + + val entityVelocity = ship.transform.shipToWorldRotation.transform(entity.deltaMovement.toJOML()) + + entity.deltaMovement = Vector3d(entityVelocity) + .add(shipVelocity) + .toMinecraft() + + val direction = ship.transform.shipToWorldRotation.transform(entity.lookAngle.toJOML()) val yaw = -atan2(direction.x, direction.z) val pitch = -atan2(direction.y, sqrt((direction.x * direction.x) + (direction.z * direction.z))) entity.yRot = (yaw * (180 / Math.PI)).toFloat() @@ -78,16 +77,13 @@ object WorldEntityHandler : VSEntityHandler { entity.xRotO = entity.xRot if (entity is AbstractHurtingProjectile) { - val powerJank = Vector3d(entity.xPower, entity.yPower, entity.zPower) + val power = Vector3d(entity.xPower, entity.yPower, entity.zPower) - ship.shipTransform.transformDirectionNoScalingFromShipToWorld( - powerJank, - powerJank - ) + ship.transform.shipToWorldRotation.transform(power) - entity.xPower = powerJank.x - entity.yPower = powerJank.y - entity.zPower = powerJank.z + entity.xPower = power.x + entity.yPower = power.y + entity.zPower = power.z } return newPos From 26720096406bfd2f71642eb5ec5e3c315b895f50 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sun, 8 Jan 2023 00:12:44 -0500 Subject: [PATCH 015/437] fix: only move entities into shipyard when they're spawned into the world, not whenever setPosRaw is called --- .../shipyard_entities/MixinEntity.java | 28 ------------------- .../shipyard_entities/MixinServerLevel.java | 18 ++++++++++++ .../mixin/server/world/MixinServerLevel.java | 19 +------------ .../entity/handling/ShipyardEntityHandler.kt | 7 ++--- .../common/entity/handling/VSEntityHandler.kt | 10 +------ .../entity/handling/WorldEntityHandler.kt | 11 +++----- 6 files changed, 27 insertions(+), 66 deletions(-) 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 85a54c807..63f4c9507 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 @@ -13,7 +13,6 @@ 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.entity.handling.VSEntityManager; @@ -66,33 +65,6 @@ private void beforeTeleportTo(final double d, final double e, final double f, fi isModifyingTeleport = false; } - @Unique - private boolean isModifyingSetPos = false; - - /** - * @author ewoudje - * @reason use vs2 entity handler to handle this method - */ - @Inject(method = "setPosRaw", at = @At(value = "HEAD"), cancellable = true) - private void handlePosSet(final double x, final double y, final double z, final CallbackInfo ci) { - if (isModifyingSetPos) { - return; - } - - final Vector3d pos = new Vector3d(x, y, z); - final Ship ship; - - if ((ship = VSGameUtilsKt.getShipObjectManagingPos(level, pos)) != null) { - final var result = VSEntityManager.INSTANCE.getHandler(Entity.class.cast(this)) - .onEntityMove(Entity.class.cast(this), ship, pos); - - isModifyingSetPos = true; - setPosRaw(result.x(), result.y(), result.z()); - isModifyingSetPos = false; - ci.cancel(); - } - } - /** * 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/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinServerLevel.java index 374b9143f..4acb491cf 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 @@ -9,6 +9,10 @@ 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.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.entity.handling.VSEntityManager; import org.valkyrienskies.mod.mixinducks.world.OfLevel; @Mixin(ServerLevel.class) @@ -23,4 +27,18 @@ void configureEntitySections(final CallbackInfo ci) { ((OfLevel) entityManager).setLevel(ServerLevel.class.cast(this)); } + @Inject( + method = "addEntity", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/entity/PersistentEntitySectionManager;addNewEntity(Lnet/minecraft/world/level/entity/EntityAccess;)Z" + ) + ) + void preAddEntity(final Entity entity, final CallbackInfoReturnable cir) { + final Ship ship = VSGameUtilsKt.getShipManaging(entity); + if (ship != null) { + VSEntityManager.INSTANCE.getHandler(entity).freshEntityInShipyard(entity, ship); + } + } + } 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 cc2be240d..1aabc5043 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 @@ -22,7 +22,6 @@ import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.progress.ChunkProgressListener; -import net.minecraft.world.entity.Entity; import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.LevelChunk; import net.minecraft.world.level.chunk.LevelChunkSection; @@ -38,14 +37,11 @@ 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.LoadedServerShip; -import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.core.apigame.world.ServerShipWorldCore; import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate; import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.entity.handling.VSEntityManager; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.mixin.accessors.server.world.ChunkMapAccessor; @@ -177,18 +173,5 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf voxelShapeUpdates ); } - - /** - * @author ewoudje - * @reason send updates to relevant VSEntityHandler - */ - @Inject(method = "addEntity", at = @At(value = "HEAD")) - private void updateHandler(final Entity entity, final CallbackInfoReturnable cir) { - final Vector3d pos = new Vector3d(entity.getX(), entity.getY(), entity.getZ()); - final Ship ship = VSGameUtilsKt.getShipObjectManagingPos(entity.level, pos); - if (ship != null) { - VSEntityManager.INSTANCE.getHandler(entity) - .freshEntityInShipyard(entity, ship, pos); - } - } + } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/ShipyardEntityHandler.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/ShipyardEntityHandler.kt index 2f29d6945..716b11774 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/ShipyardEntityHandler.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/ShipyardEntityHandler.kt @@ -5,14 +5,15 @@ import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.entity.EntityRenderer import net.minecraft.world.entity.Entity import org.joml.Vector3d -import org.joml.Vector3dc import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.Ship import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toMinecraft object ShipyardEntityHandler : VSEntityHandler { - override fun freshEntityInShipyard(entity: Entity, ship: Ship, position: Vector3dc) {} + override fun freshEntityInShipyard(entity: Entity, ship: Ship) { + // do nothing + } override fun applyRenderTransform( ship: ClientShip, entity: T, entityRenderer: EntityRenderer, x: Double, y: Double, z: Double, @@ -50,6 +51,4 @@ object ShipyardEntityHandler : VSEntityHandler { // EW: i think it was in entity dragging logic matrixStack.mulPose(ship.renderTransform.shipToWorldRotation.toMinecraft()) } - - override fun onEntityMove(self: Entity, ship: Ship, position: Vector3dc): Vector3dc = position } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityHandler.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityHandler.kt index c9af8f134..f027cdea1 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityHandler.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityHandler.kt @@ -5,7 +5,6 @@ import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.entity.EntityRenderer import net.minecraft.world.entity.Entity import org.joml.Vector3d -import org.joml.Vector3dc import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.Ship @@ -16,7 +15,7 @@ interface VSEntityHandler { * * Gets called when a new entity gets made in the shipyard */ - fun freshEntityInShipyard(entity: Entity, ship: Ship, position: Vector3dc) + fun freshEntityInShipyard(entity: Entity, ship: Ship) /** * ApplyRenderTransform @@ -52,11 +51,4 @@ interface VSEntityHandler { fun applyRenderOnMountedEntity( ship: ClientShip, self: Entity, passenger: Entity, partialTicks: Float, matrixStack: PoseStack ) - - /** - * Gets called every move of a entity that lives in the shipyard - * - * Should call self.setPosRaw(x, y, z) - */ - fun onEntityMove(self: Entity, ship: Ship, position: Vector3dc): Vector3dc } 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 599fbd9a8..e10e2a788 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 @@ -19,8 +19,8 @@ import kotlin.math.atan2 import kotlin.math.sqrt object WorldEntityHandler : VSEntityHandler { - override fun freshEntityInShipyard(entity: Entity, ship: Ship, position: Vector3dc) { - moveEntityFromShipyardToWorld(entity, ship, position) + override fun freshEntityInShipyard(entity: Entity, ship: Ship) { + moveEntityFromShipyardToWorld(entity, ship) } override fun applyRenderTransform( @@ -47,11 +47,8 @@ object WorldEntityHandler : VSEntityHandler { ) { } - override fun onEntityMove(self: Entity, ship: Ship, position: Vector3dc) = - moveEntityFromShipyardToWorld(self, ship, position) - - fun moveEntityFromShipyardToWorld(entity: Entity, ship: Ship, position: Vector3dc): Vector3dc { - val newPos = ship.shipToWorld.transformPosition(Vector3d(position)) + private fun moveEntityFromShipyardToWorld(entity: Entity, ship: Ship): Vector3dc { + val newPos = ship.shipToWorld.transformPosition(entity.position().toJOML()) entity.setPos(newPos.x, newPos.y, newPos.z) entity.xo = entity.x entity.yo = entity.y From a202892106a70cd609a3289c49830bb96421395f Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Mon, 9 Jan 2023 16:57:47 +0100 Subject: [PATCH 016/437] fix: Ladders work (kudos to copper 1.16 code) --- .../mod/mixin/feature/ladders/FEATURE.md | 8 +++ .../feature/ladders/MixinLivingEntity.java | 62 +++++++++++++++++++ .../valkyrienskies-common.mixins.json | 1 + 3 files changed, 71 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/ladders/FEATURE.md create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/ladders/MixinLivingEntity.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ladders/FEATURE.md b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ladders/FEATURE.md new file mode 100644 index 000000000..67d5a2880 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ladders/FEATURE.md @@ -0,0 +1,8 @@ +### Ladders + +This feature makes ladders work on ships + +#### Mixins + +* `MixinLivingEntity#onClimbableMixin` Calls onClimbable for every ship that is + near in shipyard. 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 new file mode 100644 index 000000000..fea85c465 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/ladders/MixinLivingEntity.java @@ -0,0 +1,62 @@ +package org.valkyrienskies.mod.mixin.feature.ladders; + +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.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.CallbackInfoReturnable; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(LivingEntity.class) +public abstract class MixinLivingEntity extends Entity { + + @Shadow + public abstract boolean onClimbable(); + + @Unique + private boolean isModifyingClimbable = false; + + public MixinLivingEntity(final EntityType entityType, final Level level) { + super(entityType, level); + } + + @Inject( + at = @At("TAIL"), + method = "onClimbable", + cancellable = true + ) + private void onClimbableMixin(final CallbackInfoReturnable cir) { + if (!cir.getReturnValue()) { + if (isModifyingClimbable) { + return; + } + + isModifyingClimbable = true; + + final Vec3 pos = this.position(); + + final double origX = pos.x; + final double origY = pos.y; + final double origZ = pos.z; + + VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level, origX, origY, origZ, 1, (x, y, z) -> { + this.setPosRaw(x, y, z); + + if (onClimbable()) { + cir.setReturnValue(true); + } + + this.setPosRaw(origX, origY, origZ); + + }); + + isModifyingClimbable = false; + } + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index fa2bc3a76..1c00ccd4e 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -27,6 +27,7 @@ "feature.fire_between_ship_and_world.LavaFluidMixin", "feature.fluid_escaping_ship_config.MixinFlowingFluid", "feature.get_entities.MixinLevel", + "feature.ladders.MixinLivingEntity", "feature.mob_spawning.NaturalSpawnerMixin", "feature.render_pathfinding.MixinDebugPackets", "feature.screen_distance_check.MixinScreenHandler", From e5fe8beaca605531444db4a74e6e2da0bdfee975 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Tue, 10 Jan 2023 00:22:25 +0100 Subject: [PATCH 017/437] createNewShipWithBlocks doesn't allow empty DenseBlockPosSet --- .../org/valkyrienskies/mod/common/assembly/ShipAssembly.kt | 2 ++ 1 file changed, 2 insertions(+) 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 d0bbf783c..4b1e42dca 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 @@ -22,6 +22,8 @@ import org.valkyrienskies.mod.util.relocateBlock 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 From 87293dcd25e3894c2711d73b116d700c4b9b7d9c Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Mon, 9 Jan 2023 18:37:28 -0500 Subject: [PATCH 018/437] change to LGPLv3 --- LICENSE | 366 +++++++++++++++++++++++++------------------------------- 1 file changed, 165 insertions(+), 201 deletions(-) diff --git a/LICENSE b/LICENSE index 261eeb9e9..0a041280b 100644 --- a/LICENSE +++ b/LICENSE @@ -1,201 +1,165 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. From bf383c7c247a667d1a5685ddb0996e77ae985902 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Tue, 10 Jan 2023 17:38:23 +0100 Subject: [PATCH 019/437] Create 0.5g compat for fabric and create --- build.gradle | 11 +++++++-- common/build.gradle | 4 ++++ .../flywheel}/InstancingEngineAccessor.java | 4 +++- .../flywheel}/MixinInstanceManager.java | 4 +++- .../flywheel}/MixinInstanceWorld.java | 23 +++++++++++++++---- .../flywheel}/MixinInstancingEngine.java | 19 ++++++++++++--- .../flywheel}/MixinTileInstanceManager.java | 8 ++++--- .../mixinducks/MixinInstancingEngineDuck.java | 2 +- .../MixinTileInstanceManagerDuck.java | 2 +- .../valkyrienskies-common.mixins.json | 5 ++++ fabric/build.gradle | 11 +++++++++ fabric/gradle.properties | 18 +++++++++++++++ forge/build.gradle | 4 ++-- forge/gradle.properties | 8 +++---- .../valkyrienskies-forge.mixins.json | 5 ---- 15 files changed, 100 insertions(+), 28 deletions(-) rename {forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client => common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel}/InstancingEngineAccessor.java (77%) rename {forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client => common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel}/MixinInstanceManager.java (94%) rename {forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client => common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel}/MixinInstanceWorld.java (70%) rename {forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client => common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel}/MixinInstancingEngine.java (56%) rename {forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client => common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel}/MixinTileInstanceManager.java (92%) rename {forge/src/main/java/org/valkyrienskies/mod/forge => common/src/main/java/org/valkyrienskies/mod}/mixinducks/MixinInstancingEngineDuck.java (82%) rename {forge/src/main/java/org/valkyrienskies/mod/forge => common/src/main/java/org/valkyrienskies/mod}/mixinducks/MixinTileInstanceManagerDuck.java (87%) diff --git a/build.gradle b/build.gradle index ce4468f11..a271cfecd 100644 --- a/build.gradle +++ b/build.gradle @@ -73,7 +73,7 @@ subprojects { url = "https://maven.parchmentmc.org" } maven { url = "https://cursemaven.com" } - maven { url = "https://maven.terraformersmc.com/releases/" } + maven { url = "https://maven.terraformersmc.com/releases/" } // Mod Menu maven { name = 'Kotlin for Forge' url = 'https://thedarkcolour.github.io/KotlinForForge/' @@ -82,6 +82,13 @@ subprojects { name = 'tterrag maven' url = 'https://maven.tterrag.com/' } + maven { url = "https://api.modrinth.com/maven" } // LazyDFU, Suggestion Tweaker + maven { url = "https://maven.shedaniel.me/" } // Cloth Config, REI + 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 } } @@ -99,7 +106,7 @@ subprojects { minecraft "com.mojang:minecraft:${rootProject.minecraft_version}" // The following line declares the mojmap mappings, you may use other mappings as well mappings loom.officialMojangMappings() - + compileOnly("com.google.code.findbugs:jsr305:3.0.2") } diff --git a/common/build.gradle b/common/build.gradle index 49e2132b4..adcf1c8a3 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -20,6 +20,10 @@ dependencies { 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 + modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.8-33") } architectury { diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/InstancingEngineAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/InstancingEngineAccessor.java similarity index 77% rename from forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/InstancingEngineAccessor.java rename to common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/InstancingEngineAccessor.java index 9e72130ab..dc644a299 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/InstancingEngineAccessor.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/InstancingEngineAccessor.java @@ -1,10 +1,12 @@ -package org.valkyrienskies.mod.forge.mixin.compat.flywheel.client; +package org.valkyrienskies.mod.mixin.mod_compat.flywheel; import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; import net.minecraft.core.BlockPos; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.gen.Accessor; +@Pseudo @Mixin(value = InstancingEngine.class, remap = false) public interface InstancingEngineAccessor { @Accessor diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinInstanceManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceManager.java similarity index 94% rename from forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinInstanceManager.java rename to common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceManager.java index a475bc605..1418ee7ce 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinInstanceManager.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceManager.java @@ -1,4 +1,4 @@ -package org.valkyrienskies.mod.forge.mixin.compat.flywheel.client; +package org.valkyrienskies.mod.mixin.mod_compat.flywheel; import com.jozufozu.flywheel.api.instance.DynamicInstance; import com.jozufozu.flywheel.api.instance.TickableInstance; @@ -7,11 +7,13 @@ import net.minecraft.core.BlockPos; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Redirect; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +@Pseudo @Mixin(InstanceManager.class) public class MixinInstanceManager { diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinInstanceWorld.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceWorld.java similarity index 70% rename from forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinInstanceWorld.java rename to common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceWorld.java index 13849b804..8082adbb1 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinInstanceWorld.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceWorld.java @@ -1,23 +1,32 @@ -package org.valkyrienskies.mod.forge.mixin.compat.flywheel.client; +package org.valkyrienskies.mod.mixin.mod_compat.flywheel; +import com.jozufozu.flywheel.backend.gl.GlStateTracker; import com.jozufozu.flywheel.backend.instancing.InstanceManager; import com.jozufozu.flywheel.backend.instancing.InstanceWorld; import com.jozufozu.flywheel.event.RenderLayerEvent; +import com.mojang.math.Matrix4f; import net.minecraft.world.level.block.entity.BlockEntity; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.joml.Matrix4d; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import org.valkyrienskies.mod.forge.mixinducks.MixinInstancingEngineDuck; -import org.valkyrienskies.mod.forge.mixinducks.MixinTileInstanceManagerDuck; +import org.valkyrienskies.mod.mixinducks.MixinInstancingEngineDuck; +import org.valkyrienskies.mod.mixinducks.MixinTileInstanceManagerDuck; +@Pseudo @Mixin(value = InstanceWorld.class, remap = false) public class MixinInstanceWorld { + @Unique + private static final Logger LOGGER = LogManager.getLogger("VS2 flywheel.client.MixinInstanceWorld"); @Shadow @Final @@ -31,6 +40,8 @@ public class MixinInstanceWorld { ) ) void renderShipTiles(final RenderLayerEvent event, final CallbackInfo ci) { + //not sure if restoreState stuff should be here or in the ((MixinInstancingEngineDuck) manager).render() method + final GlStateTracker.State restoreState = GlStateTracker.getRestoreState(); final var shipManagers = ((MixinTileInstanceManagerDuck) blockEntityInstanceManager).getShipInstancingEngines(); shipManagers.forEach((ship, manager) -> { @@ -48,13 +59,17 @@ 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); + ((MixinInstancingEngineDuck) manager).render( - VectorConversionsMCKt.toMinecraft(finalProjection), + fnlProj, camInShipLocal.x, camInShipLocal.y, camInShipLocal.z, event.layer ); }); + restoreState.restore(); + } } diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinInstancingEngine.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstancingEngine.java similarity index 56% rename from forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinInstancingEngine.java rename to common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstancingEngine.java index 309c8fa86..8f3f84944 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinInstancingEngine.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstancingEngine.java @@ -1,4 +1,4 @@ -package org.valkyrienskies.mod.forge.mixin.compat.flywheel.client; +package org.valkyrienskies.mod.mixin.mod_compat.flywheel; import com.jozufozu.flywheel.backend.RenderLayer; import com.jozufozu.flywheel.backend.instancing.instancing.InstancedMaterialGroup; @@ -6,13 +6,20 @@ 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.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.Shadow; -import org.valkyrienskies.mod.forge.mixinducks.MixinInstancingEngineDuck; +import org.spongepowered.asm.mixin.Unique; +import org.valkyrienskies.mod.mixinducks.MixinInstancingEngineDuck; +@Pseudo @Mixin(value = InstancingEngine.class, remap = false) public abstract class MixinInstancingEngine

implements MixinInstancingEngineDuck { + @Unique + private static final Logger LOGGER = LogManager.getLogger("VS2 flywheel.client.MixinInstancingEngine"); @Shadow protected abstract Stream> getGroupsToRender(@Nullable RenderLayer layer); @@ -20,6 +27,12 @@ public abstract class MixinInstancingEngine

implements M @Override public void render(final Matrix4f viewProjection, final double camX, final double camY, final double camZ, final RenderLayer layer) { - this.getGroupsToRender(layer).forEach(g -> g.render(viewProjection, camX, camY, camZ, layer)); + //LOGGER.warn("step1"); + this.getGroupsToRender(layer).forEach(g -> { + //LOGGER.warn("step2"); + g.render(viewProjection, camX, camY, camZ, layer); + //LOGGER.warn("step3"); + }); + //LOGGER.warn("step4"); } } diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinTileInstanceManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinTileInstanceManager.java similarity index 92% rename from forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinTileInstanceManager.java rename to common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinTileInstanceManager.java index 1a062c3e3..32cbaec66 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/flywheel/client/MixinTileInstanceManager.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinTileInstanceManager.java @@ -1,4 +1,4 @@ -package org.valkyrienskies.mod.forge.mixin.compat.flywheel.client; +package org.valkyrienskies.mod.mixin.mod_compat.flywheel; import com.jozufozu.flywheel.api.instance.Instance; import com.jozufozu.flywheel.backend.instancing.InstanceManager; @@ -16,15 +16,17 @@ import net.minecraft.world.level.block.entity.BlockEntity; import org.joml.Vector3i; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.valkyrienskies.core.api.ships.ClientShip; import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.forge.mixinducks.MixinTileInstanceManagerDuck; +import org.valkyrienskies.mod.mixinducks.MixinTileInstanceManagerDuck; -@Mixin(value = BlockEntityInstanceManager.class, remap = false) +@Pseudo +@Mixin(value = BlockEntityInstanceManager.class) @ParametersAreNonnullByDefault public abstract class MixinTileInstanceManager extends InstanceManager implements MixinTileInstanceManagerDuck { diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixinducks/MixinInstancingEngineDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java similarity index 82% rename from forge/src/main/java/org/valkyrienskies/mod/forge/mixinducks/MixinInstancingEngineDuck.java rename to common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java index 5c2284dbb..2b9eeba86 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixinducks/MixinInstancingEngineDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java @@ -1,4 +1,4 @@ -package org.valkyrienskies.mod.forge.mixinducks; +package org.valkyrienskies.mod.mixinducks; import com.jozufozu.flywheel.backend.RenderLayer; import com.mojang.math.Matrix4f; diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixinducks/MixinTileInstanceManagerDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinTileInstanceManagerDuck.java similarity index 87% rename from forge/src/main/java/org/valkyrienskies/mod/forge/mixinducks/MixinTileInstanceManagerDuck.java rename to common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinTileInstanceManagerDuck.java index 5c95d4a73..6be3d710e 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixinducks/MixinTileInstanceManagerDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinTileInstanceManagerDuck.java @@ -1,4 +1,4 @@ -package org.valkyrienskies.mod.forge.mixinducks; +package org.valkyrienskies.mod.mixinducks; import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; import com.jozufozu.flywheel.core.shader.WorldProgram; diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 1c00ccd4e..bdf18fc8b 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -95,6 +95,11 @@ "feature.transform_particles.MixinLevelRenderer", "feature.transform_particles.MixinParticle", "feature.vs2_alpha_hud.MixinGui", + "mod_compat.flywheel.InstancingEngineAccessor", + "mod_compat.flywheel.MixinInstanceManager", + "mod_compat.flywheel.MixinInstanceWorld", + "mod_compat.flywheel.MixinInstancingEngine", + "mod_compat.flywheel.MixinTileInstanceManager", "mod_compat.optifine.MixinViewAreaOptifine", "mod_compat.optifine.RenderChunkInfoAccessorOptifine", "mod_compat.optifine_vanilla.MixinLevelRenderer", diff --git a/fabric/build.gradle b/fabric/build.gradle index f3250db8a..319cfb5d2 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -61,6 +61,17 @@ dependencies { // CC Restitched modCompileOnly("curse.maven:cc-restitched-462672:3838648") + + // 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("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}") } // Copy the VS common access widener to the generated resources folder diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 794f04cdd..7973021b4 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1 +1,19 @@ loader_platform=Fabric +create_version=0.5.0g-821 +# 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 +# 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 +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 diff --git a/forge/build.gradle b/forge/build.gradle index f8b1c54d0..e0a534a5b 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -66,8 +66,8 @@ dependencies { modCompileOnly("curse.maven:rubidium-574856:4024781") // Create compat - modImplementation("com.simibubi.create:create-${create_minecraft_version}:${create_version}:slim") { transitive = false } - modImplementation("com.jozufozu.flywheel:flywheel-forge-${flywheel_minecraft_version}:${flywheel_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 diff --git a/forge/gradle.properties b/forge/gradle.properties index f34bc126d..d19154fc0 100644 --- a/forge/gradle.properties +++ b/forge/gradle.properties @@ -1,9 +1,7 @@ loader_platform=Forge loom.platform=forge kotlin.stdlib.default.dependency=false -## Crate dep -create_minecraft_version=1.18.2 -flywheel_minecraft_version=1.18.2 -create_version=0.5.0.e-195 -flywheel_version=0.6.6-94 +#Compat +create_version=0.5.0.g-233 +flywheel_version=0.6.8-98 registrate_version=MC1.18.2-1.1.3 diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 5786e6c53..fe6489ba5 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -22,11 +22,6 @@ "compat.create.client.MixinFlwContraption", "compat.create.client.MixinScrollValueBehaviour", "compat.create.client.MixinValueBox", - "compat.flywheel.client.InstancingEngineAccessor", - "compat.flywheel.client.MixinInstanceManager", - "compat.flywheel.client.MixinInstanceWorld", - "compat.flywheel.client.MixinInstancingEngine", - "compat.flywheel.client.MixinTileInstanceManager", "compat.sodium.MixinRenderSectionManager" ], "injectors": { From 92a2999ccec138e9132f201f27b34d539cc3840f Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 10 Jan 2023 11:47:45 -0500 Subject: [PATCH 020/437] housekeeping: make Create fabric modCompileOnly --- fabric/build.gradle | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 319cfb5d2..f0b174405 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -63,15 +63,15 @@ dependencies { modCompileOnly("curse.maven:cc-restitched-462672:3838648") // 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("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}") + modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_version}+${minecraft_version}") { transitive = false } + modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version}") + modCompileOnly("com.tterrag.registrate_fabric:Registrate:${registrate_version}") + modCompileOnly("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") + modCompileOnly("me.alphamode:ForgeTags:${forge_tags_version}") + modCompileOnly("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") + 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 From a97eb740ca965d66cc9720633a2dd60d61388288 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 10 Jan 2023 21:33:26 -0500 Subject: [PATCH 021/437] housekeeping: make flywheel modCompileOnly in common --- common/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/build.gradle b/common/build.gradle index adcf1c8a3..f4adbfbf8 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 - modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.8-33") + modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.8-33") } architectury { From c5e333f50cdf088441dc971cef6e387477b33b17 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Wed, 11 Jan 2023 11:01:47 -0500 Subject: [PATCH 022/437] bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 536b3665c..bd0e93d48 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.0-beta8 +mod_version=2.1.0-beta9 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From ad4dd9aa8bd26527e75b3091097115e07f7fdb82 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Wed, 11 Jan 2023 18:00:41 +0100 Subject: [PATCH 023/437] Minor create compat updates --- fabric/build.gradle | 2 +- .../MixinBlockBreakingKineticTileEntity.java | 3 +- .../mixin/compat/create/MixinBlocks.java | 6 +- .../create/MixinCrushingWheelBlock.java | 81 ------------------- .../valkyrienskies-forge.mixins.json | 1 - gradle.properties | 2 +- 6 files changed, 6 insertions(+), 89 deletions(-) delete mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinCrushingWheelBlock.java diff --git a/fabric/build.gradle b/fabric/build.gradle index f0b174405..bb4d4cc7d 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -66,7 +66,7 @@ dependencies { modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_version}+${minecraft_version}") { transitive = false } modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version}") modCompileOnly("com.tterrag.registrate_fabric:Registrate:${registrate_version}") - modCompileOnly("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") + modImplementation("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") modCompileOnly("me.alphamode:ForgeTags:${forge_tags_version}") modCompileOnly("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") modCompileOnly("com.jamieswhiteshirt:reach-entity-attributes:${reach_entity_attributes_version}") 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 7805f4bed..7ff605744 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 @@ -25,8 +25,7 @@ public abstract class MixinBlockBreakingKineticTileEntity { at = @At( value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/components/actors/BlockBreakingKineticTileEntity;getBreakingPos()Lnet/minecraft/core/BlockPos;" - ), - remap = false + ), remap = false ) private BlockPos getBreakingBlockPos(final BlockBreakingKineticTileEntity self) { final BlockPos orig = this.getBreakingPos(); 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 78cea5d20..a9277bb6f 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 @@ -28,7 +28,7 @@ public class MixinBlocks { value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;blockPosition()Lnet/minecraft/core/BlockPos;" ), - require = 0 + require = 0, remap = false ) protected BlockPos redirectBlockPosition(final Entity entity) { final Iterator ships = @@ -48,9 +48,9 @@ protected BlockPos redirectBlockPosition(final Entity entity) { value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;" ), - require = 0 + require = 0, remap = false ) - protected Vec3 redirectPosition(final Entity entity) { + Vec3 redirectPosition(final Entity entity) { final Iterator ships = VSGameUtilsKt.getShipsIntersecting(entity.level, entity.getBoundingBox()).iterator(); if (ships.hasNext()) { diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinCrushingWheelBlock.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinCrushingWheelBlock.java deleted file mode 100644 index 23c7c2ef8..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinCrushingWheelBlock.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create; - -import com.simibubi.create.content.contraptions.components.crusher.CrushingWheelBlock; -import net.minecraft.core.BlockPos; -import net.minecraft.world.entity.Entity; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.state.BlockState; -import org.joml.Vector3d; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(CrushingWheelBlock.class) -public class MixinCrushingWheelBlock { - - @Unique - private BlockPos blockPosInside; - @Unique - private Level levelInside; - - @Inject(method = "entityInside", at = @At("HEAD")) - void startInside( - final BlockState state, final Level worldIn, final BlockPos pos, final Entity entityIn, - final CallbackInfo info) { - blockPosInside = pos; - levelInside = worldIn; - } - - @Unique - void transform(final Vector3d in) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(levelInside, blockPosInside); - if (ship != null) { - ship.getWorldToShip().transformPosition(in); - } - } - - @Redirect( - method = "entityInside", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;getX()D" - ) - ) - double getXPos(final Entity entity) { - final Vector3d vector3d = new Vector3d(entity.getX(), entity.getY(), entity.getZ()); - transform(vector3d); - return vector3d.x; - } - - @Redirect( - method = "entityInside", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;getY()D" - ) - ) - double getYPos(final Entity entity) { - final Vector3d vector3d = new Vector3d(entity.getX(), entity.getY(), entity.getZ()); - transform(vector3d); - return vector3d.x; - } - - @Redirect( - method = "entityInside", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;getZ()D" - ) - ) - double getZPos(final Entity entity) { - final Vector3d vector3d = new Vector3d(entity.getX(), entity.getY(), entity.getZ()); - transform(vector3d); - return vector3d.x; - } - -} diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index fe6489ba5..4495ecb38 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -10,7 +10,6 @@ "compat.cc_tweaked.MixinWirelessNetwork", "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", - "compat.create.MixinCrushingWheelBlock", "compat.immersivengineering.MixinBlockEntityInventory", "compat.thermalexpansion.MixinTileCoFH", "feature.forge_interact.MixinIForgePlayer", diff --git a/gradle.properties b/gradle.properties index bd0e93d48..788574d39 100644 --- a/gradle.properties +++ b/gradle.properties @@ -21,4 +21,4 @@ modrinth_api_key= modrinth_project_id=V5ujR2yw # This is set to true in CI, to ensure that VS doesn't rely on a maven hosted in someone's basement to build # you can also set it to true if some external maven is misbehaving (forge I'm looking @ u) -block_external_repositories=true +block_external_repositories= From ce70563af65d40184d8452e556c7359f5c472a56 Mon Sep 17 00:00:00 2001 From: ThePlasticPotato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Wed, 11 Jan 2023 17:37:04 -0500 Subject: [PATCH 024/437] Applied Triode's fixes for Comod error --- .../accessors/entity/EntityAccessor.java | 11 +++++++++ .../feature/ladders/MixinLivingEntity.java | 23 ++++++++++++++----- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/entity/EntityAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/entity/EntityAccessor.java index 0556f8745..69f0ea951 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/entity/EntityAccessor.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/entity/EntityAccessor.java @@ -1,6 +1,8 @@ package org.valkyrienskies.mod.mixin.accessors.entity; +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 org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; @@ -11,4 +13,13 @@ public interface EntityAccessor { @Accessor("position") void setPosNoUpdates(Vec3 pos); + @Accessor("blockPosition") + void setBlockPosition(BlockPos blockPosition); + + @Accessor("blockPosition") + BlockPos getBlockPosition(); + + @Accessor("feetBlockState") + void setFeetBlockState(BlockState feetBlockState); + } 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 fea85c465..12cb64517 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 @@ -1,5 +1,7 @@ package org.valkyrienskies.mod.mixin.feature.ladders; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; @@ -12,6 +14,7 @@ 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.mixin.accessors.entity.EntityAccessor; @Mixin(LivingEntity.class) public abstract class MixinLivingEntity extends Entity { @@ -45,17 +48,25 @@ private void onClimbableMixin(final CallbackInfoReturnable cir) { final double origY = pos.y; final double origZ = pos.z; + final EntityAccessor thisAsAccessor = (EntityAccessor) this; + final BlockPos originalBlockPosition = thisAsAccessor.getBlockPosition(); + VSGameUtilsKt.transformToNearbyShipsAndWorld(this.level, origX, origY, origZ, 1, (x, y, z) -> { - this.setPosRaw(x, y, z); - if (onClimbable()) { - cir.setReturnValue(true); + // 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.setFeetBlockState(null); + if (onClimbable()) { + cir.setReturnValue(true); + } } - this.setPosRaw(origX, origY, origZ); - }); - + // Restore the original block position + thisAsAccessor.setBlockPosition(originalBlockPosition); + thisAsAccessor.setFeetBlockState(null); isModifyingClimbable = false; } } From bd8c350393525f52801776504b7d58a31f8b8ca8 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Wed, 11 Jan 2023 19:27:19 -0500 Subject: [PATCH 025/437] bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 788574d39..3281660f6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.0-beta9 +mod_version=2.1.0-beta10 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From 43670c120b024e370e6e35d94ea342e9f4d26615 Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Sat, 14 Jan 2023 16:02:23 -0800 Subject: [PATCH 026/437] Feature/wings pt2 (#324) * Wingmogus :amogus: * feature/wings-pt2 * Fixed PhysShipImpl.transform computed incorrectly * Inject wings from BlockStateInfoProvider * Made WingManager an attachment * Partial work towards contraption wings * Updated vs-core --- .../shipyard_entities/MixinEntity.java | 10 + .../mixin/server/world/MixinServerLevel.java | 33 ++++ .../mod/common/BlockStateInfoProvider.kt | 25 +++ .../mod/common/ValkyrienSkiesMod.kt | 1 + .../mod/common/block/TestWingBlock.kt | 84 ++++++++ .../mod/common/block/WingBlock.kt | 10 + ...er.kt => AbstractShipyardEntityHandler.kt} | 6 +- .../handling/DefaultShipyardEntityHandler.kt | 3 + .../common/entity/handling/VSEntityHandler.kt | 2 + .../common/entity/handling/VSEntityManager.kt | 9 +- .../entity/handling/WorldEntityHandler.kt | 4 + .../valkyrienskies/blockstates/test_wing.json | 28 +++ .../assets/valkyrienskies/lang/en_us.json | 1 + .../models/block/test_wing.json | 181 ++++++++++++++++++ .../valkyrienskies/models/item/test_wing.json | 181 ++++++++++++++++++ .../valkyrienskies/textures/test_wing.png | Bin 0 -> 2581 bytes .../fabric/common/ValkyrienSkiesModFabric.kt | 3 + .../ContraptionShipyardEntityHandlerForge.kt | 15 ++ .../forge/common/ValkyrienSkiesModForge.kt | 4 + vs-core | 2 +- 20 files changed, 598 insertions(+), 4 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt rename common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/{ShipyardEntityHandler.kt => AbstractShipyardEntityHandler.kt} (93%) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/DefaultShipyardEntityHandler.kt create mode 100644 common/src/main/resources/assets/valkyrienskies/blockstates/test_wing.json create mode 100644 common/src/main/resources/assets/valkyrienskies/models/block/test_wing.json create mode 100644 common/src/main/resources/assets/valkyrienskies/models/item/test_wing.json create mode 100644 common/src/main/resources/assets/valkyrienskies/textures/test_wing.png create mode 100644 forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ContraptionShipyardEntityHandlerForge.kt 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 63f4c9507..16cafe92a 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 @@ -13,6 +13,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.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.entity.handling.VSEntityManager; @@ -92,6 +93,15 @@ private Entity preventSavingVehiclePosAsOurPos(final Entity originalVehicle) { } } + @Inject(method = "setRemoved", at = @At("HEAD")) + private void preSetRemoved() { + final Entity thisAsEntity = Entity.class.cast(this); + final Ship ship = VSGameUtilsKt.getShipManaging(thisAsEntity); + if (ship != null) { + VSEntityManager.INSTANCE.getHandler(thisAsEntity).entityRemovedFromShipyard(thisAsEntity, ship); + } + } + @Shadow protected abstract void positionRider(Entity passenger, Entity.MoveFunction callback); 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 1aabc5043..054f1de1d 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 @@ -14,6 +14,7 @@ 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.Holder; import net.minecraft.core.Position; import net.minecraft.resources.ResourceKey; @@ -22,6 +23,7 @@ import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.progress.ChunkProgressListener; +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; @@ -38,10 +40,13 @@ 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.Wing; +import org.valkyrienskies.core.api.ships.WingManager; import org.valkyrienskies.core.apigame.world.ServerShipWorldCore; import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate; import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.block.WingBlock; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.mixin.accessors.server.world.ChunkMapAccessor; @@ -143,6 +148,34 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf final TerrainUpdate voxelShapeUpdate = VSGameUtilsKt.toDenseVoxelUpdate(chunkSection, chunkPos); voxelShapeUpdates.add(voxelShapeUpdate); + + // region Detect wings + final ServerLevel thisAsLevel = ServerLevel.class.cast(this); + final LoadedServerShip + ship = VSGameUtilsKt.getShipObjectManagingPos(thisAsLevel, chunkX, chunkZ); + if (ship != null) { + // Sussy cast, but I don't want to expose this directly through the vs-core api + final WingManager shipAsWingManager = ship.getAttachment(WingManager.class); + final MutableBlockPos mutableBlockPos = new MutableBlockPos(); + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + 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 posZ = (chunkZ << 4) + z; + if (blockState.getBlock() instanceof WingBlock) { + mutableBlockPos.set(posX, posY, posZ); + final Wing wing = + ((WingBlock) blockState.getBlock()).getWing(thisAsLevel, + mutableBlockPos, blockState); + shipAsWingManager.setWing(shipAsWingManager.getFirstWingGroupId(), posX, posY, posZ, wing); + } + } + } + } + } + // endregion } else { final TerrainUpdate emptyVoxelShapeUpdate = getVsCore() .newEmptyVoxelShapeUpdate(chunkPos.x(), chunkPos.y(), chunkPos.z(), true); 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 815f233f6..2b7f8e0ac 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -7,10 +7,14 @@ import net.minecraft.core.MappedRegistry import net.minecraft.core.Registry import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation +import net.minecraft.server.level.ServerLevel import net.minecraft.world.level.Level import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState +import org.valkyrienskies.core.api.ships.Wing +import org.valkyrienskies.core.api.ships.WingManager 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.event.RegistryEvents @@ -89,6 +93,27 @@ object BlockStateInfo { val (newBlockMass, newBlockType) = get(newBlockState) ?: return + // region Inject wings + if (level is ServerLevel) { + val loadedShip = level.getShipObjectManagingPos(x shr 4, z shr 4) + if (loadedShip != null) { + val wingManager = loadedShip.getAttachment(WingManager::class.java)!! + val wasOldBlockWing = prevBlockState is WingBlock + val newWing: Wing? = + if (newBlockState is WingBlock) newBlockState.getWing( + level, BlockPos(x, y, z), newBlockState + ) else null + if (newWing != null) { + // Place the new wing + wingManager.setWing(wingManager.getFirstWingGroupId(), x, y, z, newWing) + } else if (wasOldBlockWing) { + // Delete the old wing + wingManager.setWing(wingManager.getFirstWingGroupId(), x, y, z, null) + } + } + } + // endregion + shipObjectWorld.onSetBlock( x, y, z, level.dimensionId, prevBlockType, newBlockType, prevBlockMass, newBlockMass 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 c01c997b5..1e85cdb8d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -22,6 +22,7 @@ object ValkyrienSkiesMod { lateinit var TEST_CHAIR: Block lateinit var TEST_HINGE: Block + lateinit var TEST_WING: Block lateinit var SHIP_CREATOR_ITEM: Item lateinit var SHIP_ASSEMBLER_ITEM: Item lateinit var SHIP_CREATOR_ITEM_SMALLER: Item 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 new file mode 100644 index 000000000..a30cafb50 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt @@ -0,0 +1,84 @@ +package org.valkyrienskies.mod.common.block + +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction.DOWN +import net.minecraft.core.Direction.EAST +import net.minecraft.core.Direction.NORTH +import net.minecraft.core.Direction.SOUTH +import net.minecraft.core.Direction.UP +import net.minecraft.core.Direction.WEST +import net.minecraft.world.item.context.BlockPlaceContext +import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block +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 +import org.valkyrienskies.mod.common.util.toJOMLD + +object TestWingBlock : + DirectionalBlock( + Properties.of(Material.METAL).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) + private val WEST_AABB = box(4.0, 0.0, 0.0, 12.0, 16.0, 16.0) + private val SOUTH_AABB = box(0.0, 0.0, 4.0, 16.0, 16.0, 12.0) + private val NORTH_AABB = box(0.0, 0.0, 4.0, 16.0, 16.0, 12.0) + private val UP_AABB = box(0.0, 4.0, 0.0, 16.0, 12.0, 16.0) + private val DOWN_AABB = box(0.0, 4.0, 0.0, 16.0, 12.0, 16.0) + + init { + registerDefaultState(this.stateDefinition.any().setValue(FACING, UP)) + } + + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { + builder.add(FACING) + } + + override fun getStateForPlacement(ctx: BlockPlaceContext): BlockState { + return defaultBlockState().setValue(FACING, ctx.nearestLookingDirection.opposite) + } + + @Deprecated("Deprecated in Java") + override fun getShape( + state: BlockState, blockGetter: BlockGetter, blockPos: BlockPos, collisionContext: CollisionContext + ): VoxelShape { + when (state.getValue(FACING)) { + DOWN -> { + return DOWN_AABB + } + NORTH -> { + return NORTH_AABB + } + SOUTH -> { + return SOUTH_AABB + } + WEST -> { + return WEST_AABB + } + EAST -> { + return EAST_AABB + } + UP -> { + return UP_AABB + } + else -> { + // This should be impossible, but have this here just in case + return UP_AABB + } + } + } + + override fun getWing(level: Level, pos: BlockPos, blockState: BlockState): Wing { + val wingPower = 150.0 + val wingDrag = 150.0 + val wingBreakingForce = null + return Wing(blockState.getValue(FACING).normal.toJOMLD(), wingPower, wingDrag, wingBreakingForce) + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt new file mode 100644 index 000000000..4fd31ee74 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt @@ -0,0 +1,10 @@ +package org.valkyrienskies.mod.common.block + +import net.minecraft.core.BlockPos +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.state.BlockState +import org.valkyrienskies.core.api.ships.Wing + +interface WingBlock { + fun getWing(level: Level, pos: BlockPos, blockState: BlockState): Wing +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/ShipyardEntityHandler.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/AbstractShipyardEntityHandler.kt similarity index 93% rename from common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/ShipyardEntityHandler.kt rename to common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/AbstractShipyardEntityHandler.kt index 716b11774..6e985e016 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/ShipyardEntityHandler.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/AbstractShipyardEntityHandler.kt @@ -10,11 +10,15 @@ import org.valkyrienskies.core.api.ships.Ship import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toMinecraft -object ShipyardEntityHandler : VSEntityHandler { +abstract class AbstractShipyardEntityHandler : VSEntityHandler { override fun freshEntityInShipyard(entity: Entity, ship: Ship) { // do nothing } + override fun entityRemovedFromShipyard(entity: Entity, ship: Ship) { + // do nothing + } + override fun applyRenderTransform( ship: ClientShip, entity: T, entityRenderer: EntityRenderer, x: Double, y: Double, z: Double, rotationYaw: Float, partialTicks: Float, matrixStack: PoseStack, buffer: MultiBufferSource, packedLight: Int diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/DefaultShipyardEntityHandler.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/DefaultShipyardEntityHandler.kt new file mode 100644 index 000000000..e65417441 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/DefaultShipyardEntityHandler.kt @@ -0,0 +1,3 @@ +package org.valkyrienskies.mod.common.entity.handling + +object DefaultShipyardEntityHandler : AbstractShipyardEntityHandler() diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityHandler.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityHandler.kt index f027cdea1..db71b3add 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityHandler.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/VSEntityHandler.kt @@ -17,6 +17,8 @@ interface VSEntityHandler { */ fun freshEntityInShipyard(entity: Entity, ship: Ship) + fun entityRemovedFromShipyard(entity: Entity, ship: Ship) + /** * ApplyRenderTransform * 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 f4444dc6e..b8728468b 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 @@ -16,9 +16,10 @@ object VSEntityManager { private val namedEntityHandlers = HashMap() private val entityHandlers = HashMap, VSEntityHandler>() private val default = WorldEntityHandler + private var contraptionHandler: VSEntityHandler = DefaultShipyardEntityHandler init { - register(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "shipyard"), ShipyardEntityHandler) + register(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "shipyard"), DefaultShipyardEntityHandler) register(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "default"), WorldEntityHandler) } @@ -33,6 +34,10 @@ object VSEntityManager { namedEntityHandlers[entityHandler] = name } + fun registerContraptionHandler(contraptionHandler: VSEntityHandler) { + this.contraptionHandler = contraptionHandler + } + /** * Pair the entity type with the entity handler * Should be preferably configured via datapacks @@ -50,7 +55,7 @@ object VSEntityManager { private fun getDefaultHandler(entity: Entity): VSEntityHandler { if (CreateCompat.isContraption(entity)) { - return ShipyardEntityHandler + return contraptionHandler } return default 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 e10e2a788..c6b7ffb4a 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 @@ -23,6 +23,10 @@ object WorldEntityHandler : VSEntityHandler { moveEntityFromShipyardToWorld(entity, ship) } + override fun entityRemovedFromShipyard(entity: Entity, ship: Ship) { + // Do nothing + } + override fun applyRenderTransform( ship: ClientShip, entity: T, entityRenderer: EntityRenderer, x: Double, y: Double, z: Double, diff --git a/common/src/main/resources/assets/valkyrienskies/blockstates/test_wing.json b/common/src/main/resources/assets/valkyrienskies/blockstates/test_wing.json new file mode 100644 index 000000000..627c29f10 --- /dev/null +++ b/common/src/main/resources/assets/valkyrienskies/blockstates/test_wing.json @@ -0,0 +1,28 @@ +{ + "variants": { + "facing=north": { + "model": "valkyrienskies:block/test_wing", + "y": 180 + }, + "facing=east": { + "model": "valkyrienskies:block/test_wing", + "y": 270 + }, + "facing=south": { + "model": "valkyrienskies:block/test_wing", + "y": 0 + }, + "facing=west": { + "model": "valkyrienskies:block/test_wing", + "y": 90 + }, + "facing=up": { + "model": "valkyrienskies:block/test_wing", + "x": 90 + }, + "facing=down": { + "model": "valkyrienskies:block/test_wing", + "x": 270 + } + } +} 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 b54382b60..e1282a2e5 100644 --- a/common/src/main/resources/assets/valkyrienskies/lang/en_us.json +++ b/common/src/main/resources/assets/valkyrienskies/lang/en_us.json @@ -3,6 +3,7 @@ "category.valkyrienskies.driving": "Driving", "block.valkyrienskies.test_chair": "Debug Chair", "block.valkyrienskies.test_hinge": "Debug Hinge", + "block.valkyrienskies.test_wing": "Debug Wing", "item.valkyrienskies.ship_creator": "Ship Creator", "item.valkyrienskies.ship_creator_smaller": "Mini Ship Creator" } diff --git a/common/src/main/resources/assets/valkyrienskies/models/block/test_wing.json b/common/src/main/resources/assets/valkyrienskies/models/block/test_wing.json new file mode 100644 index 000000000..358266113 --- /dev/null +++ b/common/src/main/resources/assets/valkyrienskies/models/block/test_wing.json @@ -0,0 +1,181 @@ +{ + "credit": "Made with Blockbench", + "parent": "valkyrienskies", + "texture_size": [64, 64], + "textures": { + "0": "valkyrienskies:test_wing", + "particle": "valkyrienskies:test_wing" + }, + "elements": [ + { + "name": "Base", + "from": [2, 2, 6.75], + "to": [14, 14, 9.25], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [3, 3, 0, 0], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3, 0.75, 6, 1.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [3, 3, 0, 6], "texture": "#0"}, + "west": {"uv": [3, 2.25, 6, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1.5, 6, 2.25], "texture": "#0"}, + "down": {"uv": [3, 0, 6, 0.75], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 0.25, 7], + "to": [13, 2.25, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [5.5, 4.5, 3, 4], "rotation": 180, "texture": "#0"}, + "east": {"uv": [7.25, 4, 7.75, 4.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [5.5, 4.5, 3, 5], "texture": "#0"}, + "west": {"uv": [6, 7.25, 6.5, 7.75], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 3.5, 5.5, 4], "texture": "#0"}, + "down": {"uv": [3, 3, 5.5, 3.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [0, 0, 6.5], + "to": [3, 3, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [6.75, 6.5, 6, 5.75], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3.75, 6, 4.5, 6.75], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0.75, 6.5, 0, 7.25], "texture": "#0"}, + "west": {"uv": [6, 5, 6.75, 5.75], "rotation": 270, "texture": "#0"}, + "up": {"uv": [4.5, 6, 5.25, 6.75], "texture": "#0"}, + "down": {"uv": [3, 6, 3.75, 6.75], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [0.25, 3, 7], + "to": [2.25, 13, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [6, 5.5, 5.5, 3], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3, 5, 5.5, 5.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [6, 5.5, 5.5, 8], "texture": "#0"}, + "west": {"uv": [3, 5.5, 5.5, 6], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3.5, 7.5, 4, 8], "texture": "#0"}, + "down": {"uv": [3, 7.5, 3.5, 8], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [0, 13, 6.5], + "to": [3, 16, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [7.25, 4.75, 6.5, 4], "rotation": 180, "texture": "#0"}, + "east": {"uv": [1.5, 6.5, 2.25, 7.25], "rotation": 90, "texture": "#0"}, + "south": {"uv": [6.75, 6.5, 6, 7.25], "texture": "#0"}, + "west": {"uv": [6.5, 3.25, 7.25, 4], "rotation": 270, "texture": "#0"}, + "up": {"uv": [6.5, 2.5, 7.25, 3.25], "texture": "#0"}, + "down": {"uv": [0.75, 6.5, 1.5, 7.25], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 13.75, 7], + "to": [13, 15.75, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [8.5, 1, 6, 0.5], "rotation": 180, "texture": "#0"}, + "east": {"uv": [4, 7.5, 4.5, 8], "rotation": 90, "texture": "#0"}, + "south": {"uv": [8.5, 1, 6, 1.5], "texture": "#0"}, + "west": {"uv": [4.5, 7.5, 5, 8], "rotation": 270, "texture": "#0"}, + "up": {"uv": [6, 0, 8.5, 0.5], "texture": "#0"}, + "down": {"uv": [0, 6, 2.5, 6.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [13, 13, 6.5], + "to": [16, 16, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [7.5, 6.25, 6.75, 5.5], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3.75, 6.75, 4.5, 7.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [7.5, 6.25, 6.75, 7], "texture": "#0"}, + "west": {"uv": [6.75, 4.75, 7.5, 5.5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [4.5, 6.75, 5.25, 7.5], "texture": "#0"}, + "down": {"uv": [3, 6.75, 3.75, 7.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [13.75, 3, 7], + "to": [15.75, 13, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [3, 8.5, 2.5, 6], "rotation": 180, "texture": "#0"}, + "east": {"uv": [6, 1.5, 8.5, 2], "rotation": 90, "texture": "#0"}, + "south": {"uv": [6.5, 2.5, 6, 5], "texture": "#0"}, + "west": {"uv": [6, 2, 8.5, 2.5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [5, 7.5, 5.5, 8], "texture": "#0"}, + "down": {"uv": [7.5, 4.5, 8, 5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [13, 0, 6.5], + "to": [16, 3, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [8, 3.25, 7.25, 2.5], "rotation": 180, "texture": "#0"}, + "east": {"uv": [0, 7.25, 0.75, 8], "rotation": 90, "texture": "#0"}, + "south": {"uv": [8, 3.25, 7.25, 4], "texture": "#0"}, + "west": {"uv": [1.5, 7.25, 2.25, 8], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0.75, 7.25, 1.5, 8], "texture": "#0"}, + "down": {"uv": [6.75, 7, 7.5, 7.75], "rotation": 180, "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "translation": [0, 3, 1], + "scale": [0.35, 0.35, 0.35] + }, + "thirdperson_lefthand": { + "translation": [0, 3, 1], + "scale": [0.35, 0.35, 0.35] + }, + "firstperson_righthand": { + "rotation": [0, -90, 25], + "translation": [1.13, 3.2, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "firstperson_lefthand": { + "rotation": [0, -90, 25], + "translation": [1.13, 3.2, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "ground": { + "translation": [0, 2, 0], + "scale": [0.5, 0.5, 0.5] + }, + "gui": { + "rotation": [14, 140, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "translation": [0, 0, -15.75], + "scale": [2, 2, 2] + } + }, + "groups": [ + { + "name": "Sail", + "origin": [8, 8, 8], + "color": 0, + "nbt": "{}", + "armAnimationEnabled": false, + "children": [ + 0, + { + "name": "Base", + "origin": [8, 8, 8], + "color": 0, + "nbt": "{}", + "armAnimationEnabled": false, + "children": [1, 2, 3, 4, 5, 6, 7, 8] + } + ] + } + ] +} diff --git a/common/src/main/resources/assets/valkyrienskies/models/item/test_wing.json b/common/src/main/resources/assets/valkyrienskies/models/item/test_wing.json new file mode 100644 index 000000000..358266113 --- /dev/null +++ b/common/src/main/resources/assets/valkyrienskies/models/item/test_wing.json @@ -0,0 +1,181 @@ +{ + "credit": "Made with Blockbench", + "parent": "valkyrienskies", + "texture_size": [64, 64], + "textures": { + "0": "valkyrienskies:test_wing", + "particle": "valkyrienskies:test_wing" + }, + "elements": [ + { + "name": "Base", + "from": [2, 2, 6.75], + "to": [14, 14, 9.25], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [3, 3, 0, 0], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3, 0.75, 6, 1.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [3, 3, 0, 6], "texture": "#0"}, + "west": {"uv": [3, 2.25, 6, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1.5, 6, 2.25], "texture": "#0"}, + "down": {"uv": [3, 0, 6, 0.75], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 0.25, 7], + "to": [13, 2.25, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [5.5, 4.5, 3, 4], "rotation": 180, "texture": "#0"}, + "east": {"uv": [7.25, 4, 7.75, 4.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [5.5, 4.5, 3, 5], "texture": "#0"}, + "west": {"uv": [6, 7.25, 6.5, 7.75], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 3.5, 5.5, 4], "texture": "#0"}, + "down": {"uv": [3, 3, 5.5, 3.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [0, 0, 6.5], + "to": [3, 3, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [6.75, 6.5, 6, 5.75], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3.75, 6, 4.5, 6.75], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0.75, 6.5, 0, 7.25], "texture": "#0"}, + "west": {"uv": [6, 5, 6.75, 5.75], "rotation": 270, "texture": "#0"}, + "up": {"uv": [4.5, 6, 5.25, 6.75], "texture": "#0"}, + "down": {"uv": [3, 6, 3.75, 6.75], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [0.25, 3, 7], + "to": [2.25, 13, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [6, 5.5, 5.5, 3], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3, 5, 5.5, 5.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [6, 5.5, 5.5, 8], "texture": "#0"}, + "west": {"uv": [3, 5.5, 5.5, 6], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3.5, 7.5, 4, 8], "texture": "#0"}, + "down": {"uv": [3, 7.5, 3.5, 8], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [0, 13, 6.5], + "to": [3, 16, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [7.25, 4.75, 6.5, 4], "rotation": 180, "texture": "#0"}, + "east": {"uv": [1.5, 6.5, 2.25, 7.25], "rotation": 90, "texture": "#0"}, + "south": {"uv": [6.75, 6.5, 6, 7.25], "texture": "#0"}, + "west": {"uv": [6.5, 3.25, 7.25, 4], "rotation": 270, "texture": "#0"}, + "up": {"uv": [6.5, 2.5, 7.25, 3.25], "texture": "#0"}, + "down": {"uv": [0.75, 6.5, 1.5, 7.25], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 13.75, 7], + "to": [13, 15.75, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [8.5, 1, 6, 0.5], "rotation": 180, "texture": "#0"}, + "east": {"uv": [4, 7.5, 4.5, 8], "rotation": 90, "texture": "#0"}, + "south": {"uv": [8.5, 1, 6, 1.5], "texture": "#0"}, + "west": {"uv": [4.5, 7.5, 5, 8], "rotation": 270, "texture": "#0"}, + "up": {"uv": [6, 0, 8.5, 0.5], "texture": "#0"}, + "down": {"uv": [0, 6, 2.5, 6.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [13, 13, 6.5], + "to": [16, 16, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [7.5, 6.25, 6.75, 5.5], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3.75, 6.75, 4.5, 7.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [7.5, 6.25, 6.75, 7], "texture": "#0"}, + "west": {"uv": [6.75, 4.75, 7.5, 5.5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [4.5, 6.75, 5.25, 7.5], "texture": "#0"}, + "down": {"uv": [3, 6.75, 3.75, 7.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [13.75, 3, 7], + "to": [15.75, 13, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [3, 8.5, 2.5, 6], "rotation": 180, "texture": "#0"}, + "east": {"uv": [6, 1.5, 8.5, 2], "rotation": 90, "texture": "#0"}, + "south": {"uv": [6.5, 2.5, 6, 5], "texture": "#0"}, + "west": {"uv": [6, 2, 8.5, 2.5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [5, 7.5, 5.5, 8], "texture": "#0"}, + "down": {"uv": [7.5, 4.5, 8, 5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [13, 0, 6.5], + "to": [16, 3, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [8, 3.25, 7.25, 2.5], "rotation": 180, "texture": "#0"}, + "east": {"uv": [0, 7.25, 0.75, 8], "rotation": 90, "texture": "#0"}, + "south": {"uv": [8, 3.25, 7.25, 4], "texture": "#0"}, + "west": {"uv": [1.5, 7.25, 2.25, 8], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0.75, 7.25, 1.5, 8], "texture": "#0"}, + "down": {"uv": [6.75, 7, 7.5, 7.75], "rotation": 180, "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "translation": [0, 3, 1], + "scale": [0.35, 0.35, 0.35] + }, + "thirdperson_lefthand": { + "translation": [0, 3, 1], + "scale": [0.35, 0.35, 0.35] + }, + "firstperson_righthand": { + "rotation": [0, -90, 25], + "translation": [1.13, 3.2, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "firstperson_lefthand": { + "rotation": [0, -90, 25], + "translation": [1.13, 3.2, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "ground": { + "translation": [0, 2, 0], + "scale": [0.5, 0.5, 0.5] + }, + "gui": { + "rotation": [14, 140, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "translation": [0, 0, -15.75], + "scale": [2, 2, 2] + } + }, + "groups": [ + { + "name": "Sail", + "origin": [8, 8, 8], + "color": 0, + "nbt": "{}", + "armAnimationEnabled": false, + "children": [ + 0, + { + "name": "Base", + "origin": [8, 8, 8], + "color": 0, + "nbt": "{}", + "armAnimationEnabled": false, + "children": [1, 2, 3, 4, 5, 6, 7, 8] + } + ] + } + ] +} diff --git a/common/src/main/resources/assets/valkyrienskies/textures/test_wing.png b/common/src/main/resources/assets/valkyrienskies/textures/test_wing.png new file mode 100644 index 0000000000000000000000000000000000000000..e588a295780a171090fb70145c4549e009da2f37 GIT binary patch literal 2581 zcmV+w3hMQVP)%jp7TH7|J={&{eAzGp5xv4L4i%3>$rB=Ekt1z;Iv~?re1_GhA14Q`{NIJq2n2D zzHud@6e0$t6dlj6<))iff&zf`oqxsiJT9IPa_Cr0nx@2YjEL}+S(7+)G{*OR9(w4Z zp-+r2y61RzzO#GJegLLUy97Tdj5r3+bG(~43hD3d27y~|`##0eBqU7{V=!X4b>$rt ziY0H4xpjY}zubceAOfl3*|kp+G!*gu0Oe@XG$l<^`^U6KL{Lhh zw0+>(aTpvJ9RJ9Na5r_XWA~o@d7xkeA5Ljvk<}00&%!I`uypD5fZ(_el17Mt_7q79 zjwqCYfl8Ullc!OL2H3l2F95C0i+J~6?~eH1+0z$sVE=(J5AxGc@BIC50;hs@lt(J@ zY1@^)0RTj*4D|OChgAxt64got*Dnx-gJ=ZhIyjC;sWgc=4te_dS8yDM%PxklqY>3= z6|FT|Yvx{FWdDB#Ns@%ee)U*wG$0eaEWj+_Y}-*@el7~DAc{B+QCjibvrplAE+(ns zIU40TbaXs}VCd=o2*(RXXh52#Xr*x+2gh;pzoV#0>;UL&W74F_fPL!2NhQwD0l0nu zFr*uTAea=4QfTd<5R|~A$rlk-D*zZ{^504;lv22^3xF6QP1CW9@H5bv0A^2qcn`?P zj%C-DCQT*^tK9y*J20u8{zwwE(%g8{N(69ypD3)_b3-Vl^2W%H3xakuwL)*|Tt{2m z>d(Bet!*`%I@eKXDB3QoVC^5C!0|kU6dVmGUg%hhh~T{6xT)WI_KqiFQm><5sYSlgYhYAf7sFY6vg6p~@p+aewG))lE7?aZ1 z+fAIrL{Wsoc6+51+R+#>#BrQA2k#%D0hPW1RzG+@U-AkB%yq=oAvAe#9*aN zoTL;RCRni(n+0xoWdp9~A|ky0`s+0nzYOQd;Daj7&CSG-?fNY(Ej8`>8Kd?B08td> z$EwvT)oPVEwj$?w9>tQ?4ngQT8gbwQI~ycvf>PP!DS0|vOGf1dyrCQ*iX#4fxIz?0 z#IY4R5n=CvGR7Dxl?tuRi@0=($qkWGiXGc`ptVhawrt*#CrGu#SukhHPha}Wi!5EX zJU{3M9)94B*ni~VpV8ZMm=nD*Mg(IF+Br3)Wr+=di15}w-beHVlu|gZ4SM?Y>GlEz z^XAS)1m1Y#jZ-G12Aq`_5E1&yeH=e}gkL=VJHVQojax>VoBuyHYt}5ZWApwbNl4Qa z5y@R)t@8ijxKUWe4+?o6@JU{vyXRy2%iZ+%_Aq0{3_Q>Fj`<7b4<$XPp8o9Fvx$?K zBZrTm9nI|Nc6jYO7_xo)c9twzVlS+D=$5nc0uv|N)Hh8deBU2oZnEE*=l47>S9fC! z?;YxA@4+%CXl!b8@+yaLy8*}Qo(%`MIO8bBC^ zJpS0@b)f?1t!t?A9a9v#2#fV|+)@``X88h&4N8R_6`|=?$JTv>GJbl-j zyIB17#Z)R4k|aSXMVh22txhFGj!Roxn|fsRj|Je!M=7svc$LPcMzq$}5^K$)YaXqS zA&_mDG$o0XJhuVAfU0aF>ko8qY+0>*zKkz zO?Kf!Ym70uZ>R@OHGl|F9NCO5v8y;qk`RU=yWZOMgNrAGv^FndaBz^urbdE7fI_ij z#}2g8nAEUi`;HMWLE}*|^BpMc5V-mqS5s&x5coc= z*R=xh@=GuO=I9B<#x3t+jKR_N4Ugx0Heh9i(RJNCM=-|Z>wnv}Zo`NniXxU>w~Ru= z={CDoXc1xgx0e$Qb<4Nkew#21iQ<^oI$z5LD~eB9;Dw78;`=^HlCX8l);!SRiyToD z<*Pm|EiHM2WNU);f*u?kL}5itYYmDK8Cn*2Hn!6=W%usgL}5e}Ml?1yqLt1UIkL~r zyQ0MG83i2e+O@$ntAi)OF|I>Dyao9j9e8uL2AdS}e* z1nZr=L}qwxU}<9UwEe6^Moh|Sb%L(KsG&8&p*q2!P^3_(AK!l_#=K7On#SeztpQ_Q zCs^-{OPydnGv;-I_0E{r3D!GfUME=ZjCq}4y)))@g7wa*>jdX6`09vx{pamZpLWeJ zpXm4^?rmH+r#iv&iBT0uhzN_X`Bq(LcB5rf|1&gy?&afse`C(5>janIxbnQ}0cYg} z$|rm2J9(V`-kzG=GY|cQkc^!Hm+l-rRU_R$jpMe17};CwOz$mT|hR@nh6= rf?vD(o9CYho{JYaUpOZ(a6a)r(ObKLS=j9L00000NkvXXu0mjf6jJ~{ literal 0 HcmV?d00001 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 4e6bea689..426bb8ebb 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 @@ -27,6 +27,7 @@ import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestHingeBlock +import org.valkyrienskies.mod.common.block.TestWingBlock import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.config.MassDatapackResolver import org.valkyrienskies.mod.common.config.VSEntityHandlerDataLoader @@ -50,6 +51,7 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_CHAIR = TestChairBlock ValkyrienSkiesMod.TEST_HINGE = TestHingeBlock + ValkyrienSkiesMod.TEST_WING = TestWingBlock ValkyrienSkiesMod.SHIP_CREATOR_ITEM = ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), 1.0) ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM = ShipAssemblerItem(Properties().tab(CreativeModeTab.TAB_MISC)) ValkyrienSkiesMod.SHIP_CREATOR_ITEM_SMALLER = ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), 0.5) @@ -78,6 +80,7 @@ class ValkyrienSkiesModFabric : ModInitializer { registerBlockAndItem("test_chair", ValkyrienSkiesMod.TEST_CHAIR) registerBlockAndItem("test_hinge", ValkyrienSkiesMod.TEST_HINGE) + registerBlockAndItem("test_wing", ValkyrienSkiesMod.TEST_WING) Registry.register( Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_assembler"), ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM 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 new file mode 100644 index 000000000..6d5b43c40 --- /dev/null +++ b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ContraptionShipyardEntityHandlerForge.kt @@ -0,0 +1,15 @@ +package org.valkyrienskies.mod.forge.common + +import net.minecraft.world.entity.Entity +import org.valkyrienskies.core.api.ships.Ship +import org.valkyrienskies.mod.common.entity.handling.AbstractShipyardEntityHandler + +object ContraptionShipyardEntityHandlerForge: AbstractShipyardEntityHandler() { + override fun freshEntityInShipyard(entity: Entity, ship: Ship) { + // TODO: Handle contraptions here + } + + override fun entityRemovedFromShipyard(entity: Entity, ship: Ship) { + // TODO: Handle contraptions here + } +} 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 421d74eca..aacac7575 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 @@ -29,6 +29,7 @@ import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestHingeBlock +import org.valkyrienskies.mod.common.block.TestWingBlock import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.config.MassDatapackResolver import org.valkyrienskies.mod.common.config.VSEntityHandlerDataLoader @@ -47,6 +48,7 @@ class ValkyrienSkiesModForge { private val BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, ValkyrienSkiesMod.MOD_ID) private val TEST_CHAIR_REGISTRY: RegistryObject private val TEST_HINGE_REGISTRY: RegistryObject + private val TEST_WING_REGISTRY: RegistryObject private val SHIP_CREATOR_ITEM_REGISTRY: RegistryObject private val SHIP_CREATOR_SMALLER_ITEM_REGISTRY: RegistryObject private val SHIP_MOUNTING_ENTITY_REGISTRY: RegistryObject> @@ -90,6 +92,7 @@ class ValkyrienSkiesModForge { TEST_CHAIR_REGISTRY = registerBlockAndItem("test_chair") { TestChairBlock } TEST_HINGE_REGISTRY = registerBlockAndItem("test_hinge") { TestHingeBlock } + TEST_WING_REGISTRY = registerBlockAndItem("test_wing") { TestWingBlock } SHIP_CREATOR_ITEM_REGISTRY = ITEMS.register("ship_creator") { ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), 1.0) } SHIP_CREATOR_SMALLER_ITEM_REGISTRY = @@ -132,6 +135,7 @@ class ValkyrienSkiesModForge { private fun loadComplete(event: FMLLoadCompleteEvent) { ValkyrienSkiesMod.TEST_CHAIR = TEST_CHAIR_REGISTRY.get() ValkyrienSkiesMod.TEST_HINGE = TEST_HINGE_REGISTRY.get() + ValkyrienSkiesMod.TEST_WING = TEST_WING_REGISTRY.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() diff --git a/vs-core b/vs-core index 855ccac69..29f489655 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 855ccac6971e5263f0870c68791c7e03d34ee189 +Subproject commit 29f489655da56021318685167fb02b89b79f7a4c From 9e9f382692198d0a874ccee32caf32b494e115cf Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sat, 14 Jan 2023 18:41:55 -0700 Subject: [PATCH 027/437] Fixed forge not running --- .../mod/mixin/feature/shipyard_entities/MixinEntity.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 16cafe92a..86cb7658f 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 @@ -4,6 +4,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.Entity.RemovalReason; import net.minecraft.world.entity.EntityType; import net.minecraft.world.level.Level; import org.joml.Vector3d; @@ -94,7 +95,7 @@ private Entity preventSavingVehiclePosAsOurPos(final Entity originalVehicle) { } @Inject(method = "setRemoved", at = @At("HEAD")) - private void preSetRemoved() { + private void preSetRemoved(final RemovalReason removalReason, final CallbackInfo ci) { final Entity thisAsEntity = Entity.class.cast(this); final Ship ship = VSGameUtilsKt.getShipManaging(thisAsEntity); if (ship != null) { From b9b5aeb0fe770690c96390e0f05741cae6994b91 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sat, 14 Jan 2023 22:07:54 -0700 Subject: [PATCH 028/437] Updated to 2.1.1 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 3281660f6..7c8f165af 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.0-beta10 +mod_version=2.1.1-beta10 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From 234755cbd03c5a404139938ea5ccfcac8ad15f31 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 15 Jan 2023 01:55:47 -0700 Subject: [PATCH 029/437] Use LevelYRange instead of IntRange to fix forge mixin crash --- .../mixin/mod_compat/flywheel/MixinTileInstanceManager.java | 4 ++-- .../mod/mixin/server/world/MixinServerLevel.java | 3 ++- .../main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 3 ++- .../kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt | 2 +- vs-core | 2 +- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinTileInstanceManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinTileInstanceManager.java index 32cbaec66..8945f4b24 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinTileInstanceManager.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinTileInstanceManager.java @@ -9,7 +9,6 @@ import com.jozufozu.flywheel.core.shader.WorldProgram; import java.util.WeakHashMap; import javax.annotation.ParametersAreNonnullByDefault; -import kotlin.ranges.IntRange; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; import net.minecraft.world.level.Level; @@ -22,6 +21,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.core.api.world.LevelYRange; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.mixinducks.MixinTileInstanceManagerDuck; @@ -56,7 +56,7 @@ void preCreateRaw(final BlockEntity blockEntity, final CallbackInfoReturnable manager = shipMaterialManagers.computeIfAbsent(ship, k -> InstancingEngine.builder(Contexts.WORLD).setIgnoreOriginCoordinate(true).build()); - final Vector3i c = ship.getChunkClaim().getCenterBlockCoordinates(new IntRange(0, 0), new Vector3i()); + final Vector3i c = ship.getChunkClaim().getCenterBlockCoordinates(new LevelYRange(0, 0), new Vector3i()); ((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/server/world/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java index 054f1de1d..d50f3fd0e 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 @@ -169,7 +169,8 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf final Wing wing = ((WingBlock) blockState.getBlock()).getWing(thisAsLevel, mutableBlockPos, blockState); - shipAsWingManager.setWing(shipAsWingManager.getFirstWingGroupId(), posX, posY, posZ, wing); + if (wing != null) + shipAsWingManager.setWing(shipAsWingManager.getFirstWingGroupId(), posX, posY, posZ, wing); } } } 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 763158182..ae3b86054 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -27,6 +27,7 @@ import org.valkyrienskies.core.api.ships.LoadedShip 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.apigame.world.IPlayer import org.valkyrienskies.core.apigame.world.ShipWorldCore import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate @@ -92,7 +93,7 @@ fun MinecraftServer.executeIf(condition: () -> Boolean, toExecute: Runnable) { } } -val Level.yRange get() = minBuildHeight until maxBuildHeight +val Level.yRange get() = LevelYRange(minBuildHeight, maxBuildHeight) fun Level.isTickingChunk(pos: ChunkPos) = isTickingChunk(pos.x, pos.z) fun Level.isTickingChunk(chunkX: Int, chunkZ: Int) = diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt index 4fd31ee74..582907cc1 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt @@ -6,5 +6,5 @@ import net.minecraft.world.level.block.state.BlockState import org.valkyrienskies.core.api.ships.Wing interface WingBlock { - fun getWing(level: Level, pos: BlockPos, blockState: BlockState): Wing + fun getWing(level: Level, pos: BlockPos, blockState: BlockState): Wing? } diff --git a/vs-core b/vs-core index 29f489655..357151f0b 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 29f489655da56021318685167fb02b89b79f7a4c +Subproject commit 357151f0bb11b50724b1a9097314dc450683ead1 From 8594eec318be6ee361a4d2de08ad6426be47ed91 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 15 Jan 2023 01:57:20 -0700 Subject: [PATCH 030/437] Revert "Updated to 2.1.1" This reverts commit b9b5aeb0fe770690c96390e0f05741cae6994b91. --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 7c8f165af..3281660f6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.1-beta10 +mod_version=2.1.0-beta10 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From a066aafc76421046ab45774a77859da0feaa467c Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sun, 15 Jan 2023 03:58:12 -0500 Subject: [PATCH 031/437] Make version number adhere to semver better (#321) * Update publish-curseforge.gradle * Update publish-curseforge.gradle * Update gradle.properties * Update publish-curseforge.gradle --- gradle-scripts/publish-curseforge.gradle | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle-scripts/publish-curseforge.gradle b/gradle-scripts/publish-curseforge.gradle index 5d89366cc..1bc0571e6 100644 --- a/gradle-scripts/publish-curseforge.gradle +++ b/gradle-scripts/publish-curseforge.gradle @@ -2,7 +2,7 @@ // alpha, beta, or release def vsReleaseType = 'alpha' if (project.hasProperty("CustomReleaseVersion")) { - def matches = project.property("CustomReleaseVersion") =~ 'release/(?:\\d+\\.){1,2}\\d+-(alpha|beta)\\d+' + def matches = project.property("CustomReleaseVersion") =~ 'release/(?:\\d+\\.){1,2}\\d+(?:-(alpha|beta).\\d+)?' vsReleaseType = matches[0][1] ?: 'release' } diff --git a/gradle.properties b/gradle.properties index 3281660f6..dcd7e0adc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4096M minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.0-beta10 +mod_version=2.1.0-beta.10 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From 660e193966a87b440a9808134b37d2364da8ada3 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 15 Jan 2023 04:22:22 -0700 Subject: [PATCH 032/437] Made wing drag 10x smaller --- .../kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 a30cafb50..441163bcd 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 @@ -77,7 +77,7 @@ object TestWingBlock : override fun getWing(level: Level, pos: BlockPos, blockState: BlockState): Wing { val wingPower = 150.0 - val wingDrag = 150.0 + val wingDrag = 15.0 val wingBreakingForce = null return Wing(blockState.getValue(FACING).normal.toJOMLD(), wingPower, wingDrag, wingBreakingForce) } From 1210ae43b3cecf5a25a9d4fd8af2d2329e7290bd Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 15 Jan 2023 06:43:27 -0700 Subject: [PATCH 033/437] Made wing drag 2x larger --- .../kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 441163bcd..f5669d8c3 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 @@ -77,7 +77,7 @@ object TestWingBlock : override fun getWing(level: Level, pos: BlockPos, blockState: BlockState): Wing { val wingPower = 150.0 - val wingDrag = 15.0 + val wingDrag = 30.0 val wingBreakingForce = null return Wing(blockState.getValue(FACING).normal.toJOMLD(), wingPower, wingDrag, wingBreakingForce) } From 08d4d3233232cf091886542724547622108d7b29 Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Mon, 16 Jan 2023 03:51:22 -0800 Subject: [PATCH 034/437] Feature/contraption wings (#355) * Initial work on contraption wings * Fixing some things * Fixed contraption wings on fabric * Updated vs-core --- .../shipyard_entities/MixinEntity.java | 5 +- .../shipyard_entities/MixinServerLevel.java | 5 +- .../mod/common/BlockStateInfoProvider.kt | 5 +- .../valkyrienskies/mod/common/VSGameUtils.kt | 6 ++ .../mod/common/block/TestWingBlock.kt | 2 +- .../mod/common/block/WingBlock.kt | 2 +- .../common/entity/handling/VSEntityManager.kt | 7 +-- fabric/build.gradle | 20 +++---- .../mixin/compat/create/Matrix3dAccessor.java | 37 ++++++++++++ .../MixinAbstractContraptionEntity.java | 59 +++++++++++++++++++ .../ContraptionShipyardEntityHandlerFabric.kt | 40 +++++++++++++ .../mod/fabric/common/CreateConversions.kt | 13 ++++ .../fabric/common/ValkyrienSkiesModFabric.kt | 2 + .../valkyrienskies-fabric.mixins.json | 2 + .../mixin/compat/create/Matrix3dAccessor.java | 35 +++++++++++ .../MixinAbstractContraptionEntity.java | 57 ++++++++++++++++++ .../ContraptionShipyardEntityHandlerForge.kt | 29 ++++++++- .../mod/forge/common/CreateConversions.kt | 13 ++++ .../forge/common/ValkyrienSkiesModForge.kt | 2 + .../valkyrienskies-forge.mixins.json | 2 + vs-core | 2 +- 21 files changed, 320 insertions(+), 25 deletions(-) create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/Matrix3dAccessor.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinAbstractContraptionEntity.java create mode 100644 fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ContraptionShipyardEntityHandlerFabric.kt create mode 100644 fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/CreateConversions.kt create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/Matrix3dAccessor.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinAbstractContraptionEntity.java create mode 100644 forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/CreateConversions.kt 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 86cb7658f..24082cee3 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 @@ -14,9 +14,10 @@ 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.core.api.ships.LoadedShip; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.entity.handling.VSEntityManager; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @Mixin(Entity.class) public abstract class MixinEntity { @@ -97,7 +98,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 Ship ship = VSGameUtilsKt.getShipManaging(thisAsEntity); + 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/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinServerLevel.java index 4acb491cf..cbfe081fb 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 @@ -10,9 +10,10 @@ 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.Ship; +import org.valkyrienskies.core.api.ships.LoadedShip; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.entity.handling.VSEntityManager; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.mixinducks.world.OfLevel; @Mixin(ServerLevel.class) @@ -35,7 +36,7 @@ void configureEntitySections(final CallbackInfo ci) { ) ) void preAddEntity(final Entity entity, final CallbackInfoReturnable cir) { - final Ship ship = VSGameUtilsKt.getShipManaging(entity); + 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/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt index 2b7f8e0ac..7d064eb16 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -98,9 +98,10 @@ object BlockStateInfo { val loadedShip = level.getShipObjectManagingPos(x shr 4, z shr 4) if (loadedShip != null) { val wingManager = loadedShip.getAttachment(WingManager::class.java)!! - val wasOldBlockWing = prevBlockState is WingBlock + val wasOldBlockWing = prevBlockState.block is WingBlock + val newBlockStateBlock = newBlockState.block val newWing: Wing? = - if (newBlockState is WingBlock) newBlockState.getWing( + if (newBlockStateBlock is WingBlock) newBlockStateBlock.getWing( level, BlockPos(x, y, z), newBlockState ) else null if (newWing != null) { 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 ae3b86054..2ebe5a46a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -282,6 +282,9 @@ fun ServerLevel.getShipObjectManagingPos(chunkPos: ChunkPos) = fun ServerLevel.getShipObjectManagingPos(posX: Double, posY: Double, posZ: Double) = getShipObjectManagingPos(posX.toInt() shr 4, posZ.toInt() shr 4) +fun ServerLevel.getShipObjectManagingPos(pos: Vector3dc) = + getShipObjectManagingPos(pos.x().toInt() shr 4, pos.z().toInt() shr 4) + private fun getShipManagingPosImpl(world: Level, x: Int, z: Int): Ship? { return if (world.isChunkInShipyard(x, z)) { world.shipObjectWorld.allShips.getByChunkPos(x, z, world.dimensionId) @@ -329,6 +332,9 @@ fun ServerLevel.getShipManagingPos(chunkX: Int, chunkZ: Int) = fun ServerLevel.getShipManagingPos(blockPos: BlockPos) = getShipManagingPos(blockPos.x shr 4, blockPos.z shr 4) +fun ServerLevel.getShipManagingPos(pos: Vector3dc) = + getShipManagingPos(pos.x().toInt() shr 4, pos.z().toInt() shr 4) + fun ServerLevel.getShipManagingPos(posX: Double, posY: Double, posZ: Double) = getShipManagingPos(posX.toInt() shr 4, posZ.toInt() shr 4) 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 f5669d8c3..e1a15c68e 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 @@ -75,7 +75,7 @@ object TestWingBlock : } } - override fun getWing(level: Level, pos: BlockPos, blockState: BlockState): Wing { + override fun getWing(level: Level?, pos: BlockPos?, blockState: BlockState): Wing { val wingPower = 150.0 val wingDrag = 30.0 val wingBreakingForce = null diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt index 582907cc1..cfedf8c06 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/WingBlock.kt @@ -6,5 +6,5 @@ import net.minecraft.world.level.block.state.BlockState import org.valkyrienskies.core.api.ships.Wing interface WingBlock { - fun getWing(level: Level, pos: BlockPos, blockState: BlockState): Wing? + fun getWing(level: Level?, pos: BlockPos?, blockState: BlockState): Wing? } 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 b8728468b..f66654dd1 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 @@ -50,14 +50,13 @@ object VSEntityManager { } fun getHandler(entity: Entity): VSEntityHandler { - return entityHandlers[entity.type] ?: getDefaultHandler(entity) - } - - private fun getDefaultHandler(entity: Entity): VSEntityHandler { if (CreateCompat.isContraption(entity)) { return contraptionHandler } + return entityHandlers[entity.type] ?: getDefaultHandler(entity) + } + private fun getDefaultHandler(entity: Entity): VSEntityHandler { return default } diff --git a/fabric/build.gradle b/fabric/build.gradle index bb4d4cc7d..20b16bd33 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")) - modCompileOnly("curse.maven:sodium-394468:3669187") + modImplementation("curse.maven:sodium-394468:3669187") modImplementation("com.terraformersmc:modmenu:3.2.3") // Depend on the fabric API @@ -60,18 +60,18 @@ dependencies { } // CC Restitched - modCompileOnly("curse.maven:cc-restitched-462672:3838648") + modImplementation("curse.maven:cc-restitched-462672:3838648") // Create compat - modCompileOnly("com.simibubi.create:create-fabric-${minecraft_version}:${create_version}+${minecraft_version}") { transitive = false } - modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version}") - modCompileOnly("com.tterrag.registrate_fabric:Registrate:${registrate_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:${port_lib_version}+${minecraft_version}") - modCompileOnly("me.alphamode:ForgeTags:${forge_tags_version}") - modCompileOnly("net.minecraftforge:forgeconfigapiport-fabric:${forge_config_api_port_version}") - 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}") + 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}") + modImplementation("io.github.tropheusj:milk-lib:${milk_lib_version}") } // Copy the VS common access widener to the generated resources folder 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 new file mode 100644 index 000000000..8a6192c90 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/Matrix3dAccessor.java @@ -0,0 +1,37 @@ +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; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Pseudo +@Mixin(Matrix3d.class) +public interface Matrix3dAccessor { + @Accessor("m00") + double getM00(); + + @Accessor("m01") + double getM01(); + + @Accessor("m02") + double getM02(); + + @Accessor("m10") + double getM10(); + + @Accessor("m11") + double getM11(); + + @Accessor("m12") + double getM12(); + + @Accessor("m20") + double getM20(); + + @Accessor("m21") + double getM21(); + + @Accessor("m22") + double getM22(); +} diff --git a/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 new file mode 100644 index 000000000..4d3ebb77e --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinAbstractContraptionEntity.java @@ -0,0 +1,59 @@ +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; +import org.jetbrains.annotations.NotNull; +import org.joml.Matrix3d; +import org.joml.Matrix4d; +import org.joml.Matrix4dc; +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.CallbackInfo; +import org.valkyrienskies.core.api.ships.ContraptionWingProvider; +import org.valkyrienskies.core.api.ships.LoadedServerShip; +import org.valkyrienskies.core.api.ships.WingManager; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import org.valkyrienskies.mod.fabric.common.CreateConversionsKt; + +@Pseudo +@Mixin(AbstractContraptionEntity.class) +public abstract class MixinAbstractContraptionEntity implements ContraptionWingProvider { + + @Unique + private int wingGroupId = -1; + + @Override + public int getWingGroupId() { + return wingGroupId; + } + + @Override + public void setWingGroupId(final int wingGroupId) { + this.wingGroupId = wingGroupId; + } + + @Inject(method = "tick", at = @At("HEAD")) + private void postTick(final CallbackInfo ci) { + final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); + final Level level = thisAsAbstractContraptionEntity.level; + if (wingGroupId != -1 && !level.isClientSide) { + final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos((ServerLevel) level, VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); + ship.getAttachment(WingManager.class).setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); + } + } + + @NotNull + @Override + public Matrix4dc computeContraptionWingTransform() { + final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); + final Matrix3d rotationMatrix = CreateConversionsKt.toJOML(thisAsAbstractContraptionEntity.getRotationState().asMatrix()); + final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position()); + return new Matrix4d(rotationMatrix).setTranslation(pos); + } +} 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 new file mode 100644 index 000000000..688ea6998 --- /dev/null +++ b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/ContraptionShipyardEntityHandlerFabric.kt @@ -0,0 +1,40 @@ +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 +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate +import org.valkyrienskies.core.api.ships.ContraptionWingProvider +import org.valkyrienskies.core.api.ships.LoadedServerShip +import org.valkyrienskies.core.api.ships.Ship +import org.valkyrienskies.core.api.ships.WingManager +import org.valkyrienskies.mod.common.block.WingBlock +import org.valkyrienskies.mod.common.entity.handling.AbstractShipyardEntityHandler + +object ContraptionShipyardEntityHandlerFabric: AbstractShipyardEntityHandler() { + override fun freshEntityInShipyard(entity: Entity, ship: Ship) { + if (entity is AbstractContraptionEntity && ship is LoadedServerShip) { + entity as ContraptionWingProvider + val attachment = ship.getAttachment(WingManager::class.java)!! + entity.wingGroupId = attachment.createWingGroup() + entity.contraption.blocks.forEach { (pos: BlockPos, blockInfo: StructureTemplate.StructureBlockInfo) -> + val block = blockInfo.state.block + if (block is WingBlock) { + val wing = block.getWing(null, null, blockInfo.state) + attachment.setWing(entity.wingGroupId, pos.x, pos.y, pos.z, wing) + } + } + val transform = entity.computeContraptionWingTransform() + attachment.setWingGroupTransform(entity.wingGroupId, transform) + } + } + + override fun entityRemovedFromShipyard(entity: Entity, ship: Ship) { + if (entity is AbstractContraptionEntity && ship is LoadedServerShip) { + entity as ContraptionWingProvider + val attachment = ship.getAttachment(WingManager::class.java)!! + attachment.deleteWingGroup(entity.wingGroupId) + entity.wingGroupId = -1 + } + } +} diff --git a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/CreateConversions.kt b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/CreateConversions.kt new file mode 100644 index 000000000..c9fdab93e --- /dev/null +++ b/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/CreateConversions.kt @@ -0,0 +1,13 @@ +package org.valkyrienskies.mod.fabric.common + +import org.joml.Matrix3d +import org.valkyrienskies.mod.fabric.mixin.compat.create.Matrix3dAccessor + +fun com.simibubi.create.foundation.collision.Matrix3d.toJOML(): Matrix3d { + val accessor = this as Matrix3dAccessor + return Matrix3d( + accessor.m00, accessor.m01, accessor.m02, + accessor.m10, accessor.m11, accessor.m12, + accessor.m20, accessor.m21, accessor.m22 + ).transpose() +} 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 426bb8ebb..b51fae58c 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 @@ -33,6 +33,7 @@ import org.valkyrienskies.mod.common.config.MassDatapackResolver import org.valkyrienskies.mod.common.config.VSEntityHandlerDataLoader 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.item.ShipAssemblerItem import org.valkyrienskies.mod.common.item.ShipCreatorItem import org.valkyrienskies.mod.event.RegistryEvents @@ -77,6 +78,7 @@ class ValkyrienSkiesModFabric : ModInitializer { if (isClient) onInitializeClient() ValkyrienSkiesMod.init(vsCore) + VSEntityManager.registerContraptionHandler(ContraptionShipyardEntityHandlerFabric) registerBlockAndItem("test_chair", ValkyrienSkiesMod.TEST_CHAIR) registerBlockAndItem("test_hinge", ValkyrienSkiesMod.TEST_HINGE) diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 53e2cb6b0..dc75436f1 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -8,6 +8,8 @@ "compat.cc_restitched.MixinTurtleBrain", "compat.cc_restitched.MixinTurtleMoveCommand", "compat.cc_restitched.MixinWirelessNetwork", + "compat.create.Matrix3dAccessor", + "compat.create.MixinAbstractContraptionEntity", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", "world.level.block.FireMixin" 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 new file mode 100644 index 000000000..442fa71a3 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/Matrix3dAccessor.java @@ -0,0 +1,35 @@ +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; + +@Mixin(Matrix3d.class) +public interface Matrix3dAccessor { + @Accessor("m00") + double getM00(); + + @Accessor("m01") + double getM01(); + + @Accessor("m02") + double getM02(); + + @Accessor("m10") + double getM10(); + + @Accessor("m11") + double getM11(); + + @Accessor("m12") + double getM12(); + + @Accessor("m20") + double getM20(); + + @Accessor("m21") + double getM21(); + + @Accessor("m22") + double getM22(); +} diff --git a/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 new file mode 100644 index 000000000..d3df7bd4d --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinAbstractContraptionEntity.java @@ -0,0 +1,57 @@ +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; +import org.jetbrains.annotations.NotNull; +import org.joml.Matrix3d; +import org.joml.Matrix4d; +import org.joml.Matrix4dc; +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.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.ContraptionWingProvider; +import org.valkyrienskies.core.api.ships.LoadedServerShip; +import org.valkyrienskies.core.api.ships.WingManager; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import org.valkyrienskies.mod.forge.common.CreateConversionsKt; + +@Mixin(AbstractContraptionEntity.class) +public abstract class MixinAbstractContraptionEntity implements ContraptionWingProvider { + + @Unique + private int wingGroupId = -1; + + @Override + public int getWingGroupId() { + return wingGroupId; + } + + @Override + public void setWingGroupId(final int wingGroupId) { + this.wingGroupId = wingGroupId; + } + + @Inject(method = "tick", at = @At("HEAD")) + private void postTick(final CallbackInfo ci) { + final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); + final Level level = thisAsAbstractContraptionEntity.level; + if (wingGroupId != -1 && !level.isClientSide) { + final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos((ServerLevel) level, VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); + ship.getAttachment(WingManager.class).setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); + } + } + + @NotNull + @Override + public Matrix4dc computeContraptionWingTransform() { + final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); + final Matrix3d rotationMatrix = CreateConversionsKt.toJOML(thisAsAbstractContraptionEntity.getRotationState().asMatrix()); + final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position()); + return new Matrix4d(rotationMatrix).setTranslation(pos); + } +} 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 6d5b43c40..531be51eb 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,15 +1,40 @@ 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 +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate +import org.valkyrienskies.core.api.ships.ContraptionWingProvider +import org.valkyrienskies.core.api.ships.LoadedServerShip import org.valkyrienskies.core.api.ships.Ship +import org.valkyrienskies.core.api.ships.WingManager +import org.valkyrienskies.mod.common.block.WingBlock import org.valkyrienskies.mod.common.entity.handling.AbstractShipyardEntityHandler object ContraptionShipyardEntityHandlerForge: AbstractShipyardEntityHandler() { override fun freshEntityInShipyard(entity: Entity, ship: Ship) { - // TODO: Handle contraptions here + if (entity is AbstractContraptionEntity && ship is LoadedServerShip) { + entity as ContraptionWingProvider + val attachment = ship.getAttachment(WingManager::class.java)!! + entity.wingGroupId = attachment.createWingGroup() + entity.contraption.blocks.forEach { (pos: BlockPos, blockInfo: StructureTemplate.StructureBlockInfo) -> + val block = blockInfo.state.block + if (block is WingBlock) { + val wing = block.getWing(null, null, blockInfo.state) + attachment.setWing(entity.wingGroupId, pos.x, pos.y, pos.z, wing) + } + } + val transform = entity.computeContraptionWingTransform() + attachment.setWingGroupTransform(entity.wingGroupId, transform) + } } override fun entityRemovedFromShipyard(entity: Entity, ship: Ship) { - // TODO: Handle contraptions here + if (entity is AbstractContraptionEntity && ship is LoadedServerShip) { + entity as ContraptionWingProvider + val attachment = ship.getAttachment(WingManager::class.java)!! + attachment.deleteWingGroup(entity.wingGroupId) + entity.wingGroupId = -1 + } } } diff --git a/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/CreateConversions.kt b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/CreateConversions.kt new file mode 100644 index 000000000..e82d6115f --- /dev/null +++ b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/CreateConversions.kt @@ -0,0 +1,13 @@ +package org.valkyrienskies.mod.forge.common + +import org.joml.Matrix3d +import org.valkyrienskies.mod.forge.mixin.compat.create.Matrix3dAccessor + +fun com.simibubi.create.foundation.collision.Matrix3d.toJOML(): Matrix3d { + val accessor = this as Matrix3dAccessor + return Matrix3d( + accessor.m00, accessor.m01, accessor.m02, + accessor.m10, accessor.m11, accessor.m12, + accessor.m20, accessor.m21, accessor.m22 + ).transpose() +} 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 aacac7575..397d9a14b 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 @@ -36,6 +36,7 @@ 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.item.ShipAssemblerItem import org.valkyrienskies.mod.common.item.ShipCreatorItem import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig @@ -66,6 +67,7 @@ class ValkyrienSkiesModForge { VSForgeNetworking.registerPacketHandlers(vsCore.hooks) ValkyrienSkiesMod.init(vsCore) + VSEntityManager.registerContraptionHandler(ContraptionShipyardEntityHandlerForge) val modBus = Bus.MOD.bus().get() val forgeBus = Bus.FORGE.bus().get() diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 4495ecb38..3eb394e73 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -8,8 +8,10 @@ "compat.cc_tweaked.MixinTurtleBrain", "compat.cc_tweaked.MixinTurtleMoveCommand", "compat.cc_tweaked.MixinWirelessNetwork", + "compat.create.Matrix3dAccessor", "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", + "compat.create.MixinAbstractContraptionEntity", "compat.immersivengineering.MixinBlockEntityInventory", "compat.thermalexpansion.MixinTileCoFH", "feature.forge_interact.MixinIForgePlayer", diff --git a/vs-core b/vs-core index 357151f0b..b8034cc22 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 357151f0bb11b50724b1a9097314dc450683ead1 +Subproject commit b8034cc22c257ceb2c99f4094b076c36ed876353 From 346ea895663d4a2fefdd250335a422aa5f69e4e1 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Mon, 16 Jan 2023 23:40:41 -0500 Subject: [PATCH 035/437] fix: potential nullptr/classcastexception --- .../create/MixinAbstractContraptionEntity.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 4d3ebb77e..4c8a02439 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 @@ -42,9 +42,13 @@ public void setWingGroupId(final int wingGroupId) { private void postTick(final CallbackInfo ci) { final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); final Level level = thisAsAbstractContraptionEntity.level; - if (wingGroupId != -1 && !level.isClientSide) { - final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos((ServerLevel) level, VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); - ship.getAttachment(WingManager.class).setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); + if (wingGroupId != -1 && level instanceof ServerLevel serverLevel) { + final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(serverLevel, + VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); + if (ship != null) { + ship.getAttachment(WingManager.class) + .setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); + } } } @@ -52,7 +56,8 @@ 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.position()); return new Matrix4d(rotationMatrix).setTranslation(pos); } From a7ac2a60513b32331d9987ab2e62c3bb3d5b0a57 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 16 Jan 2023 23:14:43 -0700 Subject: [PATCH 036/437] Don't transpose create matrices --- .../org/valkyrienskies/mod/fabric/common/CreateConversions.kt | 2 +- .../org/valkyrienskies/mod/forge/common/CreateConversions.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 c9fdab93e..1f65afc9a 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 @@ -9,5 +9,5 @@ fun com.simibubi.create.foundation.collision.Matrix3d.toJOML(): Matrix3d { accessor.m00, accessor.m01, accessor.m02, accessor.m10, accessor.m11, accessor.m12, accessor.m20, accessor.m21, accessor.m22 - ).transpose() + ) } 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 e82d6115f..68f3319a4 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 @@ -9,5 +9,5 @@ fun com.simibubi.create.foundation.collision.Matrix3d.toJOML(): Matrix3d { accessor.m00, accessor.m01, accessor.m02, accessor.m10, accessor.m11, accessor.m12, accessor.m20, accessor.m21, accessor.m22 - ).transpose() + ) } From d79c940d9d17b509e156d62ada4e52e6e5a599b1 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 17 Jan 2023 04:25:07 -0700 Subject: [PATCH 037/437] Added flap blocks --- .../mod/common/ValkyrienSkiesMod.kt | 1 + .../mod/common/block/TestFlapBlock.kt | 85 ++++++++ .../mod/common/block/TestWingBlock.kt | 6 +- .../valkyrienskies/blockstates/test_flap.json | 28 +++ .../assets/valkyrienskies/lang/en_us.json | 1 + .../valkyrienskies/models/item/test_flap.json | 181 ++++++++++++++++++ .../fabric/common/ValkyrienSkiesModFabric.kt | 3 + .../forge/common/ValkyrienSkiesModForge.kt | 4 + vs-core | 2 +- 9 files changed, 309 insertions(+), 2 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestFlapBlock.kt create mode 100644 common/src/main/resources/assets/valkyrienskies/blockstates/test_flap.json create mode 100644 common/src/main/resources/assets/valkyrienskies/models/item/test_flap.json 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 1e85cdb8d..bbc5f5d30 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -22,6 +22,7 @@ object ValkyrienSkiesMod { lateinit var TEST_CHAIR: Block lateinit var TEST_HINGE: Block + lateinit var TEST_FLAP: Block lateinit var TEST_WING: Block lateinit var SHIP_CREATOR_ITEM: Item lateinit var SHIP_ASSEMBLER_ITEM: Item 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 new file mode 100644 index 000000000..60a505200 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestFlapBlock.kt @@ -0,0 +1,85 @@ +package org.valkyrienskies.mod.common.block + +import net.minecraft.core.BlockPos +import net.minecraft.core.Direction.DOWN +import net.minecraft.core.Direction.EAST +import net.minecraft.core.Direction.NORTH +import net.minecraft.core.Direction.SOUTH +import net.minecraft.core.Direction.UP +import net.minecraft.core.Direction.WEST +import net.minecraft.world.item.context.BlockPlaceContext +import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.Block +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 +import org.valkyrienskies.mod.common.util.toJOMLD + +object TestFlapBlock : + DirectionalBlock( + Properties.of(Material.METAL).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) + private val WEST_AABB = box(4.0, 0.0, 0.0, 12.0, 16.0, 16.0) + private val SOUTH_AABB = box(0.0, 0.0, 4.0, 16.0, 16.0, 12.0) + private val NORTH_AABB = box(0.0, 0.0, 4.0, 16.0, 16.0, 12.0) + private val UP_AABB = box(0.0, 4.0, 0.0, 16.0, 12.0, 16.0) + private val DOWN_AABB = box(0.0, 4.0, 0.0, 16.0, 12.0, 16.0) + + init { + registerDefaultState(this.stateDefinition.any().setValue(FACING, UP)) + } + + override fun createBlockStateDefinition(builder: StateDefinition.Builder) { + builder.add(FACING) + } + + override fun getStateForPlacement(ctx: BlockPlaceContext): BlockState { + return defaultBlockState().setValue(FACING, ctx.nearestLookingDirection.opposite) + } + + @Deprecated("Deprecated in Java") + override fun getShape( + state: BlockState, blockGetter: BlockGetter, blockPos: BlockPos, collisionContext: CollisionContext + ): VoxelShape { + when (state.getValue(FACING)) { + DOWN -> { + return DOWN_AABB + } + NORTH -> { + return NORTH_AABB + } + SOUTH -> { + return SOUTH_AABB + } + WEST -> { + return WEST_AABB + } + EAST -> { + return EAST_AABB + } + UP -> { + return UP_AABB + } + else -> { + // This should be impossible, but have this here just in case + return UP_AABB + } + } + } + + override fun getWing(level: Level?, pos: BlockPos?, blockState: BlockState): Wing { + val wingPower = 150.0 + val wingDrag = 30.0 + val wingBreakingForce = null + val wingCamberAttackAngleBias = 0.0 + return Wing(blockState.getValue(FACING).normal.toJOMLD(), wingPower, wingDrag, wingBreakingForce, wingCamberAttackAngleBias) + } +} 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 e1a15c68e..2dfe55047 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 @@ -79,6 +79,10 @@ object TestWingBlock : val wingPower = 150.0 val wingDrag = 30.0 val wingBreakingForce = null - return Wing(blockState.getValue(FACING).normal.toJOMLD(), wingPower, wingDrag, wingBreakingForce) + val wingCamberAttackAngleBias = 10.0 + return Wing( + blockState.getValue(FACING).normal.toJOMLD(), wingPower, wingDrag, wingBreakingForce, + wingCamberAttackAngleBias + ) } } diff --git a/common/src/main/resources/assets/valkyrienskies/blockstates/test_flap.json b/common/src/main/resources/assets/valkyrienskies/blockstates/test_flap.json new file mode 100644 index 000000000..627c29f10 --- /dev/null +++ b/common/src/main/resources/assets/valkyrienskies/blockstates/test_flap.json @@ -0,0 +1,28 @@ +{ + "variants": { + "facing=north": { + "model": "valkyrienskies:block/test_wing", + "y": 180 + }, + "facing=east": { + "model": "valkyrienskies:block/test_wing", + "y": 270 + }, + "facing=south": { + "model": "valkyrienskies:block/test_wing", + "y": 0 + }, + "facing=west": { + "model": "valkyrienskies:block/test_wing", + "y": 90 + }, + "facing=up": { + "model": "valkyrienskies:block/test_wing", + "x": 90 + }, + "facing=down": { + "model": "valkyrienskies:block/test_wing", + "x": 270 + } + } +} 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 e1282a2e5..4130d58dc 100644 --- a/common/src/main/resources/assets/valkyrienskies/lang/en_us.json +++ b/common/src/main/resources/assets/valkyrienskies/lang/en_us.json @@ -3,6 +3,7 @@ "category.valkyrienskies.driving": "Driving", "block.valkyrienskies.test_chair": "Debug Chair", "block.valkyrienskies.test_hinge": "Debug Hinge", + "block.valkyrienskies.test_flap": "Debug Flap", "block.valkyrienskies.test_wing": "Debug Wing", "item.valkyrienskies.ship_creator": "Ship Creator", "item.valkyrienskies.ship_creator_smaller": "Mini Ship Creator" diff --git a/common/src/main/resources/assets/valkyrienskies/models/item/test_flap.json b/common/src/main/resources/assets/valkyrienskies/models/item/test_flap.json new file mode 100644 index 000000000..358266113 --- /dev/null +++ b/common/src/main/resources/assets/valkyrienskies/models/item/test_flap.json @@ -0,0 +1,181 @@ +{ + "credit": "Made with Blockbench", + "parent": "valkyrienskies", + "texture_size": [64, 64], + "textures": { + "0": "valkyrienskies:test_wing", + "particle": "valkyrienskies:test_wing" + }, + "elements": [ + { + "name": "Base", + "from": [2, 2, 6.75], + "to": [14, 14, 9.25], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [3, 3, 0, 0], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3, 0.75, 6, 1.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [3, 3, 0, 6], "texture": "#0"}, + "west": {"uv": [3, 2.25, 6, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1.5, 6, 2.25], "texture": "#0"}, + "down": {"uv": [3, 0, 6, 0.75], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 0.25, 7], + "to": [13, 2.25, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [5.5, 4.5, 3, 4], "rotation": 180, "texture": "#0"}, + "east": {"uv": [7.25, 4, 7.75, 4.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [5.5, 4.5, 3, 5], "texture": "#0"}, + "west": {"uv": [6, 7.25, 6.5, 7.75], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 3.5, 5.5, 4], "texture": "#0"}, + "down": {"uv": [3, 3, 5.5, 3.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [0, 0, 6.5], + "to": [3, 3, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [6.75, 6.5, 6, 5.75], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3.75, 6, 4.5, 6.75], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0.75, 6.5, 0, 7.25], "texture": "#0"}, + "west": {"uv": [6, 5, 6.75, 5.75], "rotation": 270, "texture": "#0"}, + "up": {"uv": [4.5, 6, 5.25, 6.75], "texture": "#0"}, + "down": {"uv": [3, 6, 3.75, 6.75], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [0.25, 3, 7], + "to": [2.25, 13, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [6, 5.5, 5.5, 3], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3, 5, 5.5, 5.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [6, 5.5, 5.5, 8], "texture": "#0"}, + "west": {"uv": [3, 5.5, 5.5, 6], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3.5, 7.5, 4, 8], "texture": "#0"}, + "down": {"uv": [3, 7.5, 3.5, 8], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [0, 13, 6.5], + "to": [3, 16, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [7.25, 4.75, 6.5, 4], "rotation": 180, "texture": "#0"}, + "east": {"uv": [1.5, 6.5, 2.25, 7.25], "rotation": 90, "texture": "#0"}, + "south": {"uv": [6.75, 6.5, 6, 7.25], "texture": "#0"}, + "west": {"uv": [6.5, 3.25, 7.25, 4], "rotation": 270, "texture": "#0"}, + "up": {"uv": [6.5, 2.5, 7.25, 3.25], "texture": "#0"}, + "down": {"uv": [0.75, 6.5, 1.5, 7.25], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 13.75, 7], + "to": [13, 15.75, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [8.5, 1, 6, 0.5], "rotation": 180, "texture": "#0"}, + "east": {"uv": [4, 7.5, 4.5, 8], "rotation": 90, "texture": "#0"}, + "south": {"uv": [8.5, 1, 6, 1.5], "texture": "#0"}, + "west": {"uv": [4.5, 7.5, 5, 8], "rotation": 270, "texture": "#0"}, + "up": {"uv": [6, 0, 8.5, 0.5], "texture": "#0"}, + "down": {"uv": [0, 6, 2.5, 6.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [13, 13, 6.5], + "to": [16, 16, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [7.5, 6.25, 6.75, 5.5], "rotation": 180, "texture": "#0"}, + "east": {"uv": [3.75, 6.75, 4.5, 7.5], "rotation": 90, "texture": "#0"}, + "south": {"uv": [7.5, 6.25, 6.75, 7], "texture": "#0"}, + "west": {"uv": [6.75, 4.75, 7.5, 5.5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [4.5, 6.75, 5.25, 7.5], "texture": "#0"}, + "down": {"uv": [3, 6.75, 3.75, 7.5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [13.75, 3, 7], + "to": [15.75, 13, 9], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [3, 8.5, 2.5, 6], "rotation": 180, "texture": "#0"}, + "east": {"uv": [6, 1.5, 8.5, 2], "rotation": 90, "texture": "#0"}, + "south": {"uv": [6.5, 2.5, 6, 5], "texture": "#0"}, + "west": {"uv": [6, 2, 8.5, 2.5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [5, 7.5, 5.5, 8], "texture": "#0"}, + "down": {"uv": [7.5, 4.5, 8, 5], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [13, 0, 6.5], + "to": [16, 3, 9.5], + "rotation": {"angle": 0, "axis": "x", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [8, 3.25, 7.25, 2.5], "rotation": 180, "texture": "#0"}, + "east": {"uv": [0, 7.25, 0.75, 8], "rotation": 90, "texture": "#0"}, + "south": {"uv": [8, 3.25, 7.25, 4], "texture": "#0"}, + "west": {"uv": [1.5, 7.25, 2.25, 8], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0.75, 7.25, 1.5, 8], "texture": "#0"}, + "down": {"uv": [6.75, 7, 7.5, 7.75], "rotation": 180, "texture": "#0"} + } + } + ], + "display": { + "thirdperson_righthand": { + "translation": [0, 3, 1], + "scale": [0.35, 0.35, 0.35] + }, + "thirdperson_lefthand": { + "translation": [0, 3, 1], + "scale": [0.35, 0.35, 0.35] + }, + "firstperson_righthand": { + "rotation": [0, -90, 25], + "translation": [1.13, 3.2, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "firstperson_lefthand": { + "rotation": [0, -90, 25], + "translation": [1.13, 3.2, 1.13], + "scale": [0.68, 0.68, 0.68] + }, + "ground": { + "translation": [0, 2, 0], + "scale": [0.5, 0.5, 0.5] + }, + "gui": { + "rotation": [14, 140, 0], + "scale": [0.625, 0.625, 0.625] + }, + "fixed": { + "translation": [0, 0, -15.75], + "scale": [2, 2, 2] + } + }, + "groups": [ + { + "name": "Sail", + "origin": [8, 8, 8], + "color": 0, + "nbt": "{}", + "armAnimationEnabled": false, + "children": [ + 0, + { + "name": "Base", + "origin": [8, 8, 8], + "color": 0, + "nbt": "{}", + "armAnimationEnabled": false, + "children": [1, 2, 3, 4, 5, 6, 7, 8] + } + ] + } + ] +} 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 b51fae58c..fb8474c01 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 @@ -27,6 +27,7 @@ import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestHingeBlock +import org.valkyrienskies.mod.common.block.TestFlapBlock import org.valkyrienskies.mod.common.block.TestWingBlock import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.config.MassDatapackResolver @@ -52,6 +53,7 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_CHAIR = TestChairBlock ValkyrienSkiesMod.TEST_HINGE = TestHingeBlock + ValkyrienSkiesMod.TEST_FLAP = TestFlapBlock ValkyrienSkiesMod.TEST_WING = TestWingBlock ValkyrienSkiesMod.SHIP_CREATOR_ITEM = ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), 1.0) ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM = ShipAssemblerItem(Properties().tab(CreativeModeTab.TAB_MISC)) @@ -82,6 +84,7 @@ class ValkyrienSkiesModFabric : ModInitializer { 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"), 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 397d9a14b..528169bfd 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 @@ -29,6 +29,7 @@ import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestHingeBlock +import org.valkyrienskies.mod.common.block.TestFlapBlock import org.valkyrienskies.mod.common.block.TestWingBlock import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.config.MassDatapackResolver @@ -49,6 +50,7 @@ class ValkyrienSkiesModForge { private val BLOCK_ENTITIES = DeferredRegister.create(ForgeRegistries.BLOCK_ENTITIES, ValkyrienSkiesMod.MOD_ID) private val TEST_CHAIR_REGISTRY: RegistryObject private val TEST_HINGE_REGISTRY: RegistryObject + private val TEST_FLAP_REGISTRY: RegistryObject private val TEST_WING_REGISTRY: RegistryObject private val SHIP_CREATOR_ITEM_REGISTRY: RegistryObject private val SHIP_CREATOR_SMALLER_ITEM_REGISTRY: RegistryObject @@ -94,6 +96,7 @@ 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 } SHIP_CREATOR_ITEM_REGISTRY = ITEMS.register("ship_creator") { ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), 1.0) } @@ -137,6 +140,7 @@ class ValkyrienSkiesModForge { private fun loadComplete(event: FMLLoadCompleteEvent) { ValkyrienSkiesMod.TEST_CHAIR = TEST_CHAIR_REGISTRY.get() ValkyrienSkiesMod.TEST_HINGE = TEST_HINGE_REGISTRY.get() + ValkyrienSkiesMod.TEST_FLAP = TEST_FLAP_REGISTRY.get() ValkyrienSkiesMod.TEST_WING = TEST_WING_REGISTRY.get() ValkyrienSkiesMod.SHIP_CREATOR_ITEM = SHIP_CREATOR_ITEM_REGISTRY.get() ValkyrienSkiesMod.SHIP_CREATOR_ITEM_SMALLER = SHIP_CREATOR_SMALLER_ITEM_REGISTRY.get() diff --git a/vs-core b/vs-core index b8034cc22..2b2f93f79 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit b8034cc22c257ceb2c99f4094b076c36ed876353 +Subproject commit 2b2f93f79313bab3c8bc19fc90e2d3bc5e03b4ef From 3a41156ebe7db79b943c44ad66a463a8ddde0fe2 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 17 Jan 2023 05:27:12 -0700 Subject: [PATCH 038/437] Fixed third person camera blocking on mounted ships --- .../mod/mixin/client/MixinCamera.java | 48 ++++++++++++++++++- .../mod/common/world/RaycastUtils.kt | 9 +++- 2 files changed, 55 insertions(+), 2 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 51e08d066..d8ccabe22 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 @@ -6,6 +6,13 @@ import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.HitResult.Type; +import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import org.joml.Quaterniond; import org.joml.Quaterniondc; @@ -20,6 +27,7 @@ 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) public abstract class MixinCamera implements IVSCamera { @@ -52,6 +60,8 @@ public abstract class MixinCamera implements IVSCamera { private float eyeHeight; @Shadow private float eyeHeightOld; + @Shadow + private Vec3 position; @Shadow protected abstract double getMaxZoom(double startingDistance); @@ -92,7 +102,12 @@ public void setupWithShipMounted(final @NotNull BlockGetter level, final @NotNul dist = dist > 4 ? dist : 4; - this.move(-this.getMaxZoom(4.0 * (dist / 4.0)), 0.0, 0.0); + if (this.level instanceof Level) { + this.move(-this.getMaxZoomIgnoringMountedShip((Level) this.level, 4.0 * (dist / 4.0), shipMountedTo), + 0.0, 0.0); + } else { + this.move(-this.getMaxZoom(4.0 * (dist / 4.0)), 0.0, 0.0); + } } } @@ -112,4 +127,35 @@ private void setRotationWithShipTransform(final float yaw, final float pitch, fi this.left.set(1.0F, 0.0F, 0.0F); this.left.transform(this.rotation); } + + /** + * When in third person, do not block the camera on the ship the player is mounted to + */ + @Unique + private double getMaxZoomIgnoringMountedShip(final Level level, double maxZoom, + final @NotNull ClientShip toIgnore) { + for (int i = 0; i < 8; ++i) { + float f = (float) ((i & 1) * 2 - 1); + float g = (float) ((i >> 1 & 1) * 2 - 1); + float h = (float) ((i >> 2 & 1) * 2 - 1); + f *= 0.1F; + g *= 0.1F; + h *= 0.1F; + final Vec3 vec3 = this.position.add(f, g, h); + final Vec3 vec32 = + new Vec3(this.position.x - (double) this.forwards.x() * maxZoom + (double) f + (double) h, + this.position.y - (double) this.forwards.y() * maxZoom + (double) g, + this.position.z - (double) this.forwards.z() * maxZoom + (double) h); + final HitResult hitResult = RaycastUtilsKt.clipIncludeShips(level, + new ClipContext(vec3, vec32, Block.VISUAL, Fluid.NONE, this.entity), true, toIgnore.getId()); + if (hitResult.getType() != Type.MISS) { + final double e = hitResult.getLocation().distanceTo(this.position); + if (e < maxZoom) { + maxZoom = e; + } + } + } + + return maxZoom; + } } 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 b34dfaa38..976902290 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,6 +18,7 @@ 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.properties.ShipId import org.valkyrienskies.core.game.ships.ShipObjectClient import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.toJOML @@ -30,7 +31,9 @@ import java.util.function.Predicate private val logger = LogManager.getLogger("RaycastUtilsKt") @JvmOverloads -fun Level.clipIncludeShips(ctx: ClipContext, shouldTransformHitPos: Boolean = true): BlockHitResult { +fun Level.clipIncludeShips( + ctx: ClipContext, shouldTransformHitPos: Boolean = true, skipShip: ShipId? = null +): BlockHitResult { val vanillaHit = vanillaClip(ctx) if (shipObjectWorld == null) { @@ -50,6 +53,10 @@ fun Level.clipIncludeShips(ctx: ClipContext, shouldTransformHitPos: Boolean = tr // 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)) { + // 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 shipStart = worldToShip.transformPosition(ctx.from.toJOML()).toMinecraft() From b3b2dc9167b77678de7c56b8de23eb53d0d13173 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 17 Jan 2023 05:30:49 -0700 Subject: [PATCH 039/437] fix: potential nullptr/classcastexception pt2 --- .../compat/create/MixinAbstractContraptionEntity.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 d3df7bd4d..28876cf44 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 @@ -40,8 +40,9 @@ public void setWingGroupId(final int wingGroupId) { private void postTick(final CallbackInfo ci) { final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); final Level level = thisAsAbstractContraptionEntity.level; - if (wingGroupId != -1 && !level.isClientSide) { - final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos((ServerLevel) level, VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); + if (wingGroupId != -1 && level instanceof ServerLevel serverLevel) { + final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(serverLevel, + VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); ship.getAttachment(WingManager.class).setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); } } @@ -50,7 +51,8 @@ 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.position()); return new Matrix4d(rotationMatrix).setTranslation(pos); } From 44bea1d5973eb0448ea1b9ef6bd1dfe024d3821b Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 17 Jan 2023 06:11:50 -0700 Subject: [PATCH 040/437] Made ShipCreatorItem work on ships --- .../mod/common/item/ShipCreatorItem.kt | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) 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 5471735f0..488f026fa 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 @@ -9,16 +9,20 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.context.UseOnContext import net.minecraft.world.level.block.state.BlockState +import org.joml.Vector3d +import org.valkyrienskies.core.impl.game.ships.ShipDataCommon +import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl import org.valkyrienskies.mod.common.dimensionId -import org.valkyrienskies.mod.common.isChunkInShipyard +import org.valkyrienskies.mod.common.getShipManagingPos 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.util.toJOMLD import org.valkyrienskies.mod.common.yRange import org.valkyrienskies.mod.util.relocateBlock -class ShipCreatorItem(properties: Properties, private val scale: Double) : Item(properties) { - +class ShipCreatorItem(properties: Properties, private val scale: Double, private val minScaling: Double = 0.25) : Item(properties) { + override fun isFoil(stack: ItemStack): Boolean { return true } @@ -29,19 +33,33 @@ class ShipCreatorItem(properties: Properties, private val scale: Double) : Item( val blockState: BlockState = level.getBlockState(blockPos) if (!level.isClientSide) { - if (ctx.level.isChunkInShipyard(blockPos.x shr 4, blockPos.z shr 4)) { - ctx.player?.sendMessage(TextComponent("That chunk is already part of a ship!"), Util.NIL_UUID) - } else if (!blockState.isAir) { + val parentShip = ctx.level.getShipManagingPos(blockPos) + if (!blockState.isAir) { // Make a ship val dimensionId = level.dimensionId - val shipData = level.shipObjectWorld.createNewShipAtBlock(blockPos.toJOML(), false, scale, dimensionId) + val serverShip = + level.shipObjectWorld.createNewShipAtBlock(blockPos.toJOML(), false, scale, dimensionId) - val centerPos = shipData.chunkClaim.getCenterBlockCoordinates(level.yRange).toBlockPos() + val centerPos = serverShip.chunkClaim.getCenterBlockCoordinates(level.yRange).toBlockPos() // Move the block from the world to a ship - level.relocateBlock(blockPos, centerPos, shipData, NORTH) - + level.relocateBlock(blockPos, centerPos, serverShip, NORTH) ctx.player?.sendMessage(TextComponent("SHIPIFIED!"), Util.NIL_UUID) + if (parentShip != null) { + // Compute the ship transform + val newShipPosInWorld = + parentShip.shipToWorld.transformPosition(blockPos.toJOMLD().add(0.5, 0.5, 0.5)) + val newShipPosInShipyard = blockPos.toJOMLD().add(0.5, 0.5, 0.5) + val newShipRotation = parentShip.transform.shipToWorldRotation + var newShipScaling = parentShip.transform.shipToWorldScaling.mul(scale, Vector3d()) + if (newShipScaling.x() < scale) { + // Do not allow scaling to go below minScaling + newShipScaling = Vector3d(minScaling, minScaling, minScaling) + } + val shipTransform = + ShipTransformImpl(newShipPosInWorld, newShipPosInShipyard, newShipRotation, newShipScaling) + (serverShip as ShipDataCommon).transform = shipTransform + } } } From df47d4b7c05b2540dd489b133f74d03405a19dce Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 17 Jan 2023 11:13:29 -0500 Subject: [PATCH 041/437] fix: flywheel issue --- ...a => MixinBlockEntityInstanceManager.java} | 35 +++++++++++----- .../flywheel/MixinInstanceWorld.java | 42 ++++++++++++++----- .../flywheel/MixinInstancingEngine.java | 4 -- .../MixinBlockEntityInstanceManagerDuck.java | 11 +++++ .../MixinTileInstanceManagerDuck.java | 12 ------ .../mod/common/VSClientGameUtils.kt | 6 +++ .../valkyrienskies-common.mixins.json | 2 +- 7 files changed, 74 insertions(+), 38 deletions(-) rename common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/{MixinTileInstanceManager.java => MixinBlockEntityInstanceManager.java} (62%) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinTileInstanceManagerDuck.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinTileInstanceManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinBlockEntityInstanceManager.java similarity index 62% rename from common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinTileInstanceManager.java rename to common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinBlockEntityInstanceManager.java index 8945f4b24..6a252f0b2 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinTileInstanceManager.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinBlockEntityInstanceManager.java @@ -1,12 +1,15 @@ package org.valkyrienskies.mod.mixin.mod_compat.flywheel; +import com.jozufozu.flywheel.api.MaterialManager; import com.jozufozu.flywheel.api.instance.Instance; +import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.instancing.InstanceManager; import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; +import com.jozufozu.flywheel.backend.instancing.batching.BatchingEngine; import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstanceManager; import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; +import com.jozufozu.flywheel.config.BackendType; import com.jozufozu.flywheel.core.Contexts; -import com.jozufozu.flywheel.core.shader.WorldProgram; import java.util.WeakHashMap; import javax.annotation.ParametersAreNonnullByDefault; import net.minecraft.client.multiplayer.ClientLevel; @@ -23,23 +26,23 @@ import org.valkyrienskies.core.api.ships.ClientShip; import org.valkyrienskies.core.api.world.LevelYRange; import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.mixinducks.MixinTileInstanceManagerDuck; +import org.valkyrienskies.mod.mixinducks.MixinBlockEntityInstanceManagerDuck; @Pseudo @Mixin(value = BlockEntityInstanceManager.class) @ParametersAreNonnullByDefault -public abstract class MixinTileInstanceManager extends InstanceManager implements - MixinTileInstanceManagerDuck { +public abstract class MixinBlockEntityInstanceManager extends InstanceManager implements + MixinBlockEntityInstanceManagerDuck { - public WeakHashMap> getShipInstancingEngines() { + public WeakHashMap getShipMaterialManagers() { return shipMaterialManagers; } @Unique - private final WeakHashMap> shipMaterialManagers = + private final WeakHashMap shipMaterialManagers = new WeakHashMap<>(); - public MixinTileInstanceManager(final InstancingEngine materialManager) { + public MixinBlockEntityInstanceManager(final MaterialManager materialManager) { super(materialManager); } @@ -54,13 +57,25 @@ void preCreateRaw(final BlockEntity blockEntity, final CallbackInfoReturnable manager = shipMaterialManagers.computeIfAbsent(ship, - k -> InstancingEngine.builder(Contexts.WORLD).setIgnoreOriginCoordinate(true).build()); - final Vector3i c = ship.getChunkClaim().getCenterBlockCoordinates(new LevelYRange(0, 0), new Vector3i()); + final MaterialManager manager = + shipMaterialManagers.computeIfAbsent(ship, k -> createMaterialManager()); + final Vector3i c = + ship.getChunkClaim().getCenterBlockCoordinates(new LevelYRange(0, 0), new Vector3i()); ((InstancingEngineAccessor) manager).setOriginCoordinate(new BlockPos(c.x, c.y, c.z)); cir.setReturnValue(InstancedRenderRegistry.createInstance(manager, blockEntity)); } } } + + @Unique + private MaterialManager createMaterialManager() { + if (Backend.getBackendType() == BackendType.INSTANCING) { + return InstancingEngine.builder(Contexts.WORLD).build(); + } else if (Backend.getBackendType() == BackendType.BATCHING) { + return new BatchingEngine(); + } else { + throw new IllegalArgumentException("Unknown engine type"); + } + } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceWorld.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstanceWorld.java index 8082adbb1..0e08afb31 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,13 +1,15 @@ package org.valkyrienskies.mod.mixin.mod_compat.flywheel; +import com.jozufozu.flywheel.api.MaterialManager; import com.jozufozu.flywheel.backend.gl.GlStateTracker; import com.jozufozu.flywheel.backend.instancing.InstanceManager; import com.jozufozu.flywheel.backend.instancing.InstanceWorld; +import com.jozufozu.flywheel.backend.instancing.ParallelTaskEngine; +import com.jozufozu.flywheel.backend.instancing.batching.BatchingEngine; +import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; import com.jozufozu.flywheel.event.RenderLayerEvent; import com.mojang.math.Matrix4f; import net.minecraft.world.level.block.entity.BlockEntity; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; import org.joml.Matrix4d; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Final; @@ -18,20 +20,24 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.mod.common.VSClientGameUtils; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import org.valkyrienskies.mod.mixinducks.MixinBlockEntityInstanceManagerDuck; import org.valkyrienskies.mod.mixinducks.MixinInstancingEngineDuck; -import org.valkyrienskies.mod.mixinducks.MixinTileInstanceManagerDuck; @Pseudo @Mixin(value = InstanceWorld.class, remap = false) public class MixinInstanceWorld { - @Unique - private static final Logger LOGGER = LogManager.getLogger("VS2 flywheel.client.MixinInstanceWorld"); @Shadow @Final protected InstanceManager blockEntityInstanceManager; + @Shadow + @Final + public ParallelTaskEngine taskEngine; + @Inject( method = "renderLayer", at = @At( @@ -42,10 +48,19 @@ public class MixinInstanceWorld { void renderShipTiles(final RenderLayerEvent event, final CallbackInfo ci) { //not sure if restoreState stuff should be here or in the ((MixinInstancingEngineDuck) manager).render() method final GlStateTracker.State restoreState = GlStateTracker.getRestoreState(); - final var shipManagers = ((MixinTileInstanceManagerDuck) blockEntityInstanceManager).getShipInstancingEngines(); + final var shipManagers = + ((MixinBlockEntityInstanceManagerDuck) blockEntityInstanceManager).getShipMaterialManagers(); shipManagers.forEach((ship, manager) -> { - final Vector3d origin = VectorConversionsMCKt.toJOMLD(manager.getOriginCoordinate()); + render(ship, manager, event); + }); + restoreState.restore(); + } + + @Unique + void render(final ClientShip ship, final MaterialManager manager, final RenderLayerEvent event) { + if (manager instanceof InstancingEngine engine) { + final Vector3d origin = VectorConversionsMCKt.toJOMLD(engine.getOriginCoordinate()); final Matrix4d viewProjection = VectorConversionsMCKt.toJOML(event.viewProjection); @@ -61,15 +76,20 @@ void renderShipTiles(final RenderLayerEvent event, final CallbackInfo ci) { final Matrix4f fnlProj = VectorConversionsMCKt.toMinecraft(finalProjection); - ((MixinInstancingEngineDuck) manager).render( + ((MixinInstancingEngineDuck) engine).render( fnlProj, camInShipLocal.x, camInShipLocal.y, camInShipLocal.z, event.layer ); - }); - restoreState.restore(); - + } else if (manager instanceof BatchingEngine engine) { + event.stack.pushPose(); + VSClientGameUtils.multiplyWithShipToWorld(event.stack, ship); + engine.render(taskEngine, event); + event.stack.popPose(); + } else { + throw new IllegalArgumentException("unrecognized engine"); + } } } 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 8f3f84944..213ba443a 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 @@ -27,12 +27,8 @@ public abstract class MixinInstancingEngine

implements M @Override public void render(final Matrix4f viewProjection, final double camX, final double camY, final double camZ, final RenderLayer layer) { - //LOGGER.warn("step1"); this.getGroupsToRender(layer).forEach(g -> { - //LOGGER.warn("step2"); g.render(viewProjection, camX, camY, camZ, layer); - //LOGGER.warn("step3"); }); - //LOGGER.warn("step4"); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java new file mode 100644 index 000000000..9e9a3aea5 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java @@ -0,0 +1,11 @@ +package org.valkyrienskies.mod.mixinducks; + +import com.jozufozu.flywheel.api.MaterialManager; +import java.util.WeakHashMap; +import org.valkyrienskies.core.api.ships.ClientShip; + +public interface MixinBlockEntityInstanceManagerDuck { + + WeakHashMap getShipMaterialManagers(); + +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinTileInstanceManagerDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinTileInstanceManagerDuck.java deleted file mode 100644 index 6be3d710e..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinTileInstanceManagerDuck.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.valkyrienskies.mod.mixinducks; - -import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; -import com.jozufozu.flywheel.core.shader.WorldProgram; -import java.util.WeakHashMap; -import org.valkyrienskies.core.api.ships.ClientShip; - -public interface MixinTileInstanceManagerDuck { - - WeakHashMap> getShipInstancingEngines(); - -} 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 824793c9e..090da4119 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSClientGameUtils.kt @@ -5,12 +5,18 @@ import net.minecraft.client.Minecraft import net.minecraft.core.BlockPos import org.joml.Matrix4d 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 { + @JvmStatic + fun multiplyWithShipToWorld(poseStack: PoseStack, ship: ClientShip) { + poseStack.multiply(ship.renderTransform.shipToWorld, ship.renderTransform.shipToWorldRotation) + } + @JvmStatic fun transformRenderIfInShipyard(poseStack: PoseStack, offsetX: Double, offsetY: Double, offsetZ: Double) { val ship = Minecraft.getInstance().level?.getShipObjectManagingPos(offsetX, offsetY, offsetZ) diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index bdf18fc8b..225c7d843 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -99,7 +99,7 @@ "mod_compat.flywheel.MixinInstanceManager", "mod_compat.flywheel.MixinInstanceWorld", "mod_compat.flywheel.MixinInstancingEngine", - "mod_compat.flywheel.MixinTileInstanceManager", + "mod_compat.flywheel.MixinBlockEntityInstanceManager", "mod_compat.optifine.MixinViewAreaOptifine", "mod_compat.optifine.RenderChunkInfoAccessorOptifine", "mod_compat.optifine_vanilla.MixinLevelRenderer", From 2ed15b8afb9ae240d2cfd892d764f9a5abd3b4c0 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 17 Jan 2023 19:01:18 -0500 Subject: [PATCH 042/437] fix: player respawns --- .../shipyard_entities/MixinEntity.java | 34 ++++++++++++++++++- .../entity/handling/WorldEntityHandler.kt | 12 ++++--- 2 files changed, 40 insertions(+), 6 deletions(-) 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 24082cee3..474bda757 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 @@ -6,6 +6,7 @@ import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.Entity.RemovalReason; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Mixin; @@ -15,13 +16,18 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.valkyrienskies.core.api.ships.LoadedShip; +import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.entity.handling.VSEntityManager; +import org.valkyrienskies.mod.common.entity.handling.WorldEntityHandler; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @Mixin(Entity.class) public abstract class MixinEntity { + @Shadow + public abstract Level getLevel(); + @Shadow public abstract void setPosRaw(double d, double e, double f); @@ -47,6 +53,31 @@ private void positionRider(final Entity instance, final Entity passengerI, final .positionSetFromVehicle(passenger, Entity.class.cast(this), x, y, z)); } + @Unique + private boolean isModifyingSetPos = false; + + /** + * @author ewoudje + * @reason use vs2 entity handler to handle this method + */ + @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(); + //noinspection ConstantValue + if (!Player.class.isInstance(this) || level == null || isModifyingSetPos || + !VSGameUtilsKt.isBlockInShipyard(level, x, y, z)) { + return; + } + + final Ship ship = VSGameUtilsKt.getShipManagingPos(level, x, y, z); + if (ship != null) { + isModifyingSetPos = true; + WorldEntityHandler.INSTANCE.moveEntityFromShipyardToWorld(Entity.class.cast(this), ship, x, y, z); + isModifyingSetPos = false; + ci.cancel(); + } + } + @Unique private boolean isModifyingTeleport = false; @@ -98,7 +129,8 @@ 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, VectorConversionsMCKt.toJOML(thisAsEntity.position())); + 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/kotlin/org/valkyrienskies/mod/common/entity/handling/WorldEntityHandler.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/handling/WorldEntityHandler.kt index c6b7ffb4a..11574a70d 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 @@ -6,7 +6,6 @@ import net.minecraft.client.renderer.entity.EntityRenderer import net.minecraft.world.entity.Entity import net.minecraft.world.entity.projectile.AbstractHurtingProjectile import org.joml.Vector3d -import org.joml.Vector3dc import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.Ship import org.valkyrienskies.core.impl.util.component1 @@ -51,8 +50,13 @@ object WorldEntityHandler : VSEntityHandler { ) { } - private fun moveEntityFromShipyardToWorld(entity: Entity, ship: Ship): Vector3dc { - val newPos = ship.shipToWorld.transformPosition(entity.position().toJOML()) + fun moveEntityFromShipyardToWorld(entity: Entity, ship: Ship) = + moveEntityFromShipyardToWorld(entity, ship, entity.x, entity.y, entity.z) + + fun moveEntityFromShipyardToWorld( + entity: Entity, ship: Ship, entityX: Double, entityY: Double, entityZ: Double + ) { + val newPos = ship.shipToWorld.transformPosition(Vector3d(entityX, entityY, entityZ)) entity.setPos(newPos.x, newPos.y, newPos.z) entity.xo = entity.x entity.yo = entity.y @@ -86,7 +90,5 @@ object WorldEntityHandler : VSEntityHandler { entity.yPower = power.y entity.zPower = power.z } - - return newPos } } From 8ba6c896168ec889b3640b58656f1971fc155cc6 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 17 Jan 2023 19:07:15 -0500 Subject: [PATCH 043/437] fix: disable kicked for flying --- .../network/MixinServerGamePacketListenerImpl.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 57fbe19a9..8c4210e6d 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 @@ -1,5 +1,6 @@ package org.valkyrienskies.mod.mixin.server.network; +import com.llamalad7.mixinextras.injector.ModifyExpressionValue; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import java.util.Collections; @@ -52,6 +53,19 @@ public abstract class MixinServerGamePacketListenerImpl { @Final private MinecraftServer server; + @ModifyExpressionValue( + at = @At(value = "FIELD", + target = "Lnet/minecraft/server/network/ServerGamePacketListenerImpl;aboveGroundTickCount:I", ordinal = 0), + method = "tick" + ) + private int noFlyKick(final int original) { + if (VSGameConfig.SERVER.getEnableMovementChecks()) { + return original; + } else { + return 0; + } + } + @WrapOperation( at = @At( value = "INVOKE", From 5a32c485b23814797c6f3c99c4e8e3fa81c42c38 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 17 Jan 2023 19:41:36 -0500 Subject: [PATCH 044/437] fix: prevent crashes when missing ship world --- .../mod/mixin/client/MixinMinecraft.java | 9 ++++- .../mixin/server/MixinMinecraftServer.java | 8 ++--- .../mixin/server/world/MixinServerLevel.java | 11 ++++--- .../mod/common/IShipObjectWorldProvider.kt | 8 ++--- .../valkyrienskies/mod/common/VSGameUtils.kt | 6 ++-- ...myShipWorld.kt => DummyShipWorldClient.kt} | 33 +++++++++++++++---- 6 files changed, 52 insertions(+), 23 deletions(-) rename common/src/main/kotlin/org/valkyrienskies/mod/common/world/{DummyShipWorld.kt => DummyShipWorldClient.kt} (54%) 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 163cd599f..dc5955c30 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 @@ -13,6 +13,8 @@ import net.minecraft.world.InteractionResult; import net.minecraft.world.phys.BlockHitResult; import net.minecraft.world.phys.HitResult; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; @@ -28,12 +30,16 @@ import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.ValkyrienSkiesMod; import org.valkyrienskies.mod.common.util.EntityDragger; +import org.valkyrienskies.mod.common.world.DummyShipWorldClient; import org.valkyrienskies.mod.mixinducks.client.MinecraftDuck; @Mixin(Minecraft.class) public abstract class MixinMinecraft implements MinecraftDuck, IShipObjectWorldClientProvider, IShipObjectWorldClientCreator { + @Unique + private static final Logger log = LogManager.getLogger("VS2 MixinMinecraft"); + @Shadow private boolean pause; @@ -81,7 +87,8 @@ public ClientShipWorldCore getShipObjectWorld() { final ClientShipWorldCore shipObjectWorldCopy = shipObjectWorld; if (shipObjectWorldCopy == null) { - throw new IllegalStateException("Requested getShipObjectWorld() when shipObjectWorld was null!"); + log.warn("Requested getShipObjectWorld() when shipObjectWorld was null!"); + return DummyShipWorldClient.INSTANCE; } return shipObjectWorldCopy; } 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 710518edf..652d51a40 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 @@ -9,7 +9,7 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.players.PlayerList; -import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -72,13 +72,13 @@ public void onTick(final BooleanSupplier booleanSupplier, final CallbackInfo ci) shipWorld.setPlayers(vsPlayers); } - @NotNull + @Nullable @Override public ServerShipWorldCore getShipObjectWorld() { return shipWorld; } - @NotNull + @Nullable @Override public VSPipeline getVsPipeline() { return vsPipeline; @@ -117,7 +117,7 @@ private void postCreateLevels(final CallbackInfo ci) { shipWorld = vsPipeline.getShipWorld(); RegistryEvents.registriesAreComplete(); - + getShipObjectWorld().addDimension( VSGameUtilsKt.getDimensionId(overworld()), VSGameUtilsKt.getYRange(overworld()) 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 d50f3fd0e..773f161fc 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 @@ -30,6 +30,7 @@ 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; import org.joml.Vector3i; import org.joml.Vector3ic; @@ -63,7 +64,7 @@ public abstract class MixinServerLevel implements IShipObjectWorldServerProvider private final Set knownChunkRegions = new HashSet<>(); - @NotNull + @Nullable @Override public ServerShipWorldCore getShipObjectWorld() { return ((IShipObjectWorldServerProvider) getServer()).getShipObjectWorld(); @@ -169,8 +170,10 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf final Wing wing = ((WingBlock) blockState.getBlock()).getWing(thisAsLevel, mutableBlockPos, blockState); - if (wing != null) - shipAsWingManager.setWing(shipAsWingManager.getFirstWingGroupId(), posX, posY, posZ, wing); + if (wing != null) { + shipAsWingManager.setWing(shipAsWingManager.getFirstWingGroupId(), + posX, posY, posZ, wing); + } } } } @@ -207,5 +210,5 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf voxelShapeUpdates ); } - + } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/IShipObjectWorldProvider.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/IShipObjectWorldProvider.kt index fd673b0dd..81a157d15 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/IShipObjectWorldProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/IShipObjectWorldProvider.kt @@ -6,16 +6,16 @@ import org.valkyrienskies.core.apigame.world.ServerShipWorldCore import org.valkyrienskies.core.apigame.world.VSPipeline interface IShipObjectWorldProvider { - val shipObjectWorld: ShipWorld + val shipObjectWorld: ShipWorld? } interface IShipObjectWorldServerProvider : IShipObjectWorldProvider { - override val shipObjectWorld: ServerShipWorldCore - val vsPipeline: VSPipeline + override val shipObjectWorld: ServerShipWorldCore? + val vsPipeline: VSPipeline? } interface IShipObjectWorldClientProvider : IShipObjectWorldProvider { - override val shipObjectWorld: ClientShipWorldCore + override val shipObjectWorld: ClientShipWorldCore? } interface IShipObjectWorldClientCreator { 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 2ebe5a46a..617a5fad7 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -41,7 +41,7 @@ import org.valkyrienskies.mod.common.util.set import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toJOMLD import org.valkyrienskies.mod.common.util.toMinecraft -import org.valkyrienskies.mod.common.world.DummyShipWorld +import org.valkyrienskies.mod.common.world.DummyShipWorldClient import org.valkyrienskies.mod.mixin.accessors.resource.ResourceKeyAccessor import org.valkyrienskies.mod.mixinducks.world.entity.PlayerDuck import java.util.function.Consumer @@ -56,12 +56,12 @@ val Level.shipWorldNullable: ShipWorldCore? } val Level.shipObjectWorld - get() = shipWorldNullable ?: DummyShipWorld + get() = shipWorldNullable ?: DummyShipWorldClient val Level.allShips get() = this.shipObjectWorld.allShips val MinecraftServer.shipObjectWorld get() = (this as IShipObjectWorldServerProvider).shipObjectWorld -val MinecraftServer.vsPipeline get() = (this as IShipObjectWorldServerProvider).vsPipeline +val MinecraftServer.vsPipeline get() = (this as IShipObjectWorldServerProvider).vsPipeline!! val ServerLevel.shipObjectWorld get() = server.shipObjectWorld diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorld.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldClient.kt similarity index 54% rename from common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorld.kt rename to common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldClient.kt index 2d7ce2b85..2e096d22d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorld.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldClient.kt @@ -1,23 +1,42 @@ package org.valkyrienskies.mod.common.world import org.joml.primitives.AABBdc -import org.valkyrienskies.core.api.ships.LoadedShip +import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.QueryableShipData -import org.valkyrienskies.core.api.ships.Ship -import org.valkyrienskies.core.apigame.world.ShipWorldCore +import org.valkyrienskies.core.apigame.world.ClientShipWorldCore import org.valkyrienskies.core.apigame.world.chunks.BlockType import org.valkyrienskies.core.apigame.world.properties.DimensionId import org.valkyrienskies.core.impl.game.ships.QueryableShipDataImpl +import java.net.SocketAddress + +object DummyShipWorldClient : ClientShipWorldCore { + override fun tickNetworking(server: SocketAddress) { + throw UnsupportedOperationException() + } + + override fun postTick() { + throw UnsupportedOperationException() + } + + override fun updateRenderTransforms(partialTicks: Double) { + throw UnsupportedOperationException() + } + + override fun destroyWorld() { + throw UnsupportedOperationException() + } + + override val isSyncedWithServer: Boolean + get() = throw UnsupportedOperationException() -object DummyShipWorld : ShipWorldCore { override fun onSetBlock( posX: Int, posY: Int, posZ: Int, dimensionId: DimensionId, oldBlockType: BlockType, newBlockType: BlockType, oldBlockMass: Double, newBlockMass: Double ) { } - override val allShips: QueryableShipData get() = loadedShips - override val loadedShips: QueryableShipData = QueryableShipDataImpl() + override val allShips: QueryableShipData get() = loadedShips + override val loadedShips: QueryableShipData = QueryableShipDataImpl() override fun isChunkInShipyard(chunkX: Int, chunkZ: Int, dimensionId: DimensionId): Boolean { return false @@ -28,7 +47,7 @@ object DummyShipWorld : ShipWorldCore { } @Deprecated("redundant", replaceWith = ReplaceWith("loadedShips.getIntersecting(aabb)")) - override fun getShipObjectsIntersecting(aabb: AABBdc): List { + override fun getShipObjectsIntersecting(aabb: AABBdc): List { return emptyList() } } From 3daab568b5fdaafdf0d323d8806103cde8cddf65 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 17 Jan 2023 19:46:52 -0500 Subject: [PATCH 045/437] fix: nullptr crash on server shutdown --- .../server/network/MixinServerGamePacketListenerImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 8c4210e6d..b7c29d647 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 @@ -24,6 +24,7 @@ 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.core.apigame.world.ServerShipWorldCore; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.config.VSGameConfig; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @@ -170,9 +171,10 @@ private void transformTeleport(final double x, final double y, final double z, f at = @At("HEAD") ) void onDisconnect(final Component reason, final CallbackInfo ci) { - VSGameUtilsKt.getShipObjectWorld(this.server).onDisconnect( - VSGameUtilsKt.getPlayerWrapper(this.player) - ); + final ServerShipWorldCore world = VSGameUtilsKt.getShipObjectWorld(this.server); + if (world != null) { + world.onDisconnect(VSGameUtilsKt.getPlayerWrapper(this.player)); + } } } From 08e41b06dace6bc369f254bb7c3d5f2c797d97ca Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 17 Jan 2023 21:40:19 -0500 Subject: [PATCH 046/437] fix: missing ship worlds pt2 --- .../valkyrienskies/mod/common/VSGameUtils.kt | 7 +- .../mod/common/hooks/CommonHooksImpl.kt | 2 +- .../mod/common/world/DummyShipWorldServer.kt | 98 +++++++++++++++++++ 3 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt 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 617a5fad7..e2125d2db 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -29,6 +29,7 @@ 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.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 @@ -42,6 +43,7 @@ import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toJOMLD import org.valkyrienskies.mod.common.util.toMinecraft import org.valkyrienskies.mod.common.world.DummyShipWorldClient +import org.valkyrienskies.mod.common.world.DummyShipWorldServer import org.valkyrienskies.mod.mixin.accessors.resource.ResourceKeyAccessor import org.valkyrienskies.mod.mixinducks.world.entity.PlayerDuck import java.util.function.Consumer @@ -60,7 +62,8 @@ val Level.shipObjectWorld val Level.allShips get() = this.shipObjectWorld.allShips -val MinecraftServer.shipObjectWorld get() = (this as IShipObjectWorldServerProvider).shipObjectWorld +val MinecraftServer.shipObjectWorld: ServerShipWorldCore + get() = (this as IShipObjectWorldServerProvider).shipObjectWorld ?: DummyShipWorldServer val MinecraftServer.vsPipeline get() = (this as IShipObjectWorldServerProvider).vsPipeline!! val ServerLevel.shipObjectWorld @@ -103,7 +106,7 @@ fun MinecraftServer.getLevelFromDimensionId(dimensionId: DimensionId): ServerLev return getLevel(getResourceKey(dimensionId)) } -val Minecraft.shipObjectWorld get() = (this as IShipObjectWorldClientProvider).shipObjectWorld +val Minecraft.shipObjectWorld get() = (this as IShipObjectWorldClientProvider).shipObjectWorld ?: DummyShipWorldClient val ClientLevel.shipObjectWorld get() = Minecraft.getInstance().shipObjectWorld val IPlayer.mcPlayer: Player get() = (this as MinecraftPlayer).playerEntityReference.get()!! diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/CommonHooksImpl.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/CommonHooksImpl.kt index b5f354359..980a24c0d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/CommonHooksImpl.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/CommonHooksImpl.kt @@ -36,5 +36,5 @@ abstract class CommonHooksImpl : CoreHooksOut { get() = ValkyrienSkiesMod.currentServer?.shipObjectWorld override val currentShipClientWorld: ShipWorld - get() = Minecraft.getInstance().shipObjectWorld + get() = Minecraft.getInstance().shipObjectWorld!! } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt new file mode 100644 index 000000000..deb0bf46f --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt @@ -0,0 +1,98 @@ +package org.valkyrienskies.mod.common.world + +import org.joml.Vector3ic +import org.joml.primitives.AABBdc +import org.valkyrienskies.core.api.ships.LoadedServerShip +import org.valkyrienskies.core.api.ships.QueryableShipData +import org.valkyrienskies.core.api.ships.ServerShip +import org.valkyrienskies.core.api.ships.properties.ShipId +import org.valkyrienskies.core.api.world.LevelYRange +import org.valkyrienskies.core.apigame.constraints.VSConstraint +import org.valkyrienskies.core.apigame.constraints.VSConstraintId +import org.valkyrienskies.core.apigame.world.IPlayer +import org.valkyrienskies.core.apigame.world.ServerShipWorldCore +import org.valkyrienskies.core.apigame.world.chunks.BlockType +import org.valkyrienskies.core.apigame.world.chunks.ChunkUnwatchTask +import org.valkyrienskies.core.apigame.world.chunks.ChunkWatchTask +import org.valkyrienskies.core.apigame.world.chunks.ChunkWatchTasks +import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate +import org.valkyrienskies.core.apigame.world.properties.DimensionId +import org.valkyrienskies.core.impl.game.ships.QueryableShipDataImpl + +object DummyShipWorldServer : ServerShipWorldCore { + override var players: Set = emptySet() + + override fun addTerrainUpdates(dimensionId: DimensionId, terrainUpdates: List) { + TODO("Not yet implemented") + } + + override fun getIPlayersWatchingShipChunk(chunkX: Int, chunkZ: Int, dimensionId: DimensionId): Iterator { + TODO("Not yet implemented") + } + + override fun getChunkWatchTasks(): ChunkWatchTasks { + TODO("Not yet implemented") + } + + override fun setExecutedChunkWatchTasks( + watchTasks: Iterable, unwatchTasks: Iterable + ) { + TODO("Not yet implemented") + } + + override fun createNewShipAtBlock( + blockPosInWorldCoordinates: Vector3ic, createShipObjectImmediately: Boolean, scaling: Double, + dimensionId: DimensionId + ): ServerShip { + TODO("Not yet implemented") + } + + override fun createNewConstraint(vsConstraint: VSConstraint): VSConstraintId? { + TODO("Not yet implemented") + } + + override fun updateConstraint(constraintId: VSConstraintId, updatedVSConstraint: VSConstraint): Boolean { + TODO("Not yet implemented") + } + + override fun removeConstraint(constraintId: VSConstraintId): Boolean { + TODO("Not yet implemented") + } + + override fun addDimension(dimensionId: DimensionId, yRange: LevelYRange) { + TODO("Not yet implemented") + } + + override fun removeDimension(dimensionId: DimensionId) { + TODO("Not yet implemented") + } + + override fun onDisconnect(player: IPlayer) { + } + + override val dimensionToGroundBodyIdImmutable: Map + get() = TODO("Not yet implemented") + + override fun onSetBlock( + posX: Int, posY: Int, posZ: Int, dimensionId: DimensionId, oldBlockType: BlockType, newBlockType: BlockType, + oldBlockMass: Double, newBlockMass: Double + ) { + } + + override val allShips: QueryableShipData + get() = loadedShips + override val loadedShips: QueryableShipData = QueryableShipDataImpl() + + override fun isChunkInShipyard(chunkX: Int, chunkZ: Int, dimensionId: DimensionId): Boolean { + return false + } + + override fun isBlockInShipyard(blockX: Int, blockY: Int, blockZ: Int, dimensionId: DimensionId): Boolean { + return false + } + + @Deprecated("redundant", replaceWith = ReplaceWith("loadedShips.getIntersecting(aabb)")) + override fun getShipObjectsIntersecting(aabb: AABBdc): List { + return emptyList() + } +} From 7bfc768fa37813d6801151a4609fe7f0e3cfe392 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 17 Jan 2023 22:11:16 -0500 Subject: [PATCH 047/437] fix: crash on premature server shutdown --- .../valkyrienskies/mod/mixin/server/MixinMinecraftServer.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 652d51a40..0abf27645 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 @@ -186,7 +186,9 @@ private void postTick(final CallbackInfo ci) { at = @At("HEAD") ) private void preStopServer(final CallbackInfo ci) { - vsPipeline.setDeleteResources(true); + if (vsPipeline != null) { + vsPipeline.setDeleteResources(true); + } shipWorld = null; } } From 0a7155b02ca5e1d0e297bf3920ea37326a48a855 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Tue, 17 Jan 2023 23:30:05 -0500 Subject: [PATCH 048/437] fix: nullpointer exception --- .../mod/common/networking/VSGamePackets.kt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) 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 2834eb197..7c1efeb1b 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 @@ -3,9 +3,9 @@ package org.valkyrienskies.mod.common.networking import net.minecraft.core.Registry 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.game.ships.ShipObjectServer import org.valkyrienskies.core.impl.networking.simple.register import org.valkyrienskies.core.impl.networking.simple.registerClientHandler import org.valkyrienskies.core.impl.networking.simple.registerServerHandler @@ -27,13 +27,15 @@ object VSGamePackets { fun registerHandlers() { PacketPlayerDriving::class.registerServerHandler { driving, iPlayer -> val player = (iPlayer as MinecraftPlayer).player as ServerPlayer - if (player.vehicle is ShipMountingEntity && (player.vehicle as ShipMountingEntity).isController) { - val seat = player.vehicle!! as ShipMountingEntity - val ship = seat.level.getShipObjectManagingPos(seat.blockPosition())!! as ShipObjectServer + val seat = player.vehicle as? ShipMountingEntity + ?: return@registerServerHandler + if (seat.isController) { + val ship = seat.level.getShipObjectManagingPos(seat.blockPosition()) as? LoadedServerShip + ?: return@registerServerHandler + val attachment: SeatedControllingPlayer = ship.getAttachment() ?: SeatedControllingPlayer(seat.direction.opposite).apply { ship.setAttachment(this) } - attachment.forwardImpulse = driving.impulse.z attachment.leftImpulse = driving.impulse.x attachment.upImpulse = driving.impulse.y From 6bd2d2549374368ade9cf9cae4124a2f5bb4dc09 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Wed, 18 Jan 2023 06:13:42 -0700 Subject: [PATCH 049/437] Don't rotate the net torque T_T, fix camber angle not in radians --- .../kotlin/org/valkyrienskies/mod/common/block/TestWingBlock.kt | 2 +- vs-core | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 2dfe55047..b7c9e808a 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 @@ -79,7 +79,7 @@ object TestWingBlock : val wingPower = 150.0 val wingDrag = 30.0 val wingBreakingForce = null - val wingCamberAttackAngleBias = 10.0 + val wingCamberAttackAngleBias = Math.toRadians(10.0) return Wing( blockState.getValue(FACING).normal.toJOMLD(), wingPower, wingDrag, wingBreakingForce, wingCamberAttackAngleBias diff --git a/vs-core b/vs-core index 2b2f93f79..b3e028bdf 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 2b2f93f79313bab3c8bc19fc90e2d3bc5e03b4ef +Subproject commit b3e028bdf8c67a3bf8c31e34c2276092ff034897 From 33baabcaea9aadf6579a7121fe2a3e9a29b2b72c Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Wed, 18 Jan 2023 18:59:01 +0100 Subject: [PATCH 050/437] Rendering Events (#359) --- .../mod/event/RenderingEvents.java | 67 +++++++++++++++++++ .../MixinLevelRendererVanilla.java | 13 ++++ 2 files changed, 80 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/event/RenderingEvents.java diff --git a/common/src/main/java/org/valkyrienskies/mod/event/RenderingEvents.java b/common/src/main/java/org/valkyrienskies/mod/event/RenderingEvents.java new file mode 100644 index 000000000..4a734be59 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/event/RenderingEvents.java @@ -0,0 +1,67 @@ +package org.valkyrienskies.mod.event; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Matrix4f; +import it.unimi.dsi.fastutil.objects.ObjectList; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Consumer; +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.mod.compat.VSRenderer; +import org.valkyrienskies.mod.mixin.ValkyrienCommonMixinConfigPlugin; + +public class RenderingEvents { + + private static List> onShipsStartRendering = new ArrayList<>(); + private static List> onShipRender = new ArrayList<>(); + private static List> afterShipRender = new ArrayList<>(); + + public static void onShipsStartRendering(final Consumer event) { + onShipsStartRendering.add(event); + } + + public static void onShipRender(final Consumer event) { + onShipRender.add(event); + } + + public static void afterShipRender(final Consumer event) { + afterShipRender.add(event); + } + + public static void shipsStartRendering(final ShipStartRenderEvent event) { + onShipsStartRendering.forEach((consumer) -> consumer.accept(event)); + } + + public static void shipRendering(final ShipRenderEvent event) { + onShipRender.forEach((consumer) -> consumer.accept(event)); + } + + public static void afterShipRendered(final ShipRenderEvent event) { + afterShipRender.forEach((consumer) -> consumer.accept(event)); + } + + public static boolean eventsAreWorking() { + return ValkyrienCommonMixinConfigPlugin.getVSRenderer() == VSRenderer.VANILLA; + } + + public record ShipStartRenderEvent( + LevelRenderer renderer, + RenderType renderType, + PoseStack poseStack, + double camX, double camY, double camZ, + Matrix4f projectionMatrix) { + } + + public record ShipRenderEvent( + LevelRenderer renderer, + RenderType renderType, + PoseStack poseStack, + double camX, double camY, double camZ, + Matrix4f projectionMatrix, + ClientShip ship, + ObjectList chunks) { + } +} 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 be532a25e..ae4bc993d 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 @@ -42,6 +42,8 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.compat.VSRenderer; +import org.valkyrienskies.mod.event.RenderingEvents; +import org.valkyrienskies.mod.event.RenderingEvents.ShipRenderEvent; import org.valkyrienskies.mod.mixin.ValkyrienCommonMixinConfigPlugin; import org.valkyrienskies.mod.mixin.accessors.client.render.ViewAreaAccessor; import org.valkyrienskies.mod.mixin.mod_compat.optifine.RenderChunkInfoAccessorOptifine; @@ -166,6 +168,10 @@ private void redirectRenderChunkLayer(final LevelRenderer receiver, renderChunkLayer.call(receiver, renderType, poseStack, camX, camY, camZ, matrix4f); + RenderingEvents.shipsStartRendering(new RenderingEvents.ShipStartRenderEvent( + receiver, renderType, poseStack, camX, camY, camZ, matrix4f + )); + shipRenderChunks.forEach((ship, chunks) -> { poseStack.pushPose(); final Vector3dc center = ship.getRenderTransform().getPositionInShip(); @@ -173,7 +179,14 @@ private void redirectRenderChunkLayer(final LevelRenderer receiver, center.x(), center.y(), center.z(), camX, camY, camZ); + final var event = new ShipRenderEvent( + receiver, renderType, poseStack, camX, camY, camZ, matrix4f, ship, chunks + ); + + RenderingEvents.shipRendering(event); renderChunkLayer(renderType, poseStack, center.x(), center.y(), center.z(), matrix4f, chunks); + RenderingEvents.afterShipRendered(event); + poseStack.popPose(); }); } From 37b771461d05a8dbe52ee6d779428e2ed60e7761 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Wed, 18 Jan 2023 19:23:53 +0100 Subject: [PATCH 051/437] Moving events around --- .../mod/event/RegistryEvents.java | 29 -------- .../mod/event/RenderingEvents.java | 67 ------------------- .../MixinLevelRendererVanilla.java | 11 ++- .../mixin/server/MixinMinecraftServer.java | 4 +- .../mod/common/BlockStateInfoProvider.kt | 4 +- .../mod/common/config/VSMassDataLoader.kt | 4 +- .../mod/common/hooks/VSGameEvents.kt | 39 +++++++++++ .../fabric/common/ValkyrienSkiesModFabric.kt | 8 ++- .../forge/common/ValkyrienSkiesModForge.kt | 9 ++- 9 files changed, 63 insertions(+), 112 deletions(-) delete mode 100644 common/src/main/java/org/valkyrienskies/mod/event/RegistryEvents.java delete mode 100644 common/src/main/java/org/valkyrienskies/mod/event/RenderingEvents.java create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/VSGameEvents.kt diff --git a/common/src/main/java/org/valkyrienskies/mod/event/RegistryEvents.java b/common/src/main/java/org/valkyrienskies/mod/event/RegistryEvents.java deleted file mode 100644 index 1cdd603b6..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/event/RegistryEvents.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.valkyrienskies.mod.event; - -import java.util.ArrayList; -import java.util.List; -import net.minecraft.core.RegistryAccess; - -public class RegistryEvents { - - private static List onTagsLoaded = new ArrayList<>(); - private static List onRegistriesComplete = new ArrayList<>(); - - // this can be beter... - public static void onTagsLoaded(final Runnable event) { - onTagsLoaded.add(event); - } - - public static void tagsAreLoaded(final RegistryAccess registries, final boolean client) { - onTagsLoaded.forEach(Runnable::run); - } - - public static void onRegistriesComplete(final Runnable event) { - onRegistriesComplete.add(event); - } - - public static void registriesAreComplete() { - onRegistriesComplete.forEach(Runnable::run); - } - -} diff --git a/common/src/main/java/org/valkyrienskies/mod/event/RenderingEvents.java b/common/src/main/java/org/valkyrienskies/mod/event/RenderingEvents.java deleted file mode 100644 index 4a734be59..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/event/RenderingEvents.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.valkyrienskies.mod.event; - -import com.mojang.blaze3d.vertex.PoseStack; -import com.mojang.math.Matrix4f; -import it.unimi.dsi.fastutil.objects.ObjectList; -import java.util.ArrayList; -import java.util.List; -import java.util.function.Consumer; -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.mod.compat.VSRenderer; -import org.valkyrienskies.mod.mixin.ValkyrienCommonMixinConfigPlugin; - -public class RenderingEvents { - - private static List> onShipsStartRendering = new ArrayList<>(); - private static List> onShipRender = new ArrayList<>(); - private static List> afterShipRender = new ArrayList<>(); - - public static void onShipsStartRendering(final Consumer event) { - onShipsStartRendering.add(event); - } - - public static void onShipRender(final Consumer event) { - onShipRender.add(event); - } - - public static void afterShipRender(final Consumer event) { - afterShipRender.add(event); - } - - public static void shipsStartRendering(final ShipStartRenderEvent event) { - onShipsStartRendering.forEach((consumer) -> consumer.accept(event)); - } - - public static void shipRendering(final ShipRenderEvent event) { - onShipRender.forEach((consumer) -> consumer.accept(event)); - } - - public static void afterShipRendered(final ShipRenderEvent event) { - afterShipRender.forEach((consumer) -> consumer.accept(event)); - } - - public static boolean eventsAreWorking() { - return ValkyrienCommonMixinConfigPlugin.getVSRenderer() == VSRenderer.VANILLA; - } - - public record ShipStartRenderEvent( - LevelRenderer renderer, - RenderType renderType, - PoseStack poseStack, - double camX, double camY, double camZ, - Matrix4f projectionMatrix) { - } - - public record ShipRenderEvent( - LevelRenderer renderer, - RenderType renderType, - PoseStack poseStack, - double camX, double camY, double camZ, - Matrix4f projectionMatrix, - ClientShip ship, - ObjectList chunks) { - } -} 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 ae4bc993d..6c9cf355c 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 @@ -40,10 +40,9 @@ import org.valkyrienskies.core.api.ships.ClientShip; import org.valkyrienskies.mod.common.VSClientGameUtils; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.hooks.VSGameEvents; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.compat.VSRenderer; -import org.valkyrienskies.mod.event.RenderingEvents; -import org.valkyrienskies.mod.event.RenderingEvents.ShipRenderEvent; import org.valkyrienskies.mod.mixin.ValkyrienCommonMixinConfigPlugin; import org.valkyrienskies.mod.mixin.accessors.client.render.ViewAreaAccessor; import org.valkyrienskies.mod.mixin.mod_compat.optifine.RenderChunkInfoAccessorOptifine; @@ -168,7 +167,7 @@ private void redirectRenderChunkLayer(final LevelRenderer receiver, renderChunkLayer.call(receiver, renderType, poseStack, camX, camY, camZ, matrix4f); - RenderingEvents.shipsStartRendering(new RenderingEvents.ShipStartRenderEvent( + VSGameEvents.INSTANCE.getShipsStartRendering().emit(new VSGameEvents.ShipStartRenderEvent( receiver, renderType, poseStack, camX, camY, camZ, matrix4f )); @@ -179,13 +178,13 @@ private void redirectRenderChunkLayer(final LevelRenderer receiver, center.x(), center.y(), center.z(), camX, camY, camZ); - final var event = new ShipRenderEvent( + final var event = new VSGameEvents.ShipRenderEvent( receiver, renderType, poseStack, camX, camY, camZ, matrix4f, ship, chunks ); - RenderingEvents.shipRendering(event); + VSGameEvents.INSTANCE.getRenderShip().emit(event); renderChunkLayer(renderType, poseStack, center.x(), center.y(), center.z(), matrix4f, chunks); - RenderingEvents.afterShipRendered(event); + VSGameEvents.INSTANCE.getPostRenderShip().emit(event); poseStack.popPose(); }); 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 0abf27645..e7b5c8a25 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 @@ -24,9 +24,9 @@ import org.valkyrienskies.mod.common.ShipSavedData; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.ValkyrienSkiesMod; +import org.valkyrienskies.mod.common.hooks.VSGameEvents; import org.valkyrienskies.mod.common.util.EntityDragger; import org.valkyrienskies.mod.common.world.ChunkManagement; -import org.valkyrienskies.mod.event.RegistryEvents; import org.valkyrienskies.mod.util.KrunchSupport; @Mixin(MinecraftServer.class) @@ -116,7 +116,7 @@ private void postCreateLevels(final CallbackInfo ci) { shipWorld = vsPipeline.getShipWorld(); - RegistryEvents.registriesAreComplete(); + VSGameEvents.INSTANCE.getRegistriesCompleted().emit(null); getShipObjectWorld().addDimension( VSGameUtilsKt.getDimensionId(overworld()), 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 7d064eb16..898876681 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -16,7 +16,7 @@ import org.valkyrienskies.core.api.ships.WingManager 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.event.RegistryEvents +import org.valkyrienskies.mod.common.hooks.VSGameEvents // Other mods can then provide weights and types based on their added content // NOTE: if we have block's in vs-core we should ask getVSBlock(blockstate: BlockStat): VSBlock since thatd be more handy @@ -48,7 +48,7 @@ object BlockStateInfo { REGISTRY, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "default"), DefaultBlockStateInfoProvider ) - RegistryEvents.onRegistriesComplete { SORTED_REGISTRY = REGISTRY.sortedByDescending { it.priority } } + VSGameEvents.registriesCompleted.on { _, _ -> SORTED_REGISTRY = REGISTRY.sortedByDescending { it.priority } } } // This is [ThreadLocal] because in single-player games the Client thread and Server thread will read/write to 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 dc2298230..06139f2e3 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 @@ -13,7 +13,7 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import org.valkyrienskies.core.game.VSBlockType import org.valkyrienskies.mod.common.BlockStateInfoProvider -import org.valkyrienskies.mod.event.RegistryEvents +import org.valkyrienskies.mod.common.hooks.VSGameEvents import org.valkyrienskies.mod.util.logger import java.util.Optional @@ -60,7 +60,7 @@ object MassDatapackResolver : BlockStateInfoProvider { } init { - RegistryEvents.onTagsLoaded { + VSGameEvents.tagsAreLoaded.on { _, _ -> tags.forEach { tagInfo -> val tag: Optional>? = Registry.BLOCK.getTag(TagKey.create(Registry.BLOCK_REGISTRY, tagInfo.id)) 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 new file mode 100644 index 000000000..fd3a1ccaf --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/VSGameEvents.kt @@ -0,0 +1,39 @@ +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.valkyrienskies.core.api.ships.ClientShip +import org.valkyrienskies.core.impl.util.events.EventEmitterImpl + +object VSGameEvents { + + val registriesCompleted = EventEmitterImpl() + val tagsAreLoaded = EventEmitterImpl() + + val renderShip = EventEmitterImpl() + val postRenderShip = EventEmitterImpl() + val shipsStartRendering = EventEmitterImpl() + + data class ShipStartRenderEvent( + val renderer: LevelRenderer, + val renderType: RenderType, + val poseStack: PoseStack, + val camX: Double, val camY: Double, val camZ: Double, + val projectionMatrix: Matrix4f + ) + + data class ShipRenderEvent( + val renderer: LevelRenderer, + val renderType: RenderType, + val poseStack: PoseStack, + val camX: Double, val camY: Double, val camZ: Double, + val projectionMatrix: Matrix4f, + val ship: ClientShip, + val chunks: ObjectList + ) +} + 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 fb8474c01..7413cc983 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 @@ -26,8 +26,8 @@ import org.valkyrienskies.core.apigame.VSCoreFactory import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock -import org.valkyrienskies.mod.common.block.TestHingeBlock import org.valkyrienskies.mod.common.block.TestFlapBlock +import org.valkyrienskies.mod.common.block.TestHingeBlock import org.valkyrienskies.mod.common.block.TestWingBlock import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.config.MassDatapackResolver @@ -35,9 +35,9 @@ import org.valkyrienskies.mod.common.config.VSEntityHandlerDataLoader 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 -import org.valkyrienskies.mod.event.RegistryEvents import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.concurrent.atomic.AtomicBoolean @@ -135,7 +135,9 @@ class ValkyrienSkiesModFabric : ModInitializer { ) { _, _ -> } } }) - CommonLifecycleEvents.TAGS_LOADED.register(RegistryEvents::tagsAreLoaded) + CommonLifecycleEvents.TAGS_LOADED.register { _, _ -> + VSGameEvents.tagsAreLoaded.emit(Unit) + } } /** 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 528169bfd..6d55c1752 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 @@ -13,6 +13,7 @@ import net.minecraftforge.client.ClientRegistry import net.minecraftforge.client.ConfigGuiHandler.ConfigGuiFactory import net.minecraftforge.client.event.EntityRenderersEvent import net.minecraftforge.event.AddReloadListenerEvent +import net.minecraftforge.event.TagsUpdatedEvent import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus @@ -28,8 +29,8 @@ import org.valkyrienskies.core.impl.config.VSCoreConfig import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock -import org.valkyrienskies.mod.common.block.TestHingeBlock import org.valkyrienskies.mod.common.block.TestFlapBlock +import org.valkyrienskies.mod.common.block.TestHingeBlock import org.valkyrienskies.mod.common.block.TestWingBlock import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.config.MassDatapackResolver @@ -38,6 +39,7 @@ 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 import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig @@ -82,6 +84,7 @@ class ValkyrienSkiesModForge { modBus.addListener(::entityRenderers) modBus.addListener(::loadComplete) + forgeBus.addListener(::tagsUpdated) forgeBus.addListener(::registerResourceManagers) ModLoadingContext.get().registerExtensionPoint(ConfigGuiFactory::class.java) { @@ -137,6 +140,10 @@ class ValkyrienSkiesModForge { return blockRegistry } + private fun tagsUpdated(event: TagsUpdatedEvent) { + VSGameEvents.tagsAreLoaded.emit(Unit) + } + private fun loadComplete(event: FMLLoadCompleteEvent) { ValkyrienSkiesMod.TEST_CHAIR = TEST_CHAIR_REGISTRY.get() ValkyrienSkiesMod.TEST_HINGE = TEST_HINGE_REGISTRY.get() From 43d492dabf8ea7078a104ab0306b4be3fb6e55b8 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Wed, 18 Jan 2023 20:01:02 +0100 Subject: [PATCH 052/437] Bruh --- .../valkyrienskies/mod/mixin/server/MixinMinecraftServer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 e7b5c8a25..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 @@ -6,6 +6,7 @@ import java.util.Set; import java.util.function.BooleanSupplier; import java.util.stream.Collectors; +import kotlin.Unit; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.players.PlayerList; @@ -116,7 +117,7 @@ private void postCreateLevels(final CallbackInfo ci) { shipWorld = vsPipeline.getShipWorld(); - VSGameEvents.INSTANCE.getRegistriesCompleted().emit(null); + VSGameEvents.INSTANCE.getRegistriesCompleted().emit(Unit.INSTANCE); getShipObjectWorld().addDimension( VSGameUtilsKt.getDimensionId(overworld()), From b738847c07f88d33d7da5d73abff96ecb91cc848 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Wed, 18 Jan 2023 18:35:08 -0700 Subject: [PATCH 053/437] Use 2 iterations of gauss seidel --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index b3e028bdf..080d99d60 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit b3e028bdf8c67a3bf8c31e34c2276092ff034897 +Subproject commit 080d99d60ffc941bd99639f593d8c069d865b34e From 170ff6f3c2baef6caf66c5b330588c696893b8f7 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 20 Jan 2023 15:45:12 -0500 Subject: [PATCH 054/437] fix: re-add RegistryEvents as deprecated for addons --- .../mod/event/RegistryEvents.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/event/RegistryEvents.java diff --git a/common/src/main/java/org/valkyrienskies/mod/event/RegistryEvents.java b/common/src/main/java/org/valkyrienskies/mod/event/RegistryEvents.java new file mode 100644 index 000000000..ed9363e83 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/event/RegistryEvents.java @@ -0,0 +1,41 @@ +package org.valkyrienskies.mod.event; + +import kotlin.Unit; +import net.minecraft.core.RegistryAccess; +import org.valkyrienskies.mod.common.hooks.VSGameEvents; + +public class RegistryEvents { + + /** + * @deprecated Use VSGameEvents + */ + @Deprecated(forRemoval = true) + public static void onTagsLoaded(final Runnable event) { + VSGameEvents.INSTANCE.getTagsAreLoaded().on(x -> event.run()); + } + + /** + * @deprecated Use VSGameEvents + */ + @Deprecated(forRemoval = true) + public static void tagsAreLoaded(final RegistryAccess registries, final boolean client) { + VSGameEvents.INSTANCE.getTagsAreLoaded().emit(Unit.INSTANCE); + } + + /** + * @deprecated Use VSGameEvents + */ + @Deprecated(forRemoval = true) + public static void onRegistriesComplete(final Runnable event) { + VSGameEvents.INSTANCE.getRegistriesCompleted().on(x -> event.run()); + } + + /** + * @deprecated Use VSGameEvents + */ + @Deprecated(forRemoval = true) + public static void registriesAreComplete() { + VSGameEvents.INSTANCE.getRegistriesCompleted().emit(Unit.INSTANCE); + } + +} From 4727e939b832532fa7f5a70379ac92fab44bef83 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Thu, 19 Jan 2023 10:53:34 -0500 Subject: [PATCH 055/437] fix: move sound physics to client only closes #362 --- 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 225c7d843..fcb76e645 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -47,7 +47,6 @@ "mod_compat.sodium.MixinRegionChunkRenderer", "mod_compat.sodium.MixinRenderSectionManager", "mod_compat.sodium.MixinSodiumWorldRenderer", - "mod_compat.sound_physics_remastered.MixinSoundPhysics", "server.MixinMinecraftServer", "server.MixinPlayerList", "server.command.MixinCommands", @@ -103,6 +102,7 @@ "mod_compat.optifine.MixinViewAreaOptifine", "mod_compat.optifine.RenderChunkInfoAccessorOptifine", "mod_compat.optifine_vanilla.MixinLevelRenderer", + "mod_compat.sound_physics_remastered.MixinSoundPhysics", "mod_compat.vanilla_renderer.MixinLevelRendererVanilla", "mod_compat.vanilla_renderer.MixinViewAreaVanilla", "mod_compat.vanilla_renderer.RenderChunkInfoAccessor" From f520a5c13dd6b50c618a605b315e591c578487e7 Mon Sep 17 00:00:00 2001 From: Grant Voelker Date: Sat, 21 Jan 2023 13:12:57 -0500 Subject: [PATCH 056/437] Assembly changes (#340) * - relocateBlock uses vanilla blockstate rotate for compatibility - relocateBlock has option to update blocks around it or not - updateBlock method to thoroughly update moved blocks - Assembly updates blocks separately after moving all of them (cherry picked from commit 9c6279b0baf3d0271090e2deb459da84223e553b) * - Fixes occasional NPE when using chunk.getBlockEntity after blockstate is set (cherry picked from commit 68e04d6af13e8f705dcca6f4361350c08531eee1) * - Document numbers, clean up unnecessary flags (cherry picked from commit d23e9870b4ad26222f82c772f1b1118c8af2d784) * - More adjustment to updateBlock - Flag 64 and neighbor updates were causing blocks to break that shouldn't break. (cherry picked from commit 49f473ab4a17f2674bb71ae74c861ba15a7acc9a) --- .../mod/common/assembly/ShipAssembly.kt | 16 ++- .../mod/common/item/ShipCreatorItem.kt | 5 +- .../valkyrienskies/mod/util/RelocationUtil.kt | 101 +++++++++--------- 3 files changed, 68 insertions(+), 54 deletions(-) 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 4b1e42dca..81b7a4ce7 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 @@ -18,6 +18,7 @@ import org.valkyrienskies.mod.common.playerWrapper import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.util.relocateBlock +import org.valkyrienskies.mod.util.updateBlock fun createNewShipWithBlocks( centerBlock: BlockPos, blocks: DenseBlockPosSet, level: ServerLevel @@ -60,7 +61,20 @@ fun createNewShipWithBlocks( 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, ship) + 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)) } } 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 488f026fa..3a5108f09 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,13 +1,13 @@ 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.server.level.ServerLevel import net.minecraft.world.InteractionResult import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.context.UseOnContext +import net.minecraft.world.level.block.Rotation.NONE import net.minecraft.world.level.block.state.BlockState import org.joml.Vector3d import org.valkyrienskies.core.impl.game.ships.ShipDataCommon @@ -43,7 +43,8 @@ class ShipCreatorItem(properties: Properties, private val scale: Double, private val centerPos = serverShip.chunkClaim.getCenterBlockCoordinates(level.yRange).toBlockPos() // Move the block from the world to a ship - level.relocateBlock(blockPos, centerPos, serverShip, NORTH) + level.relocateBlock(blockPos, centerPos, true, serverShip, NONE) + ctx.player?.sendMessage(TextComponent("SHIPIFIED!"), Util.NIL_UUID) if (parentShip != null) { // Compute the ship transform 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 fb3cab362..1ac9f4875 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt @@ -1,15 +1,13 @@ package org.valkyrienskies.mod.util import net.minecraft.core.BlockPos -import net.minecraft.core.Direction -import net.minecraft.core.Direction.NORTH import net.minecraft.world.Container 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.state.BlockState -import net.minecraft.world.level.block.state.properties.BlockStateProperties import net.minecraft.world.level.chunk.LevelChunk -import net.minecraft.world.level.chunk.LevelChunk.EntityCreationType.CHECK import org.valkyrienskies.core.api.ships.ServerShip private val AIR = Blocks.AIR.defaultBlockState() @@ -22,13 +20,14 @@ private val AIR = Blocks.AIR.defaultBlockState() * @param toChunk * @param to coordinate (can be local or global coord) * @param toShip should be set when you're relocating to a ship - * @param direction Direction.NORTH is no change in direction, Direction.EAST is 90 degrees clockwise, etc. + * @param rotation Rotation.NONE is no change in direction, Rotation.CLOCKWISE_90 is 90 degrees clockwise, etc. */ fun relocateBlock( - fromChunk: LevelChunk, from: BlockPos, toChunk: LevelChunk, to: BlockPos, toShip: ServerShip?, - direction: Direction = NORTH + fromChunk: LevelChunk, from: BlockPos, toChunk: LevelChunk, to: BlockPos, doUpdate: Boolean, toShip: ServerShip?, + rotation: Rotation = NONE ) { - val state = fromChunk.getBlockState(from) + val oldState = fromChunk.getBlockState(from) + var state = fromChunk.getBlockState(from) val entity = fromChunk.getBlockEntity(from) val tag = entity?.let { @@ -45,59 +44,58 @@ fun relocateBlock( tag } - rotateBlockState(state, direction) + state = state.rotate(rotation) val level = toChunk.level fromChunk.setBlockState(from, AIR, false) - level.sendBlockUpdated(from, state, AIR, 0) toChunk.setBlockState(to, state, false) - level.sendBlockUpdated(to, state, AIR, 0) - level.chunkSource.lightEngine.checkBlock(from) - level.chunkSource.lightEngine.checkBlock(to) + + if (doUpdate) { + updateBlock(level, from, to, state) + } tag?.let { - val be = toChunk.getBlockEntity(to, CHECK)!! + val be = level.getBlockEntity(to)!! be.load(it) } } -private fun addDirection(direction1: Direction, direction2: Direction) = - Direction.from2DDataValue((direction1.get2DDataValue() + direction2.get2DDataValue()) and 3) - -private fun rotateBlockState(state: BlockState, direction: Direction) { - if (direction == NORTH) return - // TODO there are prob more relevant states that need to get modified - if (state.hasProperty(BlockStateProperties.HORIZONTAL_FACING)) { - state.setValue( - BlockStateProperties.HORIZONTAL_FACING, - addDirection(state.getValue(BlockStateProperties.HORIZONTAL_FACING), direction) - ) - } else if (state.hasProperty(BlockStateProperties.FACING)) { - state.setValue( - BlockStateProperties.FACING, - addDirection(state.getValue(BlockStateProperties.FACING), direction) - ) - } else if (state.hasProperty(BlockStateProperties.AXIS)) { - state.setValue( - BlockStateProperties.AXIS, - if (direction.axis == Direction.Axis.X) - if (state.getValue(BlockStateProperties.AXIS) == Direction.Axis.X) - Direction.Axis.Z - else if (state.getValue(BlockStateProperties.AXIS) == Direction.Axis.Z) - Direction.Axis.X - else - Direction.Axis.Y - else - state.getValue(BlockStateProperties.AXIS) - ) - } else if (state.hasProperty(BlockStateProperties.FACING_HOPPER)) { - state.setValue( - BlockStateProperties.FACING, - addDirection(state.getValue(BlockStateProperties.FACING), direction) - ) +/** + * Update block after relocate + * + * @param level + * @param fromPos old position coordinate + * @param toPos new position coordinate + * @param toState new blockstate at toPos + */ +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) } /** @@ -105,8 +103,9 @@ private fun rotateBlockState(state: BlockState, direction: Direction) { * * @param from coordinate (can be local or global coord) * @param to coordinate (can be local or global coord) + * @param doUpdate update blocks after moving * @param toShip should be set when you're relocating to a ship - * @param direction Direction.NORTH is no change in direction, Direction.EAST is 90 degrees clockwise, etc. + * @param rotation Rotation.NONE is no change in direction, Rotation.CLOCKWISE_90 is 90 degrees clockwise, etc. */ -fun Level.relocateBlock(from: BlockPos, to: BlockPos, toShip: ServerShip?, direction: Direction) = - relocateBlock(getChunkAt(from), from, getChunkAt(to), to, toShip, direction) +fun Level.relocateBlock(from: BlockPos, to: BlockPos, doUpdate: Boolean, toShip: ServerShip?, rotation: Rotation) = + relocateBlock(getChunkAt(from), from, getChunkAt(to), to, doUpdate, toShip, rotation) From fca3d2c97e819a6e32e6269800062278f461125d Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 22 Jan 2023 01:24:56 -0700 Subject: [PATCH 057/437] Added AttachmentOrientation constraint --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 080d99d60..b61972a84 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 080d99d60ffc941bd99639f593d8c069d865b34e +Subproject commit b61972a84401fdd423b68be7483cfdfabfbda9bb From 5e6edba8da6ab8c37ed9e993e9113a3f465c9a4e Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 22 Jan 2023 03:47:20 -0700 Subject: [PATCH 058/437] Update Krunch on forge --- forge/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index e0a534a5b..e870375c3 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -95,11 +95,11 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+622fabeb30") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+eb3ae45554") { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+0734c463f8") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+0b6f5db802") { transitive = false } From 90677b3af02d6ed6439bd9f96e7d11daad749d0b Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 20 Jan 2023 22:01:08 -0500 Subject: [PATCH 059/437] feat: add a heuristic to put seat entities in shipyard --- .../common/entity/handling/VSEntityManager.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) 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 f66654dd1..8a45a3a62 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,5 +1,6 @@ package org.valkyrienskies.mod.common.entity.handling +import com.google.common.cache.CacheBuilder import net.minecraft.core.Registry import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.Entity @@ -9,6 +10,8 @@ import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.networking.PacketSyncVSEntityTypes import org.valkyrienskies.mod.common.util.MinecraftPlayer import org.valkyrienskies.mod.compat.CreateCompat +import java.time.Duration +import kotlin.text.RegexOption.IGNORE_CASE // TODO if needed initialize the handler with certain settings object VSEntityManager { @@ -18,6 +21,9 @@ object VSEntityManager { private val default = WorldEntityHandler private var contraptionHandler: VSEntityHandler = DefaultShipyardEntityHandler + private val defaultHandlersCache = + CacheBuilder.newBuilder().expireAfterAccess(Duration.ofMinutes(5)).build, VSEntityHandler>() + init { register(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "shipyard"), DefaultShipyardEntityHandler) register(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "default"), WorldEntityHandler) @@ -56,7 +62,25 @@ object VSEntityManager { return entityHandlers[entity.type] ?: getDefaultHandler(entity) } + // Uses some heuristics to try to figure out which VSEntityHandler we should use for an entity private fun getDefaultHandler(entity: Entity): VSEntityHandler { + return defaultHandlersCache.get(entity.type) { determineDefaultHandler(entity) } + } + + private val seatRegistryName = "(? Date: Fri, 20 Jan 2023 23:00:09 -0500 Subject: [PATCH 060/437] optimization: terrain updates taking up a serious amount of tick time doing hashmap lookups --- .../mixin/server/world/MixinServerLevel.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) 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..237214ea5 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 @@ -6,11 +6,8 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Optional; -import java.util.Set; import java.util.concurrent.Executor; import java.util.function.BooleanSupplier; import net.minecraft.core.BlockPos; @@ -45,6 +42,7 @@ import org.valkyrienskies.core.api.ships.WingManager; import org.valkyrienskies.core.apigame.world.ServerShipWorldCore; import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate; +import org.valkyrienskies.core.impl.datastructures.DenseBlockPosSet; import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.block.WingBlock; @@ -62,7 +60,7 @@ public abstract class MixinServerLevel implements IShipObjectWorldServerProvider @NotNull public abstract MinecraftServer getServer(); - private final Set knownChunkRegions = new HashSet<>(); + private final DenseBlockPosSet knownChunkRegions = new DenseBlockPosSet(); @Nullable @Override @@ -125,7 +123,7 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf // Create DenseVoxelShapeUpdate for new loaded chunks // Also mark the chunks as loaded in the ship objects final List voxelShapeUpdates = new ArrayList<>(); - final Set currentTickChunkRegions = new HashSet<>(); + final DenseBlockPosSet currentTickChunkRegions = new DenseBlockPosSet(); for (final ChunkHolder chunkHolder : loadedChunksList) { final Optional worldChunkOptional = @@ -192,17 +190,16 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf } } - final Iterator knownChunkPosIterator = knownChunkRegions.iterator(); - while (knownChunkPosIterator.hasNext()) { - final Vector3ic knownChunkPos = knownChunkPosIterator.next(); - if (!currentTickChunkRegions.contains(knownChunkPos)) { + knownChunkRegions.forEach((x, y, z) -> { + if (!currentTickChunkRegions.contains(x, y, z)) { // Delete this chunk - final TerrainUpdate deleteVoxelShapeUpdate = - getVsCore().newDeleteTerrainUpdate(knownChunkPos.x(), knownChunkPos.y(), knownChunkPos.z()); + final TerrainUpdate deleteVoxelShapeUpdate = getVsCore().newDeleteTerrainUpdate(x, y, z); voxelShapeUpdates.add(deleteVoxelShapeUpdate); - knownChunkPosIterator.remove(); + + // DenseBlockPosSet doesn't throw ConcurrentModificationException + knownChunkRegions.remove(x, y, z); } - } + }); // Send new loaded chunks updates to the ship world shipObjectWorld.addTerrainUpdates( From 26f4c5e6ad649eb40fdb9155bd340fcddf6e5fc4 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Fri, 20 Jan 2023 23:45:09 -0500 Subject: [PATCH 061/437] optimization: speed up BlockStateInfoProvider --- .../mod/common/BlockStateInfoProvider.kt | 32 +++++++++++++------ .../valkyrienskies/mod/common/VSGameUtils.kt | 3 +- 2 files changed, 25 insertions(+), 10 deletions(-) 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 898876681..c3495e18f 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -17,6 +17,7 @@ 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 java.util.function.IntFunction // Other mods can then provide weights and types based on their added content // NOTE: if we have block's in vs-core we should ask getVSBlock(blockstate: BlockStat): VSBlock since thatd be more handy @@ -53,20 +54,33 @@ object BlockStateInfo { // This is [ThreadLocal] because in single-player games the Client thread and Server thread will read/write to // [CACHE] simultaneously. This creates a data race that can crash the game (See https://github.com/ValkyrienSkies/Valkyrien-Skies-2/issues/126). - val CACHE: ThreadLocal>> = - ThreadLocal.withInitial { Int2ObjectOpenHashMap>() } + + class Cache { + // Use a load factor of 0.5f because this map is hit very often + private val blockStateCache: Int2ObjectOpenHashMap> = + Int2ObjectOpenHashMap>(2048, 0.5f) + + fun get(blockState: BlockState): Pair? { + val blockId = Block.getId(blockState) + + if (blockId == -1) { + return null + } + + return blockStateCache.computeIfAbsent(blockId, IntFunction { iterateRegistry(blockState) }) + } + } + + private val _cache = ThreadLocal.withInitial { Cache() } + val cache: Cache get() = _cache.get() + // NOTE: this caching can get allot better, ex. default just returns constants so it might be more faster // if we store that these values do not need to be cached by double and blocktype but just that they use default impl // this gets the weight and type provided by providers; or it gets it out of the cache - fun get(blockState: BlockState): Pair? = - getId(blockState)?.let { CACHE.get().getOrPut(it) { iterateRegistry(blockState) } } - - fun getId(blockState: BlockState): Int? { - val r = Block.getId(blockState) - if (r == -1) return null - return r + fun get(blockState: BlockState): Pair? { + return cache.get(blockState) } private fun iterateRegistry(blockState: BlockState): Pair = 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 e2125d2db..452461a7d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -375,10 +375,11 @@ fun Ship.toWorldCoordinates(x: Double, y: Double, z: Double, dest: Vector3d = Ve fun LevelChunkSection.toDenseVoxelUpdate(chunkPos: Vector3ic): TerrainUpdate { val update = vsCore.newDenseTerrainUpdateBuilder(chunkPos.x(), chunkPos.y(), chunkPos.z()) + val info = BlockStateInfo.cache for (x in 0..15) { for (y in 0..15) { for (z in 0..15) { - update.addBlock(x, y, z, BlockStateInfo.get(getBlockState(x, y, z))?.second ?: vsCore.blockTypes.air) + update.addBlock(x, y, z, info.get(getBlockState(x, y, z))?.second ?: vsCore.blockTypes.air) } } } From d84531555f6d27171b763ffb6d6c9575defe3b36 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Mon, 23 Jan 2023 18:07:38 -0500 Subject: [PATCH 062/437] Revert "optimization: terrain updates taking up a serious amount of tick time doing hashmap lookups" This reverts commit 8bf4a62748b52c6a63efef1636f2b7d4d576183f. --- .../mixin/server/world/MixinServerLevel.java | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) 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 237214ea5..773f161fc 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 @@ -6,8 +6,11 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; import java.util.List; import java.util.Optional; +import java.util.Set; import java.util.concurrent.Executor; import java.util.function.BooleanSupplier; import net.minecraft.core.BlockPos; @@ -42,7 +45,6 @@ import org.valkyrienskies.core.api.ships.WingManager; import org.valkyrienskies.core.apigame.world.ServerShipWorldCore; import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate; -import org.valkyrienskies.core.impl.datastructures.DenseBlockPosSet; import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.block.WingBlock; @@ -60,7 +62,7 @@ public abstract class MixinServerLevel implements IShipObjectWorldServerProvider @NotNull public abstract MinecraftServer getServer(); - private final DenseBlockPosSet knownChunkRegions = new DenseBlockPosSet(); + private final Set knownChunkRegions = new HashSet<>(); @Nullable @Override @@ -123,7 +125,7 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf // Create DenseVoxelShapeUpdate for new loaded chunks // Also mark the chunks as loaded in the ship objects final List voxelShapeUpdates = new ArrayList<>(); - final DenseBlockPosSet currentTickChunkRegions = new DenseBlockPosSet(); + final Set currentTickChunkRegions = new HashSet<>(); for (final ChunkHolder chunkHolder : loadedChunksList) { final Optional worldChunkOptional = @@ -190,16 +192,17 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf } } - knownChunkRegions.forEach((x, y, z) -> { - if (!currentTickChunkRegions.contains(x, y, z)) { + final Iterator knownChunkPosIterator = knownChunkRegions.iterator(); + while (knownChunkPosIterator.hasNext()) { + final Vector3ic knownChunkPos = knownChunkPosIterator.next(); + if (!currentTickChunkRegions.contains(knownChunkPos)) { // Delete this chunk - final TerrainUpdate deleteVoxelShapeUpdate = getVsCore().newDeleteTerrainUpdate(x, y, z); + final TerrainUpdate deleteVoxelShapeUpdate = + getVsCore().newDeleteTerrainUpdate(knownChunkPos.x(), knownChunkPos.y(), knownChunkPos.z()); voxelShapeUpdates.add(deleteVoxelShapeUpdate); - - // DenseBlockPosSet doesn't throw ConcurrentModificationException - knownChunkRegions.remove(x, y, z); + knownChunkPosIterator.remove(); } - }); + } // Send new loaded chunks updates to the ship world shipObjectWorld.addTerrainUpdates( From ee1a38fac050259cc803bdcf142a2bc625f2099e Mon Sep 17 00:00:00 2001 From: Blixt <53824895+Blixtdraken@users.noreply.github.com> Date: Mon, 30 Jan 2023 03:09:20 +0100 Subject: [PATCH 063/437] Update README.md Fixed a typo, feel free to ignore the pull and change yourself if u don't want me in contributors --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 82cfaef18..248ac0aae 100644 --- a/README.md +++ b/README.md @@ -39,4 +39,4 @@ independent code lives in [vs-core](https://github.com/ValkyrienSkies/vs-core). ## Troubleshooting ### Running Forge in dev environment -Occasionally forge will break will strange ways. When this occurs, delete all the `build` folders, delete the `.gradle` folder of the `forge` project, and then refresh gradle. +Occasionally forge will break in strange ways. When this occurs, delete all the `build` folders, delete the `.gradle` folder of the `forge` project, and then refresh gradle. From ab74a584ea08d98366318fd8f914b735a37320ae Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Wed, 1 Feb 2023 00:13:14 -0500 Subject: [PATCH 064/437] feat: add ship scaling config options --- .../mod/common/config/VSGameConfig.kt | 12 +++++++++++- .../mod/common/item/ShipCreatorItem.kt | 9 ++++++++- .../mod/fabric/common/ValkyrienSkiesModFabric.kt | 14 ++++++++++++-- .../mod/forge/common/ValkyrienSkiesModForge.kt | 14 ++++++++++++-- 4 files changed, 43 insertions(+), 6 deletions(-) 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 2c176cce6..bbaae6cf8 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 @@ -26,7 +26,7 @@ object VSGameConfig { description = "Are Ships protected by FTB Chunk Claims?" ) var shipsProtectedByClaims = true - + @JsonSchema( description = "Are ships protected outside of build height (max and min)?" ) @@ -85,6 +85,16 @@ object VSGameConfig { description = "Allow rudimentary pathfinding on ships" ) var aiOnShips = true + + @JsonSchema( + description = "Scale of the mini ship creator" + ) + var miniShipSize = 0.5 + + @JsonSchema( + description = "Minimum scale of ships" + ) + var minScaling = 0.25 } class Common { 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 3a5108f09..8ea2bfa07 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 @@ -20,8 +20,11 @@ import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toJOMLD import org.valkyrienskies.mod.common.yRange import org.valkyrienskies.mod.util.relocateBlock +import java.util.function.DoubleSupplier -class ShipCreatorItem(properties: Properties, private val scale: Double, private val minScaling: Double = 0.25) : Item(properties) { +class ShipCreatorItem( + properties: Properties, private val scale: DoubleSupplier, private val minScaling: DoubleSupplier +) : Item(properties) { override fun isFoil(stack: ItemStack): Boolean { return true @@ -37,6 +40,10 @@ class ShipCreatorItem(properties: Properties, private val scale: Double, private if (!blockState.isAir) { // Make a ship val dimensionId = level.dimensionId + + val scale = scale.asDouble + val minScaling = minScaling.asDouble + val serverShip = level.shipObjectWorld.createNewShipAtBlock(blockPos.toJOML(), false, scale, dimensionId) 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 7413cc983..c907c5558 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 @@ -32,6 +32,7 @@ import org.valkyrienskies.mod.common.block.TestWingBlock import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.config.MassDatapackResolver 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 @@ -55,9 +56,18 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_HINGE = TestHingeBlock ValkyrienSkiesMod.TEST_FLAP = TestFlapBlock ValkyrienSkiesMod.TEST_WING = TestWingBlock - ValkyrienSkiesMod.SHIP_CREATOR_ITEM = ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), 1.0) + ValkyrienSkiesMod.SHIP_CREATOR_ITEM = ShipCreatorItem( + Properties().tab(CreativeModeTab.TAB_MISC), + { 1.0 }, + { VSGameConfig.SERVER.minScaling } + ) ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM = ShipAssemblerItem(Properties().tab(CreativeModeTab.TAB_MISC)) - ValkyrienSkiesMod.SHIP_CREATOR_ITEM_SMALLER = ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), 0.5) + ValkyrienSkiesMod.SHIP_CREATOR_ITEM_SMALLER = ShipCreatorItem( + Properties().tab(CreativeModeTab.TAB_MISC), + { VSGameConfig.SERVER.miniShipSize }, + { VSGameConfig.SERVER.minScaling } + ) + ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE = EntityType.Builder.of( ::ShipMountingEntity, MobCategory.MISC 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 6d55c1752..55a3bb9ed 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,9 +102,19 @@ class ValkyrienSkiesModForge { TEST_FLAP_REGISTRY = registerBlockAndItem("test_flap") { TestFlapBlock } TEST_WING_REGISTRY = registerBlockAndItem("test_wing") { TestWingBlock } SHIP_CREATOR_ITEM_REGISTRY = - ITEMS.register("ship_creator") { ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), 1.0) } + ITEMS.register("ship_creator") { + ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), + { 1.0 }, + { VSGameConfig.SERVER.minScaling }) + } SHIP_CREATOR_SMALLER_ITEM_REGISTRY = - ITEMS.register("ship_creator_smaller") { ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), 0.5) } + ITEMS.register("ship_creator_smaller") { + ShipCreatorItem( + Properties().tab(CreativeModeTab.TAB_MISC), + { VSGameConfig.SERVER.miniShipSize }, + { VSGameConfig.SERVER.minScaling } + ) + } SHIP_MOUNTING_ENTITY_REGISTRY = ENTITIES.register("ship_mounting_entity") { EntityType.Builder.of( ::ShipMountingEntity, From 1d5acb83d8539ce4603bf0935069b4846899c26c Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Wed, 8 Feb 2023 18:29:04 +0100 Subject: [PATCH 065/437] ShipSettings (#413) --- .../mod/mixin/server/world/MixinChunkMap.java | 10 +++++++--- .../mod/common/util/ShipSettings.kt | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt 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 2398d9c30..225f1a315 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 @@ -25,9 +25,11 @@ 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.ServerShip; import org.valkyrienskies.core.apigame.world.IPlayer; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.MinecraftPlayer; +import org.valkyrienskies.mod.common.util.ShipSettingsKt; @Mixin(ChunkMap.class) public abstract class MixinChunkMap { @@ -56,8 +58,12 @@ private void preReadChunk(final ChunkPos chunkPos, final CallbackInfoReturnable< final CompoundTag originalToReturn = compoundTag == null ? null : self.upgradeChunkTag(this.level.dimension(), this.overworldDataStorage, compoundTag, Optional.empty()); + cir.setReturnValue(originalToReturn); if (originalToReturn == null) { - if (VSGameUtilsKt.isChunkInShipyard(level, chunkPos.x, chunkPos.z)) { + 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, @@ -66,8 +72,6 @@ private void preReadChunk(final ChunkPos chunkPos, final CallbackInfoReturnable< // Its wasteful to serialize just for this to be deserialized, but it will work for now. cir.setReturnValue(ChunkSerializer.write(level, generatedChunk)); } - } else { - cir.setReturnValue(originalToReturn); } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt new file mode 100644 index 000000000..5882fc3b4 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt @@ -0,0 +1,19 @@ +package org.valkyrienskies.mod.common.util + +import org.valkyrienskies.core.api.ships.ServerShip +import org.valkyrienskies.core.api.ships.getAttachment +import org.valkyrienskies.core.api.ships.saveAttachment + +/** + * A attachment that stores ship specific settings. + */ +data class ShipSettings( + /** + * Should the ship chunks try to generate? If true it will generate chunks in the shipyard. + * You normally don't want this EVER + */ + val shouldGenerateChunks: Boolean = false +) + +val ServerShip.settings: ShipSettings + get() = getAttachment() ?: ShipSettings().also { saveAttachment(it) } From adaef375364ad254bc239465c70bca7cd90c15fa Mon Sep 17 00:00:00 2001 From: Walker Fowlkes <47339836+walksanatora@users.noreply.github.com> Date: Wed, 8 Feb 2023 12:21:14 -0800 Subject: [PATCH 066/437] 1.18.x tis-3d rendering+infared fixes (#411) This fixes rendering issues on TIS-3D meaning that TIS-3D can actually be used on ValkrienSkies ships now --- forge/build.gradle | 5 +++ .../mod/forge/compat/tis3d/README.md | 5 +++ .../forge/compat/tis3d/Tis3dClipContext.java | 30 ++++++++++++++ .../MixinBlockEntityInventory.java | 1 + .../tis3d/MixinCasingTileEntityRender.java | 31 ++++++++++++++ .../tis3d/MixinInfraredPacketEntity.java | 33 +++++++++++++++ .../compat/tis3d/MixinRenderContextImpl.java | 41 +++++++++++++++++++ .../mod/forge/mixin/compat/tis3d/README.md | 10 +++++ .../valkyrienskies-forge.mixins.json | 7 +++- 9 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/compat/tis3d/README.md create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/compat/tis3d/Tis3dClipContext.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinCasingTileEntityRender.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinInfraredPacketEntity.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinRenderContextImpl.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/README.md diff --git a/forge/build.gradle b/forge/build.gradle index e870375c3..7ae7976cb 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -73,6 +73,11 @@ dependencies { // CC Tweaked modCompileOnly("curse.maven:cc-tweaked-282001:4061947") + // TIS-3d + 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') diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/compat/tis3d/README.md b/forge/src/main/java/org/valkyrienskies/mod/forge/compat/tis3d/README.md new file mode 100644 index 000000000..481560568 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/compat/tis3d/README.md @@ -0,0 +1,5 @@ +Minimal TIS-3d compat class + +- Tis3dClipContext + - provides a modified ClipContext that only hits blocks that are solid but + not transparent diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/compat/tis3d/Tis3dClipContext.java b/forge/src/main/java/org/valkyrienskies/mod/forge/compat/tis3d/Tis3dClipContext.java new file mode 100644 index 000000000..6ff12deaa --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/compat/tis3d/Tis3dClipContext.java @@ -0,0 +1,30 @@ +package org.valkyrienskies.mod.forge.compat.tis3d; + +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.BlockGetter; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.phys.shapes.BooleanOp; +import net.minecraft.world.phys.shapes.CollisionContext; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.jetbrains.annotations.Nullable; + +public class Tis3dClipContext extends ClipContext { + private final CollisionContext collisionContext; + + public Tis3dClipContext(final Vec3 arg, final Vec3 arg2, final Block arg3, final Fluid arg4, + @Nullable final Entity arg5) { + super(arg, arg2, arg3, arg4, arg5); + this.collisionContext = arg5 == null ? CollisionContext.empty() : CollisionContext.of(arg5); + } + + @Override + public VoxelShape getBlockShape(final BlockState bs, final BlockGetter bg, final BlockPos bp) { + final VoxelShape collider = Block.COLLIDER.get(bs, bg, bp, this.collisionContext); + final VoxelShape visual = Block.VISUAL.get(bs, bg, bp, this.collisionContext); + return Shapes.join(collider, visual, BooleanOp.AND); + } +} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/immersivengineering/MixinBlockEntityInventory.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/immersivengineering/MixinBlockEntityInventory.java index bb41b74ad..d1a3ee483 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/immersivengineering/MixinBlockEntityInventory.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/immersivengineering/MixinBlockEntityInventory.java @@ -21,6 +21,7 @@ public class MixinBlockEntityInventory { ), method = "isValidForPlayer" ) + private static double redirectDistanceCheck(final Vec3 b, final Vec3 p, final Operation distanceToSqr, final BlockEntity entity, final Player player) { if (entity.getLevel() != null) { 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 new file mode 100644 index 000000000..2b06a8e75 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinCasingTileEntityRender.java @@ -0,0 +1,31 @@ +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; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Pseudo +@Mixin(CasingTileEntityRenderer.class) +public abstract class MixinCasingTileEntityRender { + @ModifyVariable(remap = false, method = "isBackFace(Lnet/minecraft/core/BlockPos;Lli/cil/tis3d/api/machine/Face;)Z", + at = @At("STORE"), ordinal = 0) + private Vec3 vs$isBackFace(final Vec3 original, final BlockPos position) { + final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, position); + if (ship != null) { + final Vector3d v3 = new Vector3d(original.x, original.y, original.z); + final Vector3d shipyard_camera = ship.getTransform().getWorldToShip().transformPosition(v3); + return new Vec3(shipyard_camera.x, shipyard_camera.y, shipyard_camera.z); + } else { + return original; + } + } +} + diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinInfraredPacketEntity.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinInfraredPacketEntity.java new file mode 100644 index 000000000..dc7e88889 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinInfraredPacketEntity.java @@ -0,0 +1,33 @@ +package org.valkyrienskies.mod.forge.mixin.compat.tis3d; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import li.cil.tis3d.common.entity.InfraredPacketEntity; +import li.cil.tis3d.util.Raytracing; +import net.minecraft.world.level.ClipContext.Block; +import net.minecraft.world.level.ClipContext.Fluid; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.valkyrienskies.mod.common.world.RaycastUtilsKt; +import org.valkyrienskies.mod.forge.compat.tis3d.Tis3dClipContext; + +@Pseudo +@Mixin(InfraredPacketEntity.class) +public class MixinInfraredPacketEntity { + @WrapOperation( + remap = false, + method = "checkCollision()Lnet/minecraft/world/phys/HitResult;", + at = @At(value = "INVOKE", remap = true, + target = "li/cil/tis3d/util/Raytracing.raytrace (Lnet/minecraft/world/level/Level;Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;Lli/cil/tis3d/util/Raytracing$CollisionDetector;)Lnet/minecraft/world/phys/HitResult;") + ) + private HitResult vs$raytrace(final Level level, final Vec3 start, final Vec3 target, + final Raytracing.CollisionDetector collisionDetector, + final Operation orig) { + return RaycastUtilsKt.clipIncludeShips(level, + new Tis3dClipContext(start, target, Block.VISUAL, Fluid.ANY, null)); + } +} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinRenderContextImpl.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinRenderContextImpl.java new file mode 100644 index 000000000..864e2edec --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/MixinRenderContextImpl.java @@ -0,0 +1,41 @@ +package org.valkyrienskies.mod.forge.mixin.compat.tis3d; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import li.cil.tis3d.client.renderer.RenderContextImpl; +import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Position; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Pseudo +@Mixin(RenderContextImpl.class) +public abstract class MixinRenderContextImpl { + @WrapOperation( + remap = false, + method = "closeEnoughForDetails(Lnet/minecraft/core/BlockPos;)Z", + at = @At(value = "INVOKE", + remap = true, + target = "Lnet/minecraft/core/BlockPos;closerToCenterThan(Lnet/minecraft/core/Position;D)Z" + ) + ) + private boolean vs$closerToCenterThan(final BlockPos instance, final Position pos, final double dist, + final Operation orig) { + // this code has been deemed better by those at the forge discord (since it calls the og function) + final ClientShip ship = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance); + if (ship != null) { + final Vector3d spos = ship.getTransform().getWorldToShip().transformPosition( + new Vector3d(pos.x(), pos.y(), pos.z()) + ); + return orig.call(instance, new Vec3(spos.x, spos.y, spos.z), dist); + } else { + return orig.call(instance, pos, dist); + } + } +} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/README.md b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/README.md new file mode 100644 index 000000000..4ce819a8b --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tis3d/README.md @@ -0,0 +1,10 @@ +Minimal TIS-3d Compatibility Mixins + +- MixinCasingBlockEntityRender + - Fixes it skipping rendering on faces that are facing away from the player + (when they are actually facing the player) +- MixinRenderContextImpl + - Fixes distance culling checks on blocks that are in the shipyard +- MixinInfaredPacketEntity + - Fixes Infrared packets to/from ship to world/world to ship/ship to + ship/ship within ship raycast diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 3eb394e73..96701e995 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -9,11 +9,12 @@ "compat.cc_tweaked.MixinTurtleMoveCommand", "compat.cc_tweaked.MixinWirelessNetwork", "compat.create.Matrix3dAccessor", + "compat.create.MixinAbstractContraptionEntity", "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", - "compat.create.MixinAbstractContraptionEntity", "compat.immersivengineering.MixinBlockEntityInventory", "compat.thermalexpansion.MixinTileCoFH", + "compat.tis3d.MixinInfraredPacketEntity", "feature.forge_interact.MixinIForgePlayer", "world.level.block.FireMixin" ], @@ -23,7 +24,9 @@ "compat.create.client.MixinFlwContraption", "compat.create.client.MixinScrollValueBehaviour", "compat.create.client.MixinValueBox", - "compat.sodium.MixinRenderSectionManager" + "compat.sodium.MixinRenderSectionManager", + "compat.tis3d.MixinCasingTileEntityRender", + "compat.tis3d.MixinRenderContextImpl" ], "injectors": { "defaultRequire": 1 From 1747df5615262cef146ffa23854d01b8a6fced26 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Thu, 9 Feb 2023 20:55:22 +0100 Subject: [PATCH 067/437] Ship settings should be var oops --- .../kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt index 5882fc3b4..c5eb9a222 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt @@ -12,7 +12,7 @@ data class ShipSettings( * Should the ship chunks try to generate? If true it will generate chunks in the shipyard. * You normally don't want this EVER */ - val shouldGenerateChunks: Boolean = false + var shouldGenerateChunks: Boolean = false ) val ServerShip.settings: ShipSettings From 6a23d06550d536df7dfb952bac186928666ed975 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sat, 11 Feb 2023 18:27:33 -0500 Subject: [PATCH 068/437] fix: Make VSGameUtilsKt null-safe --- .../valkyrienskies/mod/common/VSGameUtils.kt | 113 +++++++++--------- 1 file changed, 56 insertions(+), 57 deletions(-) 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 452461a7d..c4c90bdc9 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -50,24 +50,24 @@ import java.util.function.Consumer val vsCore get() = ValkyrienSkiesMod.vsCore -val Level.shipWorldNullable: ShipWorldCore? +val Level?.shipWorldNullable: ShipWorldCore? get() = when { + this == null -> null this is ServerLevel -> server.shipObjectWorld this.isClientSide && this is ClientLevel -> this.shipObjectWorld else -> null } -val Level.shipObjectWorld +val Level?.shipObjectWorld get() = shipWorldNullable ?: DummyShipWorldClient -val Level.allShips get() = this.shipObjectWorld.allShips +val Level?.allShips get() = this.shipObjectWorld.allShips val MinecraftServer.shipObjectWorld: ServerShipWorldCore get() = (this as IShipObjectWorldServerProvider).shipObjectWorld ?: DummyShipWorldServer val MinecraftServer.vsPipeline get() = (this as IShipObjectWorldServerProvider).vsPipeline!! -val ServerLevel.shipObjectWorld - get() = server.shipObjectWorld +val ServerLevel?.shipObjectWorld: ServerShipWorldCore get() = this?.server?.shipObjectWorld ?: DummyShipWorldServer val Level.dimensionId: DimensionId get() { @@ -107,7 +107,7 @@ fun MinecraftServer.getLevelFromDimensionId(dimensionId: DimensionId): ServerLev } val Minecraft.shipObjectWorld get() = (this as IShipObjectWorldClientProvider).shipObjectWorld ?: DummyShipWorldClient -val ClientLevel.shipObjectWorld get() = Minecraft.getInstance().shipObjectWorld +val ClientLevel?.shipObjectWorld get() = Minecraft.getInstance().shipObjectWorld val IPlayer.mcPlayer: Player get() = (this as MinecraftPlayer).playerEntityReference.get()!! @@ -123,7 +123,7 @@ fun Entity.squaredDistanceToInclShips(x: Double, y: Double, z: Double) = * Calculates the squared distance between to points. * x1/y1/z1 are transformed into world coordinates if they are on a ship */ -fun Level.squaredDistanceBetweenInclShips( +fun Level?.squaredDistanceBetweenInclShips( x1: Double, y1: Double, z1: Double, @@ -157,12 +157,11 @@ fun Level.squaredDistanceBetweenInclShips( return dx * dx + dy * dy + dz * dz } -private fun getShipObjectManagingPosImpl(world: Level, chunkX: Int, chunkZ: Int): LoadedShip? { - if (world.shipObjectWorld.isChunkInShipyard(chunkX, chunkZ, world.dimensionId)) { - val shipDataManagingPos = - world.shipObjectWorld.allShips.getByChunkPos(chunkX, chunkZ, world.dimensionId) - if (shipDataManagingPos != null) { - return world.shipObjectWorld.loadedShips.getById(shipDataManagingPos.id) +private fun getShipObjectManagingPosImpl(world: Level?, chunkX: Int, chunkZ: Int): LoadedShip? { + if (world != null && world.shipObjectWorld.isChunkInShipyard(chunkX, chunkZ, world.dimensionId)) { + val ship = world.shipObjectWorld.allShips.getByChunkPos(chunkX, chunkZ, world.dimensionId) + if (ship != null) { + return world.shipObjectWorld.loadedShips.getById(ship.id) } } return null @@ -172,7 +171,7 @@ private fun getShipObjectManagingPosImpl(world: Level, chunkX: Int, chunkZ: Int) * Get all ships intersecting an AABB in world-space, then call [cb] with the AABB itself, * followed by the AABB in the ship-space of the intersecting ships. */ -fun Level.transformFromWorldToNearbyShipsAndWorld(aabb: AABB, cb: Consumer) { +fun Level?.transformFromWorldToNearbyShipsAndWorld(aabb: AABB, cb: Consumer) { cb.accept(aabb) val tmpAABB = AABBd() getShipsIntersecting(aabb).forEach { ship -> @@ -180,21 +179,21 @@ fun Level.transformFromWorldToNearbyShipsAndWorld(aabb: AABB, cb: Consumer } } -fun Level.transformToNearbyShipsAndWorld(x: Double, y: Double, z: Double, aabbRadius: Double): List { +fun Level?.transformToNearbyShipsAndWorld(x: Double, y: Double, z: Double, aabbRadius: Double): List { val list = mutableListOf() - transformToNearbyShipsAndWorld(x, y, z, aabbRadius) { x, y, z -> list.add(Vector3d(x, y, z)) } + this?.transformToNearbyShipsAndWorld(x, y, z, aabbRadius) { x, y, z -> list.add(Vector3d(x, y, z)) } return list } -fun Level.transformToNearbyShipsAndWorld( +fun Level?.transformToNearbyShipsAndWorld( x: Double, y: Double, z: Double, aabbRadius: Double, cb: DoubleTernaryConsumer ) { - transformToNearbyShipsAndWorld(x, y, z, aabbRadius, cb::accept) + 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) @@ -228,19 +227,19 @@ fun Level.isBlockInShipyard(pos: BlockPos) = isBlockInShipyard(pos.x, pos.y, pos fun Level.isBlockInShipyard(x: Double, y: Double, z: Double) = isBlockInShipyard(x.toInt(), y.toInt(), z.toInt()) -fun Level.getShipObjectManagingPos(chunkX: Int, chunkZ: Int) = +fun Level?.getShipObjectManagingPos(chunkX: Int, chunkZ: Int) = getShipObjectManagingPosImpl(this, chunkX, chunkZ) -fun Level.getShipObjectManagingPos(blockPos: Vec3i) = +fun Level?.getShipObjectManagingPos(blockPos: Vec3i) = getShipObjectManagingPos(blockPos.x shr 4, blockPos.z shr 4) -fun Level.getShipObjectManagingPos(pos: Vector3dc) = +fun Level?.getShipObjectManagingPos(pos: Vector3dc) = getShipObjectManagingPos(pos.x().toInt() shr 4, pos.z().toInt() shr 4) -fun Level.getShipObjectManagingPos(posX: Double, posY: Double, posZ: Double) = +fun Level?.getShipObjectManagingPos(posX: Double, posY: Double, posZ: Double) = getShipObjectManagingPos(posX.toInt() shr 4, posZ.toInt() shr 4) -fun Level.getShipObjectManagingPos(chunkPos: ChunkPos) = +fun Level?.getShipObjectManagingPos(chunkPos: ChunkPos) = getShipObjectManagingPos(chunkPos.x, chunkPos.z) fun Level.getShipObjectEntityMountedTo(entity: Entity): LoadedShip? { @@ -249,54 +248,54 @@ fun Level.getShipObjectEntityMountedTo(entity: Entity): LoadedShip? { } // ClientLevel -fun ClientLevel.getShipObjectManagingPos(chunkX: Int, chunkZ: Int) = +fun ClientLevel?.getShipObjectManagingPos(chunkX: Int, chunkZ: Int) = getShipObjectManagingPosImpl(this, chunkX, chunkZ) as ClientShip? -fun ClientLevel.getShipObjectManagingPos(blockPos: Vec3i) = +fun ClientLevel?.getShipObjectManagingPos(blockPos: Vec3i) = getShipObjectManagingPos(blockPos.x shr 4, blockPos.z shr 4) -fun ClientLevel.getShipObjectManagingPos(posX: Double, posY: Double, posZ: Double) = +fun ClientLevel?.getShipObjectManagingPos(posX: Double, posY: Double, posZ: Double) = getShipObjectManagingPos(posX.toInt() shr 4, posZ.toInt() shr 4) -fun ClientLevel.getShipObjectManagingPos(pos: Vector3dc) = +fun ClientLevel?.getShipObjectManagingPos(pos: Vector3dc) = getShipObjectManagingPos(pos.x().toInt() shr 4, pos.z().toInt() shr 4) -fun ClientLevel.getShipObjectManagingPos(pos: Position) = +fun ClientLevel?.getShipObjectManagingPos(pos: Position) = getShipObjectManagingPos(pos.x().toInt() shr 4, pos.z().toInt() shr 4) -fun ClientLevel.getShipObjectManagingPos(chunkPos: ChunkPos) = +fun ClientLevel?.getShipObjectManagingPos(chunkPos: ChunkPos) = getShipObjectManagingPos(chunkPos.x, chunkPos.z) -fun ClientLevel.getShipObjectEntityMountedTo(entity: Entity): ClientShip? { +fun ClientLevel?.getShipObjectEntityMountedTo(entity: Entity): ClientShip? { val vehicle = entity.vehicle ?: return null return getShipObjectManagingPos(vehicle.position().toJOML()) } // ServerWorld -fun ServerLevel.getShipObjectManagingPos(chunkX: Int, chunkZ: Int) = +fun ServerLevel?.getShipObjectManagingPos(chunkX: Int, chunkZ: Int) = getShipObjectManagingPosImpl(this, chunkX, chunkZ) as ShipObjectServer? -fun ServerLevel.getShipObjectManagingPos(blockPos: Vec3i) = +fun ServerLevel?.getShipObjectManagingPos(blockPos: Vec3i) = getShipObjectManagingPos(blockPos.x shr 4, blockPos.z shr 4) -fun ServerLevel.getShipObjectManagingPos(chunkPos: ChunkPos) = +fun ServerLevel?.getShipObjectManagingPos(chunkPos: ChunkPos) = getShipObjectManagingPos(chunkPos.x, chunkPos.z) -fun ServerLevel.getShipObjectManagingPos(posX: Double, posY: Double, posZ: Double) = +fun ServerLevel?.getShipObjectManagingPos(posX: Double, posY: Double, posZ: Double) = getShipObjectManagingPos(posX.toInt() shr 4, posZ.toInt() shr 4) -fun ServerLevel.getShipObjectManagingPos(pos: Vector3dc) = +fun ServerLevel?.getShipObjectManagingPos(pos: Vector3dc) = getShipObjectManagingPos(pos.x().toInt() shr 4, pos.z().toInt() shr 4) -private fun getShipManagingPosImpl(world: Level, x: Int, z: Int): Ship? { - return if (world.isChunkInShipyard(x, z)) { +private fun getShipManagingPosImpl(world: Level?, x: Int, z: Int): Ship? { + return if (world != null && world.isChunkInShipyard(x, z)) { world.shipObjectWorld.allShips.getByChunkPos(x, z, world.dimensionId) } else { null } } -fun ClientLevel.transformRenderAABBToWorld(pos: Position, aabb: AABB): AABB { +fun ClientLevel?.transformRenderAABBToWorld(pos: Position, aabb: AABB): AABB { val ship = getShipObjectManagingPos(pos) if (ship != null) { return aabb.toJOML().transform(ship.renderTransform.shipToWorldMatrix).toMinecraft() @@ -307,41 +306,41 @@ fun ClientLevel.transformRenderAABBToWorld(pos: Position, aabb: AABB): AABB { fun Entity.getShipManaging(): Ship? = this.level.getShipManagingPos(this.position()) // Level -fun Level.getShipManagingPos(chunkX: Int, chunkZ: Int) = +fun Level?.getShipManagingPos(chunkX: Int, chunkZ: Int) = getShipManagingPosImpl(this, chunkX, chunkZ) -fun Level.getShipManagingPos(blockPos: BlockPos) = +fun Level?.getShipManagingPos(blockPos: BlockPos) = getShipManagingPos(blockPos.x shr 4, blockPos.z shr 4) -fun Level.getShipManagingPos(pos: Position) = +fun Level?.getShipManagingPos(pos: Position) = getShipManagingPos(pos.x().toInt() shr 4, pos.z().toInt() shr 4) -fun Level.getShipManagingPos(pos: Vector3dc) = +fun Level?.getShipManagingPos(pos: Vector3dc) = getShipManagingPos(pos.x().toInt() shr 4, pos.z().toInt() shr 4) -fun Level.getShipManagingPos(posX: Double, posY: Double, posZ: Double) = +fun Level?.getShipManagingPos(posX: Double, posY: Double, posZ: Double) = getShipManagingPos(posX.toInt() shr 4, posZ.toInt() shr 4) -fun Level.getShipManagingPos(posX: Float, posY: Float, posZ: Float) = +fun Level?.getShipManagingPos(posX: Float, posY: Float, posZ: Float) = getShipManagingPos(posX.toInt() shr 4, posZ.toInt() shr 4) -fun Level.getShipManagingPos(chunkPos: ChunkPos) = +fun Level?.getShipManagingPos(chunkPos: ChunkPos) = getShipManagingPos(chunkPos.x, chunkPos.z) // ServerLevel -fun ServerLevel.getShipManagingPos(chunkX: Int, chunkZ: Int) = +fun ServerLevel?.getShipManagingPos(chunkX: Int, chunkZ: Int) = getShipManagingPosImpl(this, chunkX, chunkZ) as ServerShip? -fun ServerLevel.getShipManagingPos(blockPos: BlockPos) = +fun ServerLevel?.getShipManagingPos(blockPos: BlockPos) = getShipManagingPos(blockPos.x shr 4, blockPos.z shr 4) -fun ServerLevel.getShipManagingPos(pos: Vector3dc) = +fun ServerLevel?.getShipManagingPos(pos: Vector3dc) = getShipManagingPos(pos.x().toInt() shr 4, pos.z().toInt() shr 4) -fun ServerLevel.getShipManagingPos(posX: Double, posY: Double, posZ: Double) = +fun ServerLevel?.getShipManagingPos(posX: Double, posY: Double, posZ: Double) = getShipManagingPos(posX.toInt() shr 4, posZ.toInt() shr 4) -fun ServerLevel.getShipManagingPos(chunkPos: ChunkPos) = +fun ServerLevel?.getShipManagingPos(chunkPos: ChunkPos) = getShipManagingPos(chunkPos.x, chunkPos.z) fun Ship.toWorldCoordinates(pos: BlockPos): Vector3d = @@ -366,7 +365,7 @@ fun Level?.toWorldCoordinates(pos: Vector3d): Vector3d { } @JvmOverloads -fun Level.toWorldCoordinates(x: Double, y: Double, z: Double, dest: Vector3d = Vector3d()): Vector3d = +fun Level?.toWorldCoordinates(x: Double, y: Double, z: Double, dest: Vector3d = Vector3d()): Vector3d = getShipManagingPos(x, y, z)?.toWorldCoordinates(x, y, z) ?: dest.set(x, y, z) @JvmOverloads @@ -392,15 +391,15 @@ fun LevelChunkSection.toDenseVoxelUpdate(chunkPos: Vector3ic): TerrainUpdate { * Different from [getWorldCoordinates(World, Vector3d)] only in that resolves the ship owning * [blockPos] rather than inferring it from [pos], which might be helpful at the boundaries of ships. */ -fun Level.getWorldCoordinates(blockPos: BlockPos, pos: Vector3d): Vector3d { +fun Level?.getWorldCoordinates(blockPos: BlockPos, pos: Vector3d): Vector3d { return this.getShipObjectManagingPos(blockPos)?.transform?.shipToWorld?.transformPosition(pos) ?: pos } -fun Level.getShipsIntersecting(aabb: AABB): Iterable = allShips.getIntersecting(aabb.toJOML()) -fun Level.getShipsIntersecting(aabb: AABBdc): Iterable = allShips.getShipDataIntersecting(aabb) +fun Level?.getShipsIntersecting(aabb: AABB): Iterable = allShips.getIntersecting(aabb.toJOML()) +fun Level?.getShipsIntersecting(aabb: AABBdc): Iterable = allShips.getShipDataIntersecting(aabb) -fun Level.transformAabbToWorld(aabb: AABB): AABB = transformAabbToWorld(aabb.toJOML()).toMinecraft() -fun Level.transformAabbToWorld(aabb: AABBd) = transformAabbToWorld(aabb, aabb) +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 { val ship1 = getShipManagingPos(aabb.minX(), aabb.minY(), aabb.minZ()) val ship2 = getShipManagingPos(aabb.maxX(), aabb.maxY(), aabb.maxZ()) From 42a3f383c3af409cc0899ddf96ed8c5dae587399 Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Sun, 12 Feb 2023 18:48:57 +0100 Subject: [PATCH 069/437] Update 1_18_blocks.json (#416) --- .../data/valkyrienskies/vs_mass/1_18_blocks.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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 6c67d052f..ab957f9e5 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 @@ -91,14 +91,14 @@ "block": "minecraft:moss_carpet", "mass": 15.0 }, - { - "block": "minecraft:cut_copper", - "mass": 2240.0 - }, { "block": "minecraft:lightning_rod", "mass": 1800.0 }, + { + "block": "minecraft:copper_block", + "mass": 8960.0 + }, { "block": "minecraft:exposed_copper", "mass": 8960.0 From aeeefb7ae5c1e60a4a533bdb9ffdeb8b1cbf9cd9 Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins <31552479+FluffyJenkins@users.noreply.github.com> Date: Mon, 13 Feb 2023 00:38:11 +0000 Subject: [PATCH 070/437] Added a Vec3 isBlockInShipyard (#417) --- .../main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 2 ++ 1 file changed, 2 insertions(+) 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 c4c90bdc9..2bb4b6347 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -224,6 +224,8 @@ fun Level.isBlockInShipyard(blockX: Int, blockY: Int, blockZ: Int) = fun Level.isBlockInShipyard(pos: BlockPos) = isBlockInShipyard(pos.x, pos.y, pos.z) +fun Level.isBlockInShipyard(pos: Vec3) = isBlockInShipyard(pos.x.toInt(), pos.y.toInt(), pos.z.toInt()) + fun Level.isBlockInShipyard(x: Double, y: Double, z: Double) = isBlockInShipyard(x.toInt(), y.toInt(), z.toInt()) From 8145558cd740924409264378f7fcc00568b8bc28 Mon Sep 17 00:00:00 2001 From: AlphaMode Date: Sat, 18 Feb 2023 20:40:14 -0600 Subject: [PATCH 071/437] 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 072/437] 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 073/437] 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 074/437] 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 426ce0d5815c8700b2cc843b638b921905dffbc7 Mon Sep 17 00:00:00 2001 From: Artem Semirenko Date: Wed, 1 Mar 2023 02:18:25 +0300 Subject: [PATCH 075/437] Use Clearable instead of Container to avoid dupe glitches in some mods (#421) --- .../kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) 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 1ac9f4875..8dfc6199c 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt @@ -1,7 +1,7 @@ package org.valkyrienskies.mod.util import net.minecraft.core.BlockPos -import net.minecraft.world.Container +import net.minecraft.world.Clearable import net.minecraft.world.level.Level import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.Rotation @@ -26,7 +26,6 @@ fun relocateBlock( fromChunk: LevelChunk, from: BlockPos, toChunk: LevelChunk, to: BlockPos, doUpdate: Boolean, toShip: ServerShip?, rotation: Rotation = NONE ) { - val oldState = fromChunk.getBlockState(from) var state = fromChunk.getBlockState(from) val entity = fromChunk.getBlockEntity(from) @@ -37,7 +36,7 @@ fun relocateBlock( tag.putInt("z", to.z) // so that it won't drop its contents - if (it is Container) { + if (it is Clearable) { it.clearContent() } @@ -82,7 +81,7 @@ fun updateBlock(level: Level, fromPos: BlockPos, toPos: BlockPos, toState: Block 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.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 From 6b810caba861b89fd14c868364aa226b6489bc65 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Wed, 1 Mar 2023 01:18:08 -0500 Subject: [PATCH 076/437] 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 077/437] 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 b5a43019ca0ab68dfa6233b02a53bdc29cf20dc1 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Mon, 13 Mar 2023 19:32:55 +0100 Subject: [PATCH 078/437] Hopefully giving better performance #431 (#432) --- .../mixin/server/world/MixinServerLevel.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) 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..b4730b031 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 @@ -7,7 +7,6 @@ import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import java.util.ArrayList; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Optional; import java.util.Set; @@ -125,7 +124,7 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf // Create DenseVoxelShapeUpdate for new loaded chunks // Also mark the chunks as loaded in the ship objects final List voxelShapeUpdates = new ArrayList<>(); - final Set currentTickChunkRegions = new HashSet<>(); + final Set unloadedChunks = new HashSet<>(knownChunkRegions); for (final ChunkHolder chunkHolder : loadedChunksList) { final Optional worldChunkOptional = @@ -141,7 +140,6 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf final LevelChunkSection chunkSection = chunkSections[sectionY]; final Vector3ic chunkPos = new Vector3i(chunkX, worldChunk.getSectionYFromSectionIndex(sectionY), chunkZ); - currentTickChunkRegions.add(chunkPos); if (!knownChunkRegions.contains(chunkPos)) { if (chunkSection != null && !chunkSection.hasOnlyAir()) { @@ -187,21 +185,19 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf } knownChunkRegions.add(chunkPos); + } else { + unloadedChunks.remove(chunkPos); } } } } - final Iterator knownChunkPosIterator = knownChunkRegions.iterator(); - while (knownChunkPosIterator.hasNext()) { - final Vector3ic knownChunkPos = knownChunkPosIterator.next(); - if (!currentTickChunkRegions.contains(knownChunkPos)) { - // Delete this chunk - final TerrainUpdate deleteVoxelShapeUpdate = - getVsCore().newDeleteTerrainUpdate(knownChunkPos.x(), knownChunkPos.y(), knownChunkPos.z()); - voxelShapeUpdates.add(deleteVoxelShapeUpdate); - knownChunkPosIterator.remove(); - } + for (final Vector3ic unloadedChunk : unloadedChunks) { + // Delete this chunk + final TerrainUpdate deleteVoxelShapeUpdate = + getVsCore().newDeleteTerrainUpdate(unloadedChunk.x(), unloadedChunk.y(), unloadedChunk.z()); + voxelShapeUpdates.add(deleteVoxelShapeUpdate); + knownChunkRegions.remove(unloadedChunk); } // Send new loaded chunks updates to the ship world From 65a6ae8c144a96c642b52b53b36520749d9d1d10 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 21 Mar 2023 23:30:04 -0600 Subject: [PATCH 079/437] Fixed slide constraint --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index b61972a84..7502f9ff2 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit b61972a84401fdd423b68be7483cfdfabfbda9bb +Subproject commit 7502f9ff2ac406c59148dc9dfc294489225ff16c From fcc29a56a37d7d4a90f737695a53ffd1f6fc8d39 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 16 Apr 2023 02:42:57 -0600 Subject: [PATCH 080/437] Use sphere MOI --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 7502f9ff2..9e9b34ab3 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 7502f9ff2ac406c59148dc9dfc294489225ff16c +Subproject commit 9e9b34ab392bd97f00aeb36dca03332238f5b2c9 From 55caf58283c99729511b499915ee6de9cde4aa32 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 16 Apr 2023 03:21:50 -0600 Subject: [PATCH 081/437] empty commit to trigger actions From 915a918fa11e8e894c8604274c73e9f839184429 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 16 Apr 2023 03:38:20 -0600 Subject: [PATCH 082/437] Send ShipAABB to clients --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 9e9b34ab3..1bbc8d76a 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 9e9b34ab392bd97f00aeb36dca03332238f5b2c9 +Subproject commit 1bbc8d76a610c256ad4090479928726765baef41 From d1a76ec8e02f5705c0599f67d2006815bd87c4e1 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 16 Apr 2023 04:15:23 -0600 Subject: [PATCH 083/437] Fixed ships not working --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 1bbc8d76a..98ef5f675 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 1bbc8d76a610c256ad4090479928726765baef41 +Subproject commit 98ef5f6755877edd64c1a33181df445430addf6b From e218b9b84b995ae7736713e8a81753a718f07c77 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 16 Apr 2023 04:47:40 -0600 Subject: [PATCH 084/437] Fixed bugs --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 98ef5f675..4b5e2cd4e 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 98ef5f6755877edd64c1a33181df445430addf6b +Subproject commit 4b5e2cd4e6517167686bbd303ea115cf828b28b6 From 4efd2e0d0f7d9cd5b6b2c7affba911af15819458 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 16 Apr 2023 20:23:21 -0600 Subject: [PATCH 085/437] Empty commit to retrigger actions From 47da856fab44b03ece68e7518735daab32c1a361 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 23 Apr 2023 20:36:43 -0400 Subject: [PATCH 086/437] Fixing CBC (#453) * Applied Triode's fixes for Comod error * CBC Compat --- build.gradle | 7 ++++ common/build.gradle | 2 + .../MixinAbstractCannonProjectile.java | 42 +++++++++++++++++++ .../valkyrienskies-common.mixins.json | 3 +- fabric/build.gradle | 3 ++ forge/build.gradle | 3 ++ gradle.properties | 1 + 7 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinAbstractCannonProjectile.java diff --git a/build.gradle b/build.gradle index a271cfecd..dee6175d1 100644 --- a/build.gradle +++ b/build.gradle @@ -89,6 +89,13 @@ 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://maven.realrobotix.me/createbigcannons/" // Create Big Cannons + content { + includeGroup "com.rbasamoyai" + } + } + } } diff --git a/common/build.gradle b/common/build.gradle index f4adbfbf8..03d023097 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -24,6 +24,8 @@ 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.rbasamoyai:createbigcannons-fabric-${minecraft_version}:${createbigcannons_version}") } architectury { 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 new file mode 100644 index 000000000..19126d790 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinAbstractCannonProjectile.java @@ -0,0 +1,42 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create_big_cannons; + +import net.minecraft.world.phys.Vec3; +import org.joml.primitives.AABBd; +import org.joml.primitives.AABBdc; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import rbasamoyai.createbigcannons.munitions.AbstractCannonProjectile; + +@Mixin(AbstractCannonProjectile.class) +public abstract class MixinAbstractCannonProjectile { + + @Shadow + protected abstract void clipAndDamage(Vec3 start, Vec3 end); + + @Unique + private void shipClipAndDamage(final Vec3 startInWorld, final Vec3 endInWorld, + final AbstractCannonProjectile projectile) { + final AABBdc pathAABB = new AABBd(VectorConversionsMCKt.toJOML(startInWorld), + VectorConversionsMCKt.toJOML(endInWorld)).correctBounds(); + + for (final Ship ship : VSGameUtilsKt.getShipsIntersecting(projectile.level, pathAABB)) { + final Vec3 start = VectorConversionsMCKt.toMinecraft( + ship.getTransform().getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(startInWorld))); + final Vec3 end = VectorConversionsMCKt.toMinecraft( + ship.getTransform().getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(endInWorld))); + clipAndDamage(start, end); + } + } + + @Inject(method = "clipAndDamage", at = @At("HEAD"), remap = false) + protected void vsClipAndDamage(final Vec3 start, final Vec3 end, final CallbackInfo ci) { + shipClipAndDamage(start, end, (AbstractCannonProjectile) (Object) this); + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index fcb76e645..1a998ddd3 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -42,6 +42,7 @@ "feature.water_in_ships_entity.MixinEntity", "feature.world_border.MixinLevel", "feature.world_border.MixinWorldBorder", + "mod_compat.create_big_cannons.MixinAbstractCannonProjectile", "mod_compat.ftb_chunks.MixinClaimedChunkManager", "mod_compat.sodium.MixinChunkTracker", "mod_compat.sodium.MixinRegionChunkRenderer", @@ -95,10 +96,10 @@ "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.flywheel.MixinBlockEntityInstanceManager", "mod_compat.optifine.MixinViewAreaOptifine", "mod_compat.optifine.RenderChunkInfoAccessorOptifine", "mod_compat.optifine_vanilla.MixinLevelRenderer", diff --git a/fabric/build.gradle b/fabric/build.gradle index 20b16bd33..97c1bfcf3 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -72,6 +72,9 @@ dependencies { 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}") + + //CBC + modImplementation("com.rbasamoyai:createbigcannons-fabric-${minecraft_version}:${createbigcannons_version}") { transitive = false } } // Copy the VS common access widener to the generated resources folder diff --git a/forge/build.gradle b/forge/build.gradle index 7ae7976cb..3c66df51c 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -70,6 +70,9 @@ dependencies { modImplementation("com.jozufozu.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}") modImplementation("com.tterrag.registrate:Registrate:${registrate_version}") + // Create : Big Cannons + modImplementation("com.rbasamoyai:createbigcannons-forge-${minecraft_version}:${createbigcannons_version}") { transitive = false } + // CC Tweaked modCompileOnly("curse.maven:cc-tweaked-282001:4061947") diff --git a/gradle.properties b/gradle.properties index dcd7e0adc..07d0904ff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,6 +8,7 @@ architectury_version=4.10.86 fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 +createbigcannons_version=+ # 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 3d6262a8bd255322f95da20765ffeef7595a234c Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Tue, 25 Apr 2023 17:18:25 -0700 Subject: [PATCH 087/437] Fix drag coefficient equation (#455) --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 4b5e2cd4e..2c1dcb1c7 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 4b5e2cd4e6517167686bbd303ea115cf828b28b6 +Subproject commit 2c1dcb1c74d05a9e7be0f753ffc6273284c30242 From c53fb53ba5b1595436b855b3672a135aca287c38 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 25 Apr 2023 20:21:58 -0600 Subject: [PATCH 088/437] Made MixinAbstractCannonProjectile Pseudo --- build.gradle | 7 ------- common/build.gradle | 2 -- .../MixinAbstractCannonProjectile.java | 13 +++++++++---- fabric/build.gradle | 3 --- forge/build.gradle | 3 --- gradle.properties | 1 - 6 files changed, 9 insertions(+), 20 deletions(-) diff --git a/build.gradle b/build.gradle index dee6175d1..a271cfecd 100644 --- a/build.gradle +++ b/build.gradle @@ -89,13 +89,6 @@ 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://maven.realrobotix.me/createbigcannons/" // Create Big Cannons - content { - includeGroup "com.rbasamoyai" - } - } - } } diff --git a/common/build.gradle b/common/build.gradle index 03d023097..f4adbfbf8 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -24,8 +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("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:0.6.8-33") - - modCompileOnly("com.rbasamoyai:createbigcannons-fabric-${minecraft_version}:${createbigcannons_version}") } architectury { 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 19126d790..96439c2b4 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,9 +1,11 @@ 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; import org.joml.primitives.AABBdc; 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; @@ -12,9 +14,12 @@ import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import rbasamoyai.createbigcannons.munitions.AbstractCannonProjectile; -@Mixin(AbstractCannonProjectile.class) +/** + * 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 { @Shadow @@ -22,7 +27,7 @@ public abstract class MixinAbstractCannonProjectile { @Unique private void shipClipAndDamage(final Vec3 startInWorld, final Vec3 endInWorld, - final AbstractCannonProjectile projectile) { + final Projectile projectile) { final AABBdc pathAABB = new AABBd(VectorConversionsMCKt.toJOML(startInWorld), VectorConversionsMCKt.toJOML(endInWorld)).correctBounds(); @@ -37,6 +42,6 @@ private void shipClipAndDamage(final Vec3 startInWorld, final Vec3 endInWorld, @Inject(method = "clipAndDamage", at = @At("HEAD"), remap = false) protected void vsClipAndDamage(final Vec3 start, final Vec3 end, final CallbackInfo ci) { - shipClipAndDamage(start, end, (AbstractCannonProjectile) (Object) this); + shipClipAndDamage(start, end, Projectile.class.cast(this)); } } diff --git a/fabric/build.gradle b/fabric/build.gradle index 97c1bfcf3..20b16bd33 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -72,9 +72,6 @@ dependencies { 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}") - - //CBC - modImplementation("com.rbasamoyai:createbigcannons-fabric-${minecraft_version}:${createbigcannons_version}") { transitive = false } } // Copy the VS common access widener to the generated resources folder diff --git a/forge/build.gradle b/forge/build.gradle index 3c66df51c..7ae7976cb 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -70,9 +70,6 @@ dependencies { modImplementation("com.jozufozu.flywheel:flywheel-forge-${minecraft_version}:${flywheel_version}") modImplementation("com.tterrag.registrate:Registrate:${registrate_version}") - // Create : Big Cannons - modImplementation("com.rbasamoyai:createbigcannons-forge-${minecraft_version}:${createbigcannons_version}") { transitive = false } - // CC Tweaked modCompileOnly("curse.maven:cc-tweaked-282001:4061947") diff --git a/gradle.properties b/gradle.properties index 07d0904ff..dcd7e0adc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,6 @@ architectury_version=4.10.86 fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 -createbigcannons_version=+ # 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 01d382985a8dbab5932a058ffbb97aed5d372edf Mon Sep 17 00:00:00 2001 From: StewStrong Date: Wed, 26 Apr 2023 20:04:16 -0600 Subject: [PATCH 089/437] Added Vector2 types to JOMLSerializationModule --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 2c1dcb1c7..89954f672 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 2c1dcb1c74d05a9e7be0f753ffc6273284c30242 +Subproject commit 89954f67276803bdaf0d9c6eb416618faa8be0f8 From 2077c6ae192d12f946751515ebc7358545f8da0d Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Thu, 27 Apr 2023 04:00:36 -0700 Subject: [PATCH 090/437] Feature/commands 2 (#457) * Commands (reworked:tm:)! Initial commit * Making its vs-coreified * Optional Slugs * ShipSelector Reco & Parsing WIP * Configurable /tp recommend + mapNotNull * Making arguments better * Merging the merge * More teleport commands * Fixed compile errors * Fixed ship deletion * Make ShipArgument return loaded and unloaded ships * An attempt at sending response text to players (doesnt work) * Added vs-core teleporting code * Got ship teleporting working * Empty commit to retrigger actions * Disable vs scaling command * Update vs-core to main --------- Co-authored-by: ewoudje <7384674+ewoudje@users.noreply.github.com> --- .../MixinClientSuggestionProvider.java | 32 ++++ .../commands/MixinCommandSourceStack.java | 35 ++++ .../feature/command/VSCommandSource.java | 16 ++ .../mod/common/command/ShipArgument.kt | 83 +++++++++ .../mod/common/command/ShipArgumentParser.kt | 168 ++++++++++++++++++ .../mod/common/command/ShipSelecter.kt | 22 +++ .../mod/common/command/VSCommands.kt | 167 +++++++++++++++++ .../mod/common/config/VSGameConfig.kt | 5 + .../mod/common/world/DummyShipWorldServer.kt | 10 ++ .../valkyrienskies-common.mixins.json | 2 + .../fabric/common/ValkyrienSkiesModFabric.kt | 8 +- .../forge/common/ValkyrienSkiesModForge.kt | 14 ++ vs-core | 2 +- 13 files changed, 562 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinClientSuggestionProvider.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinCommandSourceStack.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/command/VSCommandSource.java create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentParser.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipSelecter.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt 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 new file mode 100644 index 000000000..8e670f92d --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinClientSuggestionProvider.java @@ -0,0 +1,32 @@ +package org.valkyrienskies.mod.mixin.feature.commands; + +import java.util.UUID; +import net.minecraft.client.Minecraft; +import net.minecraft.client.multiplayer.ClientSuggestionProvider; +import net.minecraft.network.chat.Component; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.valkyrienskies.core.api.world.ShipWorld; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.mixinducks.feature.command.VSCommandSource; + +@Mixin(ClientSuggestionProvider.class) +public class MixinClientSuggestionProvider implements VSCommandSource { + @Shadow + @Final + private Minecraft minecraft; + + @NotNull + @Override + public ShipWorld getShipWorld() { + assert this.minecraft.level != null; + return VSGameUtilsKt.getShipObjectWorld(this.minecraft.level); + } + + @Override + public void sendVSMessage(final Component component, final UUID uUID) { + minecraft.player.sendMessage(component, uUID); + } +} 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 new file mode 100644 index 000000000..0dc7b1756 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinCommandSourceStack.java @@ -0,0 +1,35 @@ +package org.valkyrienskies.mod.mixin.feature.commands; + +import java.util.UUID; +import net.minecraft.commands.CommandSource; +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.network.chat.Component; +import net.minecraft.server.level.ServerLevel; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.valkyrienskies.core.apigame.world.ShipWorldCore; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.mixinducks.feature.command.VSCommandSource; + +@Mixin(CommandSourceStack.class) +public abstract class MixinCommandSourceStack implements VSCommandSource { + @Shadow + @Final + private CommandSource source; + + @Shadow + public abstract ServerLevel getLevel(); + + @NotNull + @Override + public ShipWorldCore getShipWorld() { + return VSGameUtilsKt.getShipObjectWorld(getLevel()); + } + + @Override + public void sendVSMessage(final Component component, final UUID uUID) { + source.sendMessage(component, uUID); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/command/VSCommandSource.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/command/VSCommandSource.java new file mode 100644 index 000000000..8845b3ceb --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/command/VSCommandSource.java @@ -0,0 +1,16 @@ +package org.valkyrienskies.mod.mixinducks.feature.command; + +import java.util.UUID; +import net.minecraft.network.chat.Component; +import org.valkyrienskies.core.api.world.ShipWorld; + +public interface VSCommandSource { + + ShipWorld getShipWorld(); + + void sendVSMessage(final Component component, final UUID uUID); + + default void sendVSMessage(final Component component) { + sendVSMessage(component, null); + } +} 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 new file mode 100644 index 000000000..533f924f7 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt @@ -0,0 +1,83 @@ +package org.valkyrienskies.mod.common.command + +import com.mojang.brigadier.StringReader +import com.mojang.brigadier.arguments.ArgumentType +import com.mojang.brigadier.context.CommandContext +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.network.chat.TranslatableComponent +import org.valkyrienskies.core.api.ships.Ship +import org.valkyrienskies.mod.mixinducks.feature.command.VSCommandSource +import java.util.concurrent.CompletableFuture + +class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType { + private val EXAMPLES = listOf("the-mogus", "@v", "@v[slug=the-mogus]") + + override fun listSuggestions( + context: CommandContext, builder: SuggestionsBuilder + ): CompletableFuture = if (context.source is VSCommandSource) { + val reader = StringReader(builder.input) + reader.cursor = builder.start + + val parser = ShipArgumentParser(context.source as VSCommandSource, selectorOnly) + + try { + parser.parse(reader) + } catch (_: CommandSyntaxException) { + + } + + val nBuilder = builder.createOffset(reader.cursor) + parser.suggestionProvider(nBuilder) + + nBuilder.buildFuture() + } else super.listSuggestions(context, builder) + + override fun parse(reader: StringReader): ShipSelector = + ShipArgumentParser(null, selectorOnly).parse(reader) + + companion object { + + fun selectorOnly(): ShipArgument = ShipArgument(true) + fun ships(): ShipArgument = ShipArgument(false) + + /** + * @return Can return either a loaded ship or an unloaded ship + */ + fun getShips(context: CommandContext, argName: String): Set { + val selector = context.getArgument(argName, ShipSelector::class.java) + + val fromLoadedShips = selector.select(context.source.shipWorld.loadedShips) + val fromLoadedShipIds = fromLoadedShips.map { it.id }.toSet() + + val fromUnloadedShips = selector.select(context.source.shipWorld.allShips) + + // Return loaded ships and unloaded ships, do not return a loaded ship twice + return fromLoadedShips + (fromUnloadedShips.filter { !fromLoadedShipIds.contains(it.id) }) + } + + /** + * @return Can return either a loaded ship or an unloaded ship + */ + fun getShip(context: CommandContext, argName: String): Ship { + val selector = context.getArgument(argName, ShipSelector::class.java) + + // First attempt to return a loaded ship + val loadedShips = selector.select(context.source.shipWorld.loadedShips) + if (loadedShips.size == 1) return loadedShips.first() + + // Then try to return an unloaded ship + val r = selector.select(context.source.shipWorld.allShips) + if (r.isEmpty()) throw ERROR_NO_SHIP_FOUND + if (r.size == 1) return r.first() else throw ERROR_MANY_SHIP_FOUND + } + + private val ERROR_NO_SHIP_FOUND = CommandRuntimeException(TranslatableComponent("argument.ship.no_found")) + private val ERROR_MANY_SHIP_FOUND = + CommandRuntimeException(TranslatableComponent("argument.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 new file mode 100644 index 000000000..f64f786af --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgumentParser.kt @@ -0,0 +1,168 @@ +package org.valkyrienskies.mod.common.command + +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 org.valkyrienskies.core.api.ships.properties.ShipId +import org.valkyrienskies.mod.mixinducks.feature.command.VSCommandSource + +class ShipArgumentParser(private val source: VSCommandSource?, private var selectorOnly: Boolean) { + var suggestionProvider: (SuggestionsBuilder) -> Unit = {} + var slug: String? = null + var limit: Int? = null + var id: ShipId? = null + + fun parse(reader: StringReader): ShipSelector { + val start = reader.cursor + + suggestSelectorOrSlug() + + if (!reader.canRead()) + throw ERROR_MISSING_SELECTOR_TYPE.createWithContext(reader) + + // Read the selector type + if (reader.read() == '@') { + reader.expectR('v') + + suggestOpenOptions() + if (reader.canRead() && reader.read() == '[') { + + // Read the selector arguments ex @v[slug=mogus,limit=1] + while (reader.canRead() && reader.peek() != ']') { + suggestOptions() + reader.skipWhitespace() + + val i = reader.cursor + val s = reader.readString() + + if (!isOption(s)) { + reader.cursor = i + throw ERROR_UNKNOWN_OPTION.createWithContext(reader, s) + } + + reader.skipWhitespace() + + suggestEquals() + + if (!reader.canRead() || reader.peek() != '=') { + throw ERROR_EXPECTED_OPTION_VALUE.createWithContext(reader, s) + } + + reader.skip() + reader.skipWhitespace() + + suggestionsOfOption(s) + + reader.skipWhitespace() + if (reader.canRead()) + parseOption(s, reader) + else throw ERROR_EXPECTED_OPTION_VALUE.createWithContext(reader, s) + reader.skipWhitespace() + + suggestOptionsNextOrClose() + reader.skipWhitespace() + } + + if (!reader.canRead() || reader.read() != ']') + throw ERROR_EXPECTED_END_OF_OPTIONS.createWithContext(reader) + + suggest { _, _ -> } + } + } else if (!selectorOnly) { + suggestionsOfOption("slug") + reader.cursor = start + slug = reader.readUnquotedString() + } + + return ShipSelector(slug, id, limit ?: Int.MAX_VALUE) + } + + private fun isOption(s: String): Boolean = when (s) { + "slug", "limit", "id" -> true + else -> false + } + + // TODO keep a dynamic list of options... + private fun suggestOptions() = suggest { builder, source -> + builder.suggest("slug=") + builder.suggest("limit=") + builder.suggest("id=") + } + + private fun suggestSelectorOrSlug() = suggest { builder, source -> + builder.suggest("@v") + if (!selectorOnly) { + source.shipWorld.allShips + .mapNotNull { it.slug } + .filter { it.startsWith(builder.remaining) } + .forEach { builder.suggest(it.substring(builder.remaining.length)) } + } + } + + fun suggestionsOfOption(option: String): Unit = when (option) { + "slug" -> + suggest { builder, source -> + source.shipWorld.allShips + .mapNotNull { it.slug } + .filter { it.startsWith(builder.remaining) } + .forEach { builder.suggest(it.substring(builder.remaining.length)) } + } + + "limit" -> {} + else -> throw ERROR_UNKNOWN_OPTION.create(option) + } + + fun parseOption(option: String, reader: StringReader): Unit = when (option) { + "slug" -> { + val start = reader.cursor + val slug = reader.readUnquotedString() + + if (source?.shipWorld?.allShips?.any { it.slug == slug } == false) { + reader.cursor = start + throw ERROR_INVALID_SLUG_OR_ID.create() + } + + this.slug = slug + } + + "limit" -> limit = reader.readInt() + else -> throw ERROR_UNKNOWN_OPTION.create(option) + } + + private fun suggestEquals() = suggest { builder, _ -> + builder.suggest('='.toString()) + } + + private fun suggestOpenOptions() = suggest { builder, _ -> + builder.suggest("[") + } + + private fun suggestOptionsNextOrClose() = suggest { builder, _ -> + builder.suggest(",") + builder.suggest("]") + } + + private fun suggest(builder: (SuggestionsBuilder, VSCommandSource) -> Unit) { + if (source != null) suggestionProvider = { builder(it, source) } + } + + private fun StringReader.expectR(s: Char) { + suggest { builder, source -> builder.suggest(s.toString()) } + this.expect(s) + } + + companion object { + val ERROR_MISSING_SELECTOR_TYPE = + SimpleCommandExceptionType(TranslatableComponent("argument.ship.selector.missing")) + val ERROR_INVALID_SLUG_OR_ID = + SimpleCommandExceptionType(TranslatableComponent("argument.ship.invalid")) + val ERROR_EXPECTED_END_OF_OPTIONS = + SimpleCommandExceptionType(TranslatableComponent("argument.ship.options.unterminated")) + val ERROR_EXPECTED_OPTION_VALUE = + DynamicCommandExceptionType { TranslatableComponent("argument.ship.options.valueless", it) } + val ERROR_UNKNOWN_OPTION = + DynamicCommandExceptionType { TranslatableComponent("argument.entity.options.unknown", it) } + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipSelecter.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipSelecter.kt new file mode 100644 index 000000000..63bc75b63 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipSelecter.kt @@ -0,0 +1,22 @@ +package org.valkyrienskies.mod.common.command + +import org.valkyrienskies.core.api.ships.QueryableShipData +import org.valkyrienskies.core.api.ships.Ship +import org.valkyrienskies.core.api.ships.properties.ShipId + +data class ShipSelector( + val slug: String? = null, + val id: ShipId? = null, + val maxAmount: Int = Int.MAX_VALUE +) { + + fun select(queryableShipData: QueryableShipData): Set { + var found = queryableShipData.asSequence() + + slug?.let { slug -> found = found.filter { it.slug == slug } } + id?.let { id -> found = found.filter { it.id == id } } + + return found.take(maxAmount).toSet() + } +} + 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 new file mode 100644 index 000000000..cb8c6e09f --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/VSCommands.kt @@ -0,0 +1,167 @@ +package org.valkyrienskies.mod.common.command + +import com.mojang.brigadier.CommandDispatcher +import com.mojang.brigadier.arguments.ArgumentType +import com.mojang.brigadier.arguments.StringArgumentType +import com.mojang.brigadier.builder.LiteralArgumentBuilder +import com.mojang.brigadier.builder.RequiredArgumentBuilder +import com.mojang.brigadier.context.CommandContext +import net.minecraft.commands.CommandRuntimeException +import net.minecraft.commands.CommandSourceStack +import net.minecraft.commands.arguments.EntityArgument +import net.minecraft.commands.arguments.coordinates.BlockPosArgument +import net.minecraft.network.chat.TextComponent +import org.valkyrienskies.core.api.ships.ServerShip +import org.valkyrienskies.core.api.world.ServerShipWorld +import org.valkyrienskies.core.api.world.ShipWorld +import org.valkyrienskies.core.impl.util.x +import org.valkyrienskies.core.impl.util.y +import org.valkyrienskies.core.impl.util.z +import org.valkyrienskies.mod.common.vsCore +import org.valkyrienskies.mod.mixinducks.feature.command.VSCommandSource +import org.valkyrienskies.mod.util.logger + +object VSCommands { + private val LOGGER by logger() + + private fun literal(name: String) = + LiteralArgumentBuilder.literal(name) + + private fun argument(name: String, type: ArgumentType) = + RequiredArgumentBuilder.argument(name, type) + + fun registerServerCommands(dispatcher: CommandDispatcher) { + dispatcher as CommandDispatcher + + dispatcher.register( + literal("vs") + .then(literal("delete").then(argument("ships", ShipArgument.ships()).executes { + try { + val r = ShipArgument.getShips(it, "ships").toList() as List + vsCore.deleteShips(it.source.shipWorld as ServerShipWorld, r) + it.source.sendVSMessage(TextComponent("Deleted ${r.size} ships!")) + r.size + } catch (e: Exception) { + if (e !is CommandRuntimeException) LOGGER.throwing(e) + throw e + } + })) + + // Single ship commands + .then( + literal("ship").then( + argument("ship", ShipArgument.ships()) + + // Delete a ship + .then(literal("delete").executes { + try { + vsCore.deleteShips( + it.source.shipWorld as ServerShipWorld, + listOf(ShipArgument.getShip(it, "ship") as ServerShip) + ) + 1 + } catch (e: Exception) { + if (e !is CommandRuntimeException) LOGGER.throwing(e) + throw e + } + }) + + // Rename a ship + .then( + literal("rename") + .then(argument("newName", StringArgumentType.string()) + .executes { + try { + vsCore.renameShip( + ShipArgument.getShip(it, "ship") as ServerShip, + StringArgumentType.getString(it, "newName") + ) + 1 + } catch (e: Exception) { + if (e !is CommandRuntimeException) LOGGER.throwing(e) + throw e + } + }) + ) + + /* 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 + } + }) + ) + */ + ) + ) + ) + + dispatcher.root.children.first { it.name == "teleport" }.apply { + addChild( + argument("ship", ShipArgument.selectorOnly()).executes { + val ship = ShipArgument.getShip(it, "ship") + val source = it.source as CommandSourceStack + val shipPos = ship.transform.positionInWorld + + source.entity?.let { it.teleportTo(shipPos.x, shipPos.y, shipPos.z); 1 } ?: 0 + }.then( + argument("entity", EntityArgument.entity()).executes { + val ship = ShipArgument.getShip(it, "ship") + it as CommandContext + val entity = EntityArgument.getEntity(it, "entity") + + vsCore.teleportShip( + it.source.shipWorld as ServerShipWorld, ship as ServerShip, entity.x, entity.y, entity.z + ) + + 1 + } + ).then( + argument("pos", BlockPosArgument.blockPos()).executes { + val ship = ShipArgument.getShip(it, "ship") + it as CommandContext + val pos = BlockPosArgument.getSpawnablePos(it, "pos") + + vsCore.teleportShip( + it.source.shipWorld as ServerShipWorld, ship as ServerShip, pos.x.toDouble(), + pos.y.toDouble(), pos.z.toDouble() + ) + + 1 + } + ).build() + ) + + getChild("targets").addChild( + argument("ship", ShipArgument.selectorOnly()).executes { + val ship = ShipArgument.getShip(it, "ship") + it as CommandContext + val entities = EntityArgument.getEntities(it, "targets") + val shipPos = ship.transform.positionInWorld + + entities.forEach { it.teleportTo(shipPos.x, shipPos.y, shipPos.z) } + + entities.size + }.build() + ) + } + } + + fun registerClientCommands(dispatcher: CommandDispatcher) { + // TODO implement client commands + } +} + +val CommandSourceStack.shipWorld: ShipWorld + get() = (this as VSCommandSource).shipWorld 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 bbaae6cf8..6303849de 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 @@ -16,6 +16,11 @@ object VSGameConfig { class Client { @JsonSchema(description = "Renders the VS2 debug HUD with TPS") var renderDebugText = false + + @JsonSchema( + description = "Recommend ship slugs in mc commands where player names could be used ex. /tp ship-name wich could pollute user autocomplete" + ) + var recommendSlugsInMcCommands = true } class Server { diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt index deb0bf46f..72db1d055 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt @@ -1,5 +1,7 @@ package org.valkyrienskies.mod.common.world +import org.joml.Quaterniondc +import org.joml.Vector3dc import org.joml.Vector3ic import org.joml.primitives.AABBdc import org.valkyrienskies.core.api.ships.LoadedServerShip @@ -70,6 +72,14 @@ object DummyShipWorldServer : ServerShipWorldCore { override fun onDisconnect(player: IPlayer) { } + override fun deleteShip(ship: ServerShip) { + TODO("Not yet implemented") + } + + override fun teleportShip(ship: ServerShip, positionInWorld: Vector3dc, shipToWorldRotation: Quaterniondc) { + TODO("Not yet implemented") + } + override val dimensionToGroundBodyIdImmutable: Map get() = TODO("Not yet implemented") diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 1a998ddd3..c45b688a4 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.MixinCommandSourceStack", "feature.conduit_fix.ConduitMixin", "feature.container_distance_check.MixinRandomizableContainerBlockEntity", "feature.dispensers.MixinDefaultDispenseItemBehavior", @@ -79,6 +80,7 @@ "client.renderer.MixinLevelRenderer", "client.world.MixinClientChunkCache", "client.world.MixinClientLevel", + "feature.commands.MixinClientSuggestionProvider", "feature.fix_render_chunk_sorting.MixinRenderChunk", "feature.fluid_camera_fix.MixinCamera", "feature.render_blockentity_distance_check.MixinBlockEntityRenderDispatcher", 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 c907c5558..4336e0a3d 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,6 +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.event.lifecycle.v1.CommonLifecycleEvents import net.fabricmc.fabric.api.`object`.builder.v1.block.entity.FabricBlockEntityTypeBuilder import net.fabricmc.fabric.api.resource.IdentifiableResourceReloadListener @@ -30,6 +31,7 @@ import org.valkyrienskies.mod.common.block.TestFlapBlock import org.valkyrienskies.mod.common.block.TestHingeBlock import org.valkyrienskies.mod.common.block.TestWingBlock import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity +import org.valkyrienskies.mod.common.command.VSCommands import org.valkyrienskies.mod.common.config.MassDatapackResolver import org.valkyrienskies.mod.common.config.VSEntityHandlerDataLoader import org.valkyrienskies.mod.common.config.VSGameConfig @@ -67,7 +69,7 @@ class ValkyrienSkiesModFabric : ModInitializer { { VSGameConfig.SERVER.miniShipSize }, { VSGameConfig.SERVER.minScaling } ) - + ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE = EntityType.Builder.of( ::ShipMountingEntity, MobCategory.MISC @@ -117,6 +119,10 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE ) + CommandRegistrationCallback.EVENT.register { dispatcher, _ -> + VSCommands.registerServerCommands(dispatcher) + } + // registering data loaders val loader1 = MassDatapackResolver.loader // the get makes a new instance so get it only once val loader2 = VSEntityHandlerDataLoader // the get makes a new instance so get it only once 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 55a3bb9ed..40a6e17cb 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,5 +1,6 @@ package org.valkyrienskies.mod.forge.common +import net.minecraft.commands.Commands.CommandSelection.* import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.MobCategory @@ -14,6 +15,7 @@ import net.minecraftforge.client.ConfigGuiHandler.ConfigGuiFactory import net.minecraftforge.client.event.EntityRenderersEvent import net.minecraftforge.event.AddReloadListenerEvent import net.minecraftforge.event.TagsUpdatedEvent +import net.minecraftforge.event.RegisterCommandsEvent import net.minecraftforge.fml.ModLoadingContext import net.minecraftforge.fml.common.Mod import net.minecraftforge.fml.common.Mod.EventBusSubscriber.Bus @@ -33,6 +35,7 @@ import org.valkyrienskies.mod.common.block.TestFlapBlock import org.valkyrienskies.mod.common.block.TestHingeBlock import org.valkyrienskies.mod.common.block.TestWingBlock import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity +import org.valkyrienskies.mod.common.command.VSCommands import org.valkyrienskies.mod.common.config.MassDatapackResolver import org.valkyrienskies.mod.common.config.VSEntityHandlerDataLoader import org.valkyrienskies.mod.common.config.VSGameConfig @@ -84,6 +87,7 @@ class ValkyrienSkiesModForge { modBus.addListener(::entityRenderers) modBus.addListener(::loadComplete) + forgeBus.addListener(::registerCommands) forgeBus.addListener(::tagsUpdated) forgeBus.addListener(::registerResourceManagers) @@ -150,6 +154,16 @@ class ValkyrienSkiesModForge { return blockRegistry } + private fun registerCommands(event: RegisterCommandsEvent) { + if (event.environment == ALL || event.environment == DEDICATED) { + VSCommands.registerServerCommands(event.dispatcher) + } + + if (event.environment == ALL || event.environment == INTEGRATED) { + VSCommands.registerClientCommands(event.dispatcher) + } + } + private fun tagsUpdated(event: TagsUpdatedEvent) { VSGameEvents.tagsAreLoaded.emit(Unit) } diff --git a/vs-core b/vs-core index 89954f672..4e7914ba1 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 89954f67276803bdaf0d9c6eb416618faa8be0f8 +Subproject commit 4e7914ba1f1baec8ce2b8fe8e9a657d342b7f836 From 2ec76b584dc975bb019696d24e03778122b689a4 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 28 Apr 2023 02:02:18 -0600 Subject: [PATCH 091/437] Fixed commands not working on forge --- .../valkyrienskies/mod/forge/common/ValkyrienSkiesModForge.kt | 4 +--- 1 file changed, 1 insertion(+), 3 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 40a6e17cb..c52ab06f5 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 @@ -155,9 +155,7 @@ class ValkyrienSkiesModForge { } private fun registerCommands(event: RegisterCommandsEvent) { - if (event.environment == ALL || event.environment == DEDICATED) { - VSCommands.registerServerCommands(event.dispatcher) - } + VSCommands.registerServerCommands(event.dispatcher) if (event.environment == ALL || event.environment == INTEGRATED) { VSCommands.registerClientCommands(event.dispatcher) From ff0be862a714088202b506886af8d9956baaf8b5 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Apr 2023 12:04:00 -0400 Subject: [PATCH 092/437] cbc autocannon patch (#460) * Applied Triode's fixes for Comod error * CBC Compat * aeugh --- .../MixinPitchOrientedContraptionEntity.java | 55 +++++++++++++++++++ .../valkyrienskies-common.mixins.json | 1 + 2 files changed, 56 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinPitchOrientedContraptionEntity.java 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 new file mode 100644 index 000000000..820768f90 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinPitchOrientedContraptionEntity.java @@ -0,0 +1,55 @@ +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; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.Nullable; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import rbasamoyai.createbigcannons.cannon_control.ControlPitchContraption; + +@Pseudo +@Mixin(targets = "rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity") +public abstract class MixinPitchOrientedContraptionEntity extends OrientedContraptionEntity { + + @Shadow + private BlockPos controllerPos; + + @Shadow + protected abstract ControlPitchContraption getController(); + + public MixinPitchOrientedContraptionEntity(final EntityType type, + final Level world) { + super(type, world); + } + + @Inject(method = "processRiderPositionHook", at = @At("HEAD"), cancellable = true, remap = false) + protected void vsProcesssRiderPositionHook( + final Entity passenger, @Nullable Vec3 original, final CallbackInfoReturnable ci) { + + if (original != null) { + final Vector3d editOriginal = VectorConversionsMCKt.toJOML(original); + + final Ship ship = VSGameUtilsKt.getShipObjectManagingPos(level, controllerPos); + + if (ship != null) { + ship.getShipToWorld().transformPosition(editOriginal); + + original = VectorConversionsMCKt.toMinecraft(editOriginal).add(0.5, 1, 0.5) + .subtract(0, passenger.getEyeHeight(), 0); + ci.setReturnValue(original); + } + } + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index c45b688a4..c4b4a2c09 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -44,6 +44,7 @@ "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", From b5431b244c8daa05ced6f295a5b09a305e14a9ac Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Apr 2023 12:49:21 -0400 Subject: [PATCH 093/437] CBC Autocannon Patch, but it actually works this time (#461) * Applied Triode's fixes for Comod error * CBC Compat * aeugh * quikfix --- common/build.gradle | 2 ++ .../MixinPitchOrientedContraptionEntity.java | 5 +---- gradle.properties | 1 + 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index f4adbfbf8..ecc6dbbd5 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -23,6 +23,8 @@ 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-33") } 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 820768f90..69a66995f 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 @@ -17,7 +17,7 @@ import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import rbasamoyai.createbigcannons.cannon_control.ControlPitchContraption; + @Pseudo @Mixin(targets = "rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity") @@ -26,9 +26,6 @@ public abstract class MixinPitchOrientedContraptionEntity extends OrientedContra @Shadow private BlockPos controllerPos; - @Shadow - protected abstract ControlPitchContraption getController(); - public MixinPitchOrientedContraptionEntity(final EntityType type, final Level world) { super(type, world); diff --git a/gradle.properties b/gradle.properties index dcd7e0adc..473aa7ed1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,6 +8,7 @@ architectury_version=4.10.86 fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 +create_fabric_version=0.5.0.i-934+1.18.2 # 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 be4df7f57c02de18b4f752be17c9dbb1ddccbc87 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sun, 30 Apr 2023 19:25:43 -0400 Subject: [PATCH 094/437] build: update jvm args (#435) hopefully this fixes gradle daemon disappeared unexpectedly error in ci --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 473aa7ed1..bae1daf22 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -org.gradle.jvmargs=-Xmx4096M +org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 From a247d65b36a725cc066626828aff25bb1e53055e Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sun, 30 Apr 2023 19:27:11 -0400 Subject: [PATCH 095/437] bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index bae1daf22..76b94046b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.0-beta.10 +mod_version=2.1.0-beta.11 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From 0d3b5424b81366c320def7f9bf3fb7786cf617e8 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sun, 30 Apr 2023 23:07:56 -0400 Subject: [PATCH 096/437] bump version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 76b94046b..801d16d3d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.0-beta.11 +mod_version=2.1.0-beta.12 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From 5bc461b018c08edbfea95ab5ab4b807b899a3883 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 1 May 2023 02:52:30 -0600 Subject: [PATCH 097/437] Disabled TestHingeBlock damping --- .../valkyrienskies/mod/common/block/TestHingeBlock.kt | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) 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 73d08e731..b22a496ec 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 @@ -35,9 +35,6 @@ import org.joml.Vector3d import org.joml.Vector3dc import org.valkyrienskies.core.apigame.constraints.VSAttachmentConstraint import org.valkyrienskies.core.apigame.constraints.VSHingeOrientationConstraint -import org.valkyrienskies.core.apigame.constraints.VSPosDampingConstraint -import org.valkyrienskies.core.apigame.constraints.VSRotDampingAxes.PERPENDICULAR -import org.valkyrienskies.core.apigame.constraints.VSRotDampingConstraint import org.valkyrienskies.core.impl.game.ships.ShipDataCommon import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl import org.valkyrienskies.mod.common.ValkyrienSkiesMod @@ -232,12 +229,12 @@ object TestHingeBlock : } // Add position damping to make the hinge more stable - val posDampingConstraint = VSPosDampingConstraint(shipId0, shipId1, 1e-10, attachmentLocalPos0, attachmentLocalPos1, 1e10, 1e3) - blockEntity.get().constraintId = level.shipObjectWorld.createNewConstraint(posDampingConstraint) + // val posDampingConstraint = VSPosDampingConstraint(shipId0, shipId1, 1e-10, attachmentLocalPos0, attachmentLocalPos1, 1e10, 1e-2) + // blockEntity.get().constraintId = level.shipObjectWorld.createNewConstraint(posDampingConstraint) // Add perpendicular rotation damping to make the hinge more stable - val perpendicularRotDampingConstraint = VSRotDampingConstraint(shipId0, shipId1, 1e-10, hingeOrientation, hingeOrientation, 1e10, 1e3, PERPENDICULAR) - blockEntity.get().constraintId = level.shipObjectWorld.createNewConstraint(perpendicularRotDampingConstraint) + // val perpendicularRotDampingConstraint = VSRotDampingConstraint(shipId0, shipId1, 1e-10, hingeOrientation, hingeOrientation, 1e10, 1e-2, ALL_AXES) + // blockEntity.get().constraintId = level.shipObjectWorld.createNewConstraint(perpendicularRotDampingConstraint) // Add parallel rotation damping to prevent the hinge from spinning forever // val parallelRotDampingConstraint = VSRotDampingConstraint(shipId0, shipId1, 0.0, hingeOrientation, hingeOrientation, 1e10, 1e-1, PARALLEL) From c3076eba2428b4bef3a4732aea55051d928f41ae Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Thu, 4 May 2023 05:40:26 -0700 Subject: [PATCH 098/437] Feature/more commands (#470) * Make ship teleports reset rot/vel/omega * Fixed vs suggestions being sus * Fixed /teleport @v being sus, and /vs delete ship-name not working * Added `/vs set-static` command * Made `/teleport` work on multiple ships * Fixed `/teleport Dev @v[slug=` suggestions * Added `/vs teleport` command * Let `/vs teleport` command set velocity and rotational velocity * Updated vs-core to main --- .../mod/common/command/RelativeVector3.kt | 27 ++ .../common/command/RelativeVector3Argument.kt | 191 ++++++++++++ .../mod/common/command/ShipArgument.kt | 11 +- .../mod/common/command/ShipArgumentParser.kt | 24 +- .../mod/common/command/VSCommands.kt | 274 +++++++++++++++--- .../mod/common/world/DummyShipWorldServer.kt | 5 +- vs-core | 2 +- 7 files changed, 485 insertions(+), 49 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3Argument.kt diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3.kt new file mode 100644 index 000000000..f54cdb6d5 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3.kt @@ -0,0 +1,27 @@ +package org.valkyrienskies.mod.common.command + +import org.joml.Quaterniond +import org.joml.Vector3d +import java.lang.Math.toRadians + +data class RelativeVector3(val x: RelativeValue, val y: RelativeValue, val z: RelativeValue) { + fun toEulerRotation(sourcePitchDegrees: Double, sourceYawDegrees: Double, sourceRollDegrees: Double): Quaterniond = + Quaterniond().rotateXYZ( + toRadians(x.getRelativeValue(sourcePitchDegrees)), + toRadians(y.getRelativeValue(sourceYawDegrees)), + toRadians(z.getRelativeValue(sourceRollDegrees)), + ) + + fun toEulerRotationFromMCEntity(mcEntityPitch: Double, mcEntityYaw: Double) = + toEulerRotation(mcEntityPitch, -mcEntityYaw, 0.0) + + fun toVector3d(sourceX: Double, sourceY: Double, sourceZ: Double): Vector3d = Vector3d( + x.getRelativeValue(sourceX), y.getRelativeValue(sourceY), z.getRelativeValue(sourceZ) + ) +} + +data class RelativeValue(private val angleDegrees: Double, private val isRelative: Boolean) { + fun getRelativeValue(sourceAngleDegrees: Double): Double { + return if (isRelative) sourceAngleDegrees + angleDegrees else angleDegrees + } +} 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 new file mode 100644 index 000000000..d3b1d3f8b --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3Argument.kt @@ -0,0 +1,191 @@ +package org.valkyrienskies.mod.common.command + +import com.mojang.brigadier.StringReader +import com.mojang.brigadier.arguments.ArgumentType +import com.mojang.brigadier.context.CommandContext +import com.mojang.brigadier.exceptions.CommandSyntaxException +import com.mojang.brigadier.exceptions.SimpleCommandExceptionType +import com.mojang.brigadier.suggestion.Suggestions +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 java.util.concurrent.CompletableFuture + +class RelativeVector3Argument : ArgumentType { + override fun parse(reader: StringReader): RelativeVector3 = RelativeVector3ArgumentParser().parse(reader, false) + + override fun listSuggestions( + context: CommandContext?, builder: SuggestionsBuilder + ): CompletableFuture? { + val reader = StringReader(builder.input) + reader.cursor = builder.start + + val parser = RelativeVector3ArgumentParser() + try { + parser.parse(reader, true) + } catch (_: CommandSyntaxException) { + } + + // Reset cursor to fix suggestions + reader.cursor = builder.start + + val nBuilder = builder.createOffset(reader.cursor) + parser.suggestionProvider(nBuilder) + + return nBuilder.buildFuture() + } + + override fun getExamples(): Collection { + return EXAMPLES + } + + companion object { + private val EXAMPLES: Collection = listOf("(0 0 0)", "(~ ~ ~)", "(~0.5 ~1 ~-5)") + + private val DUMMY_EULER_ANGLES = + RelativeVector3(RelativeValue(0.0, false), RelativeValue(0.0, false), RelativeValue(0.0, false)) + + fun relativeVector3() = RelativeVector3Argument() + + fun getRelativeVector3(commandContext: CommandContext, string: String?): RelativeVector3 { + return commandContext.getArgument( + string, + RelativeVector3::class.java + ) as RelativeVector3 + } + + private class RelativeVector3ArgumentParser { + var suggestionProvider: (SuggestionsBuilder) -> Unit = {} + + fun parse(reader: StringReader, invokedByListSuggestions: Boolean): RelativeVector3 { + val i: Int = reader.cursor + if (!reader.canRead()) { + throw RotationArgument.ERROR_NOT_COMPLETE.createWithContext(reader) + } else { + if (!reader.canRead()) { + if (invokedByListSuggestions) { + // Suggest setting rotation to 0 + suggest { builder -> + builder.suggest("(0 0 0)") + } + } else { + return DUMMY_EULER_ANGLES + } + } + + if (reader.canRead() && reader.peek() == '(') { + reader.skip() + + if (!reader.canRead()) { + if (invokedByListSuggestions) { + // Suggest ending with 0 pitch 0 yaw and 0 roll + suggest { builder -> + builder.suggest("${builder.remaining}0 0 0)") + } + } else { + return DUMMY_EULER_ANGLES + } + } + + val worldCoordinate = WorldCoordinate.parseDouble(reader, false) + + if (!reader.canRead()) { + if (invokedByListSuggestions) { + // Suggest ending with 0 yaw and 0 roll + suggest { builder -> + builder.suggest("${builder.remaining} 0 0)") + } + } else { + return DUMMY_EULER_ANGLES + } + } + + if (reader.canRead() && reader.peek() == ' ') { + reader.skip() + + if (!reader.canRead()) { + if (invokedByListSuggestions) { + // Suggest ending with 0 yaw and 0 roll + suggest { builder -> + builder.suggest("${builder.remaining}0 0)") + } + } else { + return DUMMY_EULER_ANGLES + } + } + + val worldCoordinate2 = WorldCoordinate.parseDouble(reader, false) + + if (!reader.canRead()) { + if (invokedByListSuggestions) { + // Suggest ending with 0 roll + suggest { builder -> + builder.suggest("${builder.remaining} 0)") + } + } else { + return DUMMY_EULER_ANGLES + } + } + + if (reader.canRead() && reader.peek() == ' ') { + reader.skip() + if (!reader.canRead()) { + if (invokedByListSuggestions) { + // Suggest ending with 0 roll + suggest { builder -> + builder.suggest("${builder.remaining}0)") + } + } else { + return DUMMY_EULER_ANGLES + } + } + val worldCoordinate3 = WorldCoordinate.parseDouble(reader, false) + if (reader.canRead()) { + if (reader.peek() == ')') { + reader.skip() + val pitchEulerAngle = + RelativeValue(worldCoordinate.get(0.0), worldCoordinate.isRelative) + val yawEulerAngle = + RelativeValue(worldCoordinate2.get(0.0), worldCoordinate2.isRelative) + val rollEulerAngle = + RelativeValue(worldCoordinate3.get(0.0), worldCoordinate3.isRelative) + + suggest { builder -> + builder.suggest(builder.remaining) + } + return RelativeVector3(pitchEulerAngle, yawEulerAngle, rollEulerAngle) + } + } else { + if (invokedByListSuggestions) { + // Suggest ending with a ")" + suggest { builder -> + builder.suggest("${builder.remaining})") + } + throw SimpleCommandExceptionType( + TranslatableComponent("Expected )") + ).createWithContext(reader) + } else { + return DUMMY_EULER_ANGLES + } + } + } + } + + if (!reader.canRead()) { + reader.cursor = i + throw RotationArgument.ERROR_NOT_COMPLETE.createWithContext(reader) + } + } + reader.cursor = i + throw RotationArgument.ERROR_NOT_COMPLETE.createWithContext(reader) + } + } + + private fun suggest(builder: (SuggestionsBuilder) -> Unit) { + suggestionProvider = { builder(it) } + } + } + } +} 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 533f924f7..c3612d48f 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 @@ -21,14 +21,21 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType val reader = StringReader(builder.input) reader.cursor = builder.start + val startsWithAt = reader.canRead() && reader.peek() == '@' + val parser = ShipArgumentParser(context.source as VSCommandSource, selectorOnly) try { - parser.parse(reader) + parser.parse(reader, true) } catch (_: CommandSyntaxException) { } + // Reset cursor to fix suggestions + if (!startsWithAt) { + reader.cursor = builder.start + } + val nBuilder = builder.createOffset(reader.cursor) parser.suggestionProvider(nBuilder) @@ -36,7 +43,7 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType } else super.listSuggestions(context, builder) override fun parse(reader: StringReader): ShipSelector = - ShipArgumentParser(null, selectorOnly).parse(reader) + ShipArgumentParser(null, selectorOnly).parse(reader, false) companion object { 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 f64f786af..3eca4699e 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 @@ -14,7 +14,7 @@ class ShipArgumentParser(private val source: VSCommandSource?, private var selec var limit: Int? = null var id: ShipId? = null - fun parse(reader: StringReader): ShipSelector { + fun parse(reader: StringReader, isForSuggestion: Boolean): ShipSelector { val start = reader.cursor suggestSelectorOrSlug() @@ -38,8 +38,13 @@ class ShipArgumentParser(private val source: VSCommandSource?, private var selec val s = reader.readString() if (!isOption(s)) { - reader.cursor = i - throw ERROR_UNKNOWN_OPTION.createWithContext(reader, s) + if (isForSuggestion) { + reader.cursor = i + throw ERROR_UNKNOWN_OPTION.createWithContext(reader, s) + } + // If not for suggestion then we cannot throw an exception + // otherwise MC won't generate suggestions for this argument + return ShipSelector(null, null, 0) } reader.skipWhitespace() @@ -66,12 +71,19 @@ class ShipArgumentParser(private val source: VSCommandSource?, private var selec } if (!reader.canRead() || reader.read() != ']') - throw ERROR_EXPECTED_END_OF_OPTIONS.createWithContext(reader) + if (isForSuggestion) { + throw ERROR_EXPECTED_END_OF_OPTIONS.createWithContext(reader) + }else { + // If not for suggestion then we cannot throw an exception + // otherwise MC won't generate suggestions for this argument + return ShipSelector(null, null, 0) + } suggest { _, _ -> } } } else if (!selectorOnly) { suggestionsOfOption("slug") + // Reset cursor reader.cursor = start slug = reader.readUnquotedString() } @@ -97,7 +109,7 @@ class ShipArgumentParser(private val source: VSCommandSource?, private var selec source.shipWorld.allShips .mapNotNull { it.slug } .filter { it.startsWith(builder.remaining) } - .forEach { builder.suggest(it.substring(builder.remaining.length)) } + .forEach { builder.suggest(it) } } } @@ -107,7 +119,7 @@ class ShipArgumentParser(private val source: VSCommandSource?, private var selec source.shipWorld.allShips .mapNotNull { it.slug } .filter { it.startsWith(builder.remaining) } - .forEach { builder.suggest(it.substring(builder.remaining.length)) } + .forEach { builder.suggest(it) } } "limit" -> {} 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 cb8c6e09f..8720888a6 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 @@ -2,6 +2,7 @@ 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.StringArgumentType import com.mojang.brigadier.builder.LiteralArgumentBuilder import com.mojang.brigadier.builder.RequiredArgumentBuilder @@ -10,13 +11,21 @@ import net.minecraft.commands.CommandRuntimeException 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.TextComponent +import org.joml.Vector3d import org.valkyrienskies.core.api.ships.ServerShip 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.impl.util.x import org.valkyrienskies.core.impl.util.y import org.valkyrienskies.core.impl.util.z +import org.valkyrienskies.mod.common.util.toJOML +import org.valkyrienskies.mod.common.util.toJOMLD import org.valkyrienskies.mod.common.vsCore import org.valkyrienskies.mod.mixinducks.feature.command.VSCommandSource import org.valkyrienskies.mod.util.logger @@ -46,6 +55,186 @@ object VSCommands { throw e } })) + .then( + literal("set-static").then( + argument("ships", ShipArgument.ships()).then( + argument("is-static", BoolArgumentType.bool()).executes { + try { + 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 + } + + } + it.source.sendVSMessage( + TextComponent("Set ${r.size} ships to be is-static=$isStatic!") + ) + r.size + } catch (e: Exception) { + if (e !is CommandRuntimeException) LOGGER.throwing(e) + throw e + } + }) + ) + ) + .then( + literal("teleport").then( + argument("ships", ShipArgument.ships()).then( + argument("position", Vec3Argument.vec3()).executes { + // If only position is present then we execute this code + try { + val r = ShipArgument.getShips(it, "ships").toList() as List + val position = + Vec3Argument.getVec3(it as CommandContext, "position") + val shipTeleportData: ShipTeleportData = + ShipTeleportDataImpl(newPos = position.toJOML()) + r.forEach { ship -> + vsCore.teleportShip( + (it as CommandContext).source.shipWorld as ServerShipWorld, + ship, shipTeleportData + ) + } + (it as CommandContext).source.sendVSMessage( + TextComponent("Teleported ${r.size} ships to $shipTeleportData!") + ) + r.size + } catch (e: Exception) { + if (e !is CommandRuntimeException) LOGGER.throwing(e) + throw e + } + }.then( + argument("euler-angles", RelativeVector3Argument.relativeVector3()).executes { + // If only position is present then we execute this code + try { + val r = ShipArgument.getShips(it, "ships").toList() as List + val position = + Vec3Argument.getVec3(it as CommandContext, "position") + val eulerAngles = + RelativeVector3Argument.getRelativeVector3( + it as CommandContext, "euler-angles" + ) + + val source = it.source as CommandSourceStack + val shipTeleportData: ShipTeleportData = + ShipTeleportDataImpl( + newPos = position.toJOML(), + newRot = eulerAngles.toEulerRotationFromMCEntity( + source.rotation.x.toDouble(), source.rotation.y.toDouble(), + ) + ) + r.forEach { ship -> + vsCore.teleportShip( + (it as CommandContext).source.shipWorld as ServerShipWorld, + ship, shipTeleportData + ) + } + (it as CommandContext).source.sendVSMessage( + TextComponent("Teleported ${r.size} ships to $shipTeleportData!") + ) + r.size + } catch (e: Exception) { + if (e !is CommandRuntimeException) LOGGER.throwing(e) + throw e + } + }.then( + argument("velocity", RelativeVector3Argument.relativeVector3()).executes { + // If only position is present then we execute this code + try { + val r = ShipArgument.getShips(it, "ships").toList() as List + val position = + Vec3Argument.getVec3( + it as CommandContext, "position" + ) + val eulerAngles = + RelativeVector3Argument.getRelativeVector3( + it as CommandContext, "euler-angles" + ) + val velocity = RelativeVector3Argument.getRelativeVector3( + it as CommandContext, "velocity" + ) + + val source = it.source as CommandSourceStack + 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) + ) + r.forEach { ship -> + vsCore.teleportShip( + (it as CommandContext).source.shipWorld as ServerShipWorld, + ship, shipTeleportData + ) + } + (it as CommandContext).source.sendVSMessage( + TextComponent("Teleported ${r.size} ships to $shipTeleportData!") + ) + r.size + } catch (e: Exception) { + if (e !is CommandRuntimeException) LOGGER.throwing(e) + throw e + } + }.then( + argument( + "angular-velocity", RelativeVector3Argument.relativeVector3() + ).executes { + // If only position is present then we execute this code + try { + val r = ShipArgument.getShips(it, "ships").toList() as List + val position = + Vec3Argument.getVec3( + it as CommandContext, "position" + ) + val eulerAngles = + RelativeVector3Argument.getRelativeVector3( + it as CommandContext, "euler-angles" + ) + val velocity = RelativeVector3Argument.getRelativeVector3( + it as CommandContext, "velocity" + ) + val angularVelocity = RelativeVector3Argument.getRelativeVector3( + it as CommandContext, "angular-velocity" + ) + + val source = it.source as CommandSourceStack + 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), + newOmega = angularVelocity.toVector3d(0.0, 0.0, 0.0) + ) + r.forEach { ship -> + vsCore.teleportShip( + (it as CommandContext).source.shipWorld as ServerShipWorld, + ship, shipTeleportData + ) + } + (it as CommandContext).source.sendVSMessage( + TextComponent("Teleported ${r.size} ships to $shipTeleportData!") + ) + r.size + } catch (e: Exception) { + if (e !is CommandRuntimeException) LOGGER.throwing(e) + throw e + } + } + ) + ) + ) + ) + ) + ) // Single ship commands .then( @@ -84,61 +273,72 @@ 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 - } - }) - ) - */ + /* 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 + } + }) + ) + */ ) ) ) dispatcher.root.children.first { it.name == "teleport" }.apply { addChild( - argument("ship", ShipArgument.selectorOnly()).executes { - val ship = ShipArgument.getShip(it, "ship") + argument("ships", ShipArgument.selectorOnly()).executes { + val serverShips = ShipArgument.getShips(it, "ships").toList() as List + val serverShip = serverShips.singleOrNull() ?: throw CommandRuntimeException( + TextComponent("Can only accept 1 ship as input") + ) val source = it.source as CommandSourceStack - val shipPos = ship.transform.positionInWorld + val shipPos = serverShip.transform.positionInWorld - source.entity?.let { it.teleportTo(shipPos.x, shipPos.y, shipPos.z); 1 } ?: 0 + source.entity?.let { entity -> entity.teleportTo(shipPos.x, shipPos.y, shipPos.z); 1 } ?: 0 }.then( argument("entity", EntityArgument.entity()).executes { - val ship = ShipArgument.getShip(it, "ship") - it as CommandContext - val entity = EntityArgument.getEntity(it, "entity") + val serverShips = ShipArgument.getShips(it, "ships").toList() as List + val entity = EntityArgument.getEntity(it as CommandContext, "entity") - vsCore.teleportShip( - it.source.shipWorld as ServerShipWorld, ship as ServerShip, entity.x, entity.y, entity.z + serverShips.forEach { serverShip -> + vsCore.teleportShip( + it.source.shipWorld as ServerShipWorld, serverShip, + ShipTeleportDataImpl(newPos = Vector3d(entity.x, entity.y, entity.z)) + ) + } + (it as CommandContext).source.sendVSMessage( + TextComponent("Teleported ${serverShips.size} ships!") ) - - 1 + serverShips.size } ).then( argument("pos", BlockPosArgument.blockPos()).executes { - val ship = ShipArgument.getShip(it, "ship") + val serverShips = ShipArgument.getShips(it, "ships").toList() as List it as CommandContext val pos = BlockPosArgument.getSpawnablePos(it, "pos") - vsCore.teleportShip( - it.source.shipWorld as ServerShipWorld, ship as ServerShip, pos.x.toDouble(), - pos.y.toDouble(), pos.z.toDouble() + serverShips.forEach { serverShip -> + vsCore.teleportShip( + it.source.shipWorld as ServerShipWorld, serverShip, + ShipTeleportDataImpl(newPos = pos.toJOMLD()) + ) + } + (it as CommandContext).source.sendVSMessage( + TextComponent("Teleported ${serverShips.size} ships!") ) - - 1 + serverShips.size } ).build() ) @@ -150,7 +350,7 @@ object VSCommands { val entities = EntityArgument.getEntities(it, "targets") val shipPos = ship.transform.positionInWorld - entities.forEach { it.teleportTo(shipPos.x, shipPos.y, shipPos.z) } + entities.forEach { entity -> entity.teleportTo(shipPos.x, shipPos.y, shipPos.z) } entities.size }.build() diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt index 72db1d055..d6dfbaf9f 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt @@ -1,7 +1,5 @@ package org.valkyrienskies.mod.common.world -import org.joml.Quaterniondc -import org.joml.Vector3dc import org.joml.Vector3ic import org.joml.primitives.AABBdc import org.valkyrienskies.core.api.ships.LoadedServerShip @@ -9,6 +7,7 @@ import org.valkyrienskies.core.api.ships.QueryableShipData import org.valkyrienskies.core.api.ships.ServerShip import org.valkyrienskies.core.api.ships.properties.ShipId import org.valkyrienskies.core.api.world.LevelYRange +import org.valkyrienskies.core.apigame.ShipTeleportData import org.valkyrienskies.core.apigame.constraints.VSConstraint import org.valkyrienskies.core.apigame.constraints.VSConstraintId import org.valkyrienskies.core.apigame.world.IPlayer @@ -76,7 +75,7 @@ object DummyShipWorldServer : ServerShipWorldCore { TODO("Not yet implemented") } - override fun teleportShip(ship: ServerShip, positionInWorld: Vector3dc, shipToWorldRotation: Quaterniondc) { + override fun teleportShip(ship: ServerShip, teleportData: ShipTeleportData) { TODO("Not yet implemented") } diff --git a/vs-core b/vs-core index 4e7914ba1..34c9f406c 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 4e7914ba1f1baec8ce2b8fe8e9a657d342b7f836 +Subproject commit 34c9f406c0981dc018196766227a7b5ebceb00d8 From 2c6dc56d9122b69a3b414f074271595580678a89 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Fri, 5 May 2023 18:06:40 -0400 Subject: [PATCH 099/437] added null check on controller pos :clueless: (#472) --- .../create_big_cannons/MixinPitchOrientedContraptionEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 69a66995f..31d32a8b0 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 @@ -35,7 +35,7 @@ public MixinPitchOrientedContraptionEntity(final EntityType type, protected void vsProcesssRiderPositionHook( final Entity passenger, @Nullable Vec3 original, final CallbackInfoReturnable ci) { - if (original != null) { + if (original != null && controllerPos != null) { final Vector3d editOriginal = VectorConversionsMCKt.toJOML(original); final Ship ship = VSGameUtilsKt.getShipObjectManagingPos(level, controllerPos); From 63152a0441a4340a7614746df20ca4f2b1767066 Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Sat, 6 May 2023 12:31:47 -0700 Subject: [PATCH 100/437] Only compute ship AABB on server (#475) * Only compute ship AABB on server * Update vs-core to main --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 34c9f406c..c1992803a 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 34c9f406c0981dc018196766227a7b5ebceb00d8 +Subproject commit c1992803a53e8bcbed15ad89977934bc66b81226 From a58572d28bb361ba185bfdeffa463794b4463299 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sat, 6 May 2023 17:50:51 -0600 Subject: [PATCH 101/437] Made more physics settings configurable --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index c1992803a..a12786509 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit c1992803a53e8bcbed15ad89977934bc66b81226 +Subproject commit a12786509040d582b738a9e9b2e73709956428a0 From fae763f66ab86e2f8c7fa2464f101aefb5e4fa15 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 7 May 2023 06:18:18 -0600 Subject: [PATCH 102/437] Added ShipForcesInducer.applyForcesAndLookupPhysShips() --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index a12786509..5927fdde5 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit a12786509040d582b738a9e9b2e73709956428a0 +Subproject commit 5927fdde55cefb47e3f9fd73026c86ed4cd13e26 From 5a40781d5d083dca03e0d82cf6ec00a0a8a0b647 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 7 May 2023 07:42:03 -0600 Subject: [PATCH 103/437] Fixed PhysShip.isStatic somehow being false for ground shapes --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 5927fdde5..92bdb6d08 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 5927fdde55cefb47e3f9fd73026c86ed4cd13e26 +Subproject commit 92bdb6d0828e4a1e7a9c3937108dab3a442d870c From 5c9e3bf764a6a9be1f2c1c7c0da3188c06f1a785 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 8 May 2023 03:38:30 -0600 Subject: [PATCH 104/437] Fixed replay mod compat (hopefully) --- .../mod/mixinducks/feature/command/VSCommandSource.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/command/VSCommandSource.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/command/VSCommandSource.java index 8845b3ceb..05871bab0 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/command/VSCommandSource.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/command/VSCommandSource.java @@ -1,6 +1,7 @@ package org.valkyrienskies.mod.mixinducks.feature.command; import java.util.UUID; +import net.minecraft.Util; import net.minecraft.network.chat.Component; import org.valkyrienskies.core.api.world.ShipWorld; @@ -11,6 +12,6 @@ public interface VSCommandSource { void sendVSMessage(final Component component, final UUID uUID); default void sendVSMessage(final Component component) { - sendVSMessage(component, null); + sendVSMessage(component, Util.NIL_UUID); } } From 2c04a9a70d852ad8e69bb1d550143227f0061071 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 8 May 2023 04:26:26 -0600 Subject: [PATCH 105/437] Optimized MixinServerLevel.postTick() --- .../server/world/ChunkMapAccessor.java | 2 + .../mixin/server/world/MixinServerLevel.java | 59 +++++++++++-------- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/world/ChunkMapAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/world/ChunkMapAccessor.java index cf0a33a47..c91c849ae 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/world/ChunkMapAccessor.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/world/ChunkMapAccessor.java @@ -19,4 +19,6 @@ void callUpdateChunkTracking(ServerPlayer player, ChunkPos pos, @Invoker("getChunks") Iterable callGetChunks(); + @Invoker("getVisibleChunkIfPresent") + ChunkHolder callGetVisibleChunkIfPresent(long l); } 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 b4730b031..c3afd9c00 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 @@ -2,14 +2,15 @@ import static org.valkyrienskies.mod.common.ValkyrienSkiesMod.getVsCore; -import com.google.common.collect.Lists; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import java.util.ArrayList; -import java.util.HashSet; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import java.util.Optional; -import java.util.Set; import java.util.concurrent.Executor; import java.util.function.BooleanSupplier; import net.minecraft.core.BlockPos; @@ -22,6 +23,7 @@ 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.block.state.BlockState; import net.minecraft.world.level.chunk.ChunkGenerator; import net.minecraft.world.level.chunk.LevelChunk; @@ -61,7 +63,8 @@ public abstract class MixinServerLevel implements IShipObjectWorldServerProvider @NotNull public abstract MinecraftServer getServer(); - private final Set knownChunkRegions = new HashSet<>(); + // Map from ChunkPos to the list of voxel chunks that chunk owns + private final Map> knownChunks = new HashMap<>(); @Nullable @Override @@ -118,30 +121,31 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf final ServerLevel self = ServerLevel.class.cast(this); final ServerShipWorldCore shipObjectWorld = VSGameUtilsKt.getShipObjectWorld(self); // Find newly loaded chunks - final List loadedChunksList = Lists.newArrayList( - ((ChunkMapAccessor) chunkSource.chunkMap).callGetChunks()); + final ChunkMapAccessor chunkMapAccessor = (ChunkMapAccessor) chunkSource.chunkMap; // Create DenseVoxelShapeUpdate for new loaded chunks // Also mark the chunks as loaded in the ship objects final List voxelShapeUpdates = new ArrayList<>(); - final Set unloadedChunks = new HashSet<>(knownChunkRegions); - for (final ChunkHolder chunkHolder : loadedChunksList) { + for (final ChunkHolder chunkHolder : chunkMapAccessor.callGetChunks()) { final Optional worldChunkOptional = chunkHolder.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).left(); if (worldChunkOptional.isPresent()) { final LevelChunk worldChunk = worldChunkOptional.get(); - final int chunkX = worldChunk.getPos().x; - final int chunkZ = worldChunk.getPos().z; + if (!knownChunks.containsKey(worldChunk.getPos())) { + final List voxelChunkPositions = new ArrayList<>(); - final LevelChunkSection[] chunkSections = worldChunk.getSections(); + final int chunkX = worldChunk.getPos().x; + final int chunkZ = worldChunk.getPos().z; - for (int sectionY = 0; sectionY < chunkSections.length; sectionY++) { - final LevelChunkSection chunkSection = chunkSections[sectionY]; - final Vector3ic chunkPos = - new Vector3i(chunkX, worldChunk.getSectionYFromSectionIndex(sectionY), chunkZ); + final LevelChunkSection[] chunkSections = worldChunk.getSections(); + + for (int sectionY = 0; sectionY < chunkSections.length; sectionY++) { + final LevelChunkSection chunkSection = chunkSections[sectionY]; + final Vector3ic chunkPos = + new Vector3i(chunkX, worldChunk.getSectionYFromSectionIndex(sectionY), chunkZ); + voxelChunkPositions.add(chunkPos); - if (!knownChunkRegions.contains(chunkPos)) { if (chunkSection != null && !chunkSection.hasOnlyAir()) { // Add this chunk to the ground rigid body final TerrainUpdate voxelShapeUpdate = @@ -183,21 +187,24 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf .newEmptyVoxelShapeUpdate(chunkPos.x(), chunkPos.y(), chunkPos.z(), true); voxelShapeUpdates.add(emptyVoxelShapeUpdate); } - - knownChunkRegions.add(chunkPos); - } else { - unloadedChunks.remove(chunkPos); } + knownChunks.put(worldChunk.getPos(), voxelChunkPositions); } } } - for (final Vector3ic unloadedChunk : unloadedChunks) { - // Delete this chunk - final TerrainUpdate deleteVoxelShapeUpdate = - getVsCore().newDeleteTerrainUpdate(unloadedChunk.x(), unloadedChunk.y(), unloadedChunk.z()); - voxelShapeUpdates.add(deleteVoxelShapeUpdate); - knownChunkRegions.remove(unloadedChunk); + final Iterator>> knownChunkPosIterator = knownChunks.entrySet().iterator(); + while (knownChunkPosIterator.hasNext()) { + final Entry> knownChunkPosEntry = knownChunkPosIterator.next(); + if (chunkMapAccessor.callGetVisibleChunkIfPresent(knownChunkPosEntry.getKey().toLong()) == null) { + // Delete this chunk + for (final Vector3ic unloadedChunk : knownChunkPosEntry.getValue()) { + final TerrainUpdate deleteVoxelShapeUpdate = + getVsCore().newDeleteTerrainUpdate(unloadedChunk.x(), unloadedChunk.y(), unloadedChunk.z()); + voxelShapeUpdates.add(deleteVoxelShapeUpdate); + } + knownChunkPosIterator.remove(); + } } // Send new loaded chunks updates to the ship world From 0623b7d01838f9af3288e051ae2582487efd9031 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 8 May 2023 05:16:02 -0600 Subject: [PATCH 106/437] Added `/vs get-ship` to get the name of the ship player is looking at --- .../mod/common/command/VSCommands.kt | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) 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 8720888a6..cefa11ea3 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,6 +13,8 @@ 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.TextComponent +import net.minecraft.world.entity.Entity +import net.minecraft.world.phys.BlockHitResult import org.joml.Vector3d import org.valkyrienskies.core.api.ships.ServerShip import org.valkyrienskies.core.api.world.ServerShipWorld @@ -24,6 +26,7 @@ import org.valkyrienskies.core.impl.game.ships.ShipObject import org.valkyrienskies.core.impl.util.x import org.valkyrienskies.core.impl.util.y import org.valkyrienskies.core.impl.util.z +import org.valkyrienskies.mod.common.getShipManagingPos import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toJOMLD import org.valkyrienskies.mod.common.vsCore @@ -235,6 +238,40 @@ object VSCommands { ) ) ) + .then(literal("get-ship").executes { + try { + val mcCommandContext = it as CommandContext + + var success = false + val sourceEntity: Entity? = mcCommandContext.source.entity + if (sourceEntity != null) { + val rayTrace = sourceEntity.pick(10.0, 1.0.toFloat(), false) + if (rayTrace is BlockHitResult) { + val ship = sourceEntity.level.getShipManagingPos(rayTrace.blockPos) + if (ship != null) { + (it.source as VSCommandSource).sendVSMessage( + TextComponent("Found ship with slug ${ship.slug}") + ) + success = true + } + } + if (success) { + 1 + } else { + (it.source as VSCommandSource).sendVSMessage(TextComponent("No ship found!")) + 0 + } + } else { + (it.source as VSCommandSource).sendVSMessage( + TextComponent("/vs get-ship can only be run by entities!") + ) + 0 + } + } catch (e: Exception) { + if (e !is CommandRuntimeException) LOGGER.throwing(e) + throw e + } + }) // Single ship commands .then( From 5747aa2ad0ba190c003afa51e37d3831765efc58 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 8 May 2023 06:13:13 -0600 Subject: [PATCH 107/437] Added translation keys for VSCommands --- .../mod/common/command/ShipArgument.kt | 4 +-- .../mod/common/command/VSCommands.kt | 36 ++++++++++++------- .../assets/valkyrienskies/lang/en_us.json | 12 ++++++- 3 files changed, 36 insertions(+), 16 deletions(-) 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 c3612d48f..e73a5a5f7 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 @@ -81,9 +81,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.ship.no_found")) + private val ERROR_NO_SHIP_FOUND = CommandRuntimeException(TranslatableComponent("argument.valkyrienskies.ship.no_found")) private val ERROR_MANY_SHIP_FOUND = - CommandRuntimeException(TranslatableComponent("argument.ship.multiple_found")) + CommandRuntimeException(TranslatableComponent("argument.valkyrienskies.ship.multiple_found")) } override fun getExamples(): Collection = EXAMPLES 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 cefa11ea3..134c273df 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.TextComponent +import net.minecraft.network.chat.TranslatableComponent import net.minecraft.world.entity.Entity import net.minecraft.world.phys.BlockHitResult import org.joml.Vector3d @@ -35,6 +35,14 @@ import org.valkyrienskies.mod.util.logger object VSCommands { private val LOGGER by logger() + private const val DELETED_SHIPS_MESSAGE = "command.valkyrienskies.delete.success" + private const val SET_SHIP_STATIC_SUCCESS_MESSAGE = "command.valkyrienskies.set_static.success" + private const val TELEPORT_SHIP_SUCCESS_MESSAGE = "command.valkyrienskies.teleport.success" + private const val GET_SHIP_SUCCESS_MESSAGE = "command.valkyrienskies.get_ship.success" + private const val GET_SHIP_FAIL_MESSAGE = "command.valkyrienskies.get_ship.fail" + 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 fun literal(name: String) = LiteralArgumentBuilder.literal(name) @@ -51,7 +59,7 @@ object VSCommands { try { val r = ShipArgument.getShips(it, "ships").toList() as List vsCore.deleteShips(it.source.shipWorld as ServerShipWorld, r) - it.source.sendVSMessage(TextComponent("Deleted ${r.size} ships!")) + it.source.sendVSMessage(TranslatableComponent(DELETED_SHIPS_MESSAGE, r.size)) r.size } catch (e: Exception) { if (e !is CommandRuntimeException) LOGGER.throwing(e) @@ -76,7 +84,9 @@ object VSCommands { } it.source.sendVSMessage( - TextComponent("Set ${r.size} ships to be is-static=$isStatic!") + TranslatableComponent( + SET_SHIP_STATIC_SUCCESS_MESSAGE, r.size, if (isStatic) "true" else "false" + ) ) r.size } catch (e: Exception) { @@ -104,7 +114,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TextComponent("Teleported ${r.size} ships to $shipTeleportData!") + TranslatableComponent(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -138,7 +148,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TextComponent("Teleported ${r.size} ships to $shipTeleportData!") + TranslatableComponent(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -178,7 +188,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TextComponent("Teleported ${r.size} ships to $shipTeleportData!") + TranslatableComponent(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -224,7 +234,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TextComponent("Teleported ${r.size} ships to $shipTeleportData!") + TranslatableComponent(TELEPORT_SHIP_SUCCESS_MESSAGE, r.size, shipTeleportData.toString()) ) r.size } catch (e: Exception) { @@ -250,7 +260,7 @@ object VSCommands { val ship = sourceEntity.level.getShipManagingPos(rayTrace.blockPos) if (ship != null) { (it.source as VSCommandSource).sendVSMessage( - TextComponent("Found ship with slug ${ship.slug}") + TranslatableComponent(GET_SHIP_SUCCESS_MESSAGE, ship.slug) ) success = true } @@ -258,12 +268,12 @@ object VSCommands { if (success) { 1 } else { - (it.source as VSCommandSource).sendVSMessage(TextComponent("No ship found!")) + (it.source as VSCommandSource).sendVSMessage(TranslatableComponent(GET_SHIP_FAIL_MESSAGE)) 0 } } else { (it.source as VSCommandSource).sendVSMessage( - TextComponent("/vs get-ship can only be run by entities!") + TranslatableComponent(GET_SHIP_ONLY_USABLE_BY_ENTITIES_MESSAGE) ) 0 } @@ -338,7 +348,7 @@ object VSCommands { argument("ships", ShipArgument.selectorOnly()).executes { val serverShips = ShipArgument.getShips(it, "ships").toList() as List val serverShip = serverShips.singleOrNull() ?: throw CommandRuntimeException( - TextComponent("Can only accept 1 ship as input") + TranslatableComponent(TELEPORT_FIRST_ARG_CAN_ONLY_INPUT_1_SHIP) ) val source = it.source as CommandSourceStack val shipPos = serverShip.transform.positionInWorld @@ -356,7 +366,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TextComponent("Teleported ${serverShips.size} ships!") + TranslatableComponent(TELEPORTED_MULTIPLE_SHIPS_SUCCESS, serverShips.size) ) serverShips.size } @@ -373,7 +383,7 @@ object VSCommands { ) } (it as CommandContext).source.sendVSMessage( - TextComponent("Teleported ${serverShips.size} ships!") + TranslatableComponent(TELEPORTED_MULTIPLE_SHIPS_SUCCESS, serverShips.size) ) serverShips.size } 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 4130d58dc..9851fd5b8 100644 --- a/common/src/main/resources/assets/valkyrienskies/lang/en_us.json +++ b/common/src/main/resources/assets/valkyrienskies/lang/en_us.json @@ -6,5 +6,15 @@ "block.valkyrienskies.test_flap": "Debug Flap", "block.valkyrienskies.test_wing": "Debug Wing", "item.valkyrienskies.ship_creator": "Ship Creator", - "item.valkyrienskies.ship_creator_smaller": "Mini Ship Creator" + "item.valkyrienskies.ship_creator_smaller": "Mini Ship Creator", + "argument.valkyrienskies.ship.no_found": "Ship not found", + "argument.valkyrienskies.ship.multiple_found": "Multiple ships found", + "command.valkyrienskies.delete.success": "Deleted %d ships!", + "command.valkyrienskies.set_static.success": "Set %d ships to be is-static=%s!", + "command.valkyrienskies.teleport.success": "Teleported %d ships to %s!", + "command.valkyrienskies.teleport.multiple_ship_success": "Teleported %d ships!", + "command.valkyrienskies.mc_teleport.can_only_teleport_to_one_ship": "Can only teleport to exactly 1 ship", + "command.valkyrienskies.get_ship.success": "Found ship with slug %s", + "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!" } From 93fd59898f94b124ee777a33818b72c9b5a002e8 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 15 May 2023 23:49:16 -0600 Subject: [PATCH 108/437] Fixed compatibility with Ender Storage --- .../valkyrienskies/mod/common/world/RaycastUtils.kt | 10 +++------- .../main/resources/valkyrienskies-common.accesswidener | 6 ++++++ 2 files changed, 9 insertions(+), 7 deletions(-) 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 976902290..2b132b940 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 @@ -73,15 +73,11 @@ fun Level.clipIncludeShips( } } - if (!shouldTransformHitPos) { - closestHitPos = closestHit.location + if (shouldTransformHitPos) { + closestHit.location = closestHitPos } - return if (closestHit.type == HitResult.Type.MISS) { - BlockHitResult.miss(closestHitPos, closestHit.direction, closestHit.blockPos) - } else { - BlockHitResult(closestHitPos, closestHit.direction, closestHit.blockPos, closestHit.isInside) - } + return closestHit } // copy paste of vanilla raycast with the option to specify a custom start/end diff --git a/common/src/main/resources/valkyrienskies-common.accesswidener b/common/src/main/resources/valkyrienskies-common.accesswidener index 33a2d1d41..2f5276228 100644 --- a/common/src/main/resources/valkyrienskies-common.accesswidener +++ b/common/src/main/resources/valkyrienskies-common.accesswidener @@ -18,3 +18,9 @@ accessible class net/minecraft/client/renderer/chunk/ChunkRenderDispatcher$Ch accessible class net/minecraft/client/renderer/LevelRenderer$RenderChunkStorage accessible field net/minecraft/client/renderer/LevelRenderer$RenderChunkInfo chunk Lnet/minecraft/client/renderer/chunk/ChunkRenderDispatcher$RenderChunk; + +# For modifying BlockHitResult.location +# Remove final +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; From 891b637994a33c7fa57705d498eafa30ad37b1bf Mon Sep 17 00:00:00 2001 From: StewStrong Date: Tue, 16 May 2023 01:03:54 -0600 Subject: [PATCH 109/437] Updated version to 2.1.0-beta.13 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 801d16d3d..bd6c37e9a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.0-beta.12 +mod_version=2.1.0-beta.13 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From f5870a6277b3e6e326914aa6eebc96d80651c527 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Mon, 29 May 2023 04:22:15 -0600 Subject: [PATCH 110/437] Fixed null pointer error --- .../org/valkyrienskies/mod/common/world/ChunkManagement.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/ChunkManagement.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/ChunkManagement.kt index ff9f6b90b..cc464c42d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/ChunkManagement.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/ChunkManagement.kt @@ -36,11 +36,11 @@ object ChunkManagement { level.server.executeIf({ level.isTickingChunk(chunkPos) }) { for (player in chunkWatchTask.playersNeedWatching) { val minecraftPlayer = player as MinecraftPlayer - if (chunkWatchTask.dimensionId != player.dimension) { - logger.warn("Player received watch task for chunk in dimension that they are not also in!") - } val serverPlayer = minecraftPlayer.playerEntityReference.get() as ServerPlayer? if (serverPlayer != null) { + if (chunkWatchTask.dimensionId != player.dimension) { + logger.warn("Player received watch task for chunk in dimension that they are not also in!") + } val map = level.chunkSource.chunkMap as ChunkMapAccessor map.callUpdateChunkTracking(serverPlayer, chunkPos, MutableObject(), false, true) } From 49cdf4c0e96c03749f8b9bf2a51401434072284f Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 2 Jun 2023 00:49:58 -0600 Subject: [PATCH 111/437] Fix Krunch memory leak when unloading worlds --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 92bdb6d08..85eac57a4 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 92bdb6d0828e4a1e7a9c3937108dab3a442d870c +Subproject commit 85eac57a48a92f53a0efa63be2198423c424a600 From 35cd61aca9d30cedd470edec5336521519caeb82 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Fri, 2 Jun 2023 00:51:39 -0600 Subject: [PATCH 112/437] Fixed ShipObjectServerWorld.teleportShip() not working when a loaded ship is passed in as a ShipData --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 85eac57a4..ead972f38 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 85eac57a48a92f53a0efa63be2198423c424a600 +Subproject commit ead972f384499b1b7713e20dde3d0affe7fdc3f1 From 08fd9389b0442a073d5907f7568a779b71ed19e4 Mon Sep 17 00:00:00 2001 From: StewStrong Date: Sun, 4 Jun 2023 11:03:24 -0600 Subject: [PATCH 113/437] 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 114/437] 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 115/437] 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 116/437] 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 117/437] 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 118/437] 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 119/437] 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 120/437] 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 121/437] 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 122/437] Empty commit to retry actions From 13d822074ebd14612576ca0e34016a9149fe3095 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sun, 4 Jun 2023 21:38:51 -0400 Subject: [PATCH 123/437] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 23 +++++++++++++++++++ .github/ISSUE_TEMPLATE/compatibility-issue.md | 23 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/compatibility-issue.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 000000000..2a5afc315 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,23 @@ +--- +name: Bug report +about: Let us know about a bug that occurs without other mods +title: '' +labels: bug +assignees: '' + +--- + + +[ ] This issue occurs without any mods besides Valkyrien Skies + addons. + +**Describe the issue** +A clear and concise description of what the issue is + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' + +**Logs** +Go to `.minecraft/logs` and upload the `latest.log` and `debug.log` file. diff --git a/.github/ISSUE_TEMPLATE/compatibility-issue.md b/.github/ISSUE_TEMPLATE/compatibility-issue.md new file mode 100644 index 000000000..31977c819 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/compatibility-issue.md @@ -0,0 +1,23 @@ +--- +name: Compatibility issue +about: Let us know about a mod that isn't compatible with Valkyrien Skies +title: '' +labels: compat +assignees: '' + +--- + +**Which mod causes the issue?** +The name of the mod + +**Describe the issue** +A clear and concise description of what the issue is + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' + +**Logs** +Go to `.minecraft/logs` and upload the `latest.log` and `debug.log` file. From 9ac4bdd5256285f3c93613197722ffb9ae44c875 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sun, 4 Jun 2023 21:46:19 -0400 Subject: [PATCH 124/437] Update bug_report.md --- .github/ISSUE_TEMPLATE/bug_report.md | 30 ++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 2a5afc315..04f8becaa 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -4,12 +4,34 @@ about: Let us know about a bug that occurs without other mods title: '' labels: bug assignees: '' - +body: +- type: checkboxes + attributes: + label: This issue occurs when only Valkyrien Skies is installed and no other mods + options: + - label: I have tested this issue and it occurs when no other mods are installed +- type: dropdown + attributes: + label: Minecraft Version + description: What Minecraft version does this issue occur on? + options: + - 1.16 + - 1.18 + - 1.19 + validations: + required: true +- type: dropdown + attributes: + label: Mod Loader + description: What mod loader does this issue occur on? + options: + - Forge + - Fabric + - Quilt + validations: + required: true --- - -[ ] This issue occurs without any mods besides Valkyrien Skies + addons. - **Describe the issue** A clear and concise description of what the issue is From d3ff5c0b3342ba4e39b2cfb1e876c42dd94bd512 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sun, 4 Jun 2023 21:54:35 -0400 Subject: [PATCH 125/437] Create bug_report.yml --- .github/ISSUE_TEMPLATE/bug_report.yml | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 000000000..363ff14ca --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,43 @@ +name: Bug report +about: Let us know about a bug that occurs without other mods +title: '' +labels: bug +assignees: '' +body: +- type: checkboxes + attributes: + label: This issue occurs when only Valkyrien Skies and addons are installed and no other mods + options: + - label: I have tested this issue and it occurs when no other mods are installed +- type: dropdown + attributes: + label: Minecraft Version + description: What Minecraft version does this issue occur on? + options: + - 1.16 + - 1.18 + - 1.19 + validations: + required: true +- type: dropdown + attributes: + label: Mod Loader + description: What mod loader does this issue occur on? + options: + - Forge + - Fabric + - Quilt + validations: + required: true +- type: textarea + attributes: + label: Issue description + description: Describe what happens, and what you expect to happen instead + validations: + required: true +- type: textarea + attributes: + label: Issue reproduction + description: Describe how to reproduce your issue + validations: + required: true From a5b357b05e30f3e961feb62c01da9fc80518ad9e Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sun, 4 Jun 2023 21:54:54 -0400 Subject: [PATCH 126/437] Delete bug_report.md --- .github/ISSUE_TEMPLATE/bug_report.md | 45 ---------------------------- 1 file changed, 45 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index 04f8becaa..000000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,45 +0,0 @@ ---- -name: Bug report -about: Let us know about a bug that occurs without other mods -title: '' -labels: bug -assignees: '' -body: -- type: checkboxes - attributes: - label: This issue occurs when only Valkyrien Skies is installed and no other mods - options: - - label: I have tested this issue and it occurs when no other mods are installed -- type: dropdown - attributes: - label: Minecraft Version - description: What Minecraft version does this issue occur on? - options: - - 1.16 - - 1.18 - - 1.19 - validations: - required: true -- type: dropdown - attributes: - label: Mod Loader - description: What mod loader does this issue occur on? - options: - - Forge - - Fabric - - Quilt - validations: - required: true ---- - -**Describe the issue** -A clear and concise description of what the issue is - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' - -**Logs** -Go to `.minecraft/logs` and upload the `latest.log` and `debug.log` file. From bd6f4bd6db8dc19ce92ff1cbd4c778e82a5fead3 Mon Sep 17 00:00:00 2001 From: Rubydesic Date: Sun, 4 Jun 2023 21:56:02 -0400 Subject: [PATCH 127/437] Update bug_report.yml --- .github/ISSUE_TEMPLATE/bug_report.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 363ff14ca..d3197b4ac 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,8 +1,8 @@ name: Bug report -about: Let us know about a bug that occurs without other mods -title: '' +description: Let us know about a bug that occurs without other mods +title: ' labels: bug -assignees: '' +assignees: [] body: - type: checkboxes attributes: From 98d1a8c42dae2d96034ff3fe58887b6eaf3db3c8 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Sun, 4 Jun 2023 21:56:12 -0400 Subject: [PATCH 128/437] Update bug_report.yml --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index d3197b4ac..9968322ef 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -1,6 +1,6 @@ name: Bug report description: Let us know about a bug that occurs without other mods -title: '<title> +title: '<title>' labels: bug assignees: [] body: From ce337f1d360965cfad6662b3f8f53643c5a1077a Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Sun, 4 Jun 2023 21:57:26 -0400 Subject: [PATCH 129/437] Delete compatibility-issue.md --- .github/ISSUE_TEMPLATE/compatibility-issue.md | 23 ------------------- 1 file changed, 23 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/compatibility-issue.md diff --git a/.github/ISSUE_TEMPLATE/compatibility-issue.md b/.github/ISSUE_TEMPLATE/compatibility-issue.md deleted file mode 100644 index 31977c819..000000000 --- a/.github/ISSUE_TEMPLATE/compatibility-issue.md +++ /dev/null @@ -1,23 +0,0 @@ ---- -name: Compatibility issue -about: Let us know about a mod that isn't compatible with Valkyrien Skies -title: '' -labels: compat -assignees: '' - ---- - -**Which mod causes the issue?** -The name of the mod - -**Describe the issue** -A clear and concise description of what the issue is - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' - -**Logs** -Go to `.minecraft/logs` and upload the `latest.log` and `debug.log` file. From 9de6c27608bc6e17b622fce588569dae6c21fd41 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Sun, 4 Jun 2023 22:03:13 -0400 Subject: [PATCH 130/437] Create compatibility_issue.yml --- .../ISSUE_TEMPLATE/compatibility_issue.yml | 59 +++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/compatibility_issue.yml diff --git a/.github/ISSUE_TEMPLATE/compatibility_issue.yml b/.github/ISSUE_TEMPLATE/compatibility_issue.yml new file mode 100644 index 000000000..1fa48e826 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/compatibility_issue.yml @@ -0,0 +1,59 @@ +name: Compatibility issue +description: Let us know about a bug that occurs when another mod is installed +title: '<title>' +labels: compat +assignees: [] +body: +- type: markdown + attributes: + value: | + **Note:** do not report issues with the following mods: + - Optifine + - Magma Server (maybe try Arclight?) +- type: input + attributes: + label: Mod Name + description: The name of the mod that causes the compatibility issue + validations: + required: true +- type: checkboxes + attributes: + label: This issue occurs when only Valkyrien Skies, addons, and the mod I have specified are installed and no other mods + options: + - label: I have tested this issue and it occurs with only Valkyrien Skies, addons, and the mod I have specified +- type: dropdown + attributes: + label: Minecraft Version + description: What Minecraft version does this issue occur on? + options: + - 1.16 + - 1.18 + - 1.19 + validations: + required: true +- type: dropdown + attributes: + label: Mod Loader + description: What mod loader does this issue occur on? + options: + - Forge + - Fabric + - Quilt + validations: + required: true +- type: textarea + attributes: + label: Issue description + description: Describe what happens, and what you expect to happen instead + validations: + required: true +- type: textarea + attributes: + label: Issue reproduction + description: Describe how to reproduce your issue + validations: + required: true +- type: textarea + attributes: + label: Logs + description: Go to `.minecraft/logs` and drag and drop the `latest.log` and `debug.log` file into this text field From 43df99d44b7305ff72a995775a4c6b1db6d0ca8c Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Sun, 4 Jun 2023 22:04:08 -0400 Subject: [PATCH 131/437] Update bug_report.yml --- .github/ISSUE_TEMPLATE/bug_report.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 9968322ef..36fbbc86e 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -41,3 +41,7 @@ body: description: Describe how to reproduce your issue validations: required: true +- type: textarea + attributes: + label: Logs + description: Go to `.minecraft/logs` and drag and drop the `latest.log` and `debug.log` file into this text field From d43a691e272c1f76f69c139e82cb6207b573f55e Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 5 Jun 2023 03:34:33 -0600 Subject: [PATCH 132/437] 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<KeyMapping>) { 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<Key, KeyMapping> VS2_KEYMAP = Maps.newHashMap(); + + @Shadow + @Final + private static Map<InputConstants.Key, KeyMapping> MAP; + + @Shadow + @Final + private static Map<String, KeyMapping> 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 = "<init>(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 <stew.strong.420@gmail.com> Date: Mon, 5 Jun 2023 04:14:40 -0600 Subject: [PATCH 133/437] 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 <stew.strong.420@gmail.com> Date: Mon, 5 Jun 2023 05:30:04 -0600 Subject: [PATCH 134/437] 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<FluidType, MutableTriple> + interimCalcs = new Object2ObjectArrayMap<FluidType, MutableTriple>((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<FluidState> 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<Float> 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 <stew.strong.420@gmail.com> Date: Mon, 5 Jun 2023 06:49:30 -0600 Subject: [PATCH 135/437] 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<RenderSection> sections, - final BlockRenderPass pass, final ChunkCameraContext c) { - + private ChunkRenderBounds injectBuildDrawBatches( + final RenderSection section, final Operation<ChunkRenderBounds> getBounds, final List<RenderSection> 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 <stew.strong.420@gmail.com> Date: Thu, 8 Jun 2023 19:05:50 -0600 Subject: [PATCH 136/437] 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 = "<init>(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 = "<init>", 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 <rubydesic@gmail.com> Date: Fri, 9 Jun 2023 02:54:34 -0400 Subject: [PATCH 137/437] 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 <rubydesic@gmail.com> Date: Fri, 9 Jun 2023 03:01:56 -0400 Subject: [PATCH 138/437] 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 377c5ddb454bcfd112d49faf842f87f3c9b81178 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Fri, 9 Jun 2023 03:58:46 -0400 Subject: [PATCH 139/437] Update bug_report.yml --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 36fbbc86e..5d9341bbf 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -9,6 +9,7 @@ body: label: This issue occurs when only Valkyrien Skies and addons are installed and no other mods options: - label: I have tested this issue and it occurs when no other mods are installed + required: true - type: dropdown attributes: label: Minecraft Version From af75aac04897e73b72332603ece303288a302f4c Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Fri, 9 Jun 2023 04:46:41 -0400 Subject: [PATCH 140/437] 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<String> 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 <rubydesic@gmail.com> Date: Fri, 9 Jun 2023 04:46:53 -0400 Subject: [PATCH 141/437] 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 6e2c44f6649734d1c7bc06564121f984af65f442 Mon Sep 17 00:00:00 2001 From: millennIumAMbiguity <37588844+millennIumAMbiguity@users.noreply.github.com> Date: Thu, 15 Jun 2023 00:53:44 +0200 Subject: [PATCH 142/437] Added entry for key.valkyrienskies.ship_cruise to en_us.json (#495) --- common/src/main/resources/assets/valkyrienskies/lang/en_us.json | 1 + 1 file changed, 1 insertion(+) 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..38d13de9d 100644 --- a/common/src/main/resources/assets/valkyrienskies/lang/en_us.json +++ b/common/src/main/resources/assets/valkyrienskies/lang/en_us.json @@ -1,4 +1,5 @@ { + "key.valkyrienskies.ship_cruise": "Cruise", "key.valkyrienskies.ship_down": "Descend", "category.valkyrienskies.driving": "Driving", "block.valkyrienskies.test_chair": "Debug Chair", From 3450e9e705ee5c4a905f86bc0e8535419dd4f82f Mon Sep 17 00:00:00 2001 From: Thibault <76521322+thibault0712@users.noreply.github.com> Date: Thu, 15 Jun 2023 00:54:19 +0200 Subject: [PATCH 143/437] Add Troubleshooting (#447) * Add Troubleshooting * Update README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 248ac0aae..c0ab5778b 100644 --- a/README.md +++ b/README.md @@ -40,3 +40,8 @@ independent code lives in [vs-core](https://github.com/ValkyrienSkies/vs-core). ### Running Forge in dev environment Occasionally forge will break in strange ways. When this occurs, delete all the `build` folders, delete the `.gradle` folder of the `forge` project, and then refresh gradle. + +### Change JVM arguments for small computers +`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` From cbd793dc28850522915791eef1bf6a9560539bd4 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Sat, 24 Jun 2023 00:18:32 +0200 Subject: [PATCH 144/437] Multiplayer command suggestion fixed --- .../feature/commands/MixinArgumentTypes.java | 26 +++++++++++++++++++ .../mod/common/command/ShipArgument.kt | 17 ++++++++++++ .../mod/common/command/VSCommands.kt | 12 +++++++++ .../valkyrienskies-common.mixins.json | 1 + 4 files changed, 56 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypes.java 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 new file mode 100644 index 000000000..05d072a3c --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/commands/MixinArgumentTypes.java @@ -0,0 +1,26 @@ +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 <T extends ArgumentType<?>> void register(final String id, final Class<T> argClass, final ArgumentSerializer<T> 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/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/ShipArgument.kt index e73a5a5f7..a969ab222 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,5 +1,6 @@ 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 @@ -7,6 +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.TranslatableComponent import org.valkyrienskies.core.api.ships.Ship import org.valkyrienskies.mod.mixinducks.feature.command.VSCommandSource @@ -87,4 +90,18 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType } override fun getExamples(): Collection<String> = EXAMPLES + + object Serializer : ArgumentSerializer<ShipArgument> { + 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 134c273df..a4ae3076c 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,6 +12,8 @@ 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.TranslatableComponent import net.minecraft.world.entity.Entity import net.minecraft.world.phys.BlockHitResult @@ -44,6 +46,16 @@ 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<VSCommandSource>(name) diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index c4b4a2c09..7a5921385 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.MixinArgumentTypes", "feature.commands.MixinCommandSourceStack", "feature.conduit_fix.ConduitMixin", "feature.container_distance_check.MixinRandomizableContainerBlockEntity", From cc5f70f6919fd1e9cbf166f7da1d9314c8d22848 Mon Sep 17 00:00:00 2001 From: TechTastic <74630543+TechTastic@users.noreply.github.com> Date: Thu, 13 Jul 2023 23:12:39 -0500 Subject: [PATCH 145/437] Mass Tooltip for All BlockItems (#529) * Added Tooltip to All BlockItems to display associated Block masses Added translation key for "Mass" * Added Unit Specification * Improved Config with optional Mass Tooltip Visibility always, only when advanced tootips are enabled, or disabled Created MassTooltipVisibility to store said value --- .../feature/mass_tooltip/MixinBlockItem.java | 71 +++++++++++++++++++ .../mass_tooltip/MassTooltipVisibility.java | 14 ++++ .../mod/common/config/VSGameConfig.kt | 15 ++++ .../assets/valkyrienskies/lang/en_us.json | 3 +- .../valkyrienskies-common.mixins.json | 1 + 5 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/mass_tooltip/MixinBlockItem.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/mass_tooltip/MassTooltipVisibility.java 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 new file mode 100644 index 000000000..fa9eac7dc --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/mass_tooltip/MixinBlockItem.java @@ -0,0 +1,71 @@ +package org.valkyrienskies.mod.mixin.feature.mass_tooltip; + +import java.util.List; +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; +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.valkyrienskies.mod.common.BlockStateInfo; +import org.valkyrienskies.mod.common.config.VSGameConfig; +import org.valkyrienskies.mod.mixinducks.feature.mass_tooltip.MassTooltipVisibility; +import oshi.util.tuples.Pair; + +@Mixin(BlockItem.class) +public class MixinBlockItem { + @Inject(method = "appendHoverText", at = @At("HEAD")) + private void ValkyrienSkies$addMassToTooltip(final ItemStack itemStack, final Level level, + final List<Component> list, final TooltipFlag tooltipFlag, final CallbackInfo ci) { + final MassTooltipVisibility visibility = VSGameConfig.CLIENT.getTooltip().getMassTooltipVisibility(); + if (visibility.isVisible(tooltipFlag)) { + try { + final BlockItem item = (BlockItem) itemStack.getItem(); + final Double mass = + Objects.requireNonNull(BlockStateInfo.INSTANCE.get(item.getBlock().defaultBlockState())) + .getFirst(); + list.add(new TranslatableComponent("tooltip.valkyrienskies.mass") + .append(VSGameConfig.CLIENT.getTooltip().getUseImperialUnits() ? + getImperialText(mass) : ": " + mass + "kg").withStyle(ChatFormatting.DARK_GRAY)); + } catch (final Exception ignored) { + } + } + } + + @Unique + private Pair<Integer, Integer> convertToImperial(final double mass) { + final double ounces = mass * 35.274; + final double pounds = Math.floor(ounces / 16); + return new Pair<>( + (int) pounds, + (int) Math.floor((ounces / 16 - pounds) * 16) + ); + } + + @Unique + private String getImperialText(final double mass) { + String impText = ": "; + final Pair<Integer, Integer> imperial = convertToImperial(mass); + if (imperial.getA() > 0) { + impText = impText + imperial.getA(); + if (imperial.getA() == 1) { + impText = impText + "lb. "; + } else { + impText = impText + "lbs. "; + } + } + + if (imperial.getB() > 0) { + impText = impText + imperial.getB() + "oz."; + } + + return impText; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/mass_tooltip/MassTooltipVisibility.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/mass_tooltip/MassTooltipVisibility.java new file mode 100644 index 000000000..1f28550df --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/feature/mass_tooltip/MassTooltipVisibility.java @@ -0,0 +1,14 @@ +package org.valkyrienskies.mod.mixinducks.feature.mass_tooltip; + +import net.minecraft.world.item.TooltipFlag; + +public enum MassTooltipVisibility { + ALWAYS, + ADVANCED, + DISABLED; + + public boolean isVisible(final TooltipFlag flag) { + return this.equals(ALWAYS) || + (this.equals(ADVANCED) && flag.isAdvanced()); + } +} 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 6303849de..ff408f762 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 @@ -1,6 +1,7 @@ package org.valkyrienskies.mod.common.config import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema +import org.valkyrienskies.mod.mixinducks.feature.mass_tooltip.MassTooltipVisibility object VSGameConfig { @@ -14,6 +15,8 @@ object VSGameConfig { val COMMON = Common() class Client { + val Tooltip = TOOLTIP() + @JsonSchema(description = "Renders the VS2 debug HUD with TPS") var renderDebugText = false @@ -21,6 +24,18 @@ object VSGameConfig { description = "Recommend ship slugs in mc commands where player names could be used ex. /tp ship-name wich could pollute user autocomplete" ) var recommendSlugsInMcCommands = true + + class TOOLTIP { + @JsonSchema( + description = "Set when the Mass Tooltip is Visible" + ) + var massTooltipVisibility = MassTooltipVisibility.ADVANCED + + @JsonSchema( + description = "Use Imperial Units to show Mass" + ) + var useImperialUnits = false + } } class Server { 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 38d13de9d..746c85fa4 100644 --- a/common/src/main/resources/assets/valkyrienskies/lang/en_us.json +++ b/common/src/main/resources/assets/valkyrienskies/lang/en_us.json @@ -17,5 +17,6 @@ "command.valkyrienskies.mc_teleport.can_only_teleport_to_one_ship": "Can only teleport to exactly 1 ship", "command.valkyrienskies.get_ship.success": "Found ship with slug %s", "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!" + "command.valkyrienskies.get_ship.only_usable_by_entities": "/vs get-ship can only be run by entities!", + "tooltip.valkyrienskies.mass": "Mass" } diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 7a5921385..ec76eb533 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -30,6 +30,7 @@ "feature.fluid_escaping_ship_config.MixinFlowingFluid", "feature.get_entities.MixinLevel", "feature.ladders.MixinLivingEntity", + "feature.mass_tooltip.MixinBlockItem", "feature.mob_spawning.NaturalSpawnerMixin", "feature.render_pathfinding.MixinDebugPackets", "feature.screen_distance_check.MixinScreenHandler", From 888586a559f121da31894ced83523887a3482de1 Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Sat, 15 Jul 2023 16:03:45 -0700 Subject: [PATCH 146/437] 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 61be449d8b016326ec205b9376e24ee47dc66271 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 15 Jul 2023 23:31:19 -0600 Subject: [PATCH 147/437] Revert "Updated architectury plugin and loom to latest" This reverts commit 888586a559f121da31894ced83523887a3482de1. --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 2598e178c..a271cfecd 100644 --- a/build.gradle +++ b/build.gradle @@ -7,8 +7,8 @@ buildscript { plugins { // Needed for Forge+Fabric - id "architectury-plugin" version "3.4.146" - id "dev.architectury.loom" version "1.1.346" apply false + id "architectury-plugin" version "3.4.143" + id "dev.architectury.loom" version "1.0.306" 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 06f3d357504861adf9d426e85ac5e7adf7f0dc32 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 15 Jul 2023 23:58:43 -0600 Subject: [PATCH 148/437] Updated vs-core --- 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 6e4d92bbe18f767272c219142b05a16626962447 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 16 Jul 2023 00:29:05 -0600 Subject: [PATCH 149/437] Empty commit to rerun actions From d96ae70217fc39bdb44cf51c4a82017d9b7764b1 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 16 Jul 2023 00:34:59 -0600 Subject: [PATCH 150/437] Empty commit to rerun actions again From 272da42a67415e4165241a858bb87c5890f40f9d Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 16 Jul 2023 00:42:56 -0600 Subject: [PATCH 151/437] Empty commit to rerun actions again again From dc32378baee87278b721efec8b29a9c61d2baf0a Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 16 Jul 2023 01:25:30 -0600 Subject: [PATCH 152/437] Updated version to 2.1.0-beta.14 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index bd6c37e9a..110a48fea 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.0-beta.13 +mod_version=2.1.0-beta.14 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From 3faaf10908ce4a1035962e988a13e7a326748bdf Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 16 Jul 2023 04:32:40 -0600 Subject: [PATCH 153/437] Removed saveactions from intellij recommended plugins --- .gitignore | 2 -- .idea/externalDependencies.xml | 3 +-- .idea/saveactions_settings.xml | 19 ------------------- 3 files changed, 1 insertion(+), 23 deletions(-) delete mode 100644 .idea/saveactions_settings.xml diff --git a/.gitignore b/.gitignore index 236047a85..299156b30 100644 --- a/.gitignore +++ b/.gitignore @@ -18,8 +18,6 @@ out !.idea/codeStyles/ # inspection profile !.idea/inspectionProfiles/ -# saveactions config -!.idea/saveactions_settings.xml # recommended plugins !.idea/externalDependencies.xml diff --git a/.idea/externalDependencies.xml b/.idea/externalDependencies.xml index 591c24778..14eb88d8a 100644 --- a/.idea/externalDependencies.xml +++ b/.idea/externalDependencies.xml @@ -2,9 +2,8 @@ <project version="4"> <component name="ExternalDependencies"> <plugin id="com.demonwav.minecraft-dev" /> - <plugin id="com.dubreuia" /> <plugin id="kotest-plugin-intellij" /> <plugin id="org.jetbrains.kotlin" /> <plugin id="org.toml.lang" /> </component> -</project> \ No newline at end of file +</project> diff --git a/.idea/saveactions_settings.xml b/.idea/saveactions_settings.xml deleted file mode 100644 index c7c04f56b..000000000 --- a/.idea/saveactions_settings.xml +++ /dev/null @@ -1,19 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project version="4"> - <component name="SaveActionSettings"> - <option name="actions"> - <set> - <option value="activate" /> - <option value="activateOnBatch" /> - <option value="noActionIfCompileErrors" /> - <option value="organizeImports" /> - <option value="reformat" /> - <option value="localCanBeFinal" /> - <option value="localCanBeFinalExceptImplicit" /> - <option value="useBlocks" /> - <option value="explicitTypeCanBeDiamond" /> - </set> - </option> - <option name="configurationPath" value="" /> - </component> -</project> From acba7d4175d48c1fd66dd6cd74c7c1d3d5abb1d1 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 18 Jul 2023 19:52:02 -0600 Subject: [PATCH 154/437] Let players crouch walk on ships --- .../feature/entity_collision/MixinPlayer.java | 22 +++++++++++++++++++ .../valkyrienskies-common.mixins.json | 1 + 2 files changed, 23 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinPlayer.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinPlayer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinPlayer.java new file mode 100644 index 000000000..766506f29 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/entity_collision/MixinPlayer.java @@ -0,0 +1,22 @@ +package org.valkyrienskies.mod.mixin.feature.entity_collision; + +import net.minecraft.world.entity.MoverType; +import net.minecraft.world.entity.player.Player; +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.callback.CallbackInfoReturnable; +import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider; + +@Mixin(Player.class) +public abstract class MixinPlayer implements IEntityDraggingInformationProvider { + // Allow players to crouch walk on ships + @Inject(method = "maybeBackOffFromEdge", at = @At("HEAD"), cancellable = true) + private void preMaybeBackOffFromEdge(final Vec3 vec3, final MoverType moverType, + final CallbackInfoReturnable<Vec3> callbackInfoReturnable) { + if (getDraggingInformation().isEntityBeingDraggedByAShip()) { + callbackInfoReturnable.setReturnValue(vec3); + } + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index ec76eb533..7218459c0 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -25,6 +25,7 @@ "feature.dispensers.MixinDefaultDispenseItemBehavior", "feature.distance_replace.MixinEntity", "feature.entity_collision.MixinEntity", + "feature.entity_collision.MixinPlayer", "feature.explosions.MixinExplosion", "feature.fire_between_ship_and_world.LavaFluidMixin", "feature.fluid_escaping_ship_config.MixinFlowingFluid", From c4d068cf4b0c01c57dc0d826f33a35449b164917 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 18 Jul 2023 20:58:33 -0600 Subject: [PATCH 155/437] 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<String> = EXAMPLES - - object Serializer : ArgumentSerializer<ShipArgument> { - 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<VSCommandSource>(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 fdd73b4a494f897afc9959f5258a471628754a28 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 19 Jul 2023 19:45:31 -0600 Subject: [PATCH 156/437] Updated version to 2.1.0-beta.15 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 110a48fea..c638a1010 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.0-beta.14 +mod_version=2.1.0-beta.15 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From b2de01d9de117e513e032af6267a57bdd2c9c1aa Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 19 Jul 2023 19:50:21 -0600 Subject: [PATCH 157/437] 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 e2e1dc7b3832eaf7b36160ca70fb06e14406fe0b Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Tue, 1 Aug 2023 12:39:15 +0200 Subject: [PATCH 158/437] Update misc.json (#547) * Update misc.json bedrock weight more realistic now * Update misc.json coal is normal again --- .../data/valkyrienskies/vs_mass/misc.json | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) 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 dc34f5392..065453df3 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json @@ -1,35 +1,35 @@ [ { "tag": "minecraft:fire", - "mass": 0.0 + "mass": 0.1 }, { "tag": "minecraft:portals", - "mass": 0.0 + "mass": 0.1 }, { "block": "minecraft:bedrock", - "mass": 0.0 + "mass": 3000.0 }, { "block": "minecraft:barrier", - "mass": 0.0 + "mass": 0.1 }, { "block": "minecraft:command_block", - "mass": 0.0 + "mass": 0.1 }, { "block": "minecraft:chain_command_block", - "mass": 0.0 + "mass": 0.1 }, { "block": "minecraft:repeating_command_block", - "mass": 0.0 + "mass": 0.1 }, { "block": "minecraft:structure_block", - "mass": 0.0 + "mass": 0.1 }, { "block": "minecraft:gold_block", @@ -105,7 +105,7 @@ }, { "block": "minecraft:cobweb", - "mass": 0.0 + "mass": 0.1 }, { "block": "minecraft:hay_block", From e957ee623a38f0eec0fb877aad97a3ebfc6fb761 Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Tue, 1 Aug 2023 12:39:28 +0200 Subject: [PATCH 159/437] Update redstone_components.json (#546) --- .../data/valkyrienskies/vs_mass/redstone_components.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 994ede13d..1e0424176 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 @@ -41,11 +41,11 @@ }, { "block": "minecraft:piston_head", - "mass": 0.0 + "mass": 0.1 }, { "block": "minecraft:moving_piston", - "mass": 0.0 + "mass": 0.1 }, { "block": "minecraft:tnt", @@ -97,7 +97,7 @@ }, { "block": "minecraft:tripwire", - "mass": 0.0 + "mass": 0.1 }, { "block": "minecraft:daylight_detector", From 11829d76c0cbcbe4397a402aacdcdb9c21e915f1 Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Tue, 1 Aug 2023 12:39:34 +0200 Subject: [PATCH 160/437] Update 1_18_blocks.json (#545) --- .../main/resources/data/valkyrienskies/vs_mass/1_18_blocks.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 ab957f9e5..9b692c487 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 @@ -1,7 +1,7 @@ [ { "block": "minecraft:light", - "mass": 0.0 + "mass": 0.1 }, { "block": "minecraft:rooted_dirt", From 2aece1130b5bc4e5de247891c7b6c65cf7eaf8cb Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 15 Aug 2023 06:25:58 -0600 Subject: [PATCH 161/437] Got physics kind of working, but ships fall through the ground --- forge/build.gradle | 4 ++-- vs-core | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index 7ae7976cb..cfed440f8 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -100,11 +100,11 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+eb3ae45554") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+dfd312c52f") { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+0b6f5db802") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+afc0ffa218") { transitive = false } diff --git a/vs-core b/vs-core index 9c5b345b1..325cca175 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 9c5b345b16b72c9c2dcf34678f24ec0d9a0efdee +Subproject commit 325cca17540876a8f416abb1018252a67362901b From eafc67b704432619669acf3a8a3514e0c59673ed Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 15 Aug 2023 08:10:50 -0600 Subject: [PATCH 162/437] ITS WORKING! --- forge/build.gradle | 2 +- vs-core | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index cfed440f8..f254edaca 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -100,7 +100,7 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+dfd312c52f") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+7071201df7") { transitive = false } diff --git a/vs-core b/vs-core index 325cca175..55b982748 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 325cca17540876a8f416abb1018252a67362901b +Subproject commit 55b982748440e84914b05086013cb57bc8aae560 From 0ff8f3f11953d8e4449ed6f22deea6e1cdeb1821 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 15 Aug 2023 20:45:55 -0600 Subject: [PATCH 163/437] Fixed world unload mem leak --- .../valkyrienskies/mod/mixin/server/MixinMinecraftServer.java | 1 + vs-core | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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..3c81ec086 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 @@ -189,6 +189,7 @@ private void postTick(final CallbackInfo ci) { private void preStopServer(final CallbackInfo ci) { if (vsPipeline != null) { vsPipeline.setDeleteResources(true); + vsPipeline.setArePhysicsRunning(true); } shipWorld = null; } diff --git a/vs-core b/vs-core index 55b982748..2e6e4722a 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 55b982748440e84914b05086013cb57bc8aae560 +Subproject commit 2e6e4722ae994dcbb416ecf2982ec395c17d28cd From 63a3b072d99fd6b8493c1c8b614014a533b544d2 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 16 Aug 2023 00:40:18 -0600 Subject: [PATCH 164/437] Use air chunks instead of empty updates --- forge/build.gradle | 4 ++-- vs-core | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index f254edaca..7168170b5 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -100,11 +100,11 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+7071201df7") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+61e725b93e") { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+afc0ffa218") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+63b53cc647") { transitive = false } diff --git a/vs-core b/vs-core index 2e6e4722a..00a2c0e58 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 2e6e4722ae994dcbb416ecf2982ec395c17d28cd +Subproject commit 00a2c0e58501c92179fcc22060adc255d7e023d0 From c56654feef8f8f48462779f456891567e8372589 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 16 Aug 2023 02:47:47 -0600 Subject: [PATCH 165/437] Beginning of VSPhysicsEntity --- .../mod/common/ValkyrienSkiesMod.kt | 3 ++ .../mod/common/entity/VSPhysicsEntity.kt | 20 +++++++++++++ .../common/item/PhysicsEntityCreatorItem.kt | 28 +++++++++++++++++++ .../fabric/common/ValkyrienSkiesModFabric.kt | 27 ++++++++++++++++++ .../forge/common/ValkyrienSkiesModForge.kt | 24 ++++++++++++++++ vs-core | 2 +- 6 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/entity/VSPhysicsEntity.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt 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..7b7303762 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -14,6 +14,7 @@ import org.valkyrienskies.core.impl.hooks.VSEvents import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.config.VSGameConfig import org.valkyrienskies.mod.common.entity.ShipMountingEntity +import org.valkyrienskies.mod.common.entity.VSPhysicsEntity import org.valkyrienskies.mod.common.networking.VSGamePackets import org.valkyrienskies.mod.common.util.GameTickForceApplier @@ -27,7 +28,9 @@ object ValkyrienSkiesMod { lateinit var SHIP_CREATOR_ITEM: Item lateinit var SHIP_ASSEMBLER_ITEM: Item lateinit var SHIP_CREATOR_ITEM_SMALLER: Item + lateinit var PHYSICS_ENTITY_CREATOR_ITEM: Item lateinit var SHIP_MOUNTING_ENTITY_TYPE: EntityType<ShipMountingEntity> + lateinit var PHYSICS_ENTITY_TYPE: EntityType<VSPhysicsEntity> lateinit var TEST_HINGE_BLOCK_ENTITY_TYPE: BlockEntityType<TestHingeBlockEntity> @JvmStatic 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 new file mode 100644 index 000000000..7ab39df64 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/VSPhysicsEntity.kt @@ -0,0 +1,20 @@ +package org.valkyrienskies.mod.common.entity + +import net.minecraft.nbt.CompoundTag +import net.minecraft.network.protocol.Packet +import net.minecraft.network.protocol.game.ClientboundAddEntityPacket +import net.minecraft.world.entity.Entity +import net.minecraft.world.entity.EntityType +import net.minecraft.world.level.Level + +class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity(type, level) { + override fun defineSynchedData() {} + + override fun readAdditionalSaveData(compoundTag: CompoundTag) {} + + override fun addAdditionalSaveData(compoundTag: CompoundTag) {} + + override fun getAddEntityPacket(): Packet<*> { + return ClientboundAddEntityPacket(this) + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt new file mode 100644 index 000000000..394492d4f --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt @@ -0,0 +1,28 @@ +package org.valkyrienskies.mod.common.item + +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.InteractionResult +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.context.UseOnContext +import org.valkyrienskies.mod.common.ValkyrienSkiesMod + +class PhysicsEntityCreatorItem( + properties: Properties +) : Item(properties) { + override fun isFoil(stack: ItemStack): Boolean { + return true + } + + override fun useOn(ctx: UseOnContext): InteractionResult { + val level = ctx.level as? ServerLevel ?: return super.useOn(ctx) + + if (!level.isClientSide) { + val entity = ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE.create(level)!! + entity.setPos(ctx.clickLocation) + level.addFreshEntity(entity) + } + + return super.useOn(ctx) + } +} 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 4336e0a3d..6da405a80 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 @@ -37,8 +37,10 @@ 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.VSPhysicsEntity import org.valkyrienskies.mod.common.entity.handling.VSEntityManager import org.valkyrienskies.mod.common.hooks.VSGameEvents +import org.valkyrienskies.mod.common.item.PhysicsEntityCreatorItem import org.valkyrienskies.mod.common.item.ShipAssemblerItem import org.valkyrienskies.mod.common.item.ShipCreatorItem import java.util.concurrent.CompletableFuture @@ -69,12 +71,20 @@ class ValkyrienSkiesModFabric : ModInitializer { { VSGameConfig.SERVER.miniShipSize }, { VSGameConfig.SERVER.minScaling } ) + ValkyrienSkiesMod.PHYSICS_ENTITY_CREATOR_ITEM = PhysicsEntityCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC)) ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE = EntityType.Builder.of( ::ShipMountingEntity, MobCategory.MISC ).sized(.3f, .3f) .build(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_mounting_entity").toString()) + + ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE = EntityType.Builder.of( + ::VSPhysicsEntity, + MobCategory.MISC + ).sized(.3f, .3f) + .build(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "vs_physics_entity").toString()) + ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE = FabricBlockEntityTypeBuilder.create(::TestHingeBlockEntity, ValkyrienSkiesMod.TEST_HINGE).build() @@ -110,10 +120,18 @@ class ValkyrienSkiesModFabric : ModInitializer { Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_creator_smaller"), ValkyrienSkiesMod.SHIP_CREATOR_ITEM_SMALLER ) + Registry.register( + Registry.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"), ValkyrienSkiesMod.SHIP_MOUNTING_ENTITY_TYPE ) + Registry.register( + Registry.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"), ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE @@ -169,6 +187,15 @@ class ValkyrienSkiesModFabric : ModInitializer { ) } + // TODO: Add a proper debug renderer + EntityRendererRegistry.register( + ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE + ) { context: Context -> + EmptyRenderer( + context + ) + } + VSKeyBindings.clientSetup { KeyBindingHelper.registerKeyBinding(it) } 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 c52ab06f5..c11d03880 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 @@ -41,8 +41,10 @@ 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.VSPhysicsEntity import org.valkyrienskies.mod.common.entity.handling.VSEntityManager import org.valkyrienskies.mod.common.hooks.VSGameEvents +import org.valkyrienskies.mod.common.item.PhysicsEntityCreatorItem import org.valkyrienskies.mod.common.item.ShipAssemblerItem import org.valkyrienskies.mod.common.item.ShipCreatorItem import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig @@ -59,7 +61,9 @@ class ValkyrienSkiesModForge { private val TEST_WING_REGISTRY: RegistryObject<Block> private val SHIP_CREATOR_ITEM_REGISTRY: RegistryObject<Item> private val SHIP_CREATOR_SMALLER_ITEM_REGISTRY: RegistryObject<Item> + private val PHYSICS_ENTITY_CREATOR_ITEM_REGISTRY: RegistryObject<Item> private val SHIP_MOUNTING_ENTITY_REGISTRY: RegistryObject<EntityType<ShipMountingEntity>> + private val PHYSICS_ENTITY_TYPE_REGISTRY: RegistryObject<EntityType<VSPhysicsEntity>> private val SHIP_ASSEMBLER_ITEM_REGISTRY: RegistryObject<Item> private val TEST_HINGE_BLOCK_ENTITY_TYPE_REGISTRY: RegistryObject<BlockEntityType<TestHingeBlockEntity>> @@ -119,6 +123,14 @@ class ValkyrienSkiesModForge { { VSGameConfig.SERVER.minScaling } ) } + + PHYSICS_ENTITY_CREATOR_ITEM_REGISTRY = + ITEMS.register("physics_entity_creator") { + PhysicsEntityCreatorItem( + Properties().tab(CreativeModeTab.TAB_MISC), + ) + } + SHIP_MOUNTING_ENTITY_REGISTRY = ENTITIES.register("ship_mounting_entity") { EntityType.Builder.of( ::ShipMountingEntity, @@ -126,6 +138,15 @@ class ValkyrienSkiesModForge { ).sized(.3f, .3f) .build(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_mounting_entity").toString()) } + + PHYSICS_ENTITY_TYPE_REGISTRY = ENTITIES.register("vs_physics_entity") { + EntityType.Builder.of( + ::VSPhysicsEntity, + MobCategory.MISC + ).sized(.3f, .3f) + .build(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "vs_physics_entity").toString()) + } + SHIP_ASSEMBLER_ITEM_REGISTRY = ITEMS.register("ship_assembler") { ShipAssemblerItem(Properties().tab(CreativeModeTab.TAB_MISC)) } TEST_HINGE_BLOCK_ENTITY_TYPE_REGISTRY = BLOCK_ENTITIES.register("test_hinge_block_entity") { @@ -146,6 +167,8 @@ class ValkyrienSkiesModForge { private fun entityRenderers(event: EntityRenderersEvent.RegisterRenderers) { event.registerEntityRenderer(SHIP_MOUNTING_ENTITY_REGISTRY.get(), ::EmptyRenderer) + // TODO: Add a renderer for physics entity + event.registerEntityRenderer(PHYSICS_ENTITY_TYPE_REGISTRY.get(), ::EmptyRenderer) } private fun registerBlockAndItem(registryName: String, blockSupplier: () -> Block): RegistryObject<Block> { @@ -174,6 +197,7 @@ class ValkyrienSkiesModForge { 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.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() } diff --git a/vs-core b/vs-core index 00a2c0e58..962bb82ed 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 00a2c0e58501c92179fcc22060adc255d7e023d0 +Subproject commit 962bb82edd93065626d95d697842fae1e9ad8e1e From 19e3aedf67e507b667d75139c89d030be451c62e Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 16 Aug 2023 03:05:13 -0600 Subject: [PATCH 166/437] Added debug renderer for VSPhysicsEntity --- .../mod/client/PhysicsEmptyRenderer.kt | 52 +++++++++++++++++++ .../fabric/common/ValkyrienSkiesModFabric.kt | 4 +- .../forge/common/ValkyrienSkiesModForge.kt | 4 +- 3 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/client/PhysicsEmptyRenderer.kt diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/client/PhysicsEmptyRenderer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/client/PhysicsEmptyRenderer.kt new file mode 100644 index 000000000..158bc7289 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/client/PhysicsEmptyRenderer.kt @@ -0,0 +1,52 @@ +package org.valkyrienskies.mod.client + +import com.mojang.blaze3d.vertex.PoseStack +import net.minecraft.client.Minecraft +import net.minecraft.client.renderer.ItemBlockRenderTypes +import net.minecraft.client.renderer.MultiBufferSource +import net.minecraft.client.renderer.entity.EntityRenderer +import net.minecraft.client.renderer.entity.EntityRendererProvider +import net.minecraft.client.renderer.texture.OverlayTexture +import net.minecraft.client.renderer.texture.TextureAtlas +import net.minecraft.core.BlockPos +import net.minecraft.resources.ResourceLocation +import net.minecraft.world.level.block.Blocks +import net.minecraft.world.level.block.RenderShape.INVISIBLE +import net.minecraft.world.level.block.RenderShape.MODEL +import org.valkyrienskies.mod.common.entity.VSPhysicsEntity +import java.util.Random + +class PhysicsEmptyRenderer(context: EntityRendererProvider.Context) : EntityRenderer<VSPhysicsEntity>(context) { + override fun render( + fallingBlockEntity: VSPhysicsEntity, f: Float, g: Float, poseStack: PoseStack, + multiBufferSource: MultiBufferSource, i: Int + ) { + val blockState = Blocks.DARK_OAK_WOOD.defaultBlockState() + if (blockState.renderShape != MODEL) { + return + } + val level = fallingBlockEntity.getLevel() + if (blockState === level.getBlockState( + fallingBlockEntity.blockPosition() + ) || blockState.renderShape == INVISIBLE + ) { + return + } + poseStack.pushPose() + val blockPos = BlockPos(fallingBlockEntity.x, fallingBlockEntity.boundingBox.maxY, fallingBlockEntity.z) + poseStack.translate(-0.5, 0.0, -0.5) + val blockRenderDispatcher = Minecraft.getInstance().blockRenderer + blockRenderDispatcher.modelRenderer.tesselateBlock( + level, blockRenderDispatcher.getBlockModel(blockState), blockState, blockPos, poseStack, + multiBufferSource.getBuffer( + ItemBlockRenderTypes.getMovingBlockRenderType(blockState) + ), false, Random(), blockState.getSeed(BlockPos.ZERO), OverlayTexture.NO_OVERLAY + ) + poseStack.popPose() + super.render(fallingBlockEntity, f, g, poseStack, multiBufferSource, i) + } + + override fun getTextureLocation(entity: VSPhysicsEntity): ResourceLocation { + return TextureAtlas.LOCATION_BLOCKS + } +} 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 6da405a80..a6179af0e 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 @@ -25,6 +25,7 @@ import net.minecraft.world.item.Item.Properties import net.minecraft.world.level.block.Block import org.valkyrienskies.core.apigame.VSCoreFactory import org.valkyrienskies.mod.client.EmptyRenderer +import org.valkyrienskies.mod.client.PhysicsEmptyRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestFlapBlock @@ -187,11 +188,10 @@ class ValkyrienSkiesModFabric : ModInitializer { ) } - // TODO: Add a proper debug renderer EntityRendererRegistry.register( ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE ) { context: Context -> - EmptyRenderer( + PhysicsEmptyRenderer( context ) } 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 c11d03880..517451c8c 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 @@ -29,6 +29,7 @@ import org.valkyrienskies.core.apigame.VSCoreFactory import org.valkyrienskies.core.impl.config.VSConfigClass import org.valkyrienskies.core.impl.config.VSCoreConfig import org.valkyrienskies.mod.client.EmptyRenderer +import org.valkyrienskies.mod.client.PhysicsEmptyRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestFlapBlock @@ -167,8 +168,7 @@ class ValkyrienSkiesModForge { private fun entityRenderers(event: EntityRenderersEvent.RegisterRenderers) { event.registerEntityRenderer(SHIP_MOUNTING_ENTITY_REGISTRY.get(), ::EmptyRenderer) - // TODO: Add a renderer for physics entity - event.registerEntityRenderer(PHYSICS_ENTITY_TYPE_REGISTRY.get(), ::EmptyRenderer) + event.registerEntityRenderer(PHYSICS_ENTITY_TYPE_REGISTRY.get(), ::PhysicsEmptyRenderer) } private fun registerBlockAndItem(registryName: String, blockSupplier: () -> Block): RegistryObject<Block> { From a57ea935a2a95fa37cbe552b31c3b6e6b48441cf Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 16 Aug 2023 03:36:43 -0600 Subject: [PATCH 167/437] Added shipId and rotation fields to VSPhysicsEntity --- ...Renderer.kt => VSPhysicsEntityRenderer.kt} | 8 ++-- .../mod/common/entity/VSPhysicsEntity.kt | 44 +++++++++++++++++-- .../common/item/PhysicsEntityCreatorItem.kt | 4 ++ .../mod/common/world/DummyShipWorldServer.kt | 4 ++ .../fabric/common/ValkyrienSkiesModFabric.kt | 4 +- .../forge/common/ValkyrienSkiesModForge.kt | 4 +- 6 files changed, 58 insertions(+), 10 deletions(-) rename common/src/main/kotlin/org/valkyrienskies/mod/client/{PhysicsEmptyRenderer.kt => VSPhysicsEntityRenderer.kt} (86%) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/client/PhysicsEmptyRenderer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt similarity index 86% rename from common/src/main/kotlin/org/valkyrienskies/mod/client/PhysicsEmptyRenderer.kt rename to common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt index 158bc7289..a71661be4 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/client/PhysicsEmptyRenderer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt @@ -7,16 +7,17 @@ import net.minecraft.client.renderer.MultiBufferSource import net.minecraft.client.renderer.entity.EntityRenderer import net.minecraft.client.renderer.entity.EntityRendererProvider import net.minecraft.client.renderer.texture.OverlayTexture -import net.minecraft.client.renderer.texture.TextureAtlas import net.minecraft.core.BlockPos import net.minecraft.resources.ResourceLocation +import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.RenderShape.INVISIBLE import net.minecraft.world.level.block.RenderShape.MODEL import org.valkyrienskies.mod.common.entity.VSPhysicsEntity +import org.valkyrienskies.mod.common.util.toMinecraft import java.util.Random -class PhysicsEmptyRenderer(context: EntityRendererProvider.Context) : EntityRenderer<VSPhysicsEntity>(context) { +class VSPhysicsEntityRenderer(context: EntityRendererProvider.Context) : EntityRenderer<VSPhysicsEntity>(context) { override fun render( fallingBlockEntity: VSPhysicsEntity, f: Float, g: Float, poseStack: PoseStack, multiBufferSource: MultiBufferSource, i: Int @@ -34,6 +35,7 @@ class PhysicsEmptyRenderer(context: EntityRendererProvider.Context) : EntityRend } poseStack.pushPose() val blockPos = BlockPos(fallingBlockEntity.x, fallingBlockEntity.boundingBox.maxY, fallingBlockEntity.z) + poseStack.mulPose(fallingBlockEntity.rotation.toMinecraft()) poseStack.translate(-0.5, 0.0, -0.5) val blockRenderDispatcher = Minecraft.getInstance().blockRenderer blockRenderDispatcher.modelRenderer.tesselateBlock( @@ -47,6 +49,6 @@ class PhysicsEmptyRenderer(context: EntityRendererProvider.Context) : EntityRend } override fun getTextureLocation(entity: VSPhysicsEntity): ResourceLocation { - return TextureAtlas.LOCATION_BLOCKS + return InventoryMenu.BLOCK_ATLAS } } 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 7ab39df64..ff8d0bfcf 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 @@ -6,15 +6,53 @@ import net.minecraft.network.protocol.game.ClientboundAddEntityPacket import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType import net.minecraft.world.level.Level +import org.joml.Quaternionf +import org.joml.Quaternionfc +import org.valkyrienskies.core.api.ships.properties.ShipId class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity(type, level) { - override fun defineSynchedData() {} + private var shipId: ShipId? = null + var rotation: Quaternionfc = Quaternionf() - override fun readAdditionalSaveData(compoundTag: CompoundTag) {} + fun setShipId(shipId: ShipId) { + if (this.shipId != null) { + throw IllegalStateException("Cannot define shipId, its already defined!") + } + this.shipId = shipId + } + + override fun defineSynchedData() { + // Naw, send pos/rotation using physics packets + } + + override fun readAdditionalSaveData(compoundTag: CompoundTag) { + this.shipId = compoundTag.getLong("shipId") + } - override fun addAdditionalSaveData(compoundTag: CompoundTag) {} + override fun addAdditionalSaveData(compoundTag: CompoundTag) { + compoundTag.putLong("shipId", shipId!!) + } override fun getAddEntityPacket(): Packet<*> { return ClientboundAddEntityPacket(this) } + + override fun saveWithoutId(compoundTag: CompoundTag): CompoundTag { + compoundTag.putLong("shipId", shipId!!) + compoundTag.putFloat("rotationX", rotation.x()) + compoundTag.putFloat("rotationY", rotation.y()) + compoundTag.putFloat("rotationZ", rotation.z()) + compoundTag.putFloat("rotationW", rotation.w()) + return super.saveWithoutId(compoundTag) + } + + override fun load(compoundTag: CompoundTag) { + this.shipId = compoundTag.getLong("shipId") + val rotationX = compoundTag.getFloat("rotationX") + val rotationY = compoundTag.getFloat("rotationY") + val rotationZ = compoundTag.getFloat("rotationZ") + val rotationW = compoundTag.getFloat("rotationW") + this.rotation = Quaternionf(rotationX, rotationY, rotationZ, rotationW) + super.load(compoundTag) + } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt index 394492d4f..b3d136992 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt @@ -6,6 +6,8 @@ import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.context.UseOnContext import org.valkyrienskies.mod.common.ValkyrienSkiesMod +import org.valkyrienskies.mod.common.dimensionId +import org.valkyrienskies.mod.common.shipObjectWorld class PhysicsEntityCreatorItem( properties: Properties @@ -19,6 +21,8 @@ class PhysicsEntityCreatorItem( if (!level.isClientSide) { val entity = ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE.create(level)!! + val shipId = level.shipObjectWorld.allocateShipId(level.dimensionId) + entity.setShipId(shipId) entity.setPos(ctx.clickLocation) level.addFreshEntity(entity) } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt index d6dfbaf9f..d3dc51616 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt @@ -48,6 +48,10 @@ object DummyShipWorldServer : ServerShipWorldCore { TODO("Not yet implemented") } + override fun allocateShipId(dimensionId: DimensionId): ShipId { + TODO("Not yet implemented") + } + override fun createNewConstraint(vsConstraint: VSConstraint): VSConstraintId? { TODO("Not yet implemented") } 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 a6179af0e..50a6b9dad 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 @@ -25,7 +25,7 @@ import net.minecraft.world.item.Item.Properties import net.minecraft.world.level.block.Block import org.valkyrienskies.core.apigame.VSCoreFactory import org.valkyrienskies.mod.client.EmptyRenderer -import org.valkyrienskies.mod.client.PhysicsEmptyRenderer +import org.valkyrienskies.mod.client.VSPhysicsEntityRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestFlapBlock @@ -191,7 +191,7 @@ class ValkyrienSkiesModFabric : ModInitializer { EntityRendererRegistry.register( ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE ) { context: Context -> - PhysicsEmptyRenderer( + VSPhysicsEntityRenderer( context ) } 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 517451c8c..ee6e7b027 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 @@ -29,7 +29,7 @@ import org.valkyrienskies.core.apigame.VSCoreFactory import org.valkyrienskies.core.impl.config.VSConfigClass import org.valkyrienskies.core.impl.config.VSCoreConfig import org.valkyrienskies.mod.client.EmptyRenderer -import org.valkyrienskies.mod.client.PhysicsEmptyRenderer +import org.valkyrienskies.mod.client.VSPhysicsEntityRenderer import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestFlapBlock @@ -168,7 +168,7 @@ class ValkyrienSkiesModForge { private fun entityRenderers(event: EntityRenderersEvent.RegisterRenderers) { event.registerEntityRenderer(SHIP_MOUNTING_ENTITY_REGISTRY.get(), ::EmptyRenderer) - event.registerEntityRenderer(PHYSICS_ENTITY_TYPE_REGISTRY.get(), ::PhysicsEmptyRenderer) + event.registerEntityRenderer(PHYSICS_ENTITY_TYPE_REGISTRY.get(), ::VSPhysicsEntityRenderer) } private fun registerBlockAndItem(registryName: String, blockSupplier: () -> Block): RegistryObject<Block> { From 3fed532db53a7c7e11162fa6d10661161968b11b Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 16 Aug 2023 19:44:33 -0600 Subject: [PATCH 168/437] Got basic physics entity working --- .../mod/client/VSPhysicsEntityRenderer.kt | 2 +- .../mod/common/entity/VSPhysicsEntity.kt | 123 ++++++++++++++---- .../common/item/PhysicsEntityCreatorItem.kt | 8 +- .../mod/common/world/DummyShipWorldServer.kt | 10 ++ vs-core | 2 +- 5 files changed, 120 insertions(+), 25 deletions(-) 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 a71661be4..e2f27eb66 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt @@ -36,7 +36,7 @@ class VSPhysicsEntityRenderer(context: EntityRendererProvider.Context) : EntityR poseStack.pushPose() val blockPos = BlockPos(fallingBlockEntity.x, fallingBlockEntity.boundingBox.maxY, fallingBlockEntity.z) poseStack.mulPose(fallingBlockEntity.rotation.toMinecraft()) - poseStack.translate(-0.5, 0.0, -0.5) + poseStack.translate(-0.5, -0.5, -0.5) val blockRenderDispatcher = Minecraft.getInstance().blockRenderer blockRenderDispatcher.modelRenderer.tesselateBlock( level, blockRenderDispatcher.getBlockModel(blockState), blockState, blockPos, poseStack, 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 ff8d0bfcf..fc2db9e55 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 @@ -1,36 +1,71 @@ package org.valkyrienskies.mod.common.entity +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.module.kotlin.readValue import net.minecraft.nbt.CompoundTag import net.minecraft.network.protocol.Packet import net.minecraft.network.protocol.game.ClientboundAddEntityPacket import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType import net.minecraft.world.level.Level -import org.joml.Quaternionf -import org.joml.Quaternionfc +import net.minecraft.world.level.entity.EntityInLevelCallback +import org.joml.Matrix3d +import org.joml.Quaterniond +import org.joml.Quaterniondc +import org.joml.Vector3d import org.valkyrienskies.core.api.ships.properties.ShipId +import org.valkyrienskies.core.api.ships.properties.ShipInertiaData +import org.valkyrienskies.core.api.ships.properties.ShipTransform +import org.valkyrienskies.core.apigame.physics.PhysicsEntityData +import org.valkyrienskies.core.apigame.physics.PhysicsEntityServer +import org.valkyrienskies.core.apigame.physics.VSSphereCollisionShapeData +import org.valkyrienskies.core.apigame.world.ServerShipWorldCore +import org.valkyrienskies.core.impl.game.ships.ShipInertiaDataImpl +import org.valkyrienskies.core.impl.util.serialization.VSJacksonUtil +import org.valkyrienskies.mod.common.dimensionId +import org.valkyrienskies.mod.common.shipObjectWorld +import org.valkyrienskies.mod.common.util.toMinecraft class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity(type, level) { - private var shipId: ShipId? = null - var rotation: Quaternionfc = Quaternionf() + // Physics data, persistent + private var physicsEntityData: PhysicsEntityData? = null - fun setShipId(shipId: ShipId) { - if (this.shipId != null) { - throw IllegalStateException("Cannot define shipId, its already defined!") + // The physics entity, transient, only exists server side after this entity has been added to a world + private var physicsEntityServer: PhysicsEntityServer? = null + + var rotation: Quaterniondc = Quaterniond() + + fun setPhysicsEntityData(physicsEntityData: PhysicsEntityData) { + if (this.physicsEntityData != null) { + throw IllegalStateException("Cannot define physicsEntityData, its already defined!") + } + this.physicsEntityData = physicsEntityData + } + + override fun tick() { + if (!this.level.isClientSide) { + val physicsEntityServerCopy = physicsEntityServer + if (physicsEntityServerCopy != null) { + this.setPos(physicsEntityServerCopy.shipTransform.positionInWorld.toMinecraft()) + rotation = physicsEntityServerCopy.shipTransform.shipToWorldRotation + } } - this.shipId = shipId + super.tick() } override fun defineSynchedData() { - // Naw, send pos/rotation using physics packets + // TODO: Send rotation } override fun readAdditionalSaveData(compoundTag: CompoundTag) { - this.shipId = compoundTag.getLong("shipId") + val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY) + val physicsEntityData = getMapper().readValue<PhysicsEntityData>(physicsEntityDataAsBytes) + setPhysicsEntityData(physicsEntityData) } override fun addAdditionalSaveData(compoundTag: CompoundTag) { - compoundTag.putLong("shipId", shipId!!) + val physicsEntityDataAsBytes = getMapper().writeValueAsBytes(physicsEntityData) + compoundTag.putByteArray(PHYS_DATA_NBT_KEY, physicsEntityDataAsBytes) } override fun getAddEntityPacket(): Packet<*> { @@ -38,21 +73,65 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( } override fun saveWithoutId(compoundTag: CompoundTag): CompoundTag { - compoundTag.putLong("shipId", shipId!!) - compoundTag.putFloat("rotationX", rotation.x()) - compoundTag.putFloat("rotationY", rotation.y()) - compoundTag.putFloat("rotationZ", rotation.z()) - compoundTag.putFloat("rotationW", rotation.w()) + val physicsEntityDataAsBytes = getMapper().writeValueAsBytes(physicsEntityData) + compoundTag.putByteArray(PHYS_DATA_NBT_KEY, physicsEntityDataAsBytes) return super.saveWithoutId(compoundTag) } override fun load(compoundTag: CompoundTag) { - this.shipId = compoundTag.getLong("shipId") - val rotationX = compoundTag.getFloat("rotationX") - val rotationY = compoundTag.getFloat("rotationY") - val rotationZ = compoundTag.getFloat("rotationZ") - val rotationW = compoundTag.getFloat("rotationW") - this.rotation = Quaternionf(rotationX, rotationY, rotationZ, rotationW) + if (!this.level.isClientSide && physicsEntityData != null) { + throw IllegalStateException("This entity is already loaded!") + } + val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY) + val physicsEntityData = getMapper().readValue<PhysicsEntityData>(physicsEntityDataAsBytes) + setPhysicsEntityData(physicsEntityData) super.load(compoundTag) } + + override fun setLevelCallback(callback: EntityInLevelCallback?) { + super.setLevelCallback(callback) + if (!this.level.isClientSide) { + if (callback != null) { + // 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 + ) + } else { + // Try removing the rigid body of this entity from the world + if (physicsEntityServer == null) { + throw IllegalStateException("Rigid body does not exist in the world!") + } + (level.shipObjectWorld as ServerShipWorldCore).deletePhysicsEntity(physicsEntityData!!.shipId) + physicsEntityServer = null + } + } + } + + companion object { + private const val PHYS_DATA_NBT_KEY = "phys_entity_data" + + private fun getMapper(): ObjectMapper { + return VSJacksonUtil.defaultMapper + } + + fun createBasicSphereData( + shipId: ShipId, transform: ShipTransform, radius: Double = 0.5, mass: Double = 10000.0 + ): PhysicsEntityData { + val inertia = 0.4 * mass * radius * radius + val inertiaData: ShipInertiaData = ShipInertiaDataImpl(Vector3d(), mass, Matrix3d().scale(inertia)) + val collisionShapeData = VSSphereCollisionShapeData(radius) + return PhysicsEntityData( + shipId = shipId, + transform = transform, + inertiaData = inertiaData, + linearVelocity = Vector3d(), + angularVelocity = Vector3d(), + collisionShapeData = collisionShapeData, + isStatic = false + ) + } + } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt index b3d136992..ad1d12394 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt @@ -5,9 +5,13 @@ import net.minecraft.world.InteractionResult import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.context.UseOnContext +import org.joml.Vector3d +import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl.Companion import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.dimensionId +import org.valkyrienskies.mod.common.entity.VSPhysicsEntity import org.valkyrienskies.mod.common.shipObjectWorld +import org.valkyrienskies.mod.common.util.toJOML class PhysicsEntityCreatorItem( properties: Properties @@ -22,7 +26,9 @@ class PhysicsEntityCreatorItem( if (!level.isClientSide) { val entity = ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE.create(level)!! val shipId = level.shipObjectWorld.allocateShipId(level.dimensionId) - entity.setShipId(shipId) + val transform = Companion.create(ctx.clickLocation.toJOML(), Vector3d()) + val physicsEntityData = VSPhysicsEntity.createBasicSphereData(shipId, transform) + entity.setPhysicsEntityData(physicsEntityData) entity.setPos(ctx.clickLocation) level.addFreshEntity(entity) } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt index d3dc51616..32206edb6 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt @@ -10,6 +10,8 @@ import org.valkyrienskies.core.api.world.LevelYRange import org.valkyrienskies.core.apigame.ShipTeleportData import org.valkyrienskies.core.apigame.constraints.VSConstraint import org.valkyrienskies.core.apigame.constraints.VSConstraintId +import org.valkyrienskies.core.apigame.physics.PhysicsEntityData +import org.valkyrienskies.core.apigame.physics.PhysicsEntityServer import org.valkyrienskies.core.apigame.world.IPlayer import org.valkyrienskies.core.apigame.world.ServerShipWorldCore import org.valkyrienskies.core.apigame.world.chunks.BlockType @@ -48,6 +50,14 @@ object DummyShipWorldServer : ServerShipWorldCore { TODO("Not yet implemented") } + override fun createPhysicsEntity(physicsEntityData: PhysicsEntityData, dimensionId: DimensionId): PhysicsEntityServer { + TODO("Not yet implemented") + } + + override fun deletePhysicsEntity(id: ShipId) { + TODO("Not yet implemented") + } + override fun allocateShipId(dimensionId: DimensionId): ShipId { TODO("Not yet implemented") } diff --git a/vs-core b/vs-core index 962bb82ed..4d514bc98 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 962bb82edd93065626d95d697842fae1e9ad8e1e +Subproject commit 4d514bc987ac0639b9758816bb9e0715a6d50075 From 48128877b3fd2b093526d3d9512fd375e53a4ef3 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 16 Aug 2023 20:55:37 -0600 Subject: [PATCH 169/437] Send rotation of VSPhysicsEntity --- .../mod/common/entity/VSPhysicsEntity.kt | 26 ++++++++++++++----- .../fabric/common/ValkyrienSkiesModFabric.kt | 1 + .../forge/common/ValkyrienSkiesModForge.kt | 1 + 3 files changed, 22 insertions(+), 6 deletions(-) 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 fc2db9e55..2ac1297bc 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 @@ -2,16 +2,20 @@ package org.valkyrienskies.mod.common.entity import com.fasterxml.jackson.databind.ObjectMapper 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.ClientboundAddEntityPacket +import net.minecraft.network.syncher.EntityDataAccessor +import net.minecraft.network.syncher.EntityDataSerializers +import net.minecraft.network.syncher.SynchedEntityData import net.minecraft.world.entity.Entity import net.minecraft.world.entity.EntityType import net.minecraft.world.level.Level import net.minecraft.world.level.entity.EntityInLevelCallback import org.joml.Matrix3d -import org.joml.Quaterniond -import org.joml.Quaterniondc +import org.joml.Quaternionf +import org.joml.Quaternionfc import org.joml.Vector3d import org.valkyrienskies.core.api.ships.properties.ShipId import org.valkyrienskies.core.api.ships.properties.ShipInertiaData @@ -33,7 +37,11 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( // The physics entity, transient, only exists server side after this entity has been added to a world private var physicsEntityServer: PhysicsEntityServer? = null - var rotation: Quaterniondc = Quaterniond() + val rotation: Quaternionfc + get() { + val rotationRaw = entityData.get(ROTATION_DATA) + return Quaternionf().rotateXYZ(rotationRaw.x, rotationRaw.y, rotationRaw.z) + } fun setPhysicsEntityData(physicsEntityData: PhysicsEntityData) { if (this.physicsEntityData != null) { @@ -47,14 +55,17 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( val physicsEntityServerCopy = physicsEntityServer if (physicsEntityServerCopy != null) { this.setPos(physicsEntityServerCopy.shipTransform.positionInWorld.toMinecraft()) - rotation = physicsEntityServerCopy.shipTransform.shipToWorldRotation + val eulerAngles = physicsEntityServerCopy.shipTransform.shipToWorldRotation.getEulerAnglesXYZ(Vector3d()) + this.entityData.set( + ROTATION_DATA, Rotations(eulerAngles.x.toFloat(), eulerAngles.y.toFloat(), eulerAngles.z.toFloat()) + ) } } super.tick() } override fun defineSynchedData() { - // TODO: Send rotation + entityData.define(ROTATION_DATA, Rotations(0.0f, 0.0f, 0.0f)) } override fun readAdditionalSaveData(compoundTag: CompoundTag) { @@ -91,7 +102,7 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( override fun setLevelCallback(callback: EntityInLevelCallback?) { super.setLevelCallback(callback) if (!this.level.isClientSide) { - if (callback != null) { + if (callback != null && callback != EntityInLevelCallback.NULL) { // Try adding the rigid body of this entity from the world if (physicsEntityServer != null) { throw IllegalStateException("Rigid body is already in the world!") @@ -113,6 +124,9 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( companion object { private const val PHYS_DATA_NBT_KEY = "phys_entity_data" + private val ROTATION_DATA: EntityDataAccessor<Rotations> = + SynchedEntityData.defineId(VSPhysicsEntity::class.java, EntityDataSerializers.ROTATIONS) + private fun getMapper(): ObjectMapper { return VSJacksonUtil.defaultMapper } 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 50a6b9dad..ea81e3fd1 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 @@ -84,6 +84,7 @@ class ValkyrienSkiesModFabric : ModInitializer { ::VSPhysicsEntity, MobCategory.MISC ).sized(.3f, .3f) + .updateInterval(1) .build(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "vs_physics_entity").toString()) ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE = 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 ee6e7b027..ff6d9663c 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 @@ -145,6 +145,7 @@ class ValkyrienSkiesModForge { ::VSPhysicsEntity, MobCategory.MISC ).sized(.3f, .3f) + .setUpdateInterval(1) .build(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "vs_physics_entity").toString()) } From 8456d04d1e452d7e051afd0d02aade86dbdfc31b Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 16 Aug 2023 21:15:24 -0600 Subject: [PATCH 170/437] Added model to test sphere block --- .../mod/client/VSPhysicsEntityRenderer.kt | 4 +- .../mod/common/ValkyrienSkiesMod.kt | 1 + .../blockstates/test_sphere.json | 7 + .../models/block/test_sphere.json | 2157 +++++++++++++++++ .../valkyrienskies/textures/test_sphere.png | Bin 0 -> 2641 bytes .../fabric/common/ValkyrienSkiesModFabric.kt | 4 + .../forge/common/ValkyrienSkiesModForge.kt | 5 + 7 files changed, 2176 insertions(+), 2 deletions(-) create mode 100644 common/src/main/resources/assets/valkyrienskies/blockstates/test_sphere.json create mode 100644 common/src/main/resources/assets/valkyrienskies/models/block/test_sphere.json create mode 100644 common/src/main/resources/assets/valkyrienskies/textures/test_sphere.png 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 e2f27eb66..83461ccc8 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt @@ -10,9 +10,9 @@ import net.minecraft.client.renderer.texture.OverlayTexture import net.minecraft.core.BlockPos import net.minecraft.resources.ResourceLocation import net.minecraft.world.inventory.InventoryMenu -import net.minecraft.world.level.block.Blocks import net.minecraft.world.level.block.RenderShape.INVISIBLE import net.minecraft.world.level.block.RenderShape.MODEL +import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.entity.VSPhysicsEntity import org.valkyrienskies.mod.common.util.toMinecraft import java.util.Random @@ -22,7 +22,7 @@ class VSPhysicsEntityRenderer(context: EntityRendererProvider.Context) : EntityR fallingBlockEntity: VSPhysicsEntity, f: Float, g: Float, poseStack: PoseStack, multiBufferSource: MultiBufferSource, i: Int ) { - val blockState = Blocks.DARK_OAK_WOOD.defaultBlockState() + val blockState = ValkyrienSkiesMod.TEST_SPHERE.defaultBlockState() if (blockState.renderShape != MODEL) { return } 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 7b7303762..6dac43e54 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -25,6 +25,7 @@ object ValkyrienSkiesMod { lateinit var TEST_HINGE: Block lateinit var TEST_FLAP: Block lateinit var TEST_WING: Block + lateinit var TEST_SPHERE: Block lateinit var SHIP_CREATOR_ITEM: Item lateinit var SHIP_ASSEMBLER_ITEM: Item lateinit var SHIP_CREATOR_ITEM_SMALLER: Item diff --git a/common/src/main/resources/assets/valkyrienskies/blockstates/test_sphere.json b/common/src/main/resources/assets/valkyrienskies/blockstates/test_sphere.json new file mode 100644 index 000000000..41203f87c --- /dev/null +++ b/common/src/main/resources/assets/valkyrienskies/blockstates/test_sphere.json @@ -0,0 +1,7 @@ +{ + "variants": { + "": { + "model": "valkyrienskies:block/test_sphere" + } + } +} diff --git a/common/src/main/resources/assets/valkyrienskies/models/block/test_sphere.json b/common/src/main/resources/assets/valkyrienskies/models/block/test_sphere.json new file mode 100644 index 000000000..71ac0e389 --- /dev/null +++ b/common/src/main/resources/assets/valkyrienskies/models/block/test_sphere.json @@ -0,0 +1,2157 @@ +{ + "credit": "Made with Blockbench", + "textures": { + "0": "valkyrienskies:test_sphere", + "particle": "valkyrienskies:test_sphere" + }, + "elements": [ + { + "from": [3, 3, 3], + "to": [13, 13, 13], + "faces": { + "north": {"uv": [0, 0, 10, 10], "texture": "#0"}, + "east": {"uv": [0, 0, 10, 10], "texture": "#0"}, + "south": {"uv": [0, 0, 10, 10], "texture": "#0"}, + "west": {"uv": [0, 0, 10, 10], "texture": "#0"}, + "up": {"uv": [0, 0, 10, 10], "texture": "#0"}, + "down": {"uv": [0, 0, 10, 10], "texture": "#0"} + } + }, + { + "from": [9, 6, 15], + "to": [10, 10, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [7, 5, 15], + "to": [9, 11, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 6, 2], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 6, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 6, 2], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 6, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [7, 3, 14], + "to": [9, 13, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 10, 2], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 10, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 10, 2], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 10, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [6, 3, 13], + "to": [10, 13, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 10, 4], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 10, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 10, 4], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 10, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 4, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 6, 13], + "to": [14, 10, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 4, 4], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 4, 4], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 4, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 4, 13], + "to": [13, 6, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 3, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 4, 13], + "to": [6, 6, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 3, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [4, 3, 13], + "to": [6, 4, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 2], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 2], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 3, 13], + "to": [12, 4, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 2], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 2], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 12, 13], + "to": [12, 13, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [1, 0, 2, 2], "rotation": 270, "texture": "#0"}, + "east": {"uv": [1, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [1, 0, 2, 2], "rotation": 270, "texture": "#0"}, + "west": {"uv": [1, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [2, 0, 4, 1], "texture": "#0"}, + "down": {"uv": [2, 0, 4, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [4, 12, 13], + "to": [6, 13, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [1, 0, 2, 2], "rotation": 270, "texture": "#0"}, + "east": {"uv": [1, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [1, 0, 2, 2], "rotation": 270, "texture": "#0"}, + "west": {"uv": [1, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [2, 0, 4, 1], "texture": "#0"}, + "down": {"uv": [2, 0, 4, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 10, 13], + "to": [6, 12, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 6, 1], "texture": "#0"}, + "down": {"uv": [3, 0, 6, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 10, 13], + "to": [13, 12, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 6, 1], "texture": "#0"}, + "down": {"uv": [3, 0, 6, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [2, 6, 13], + "to": [6, 10, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 4, 4], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 4, 4], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 4, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 7, 14], + "to": [7, 9, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 4], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 4], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 4, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [4, 5, 14], + "to": [7, 7, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 3, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [4, 9, 14], + "to": [7, 11, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 6, 1], "texture": "#0"}, + "down": {"uv": [3, 0, 6, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [9, 5, 14], + "to": [12, 7, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 3, 2, 6], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 3, 2, 6], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 6, 1], "texture": "#0"}, + "down": {"uv": [3, 0, 6, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [9, 4, 14], + "to": [11, 5, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 0, 3, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "down": {"uv": [3, 0, 5, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [9, 11, 14], + "to": [11, 12, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 0, 3, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "down": {"uv": [3, 0, 5, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [5, 11, 14], + "to": [7, 12, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 0, 3, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "down": {"uv": [3, 0, 5, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [5, 4, 14], + "to": [7, 5, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 0, 3, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "down": {"uv": [3, 0, 5, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [9, 9, 14], + "to": [12, 11, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 3, 4, 6], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [2, 3, 4, 6], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 3, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [9, 7, 14], + "to": [13, 9, 15], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 4], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 4], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 4, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [5, 7, 15], + "to": [6, 9, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 7, 15], + "to": [11, 9, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [6, 6, 15], + "to": [7, 10, 16], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [6, 3, 2], + "to": [10, 13, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 4, 10, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 10, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 4, 10, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 10, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 4, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [7, 3, 1], + "to": [9, 13, 2], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 2, 10, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 10, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 2, 10, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 10, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 2, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 3, 2], + "to": [12, 4, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 2, 1, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 1, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 2, 1, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 2, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [9, 4, 1], + "to": [11, 5, 2], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 1, 3, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "down": {"uv": [3, 1, 5, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 4, 2], + "to": [13, 6, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 3, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [9, 5, 1], + "to": [12, 7, 2], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 6, 2, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 6, 2, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 6, 0], "texture": "#0"}, + "down": {"uv": [3, 1, 6, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 6, 2], + "to": [14, 10, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 4, 4, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 4, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 4, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [9, 7, 1], + "to": [13, 9, 2], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 4, 2, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 4, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 4, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [9, 9, 1], + "to": [12, 11, 2], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 6, 4, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [2, 6, 4, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 3, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 10, 2], + "to": [13, 12, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 6, 0], "texture": "#0"}, + "down": {"uv": [3, 1, 6, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 12, 2], + "to": [12, 13, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [1, 2, 2, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [1, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [1, 2, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [1, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [2, 1, 4, 0], "texture": "#0"}, + "down": {"uv": [2, 1, 4, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [9, 11, 1], + "to": [11, 12, 2], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 1, 3, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "down": {"uv": [3, 1, 5, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [4, 12, 2], + "to": [6, 13, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [1, 2, 2, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [1, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [1, 2, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [1, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [2, 1, 4, 0], "texture": "#0"}, + "down": {"uv": [2, 1, 4, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [5, 11, 1], + "to": [7, 12, 2], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 1, 3, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "down": {"uv": [3, 1, 5, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [4, 9, 1], + "to": [7, 11, 2], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 6, 0], "texture": "#0"}, + "down": {"uv": [3, 1, 6, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 10, 2], + "to": [6, 12, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 6, 0], "texture": "#0"}, + "down": {"uv": [3, 1, 6, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [2, 6, 2], + "to": [6, 10, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 4, 4, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 4, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 4, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 7, 1], + "to": [7, 9, 2], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 4, 2, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 4, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 4, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [3, 4, 2], + "to": [6, 6, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 3, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [4, 5, 1], + "to": [7, 7, 2], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 3, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [4, 3, 2], + "to": [6, 4, 3], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 2, 1, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 1, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 2, 1, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 2, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [5, 4, 1], + "to": [7, 5, 2], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "east": {"uv": [2, 1, 3, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "down": {"uv": [3, 1, 5, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [7, 5, 0], + "to": [9, 11, 1], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 2, 6, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 6, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 2, 6, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 6, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 2, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [9, 6, 0], + "to": [10, 10, 1], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 1, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [10, 7, 0], + "to": [11, 9, 1], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 1, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [5, 7, 0], + "to": [6, 9, 1], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 1, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [6, 6, 0], + "to": [7, 10, 1], + "rotation": {"angle": 0, "axis": "y", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "east": {"uv": [0, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "south": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 1, 0], "rotation": 180, "texture": "#0"} + } + }, + { + "from": [15, 6, 6], + "to": [16, 10, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [15, 5, 7], + "to": [16, 11, 9], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 6, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 6, 2], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 6, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 6, 2], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [14, 3, 7], + "to": [15, 13, 9], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 10, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 10, 2], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 10, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 10, 2], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [13, 3, 6], + "to": [14, 13, 10], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 10, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 10, 4], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 10, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 10, 4], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [13, 6, 3], + "to": [14, 10, 5], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 4, 2], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 4, 2], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [13, 4, 3], + "to": [14, 6, 6], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 3, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [13, 4, 10], + "to": [14, 6, 13], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 3, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [13, 3, 10], + "to": [14, 4, 12], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 1, 2], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 1, 2], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [13, 3, 4], + "to": [14, 4, 6], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 1, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 1, 2], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 1, 2], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [13, 12, 4], + "to": [14, 13, 6], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [1, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [1, 0, 2, 2], "rotation": 270, "texture": "#0"}, + "south": {"uv": [1, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [1, 0, 2, 2], "rotation": 270, "texture": "#0"}, + "up": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [13, 12, 10], + "to": [14, 13, 12], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [1, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [1, 0, 2, 2], "rotation": 270, "texture": "#0"}, + "south": {"uv": [1, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [1, 0, 2, 2], "rotation": 270, "texture": "#0"}, + "up": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [13, 10, 10], + "to": [14, 12, 13], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 6, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 0, 6, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [13, 10, 3], + "to": [14, 12, 6], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 6, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 0, 6, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [13, 6, 10], + "to": [14, 10, 13], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 3, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [14, 7, 9], + "to": [15, 9, 13], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 4], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 4], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [14, 5, 9], + "to": [15, 7, 12], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 3, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [14, 9, 9], + "to": [15, 11, 12], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 0, 4, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 6, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 0, 6, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [14, 5, 4], + "to": [15, 7, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 3, 2, 6], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 3, 2, 6], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 6, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 0, 6, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [14, 4, 5], + "to": [15, 5, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 0, 3, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 5, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 0, 5, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [14, 11, 5], + "to": [15, 12, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 0, 3, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 5, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 0, 5, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [14, 11, 9], + "to": [15, 12, 11], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 0, 3, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 5, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 0, 5, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [14, 4, 9], + "to": [15, 5, 11], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 0, 3, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 3, 1, 5], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 0, 5, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 0, 5, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [14, 9, 4], + "to": [15, 11, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [2, 3, 4, 6], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 3, 4, 6], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 3, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 3, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [14, 7, 3], + "to": [15, 9, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 4], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 4], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [15, 7, 10], + "to": [16, 9, 11], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [15, 7, 5], + "to": [16, 9, 6], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 2, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [15, 6, 9], + "to": [16, 10, 10], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 0, 4, 1], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 0, 4, 1], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 0, 1, 1], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [2, 3, 6], + "to": [3, 13, 10], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 10, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 4, 10, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 10, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 4, 10, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 3, 7], + "to": [2, 13, 9], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 10, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 2, 10, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 10, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 2, 10, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [2, 3, 4], + "to": [3, 4, 6], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 1, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 2, 1, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 2, 1, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 4, 5], + "to": [2, 5, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 1, 3, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 5, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 1, 5, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [2, 4, 3], + "to": [3, 6, 6], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 3, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 5, 4], + "to": [2, 7, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 6, 2, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 6, 2, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 6, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 1, 6, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [2, 6, 3], + "to": [3, 10, 5], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 4, 2], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 4, 4, 6], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 4, 2], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 4, 4, 6], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 2, 2], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 2, 2], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 7, 3], + "to": [2, 9, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 4, 2, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 4, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 9, 4], + "to": [2, 11, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [2, 6, 4, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 6, 4, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 3, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [2, 10, 3], + "to": [3, 12, 6], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 6, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 1, 6, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [2, 12, 4], + "to": [3, 13, 6], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [1, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [1, 2, 2, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [1, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [1, 2, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 11, 5], + "to": [2, 12, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 1, 3, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 5, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 1, 5, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [2, 12, 10], + "to": [3, 13, 12], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [1, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [1, 2, 2, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [1, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [1, 2, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 11, 9], + "to": [2, 12, 11], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 1, 3, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 5, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 1, 5, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 9, 9], + "to": [2, 11, 12], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 6, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 1, 6, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [2, 10, 10], + "to": [3, 12, 13], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [2, 3, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 6, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 1, 6, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [2, 6, 10], + "to": [3, 10, 14], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 4, 4, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 4, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 7, 9], + "to": [2, 9, 13], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 4, 2, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 4, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [2, 4, 10], + "to": [3, 6, 13], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 3, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 5, 9], + "to": [2, 7, 12], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 3, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 3, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [2, 3, 10], + "to": [3, 4, 12], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 1, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 2, 1, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 2, 1, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [1, 4, 9], + "to": [2, 5, 11], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [2, 1, 3, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "south": {"uv": [2, 1, 3, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 5, 1, 3], "rotation": 270, "texture": "#0"}, + "up": {"uv": [3, 1, 5, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [3, 1, 5, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [0, 5, 7], + "to": [1, 11, 9], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 6, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 2, 6, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 6, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 2, 6, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [0, 6, 6], + "to": [1, 10, 7], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [0, 7, 5], + "to": [1, 9, 6], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [0, 7, 10], + "to": [1, 9, 11], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [0, 6, 9], + "to": [1, 10, 10], + "rotation": {"angle": 0, "axis": "z", "origin": [8, 8, 8]}, + "faces": { + "north": {"uv": [0, 1, 4, 0], "rotation": 90, "texture": "#0"}, + "east": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "south": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "west": {"uv": [0, 1, 4, 0], "rotation": 270, "texture": "#0"}, + "up": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"}, + "down": {"uv": [0, 1, 1, 0], "rotation": 270, "texture": "#0"} + } + }, + { + "from": [6, 0, 6], + "to": [10, 1, 7], + "faces": { + "north": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 4, 1], "texture": "#0"} + } + }, + { + "from": [5, 0, 7], + "to": [11, 1, 9], + "faces": { + "north": {"uv": [0, 0, 6, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 6, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 6, 2], "texture": "#0"}, + "down": {"uv": [0, 0, 6, 2], "texture": "#0"} + } + }, + { + "from": [3, 1, 7], + "to": [13, 2, 9], + "faces": { + "north": {"uv": [0, 0, 10, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 10, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 10, 2], "texture": "#0"}, + "down": {"uv": [0, 0, 10, 2], "texture": "#0"} + } + }, + { + "from": [2, 2, 6], + "to": [14, 3, 10], + "faces": { + "north": {"uv": [0, 0, 12, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 12, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 12, 4], "texture": "#0"}, + "down": {"uv": [0, 0, 12, 4], "texture": "#0"} + } + }, + { + "from": [6, 2, 2], + "to": [10, 3, 6], + "faces": { + "north": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 4, 4], "texture": "#0"}, + "down": {"uv": [0, 0, 4, 4], "texture": "#0"} + } + }, + { + "from": [4, 2, 3], + "to": [6, 3, 6], + "faces": { + "north": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 3], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 3], "texture": "#0"} + } + }, + { + "from": [4, 2, 10], + "to": [6, 3, 13], + "faces": { + "north": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 3], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 3], "texture": "#0"} + } + }, + { + "from": [3, 2, 10], + "to": [4, 3, 12], + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 1, 2], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 2], "texture": "#0"} + } + }, + { + "from": [3, 2, 4], + "to": [4, 3, 6], + "faces": { + "north": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 1, 2], "texture": "#0"}, + "down": {"uv": [0, 0, 1, 2], "texture": "#0"} + } + }, + { + "from": [12, 2, 4], + "to": [13, 3, 6], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 0, 0]}, + "faces": { + "north": {"uv": [1, 0, 0, 1], "texture": "#0"}, + "east": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "south": {"uv": [1, 0, 0, 1], "texture": "#0"}, + "west": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "up": {"uv": [1, 0, 0, 2], "texture": "#0"}, + "down": {"uv": [1, 0, 0, 2], "texture": "#0"} + } + }, + { + "from": [12, 2, 10], + "to": [13, 3, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 0, 0]}, + "faces": { + "north": {"uv": [1, 0, 0, 1], "texture": "#0"}, + "east": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "south": {"uv": [1, 0, 0, 1], "texture": "#0"}, + "west": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "up": {"uv": [1, 0, 0, 2], "texture": "#0"}, + "down": {"uv": [1, 0, 0, 2], "texture": "#0"} + } + }, + { + "from": [10, 2, 10], + "to": [12, 3, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 0, 0]}, + "faces": { + "north": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "east": {"uv": [3, 0, 0, 1], "texture": "#0"}, + "south": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "west": {"uv": [3, 0, 0, 1], "texture": "#0"}, + "up": {"uv": [2, 0, 0, 3], "texture": "#0"}, + "down": {"uv": [2, 0, 0, 3], "texture": "#0"} + } + }, + { + "from": [10, 2, 3], + "to": [12, 3, 6], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 0, 0]}, + "faces": { + "north": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "east": {"uv": [3, 0, 0, 1], "texture": "#0"}, + "south": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "west": {"uv": [3, 0, 0, 1], "texture": "#0"}, + "up": {"uv": [2, 0, 0, 3], "texture": "#0"}, + "down": {"uv": [2, 0, 0, 3], "texture": "#0"} + } + }, + { + "from": [6, 2, 10], + "to": [10, 3, 14], + "faces": { + "north": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 4, 4], "texture": "#0"}, + "down": {"uv": [0, 0, 4, 4], "texture": "#0"} + } + }, + { + "from": [7, 1, 9], + "to": [9, 2, 13], + "faces": { + "north": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 4], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 4], "texture": "#0"} + } + }, + { + "from": [5, 1, 9], + "to": [7, 2, 12], + "faces": { + "north": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 3], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 3], "texture": "#0"} + } + }, + { + "from": [9, 1, 9], + "to": [11, 2, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 0, 0]}, + "faces": { + "north": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "east": {"uv": [3, 0, 0, 1], "texture": "#0"}, + "south": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "west": {"uv": [3, 0, 0, 1], "texture": "#0"}, + "up": {"uv": [2, 0, 0, 3], "texture": "#0"}, + "down": {"uv": [2, 0, 0, 3], "texture": "#0"} + } + }, + { + "from": [5, 1, 4], + "to": [7, 2, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 16]}, + "faces": { + "north": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "east": {"uv": [3, 0, 0, 1], "texture": "#0"}, + "south": {"uv": [2, 0, 0, 1], "texture": "#0"}, + "west": {"uv": [3, 0, 0, 1], "texture": "#0"}, + "up": {"uv": [0, 3, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 3, 2, 0], "texture": "#0"} + } + }, + { + "from": [4, 1, 5], + "to": [5, 2, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 16]}, + "faces": { + "north": {"uv": [2, 0, 3, 1], "texture": "#0"}, + "east": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "south": {"uv": [2, 0, 3, 1], "texture": "#0"}, + "west": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "up": {"uv": [0, 3, 1, 5], "texture": "#0"}, + "down": {"uv": [0, 3, 1, 5], "texture": "#0"} + } + }, + { + "from": [11, 1, 5], + "to": [12, 2, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 16]}, + "faces": { + "north": {"uv": [2, 0, 3, 1], "texture": "#0"}, + "east": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "south": {"uv": [2, 0, 3, 1], "texture": "#0"}, + "west": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "up": {"uv": [0, 3, 1, 5], "texture": "#0"}, + "down": {"uv": [0, 3, 1, 5], "texture": "#0"} + } + }, + { + "from": [11, 1, 9], + "to": [12, 2, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 16]}, + "faces": { + "north": {"uv": [2, 0, 3, 1], "texture": "#0"}, + "east": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "south": {"uv": [2, 0, 3, 1], "texture": "#0"}, + "west": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "up": {"uv": [0, 3, 1, 5], "texture": "#0"}, + "down": {"uv": [0, 3, 1, 5], "texture": "#0"} + } + }, + { + "from": [4, 1, 9], + "to": [5, 2, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 0, 16]}, + "faces": { + "north": {"uv": [2, 0, 3, 1], "texture": "#0"}, + "east": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "south": {"uv": [2, 0, 3, 1], "texture": "#0"}, + "west": {"uv": [3, 0, 5, 1], "texture": "#0"}, + "up": {"uv": [0, 3, 1, 5], "texture": "#0"}, + "down": {"uv": [0, 3, 1, 5], "texture": "#0"} + } + }, + { + "from": [9, 1, 4], + "to": [11, 2, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 0, 16]}, + "faces": { + "north": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 3, 1], "texture": "#0"}, + "up": {"uv": [2, 3, 0, 0], "texture": "#0"}, + "down": {"uv": [2, 3, 0, 0], "texture": "#0"} + } + }, + { + "from": [7, 1, 3], + "to": [9, 2, 7], + "faces": { + "north": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 4], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 4], "texture": "#0"} + } + }, + { + "from": [7, 0, 10], + "to": [9, 1, 11], + "faces": { + "north": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 1], "texture": "#0"} + } + }, + { + "from": [7, 0, 5], + "to": [9, 1, 6], + "faces": { + "north": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 1], "texture": "#0"} + } + }, + { + "from": [6, 0, 9], + "to": [10, 1, 10], + "faces": { + "north": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "east": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "south": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "west": {"uv": [0, 0, 1, 1], "texture": "#0"}, + "up": {"uv": [0, 0, 4, 1], "texture": "#0"}, + "down": {"uv": [0, 0, 4, 1], "texture": "#0"} + } + }, + { + "from": [6, 15, 6], + "to": [10, 16, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "up": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 4, 0], "texture": "#0"} + } + }, + { + "from": [5, 15, 7], + "to": [11, 16, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 6, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 6, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "up": {"uv": [0, 2, 6, 0], "texture": "#0"}, + "down": {"uv": [0, 2, 6, 0], "texture": "#0"} + } + }, + { + "from": [3, 14, 7], + "to": [13, 15, 9], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 10, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 10, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "up": {"uv": [0, 2, 10, 0], "texture": "#0"}, + "down": {"uv": [0, 2, 10, 0], "texture": "#0"} + } + }, + { + "from": [2, 13, 6], + "to": [14, 14, 10], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 12, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 12, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "up": {"uv": [0, 4, 12, 0], "texture": "#0"}, + "down": {"uv": [0, 4, 12, 0], "texture": "#0"} + } + }, + { + "from": [6, 13, 2], + "to": [10, 14, 6], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "up": {"uv": [0, 4, 4, 0], "texture": "#0"}, + "down": {"uv": [0, 4, 4, 0], "texture": "#0"} + } + }, + { + "from": [4, 13, 3], + "to": [6, 14, 6], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "up": {"uv": [0, 3, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 3, 2, 0], "texture": "#0"} + } + }, + { + "from": [4, 13, 10], + "to": [6, 14, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "up": {"uv": [0, 3, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 3, 2, 0], "texture": "#0"} + } + }, + { + "from": [3, 13, 10], + "to": [4, 14, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "up": {"uv": [0, 2, 1, 0], "texture": "#0"}, + "down": {"uv": [0, 2, 1, 0], "texture": "#0"} + } + }, + { + "from": [3, 13, 4], + "to": [4, 14, 6], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "up": {"uv": [0, 2, 1, 0], "texture": "#0"}, + "down": {"uv": [0, 2, 1, 0], "texture": "#0"} + } + }, + { + "from": [12, 13, 4], + "to": [13, 14, 6], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 16, 0]}, + "faces": { + "north": {"uv": [1, 1, 0, 0], "texture": "#0"}, + "east": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "south": {"uv": [1, 1, 0, 0], "texture": "#0"}, + "west": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "up": {"uv": [1, 2, 0, 0], "texture": "#0"}, + "down": {"uv": [1, 2, 0, 0], "texture": "#0"} + } + }, + { + "from": [12, 13, 10], + "to": [13, 14, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 16, 0]}, + "faces": { + "north": {"uv": [1, 1, 0, 0], "texture": "#0"}, + "east": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "south": {"uv": [1, 1, 0, 0], "texture": "#0"}, + "west": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "up": {"uv": [1, 2, 0, 0], "texture": "#0"}, + "down": {"uv": [1, 2, 0, 0], "texture": "#0"} + } + }, + { + "from": [10, 13, 10], + "to": [12, 14, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 16, 0]}, + "faces": { + "north": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "east": {"uv": [3, 1, 0, 0], "texture": "#0"}, + "south": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "west": {"uv": [3, 1, 0, 0], "texture": "#0"}, + "up": {"uv": [2, 3, 0, 0], "texture": "#0"}, + "down": {"uv": [2, 3, 0, 0], "texture": "#0"} + } + }, + { + "from": [10, 13, 3], + "to": [12, 14, 6], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 16, 0]}, + "faces": { + "north": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "east": {"uv": [3, 1, 0, 0], "texture": "#0"}, + "south": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "west": {"uv": [3, 1, 0, 0], "texture": "#0"}, + "up": {"uv": [2, 3, 0, 0], "texture": "#0"}, + "down": {"uv": [2, 3, 0, 0], "texture": "#0"} + } + }, + { + "from": [6, 13, 10], + "to": [10, 14, 14], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "up": {"uv": [0, 4, 4, 0], "texture": "#0"}, + "down": {"uv": [0, 4, 4, 0], "texture": "#0"} + } + }, + { + "from": [7, 14, 9], + "to": [9, 15, 13], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "up": {"uv": [0, 4, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 4, 2, 0], "texture": "#0"} + } + }, + { + "from": [5, 14, 9], + "to": [7, 15, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "up": {"uv": [0, 3, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 3, 2, 0], "texture": "#0"} + } + }, + { + "from": [9, 14, 9], + "to": [11, 15, 12], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 16, 0]}, + "faces": { + "north": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "east": {"uv": [3, 1, 0, 0], "texture": "#0"}, + "south": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "west": {"uv": [3, 1, 0, 0], "texture": "#0"}, + "up": {"uv": [2, 3, 0, 0], "texture": "#0"}, + "down": {"uv": [2, 3, 0, 0], "texture": "#0"} + } + }, + { + "from": [5, 14, 4], + "to": [7, 15, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 16]}, + "faces": { + "north": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "east": {"uv": [3, 1, 0, 0], "texture": "#0"}, + "south": {"uv": [2, 1, 0, 0], "texture": "#0"}, + "west": {"uv": [3, 1, 0, 0], "texture": "#0"}, + "up": {"uv": [0, 0, 2, 3], "texture": "#0"}, + "down": {"uv": [0, 0, 2, 3], "texture": "#0"} + } + }, + { + "from": [4, 14, 5], + "to": [5, 15, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 16]}, + "faces": { + "north": {"uv": [2, 1, 3, 0], "texture": "#0"}, + "east": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "south": {"uv": [2, 1, 3, 0], "texture": "#0"}, + "west": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "up": {"uv": [0, 5, 1, 3], "texture": "#0"}, + "down": {"uv": [0, 5, 1, 3], "texture": "#0"} + } + }, + { + "from": [11, 14, 5], + "to": [12, 15, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 16]}, + "faces": { + "north": {"uv": [2, 1, 3, 0], "texture": "#0"}, + "east": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "south": {"uv": [2, 1, 3, 0], "texture": "#0"}, + "west": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "up": {"uv": [0, 5, 1, 3], "texture": "#0"}, + "down": {"uv": [0, 5, 1, 3], "texture": "#0"} + } + }, + { + "from": [11, 14, 9], + "to": [12, 15, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 16]}, + "faces": { + "north": {"uv": [2, 1, 3, 0], "texture": "#0"}, + "east": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "south": {"uv": [2, 1, 3, 0], "texture": "#0"}, + "west": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "up": {"uv": [0, 5, 1, 3], "texture": "#0"}, + "down": {"uv": [0, 5, 1, 3], "texture": "#0"} + } + }, + { + "from": [4, 14, 9], + "to": [5, 15, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 16]}, + "faces": { + "north": {"uv": [2, 1, 3, 0], "texture": "#0"}, + "east": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "south": {"uv": [2, 1, 3, 0], "texture": "#0"}, + "west": {"uv": [3, 1, 5, 0], "texture": "#0"}, + "up": {"uv": [0, 5, 1, 3], "texture": "#0"}, + "down": {"uv": [0, 5, 1, 3], "texture": "#0"} + } + }, + { + "from": [9, 14, 4], + "to": [11, 15, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [16, 16, 16]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 3, 0], "texture": "#0"}, + "up": {"uv": [2, 0, 0, 3], "texture": "#0"}, + "down": {"uv": [2, 0, 0, 3], "texture": "#0"} + } + }, + { + "from": [7, 14, 3], + "to": [9, 15, 7], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "up": {"uv": [0, 4, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 4, 2, 0], "texture": "#0"} + } + }, + { + "from": [7, 15, 10], + "to": [9, 16, 11], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "up": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 2, 0], "texture": "#0"} + } + }, + { + "from": [7, 15, 5], + "to": [9, 16, 6], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "up": {"uv": [0, 1, 2, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 2, 0], "texture": "#0"} + } + }, + { + "from": [6, 15, 9], + "to": [10, 16, 10], + "rotation": {"angle": 0, "axis": "y", "origin": [0, 16, 0]}, + "faces": { + "north": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "east": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "south": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "west": {"uv": [0, 1, 1, 0], "texture": "#0"}, + "up": {"uv": [0, 1, 4, 0], "texture": "#0"}, + "down": {"uv": [0, 1, 4, 0], "texture": "#0"} + } + } + ], + "groups": [ + { + "name": "el sphero", + "origin": [8, 8, 8], + "color": 0, + "children": [ + 0, + { + "name": "south", + "origin": [8, 8, 8], + "color": 0, + "children": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27] + }, + { + "name": "north", + "origin": [8, 8, 8], + "color": 0, + "children": [28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54] + }, + { + "name": "east", + "origin": [8, 8, 8], + "color": 0, + "children": [55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81] + }, + { + "name": "west", + "origin": [8, 8, 8], + "color": 0, + "children": [82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108] + }, + { + "name": "down", + "origin": [0, 0, 0], + "color": 0, + "children": [109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135] + }, + { + "name": "up", + "origin": [0, 0, 0], + "color": 0, + "children": [136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162] + } + ] + } + ] +} diff --git a/common/src/main/resources/assets/valkyrienskies/textures/test_sphere.png b/common/src/main/resources/assets/valkyrienskies/textures/test_sphere.png new file mode 100644 index 0000000000000000000000000000000000000000..ac11082a78642a87b225389da1898ab637f5d307 GIT binary patch literal 2641 zcmb7GZBUa}7DipxDk@vILqG!Qbf=<432IqVKEk2`QVS6k5G9FrD<k3%BM5|q#A;L5 zp(JW*Eg*@O#Vn>IP?P}qsz3-KgrF=2Es!Ojm>5Fx0^x;(Y`T9|opwfNo^#Kgd;gqy zp6A?qt{g~DS-*DES|1;u^{M;z9`x~9G5c%0<2~@17G22lrZs2x<rMk&Z0PwlR@?~R z5bQlur0z{TT=vX5o{G!O5BhrY5LaFVjol+)zw_=t16DrzGT{CnR<3DDa{X=o#h-%r z+Jg4hytokh!{#mcn3g}Qt|+z&zV1#a6H8O6-<do4ynBO<owNeyV!?Rr;YJ=dbNw?H zhRHJ7<p`QTw%1<euWgSY{ZyY1wfSooq=``Hgc3sGg~%)-#B>QDDBT?7Hr!sb__?@T zbQOyXmD>OFF-`4|vKuN<HMy=+(X^!kP#YbaCT^#$T-@Ez;TKb!2>ESHU5t1M+#Gez z_5om_&WgbF^SDlcWcq-{mxRc=iTJVbA2V=<Ov9Wo*?lTd*2Ey$mBLCA`8$nhhCTND zzQY12ZgP9^f|)+F(N0LV87pCWcpJ9815<}(Vk^EMxrd+Bf>u>Tu)AT2!0Nue=XYvK zy!>)a5mPni>tuvo#g?N`eu=i7|E}!(q><)mk@Fp#CAF>{J<1RdlsZ3x(~t_jxcNGK zIS11y>IjuVAilF~a2nZf`8gJ)E5kpYx)O(!Yltf<!fEWwRnyi;*edc>RDB_2$Y!!< zO&&0=>|{AVS@-5_Wh0_GV&q{Dp9H5(hz2jO%BI$-Gcd<OARAiH1G-A#y*R|6&Sf0u z1EgrIE0RSd&HoUzNO3I8ug1p>SbiRs`HsYeLZb*{zu*iYhO94vMRhDV;0~9Qu;d21 zAPlw2EmZw|=#F3K?cc;}94b2pcOxayww|nE(zli*jQCbS$u&QA1PX{a7f$)9^XytH zLX#_CY2r0Rc5|}mswa>Qjx=?#&RGhV&t!MvU2397wz^~&Y>S8xOH+Bi*SO2cdC27~ zsDHY)?7n)6k)TM4;R~oK=34uu`skqIm+bSZY(u{2S1|XiAigiS1FK(E?gU!o$6&p9 z5erwiiv_w2YJA+F!rri|fzo>2bJW37ET=>H(GDrgFgHJfA<r?o!fZwrxmvY_W#quI z3SLC>8AH5<yqp(-YJFBkvU3XXB&G^v8u94S_i+Y#Tl;%5Q5U6X20&hZ-B16w{DxO6 zjIzY|1LY@e<xniM$1cr*qUeBfy(4jg(S$&%1hv#XT^x#D`nVyEnX9xh=}BC!-u^I> zMo;&fq8_T&$oIFXfW)zSQqi#Mv%~cRPX<%+;lk6irkTu8EVfE_L+ScV|G;xP-m@~H z-xF~Bz=EDUVTzo3g{GHTdrkH{^yH~YGYKjiCPUQ%Lhk6%cvdey0p~~elYL+kJvL`z zszXA0?2(f4oqZ7ai%pP#IzhN{$S+vW5bmq6+mccGM6&kDO<mcCu-dVu6XFHTMA!0c z29)>LSXAfPZ|8eIhr$gZg$Xtw@QsCS<?fQ#-q{Z}9_c&Av$~9#==Kiby)nfxPNkKE zqvGyHVh12L$nul5ik|S{WG7}3!!n%IV{xjPE8$i)<=jRYtRjr2q6b&t!F6`C4%TA_ zF5`vs9M`lU$lXf1=lJ4anO?j#;gj;BH`dY@%@aLt>_<7ORaW6l?DiLIQ)@HFEj&YV z0xlzAwa}AQ4=*&OLUE)(*(Hs!R8r#!w7JgQouYbj4vdoFcOWG_Y{LGfov^=5*rGd1 z8u7?=f@!I}xw%?$>ybcFH9f9cg8nh&cN+8cH&^|m<yKt}c&Py~A%3dYG9-F}<x{9v zps;R4=<-&HD;-ll-dE7bE(JseRF)e-X;Zq)lY|xSos_5)uoay@+mi+}f=>=IN_hZt zwk%BIDw$wl`kf`$H6k?PUrTN>1BEQVVR}nTu~~e$0E9m4?%L7HKrjQ^4)P(jW50Zi zB^6(Xiy3?>5j>?$Tt21HC?S$SL&8WFc`j*1#fPnP4%EZp;mxRAPV+dKxSf{mfDoDf zTJg5qlxxv-y!S#!g*_rW;4&|PUt0CDisP9%L%wfFm*{y66+DeR&L50zJwG`P>@JKN zC{-(U8JN)!(~Z&7;kc%@+6o&Zna2etCAt&4W?6+Ydj=+xnK$wX=8*cC$~3}FGB~pr z@3~nec1jY?ILyy;M)bUs*ICt<JjR=E^#fhxsxcNUVM6KcbAaf_>1V(JDGErQ&cSp~ zn|x=NQ4T2)WcUM%i<pT3%$993jXYeh6SBx27C0X3JMt8XZ%{4^@5T?(564P6xwW~1 zqkY?`s4V)Y*tB|hTd_^^6)RZu^ez6xCXMJDU_^L}pgRg>A^)L^VG(o3%`!Uzx08jG z(~07_(>2)%8qGJlah@YgCFsqJruzl+-K0(DN1i6ofGP|FUvO2TR*;GcI8~ujGEfU% z$_8iW%z5?4I6w*U{DEkK)5-_N-qPmV4Ay}R<eGT`+4(37s-~ty@anQe!Xd$on`9?# zE{c*@*0aO#q-)tiqIXE}2c$5Q+wtJR#&S$e{NNN3G>6*^wu&8^F^xmOgUjqqq^$Wb zc#p6OHr?SQ$J4SY|DMuP206}xV9@YZZoh4L;7nMH)}xOsTuAfIdK-(Aj(Cxp9D_QS zf3mRnL~%Z@&}YY2M_$;xw;N6#NzF@3^ZCfT|KEh@&5sW;ysJ-YQu<!*?&BB#3!mt7 AF#rGn literal 0 HcmV?d00001 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 ea81e3fd1..7b432e8fa 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 @@ -23,6 +23,8 @@ import net.minecraft.world.item.BlockItem import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.Item.Properties import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.state.BlockBehaviour +import net.minecraft.world.level.material.Material import org.valkyrienskies.core.apigame.VSCoreFactory import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.client.VSPhysicsEntityRenderer @@ -61,6 +63,7 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_HINGE = TestHingeBlock ValkyrienSkiesMod.TEST_FLAP = TestFlapBlock ValkyrienSkiesMod.TEST_WING = TestWingBlock + ValkyrienSkiesMod.TEST_SPHERE = Block(BlockBehaviour.Properties.of(Material.STONE)) ValkyrienSkiesMod.SHIP_CREATOR_ITEM = ShipCreatorItem( Properties().tab(CreativeModeTab.TAB_MISC), { 1.0 }, @@ -110,6 +113,7 @@ class ValkyrienSkiesModFabric : ModInitializer { registerBlockAndItem("test_hinge", ValkyrienSkiesMod.TEST_HINGE) registerBlockAndItem("test_flap", ValkyrienSkiesMod.TEST_FLAP) registerBlockAndItem("test_wing", ValkyrienSkiesMod.TEST_WING) + registerBlockAndItem("test_sphere", ValkyrienSkiesMod.TEST_SPHERE) Registry.register( Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_assembler"), ValkyrienSkiesMod.SHIP_ASSEMBLER_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 ff6d9663c..dfea1eede 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 @@ -10,6 +10,8 @@ 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.minecraft.world.level.block.state.BlockBehaviour +import net.minecraft.world.level.material.Material import net.minecraftforge.client.ClientRegistry import net.minecraftforge.client.ConfigGuiHandler.ConfigGuiFactory import net.minecraftforge.client.event.EntityRenderersEvent @@ -60,6 +62,7 @@ class ValkyrienSkiesModForge { private val TEST_HINGE_REGISTRY: RegistryObject<Block> private val TEST_FLAP_REGISTRY: RegistryObject<Block> private val TEST_WING_REGISTRY: RegistryObject<Block> + private val TEST_SPHERE_REGISTRY: RegistryObject<Block> private val SHIP_CREATOR_ITEM_REGISTRY: RegistryObject<Item> private val SHIP_CREATOR_SMALLER_ITEM_REGISTRY: RegistryObject<Item> private val PHYSICS_ENTITY_CREATOR_ITEM_REGISTRY: RegistryObject<Item> @@ -110,6 +113,7 @@ class ValkyrienSkiesModForge { TEST_HINGE_REGISTRY = registerBlockAndItem("test_hinge") { TestHingeBlock } TEST_FLAP_REGISTRY = registerBlockAndItem("test_flap") { TestFlapBlock } TEST_WING_REGISTRY = registerBlockAndItem("test_wing") { TestWingBlock } + TEST_SPHERE_REGISTRY = registerBlockAndItem("test_sphere") { Block(BlockBehaviour.Properties.of(Material.STONE)) } SHIP_CREATOR_ITEM_REGISTRY = ITEMS.register("ship_creator") { ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), @@ -195,6 +199,7 @@ class ValkyrienSkiesModForge { ValkyrienSkiesMod.TEST_HINGE = TEST_HINGE_REGISTRY.get() ValkyrienSkiesMod.TEST_FLAP = TEST_FLAP_REGISTRY.get() ValkyrienSkiesMod.TEST_WING = TEST_WING_REGISTRY.get() + ValkyrienSkiesMod.TEST_SPHERE = TEST_SPHERE_REGISTRY.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() From 08900ff2dbbc99bd956ac4823e30ce29351de9ff Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 16 Aug 2023 21:38:40 -0600 Subject: [PATCH 171/437] Fixed VSPhysicsEntity loading and unloading --- .../mod/common/entity/VSPhysicsEntity.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 2ac1297bc..d0e7bbfcb 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 @@ -17,6 +17,7 @@ import org.joml.Matrix3d import org.joml.Quaternionf import org.joml.Quaternionfc import org.joml.Vector3d +import org.joml.Vector3dc import org.valkyrienskies.core.api.ships.properties.ShipId import org.valkyrienskies.core.api.ships.properties.ShipInertiaData import org.valkyrienskies.core.api.ships.properties.ShipTransform @@ -37,6 +38,9 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( // The physics entity, transient, only exists server side after this entity has been added to a world private var physicsEntityServer: PhysicsEntityServer? = null + private var clientPos: Vector3dc? = null + private var clientRotation: Quaternionfc? = null + val rotation: Quaternionfc get() { val rotationRaw = entityData.get(ROTATION_DATA) @@ -102,7 +106,8 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( override fun setLevelCallback(callback: EntityInLevelCallback?) { super.setLevelCallback(callback) if (!this.level.isClientSide) { - if (callback != null && callback != EntityInLevelCallback.NULL) { + 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!") @@ -113,7 +118,8 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( } else { // Try removing the rigid body of this entity from the world if (physicsEntityServer == null) { - throw IllegalStateException("Rigid body does not exist in the world!") + return + // throw IllegalStateException("Rigid body does not exist in the world!") } (level.shipObjectWorld as ServerShipWorldCore).deletePhysicsEntity(physicsEntityData!!.shipId) physicsEntityServer = null From 5cd9e589cf050d5cc6c734fe0a5f4438c21401ad Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 16 Aug 2023 23:04:41 -0600 Subject: [PATCH 172/437] Added lerping to VSPhysicsEntity --- .../mod/client/VSPhysicsEntityRenderer.kt | 6 +- .../mod/common/block/TestSphereBlock.kt | 28 +++++++ .../mod/common/entity/VSPhysicsEntity.kt | 79 +++++++++++++++++-- .../fabric/common/ValkyrienSkiesModFabric.kt | 6 +- .../forge/common/ValkyrienSkiesModForge.kt | 11 +-- 5 files changed, 114 insertions(+), 16 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestSphereBlock.kt 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 83461ccc8..3339af1ce 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt @@ -19,7 +19,7 @@ import java.util.Random class VSPhysicsEntityRenderer(context: EntityRendererProvider.Context) : EntityRenderer<VSPhysicsEntity>(context) { override fun render( - fallingBlockEntity: VSPhysicsEntity, f: Float, g: Float, poseStack: PoseStack, + fallingBlockEntity: VSPhysicsEntity, f: Float, partialTick: Float, poseStack: PoseStack, multiBufferSource: MultiBufferSource, i: Int ) { val blockState = ValkyrienSkiesMod.TEST_SPHERE.defaultBlockState() @@ -35,7 +35,7 @@ class VSPhysicsEntityRenderer(context: EntityRendererProvider.Context) : EntityR } poseStack.pushPose() val blockPos = BlockPos(fallingBlockEntity.x, fallingBlockEntity.boundingBox.maxY, fallingBlockEntity.z) - poseStack.mulPose(fallingBlockEntity.rotation.toMinecraft()) + poseStack.mulPose(fallingBlockEntity.getRenderRotation(partialTick).toMinecraft()) poseStack.translate(-0.5, -0.5, -0.5) val blockRenderDispatcher = Minecraft.getInstance().blockRenderer blockRenderDispatcher.modelRenderer.tesselateBlock( @@ -45,7 +45,7 @@ class VSPhysicsEntityRenderer(context: EntityRendererProvider.Context) : EntityR ), false, Random(), blockState.getSeed(BlockPos.ZERO), OverlayTexture.NO_OVERLAY ) poseStack.popPose() - super.render(fallingBlockEntity, f, g, poseStack, multiBufferSource, i) + super.render(fallingBlockEntity, f, partialTick, poseStack, multiBufferSource, i) } override fun getTextureLocation(entity: VSPhysicsEntity): ResourceLocation { 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 new file mode 100644 index 000000000..cfdb38ac8 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/block/TestSphereBlock.kt @@ -0,0 +1,28 @@ +package org.valkyrienskies.mod.common.block + +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)) { + override fun getVisualShape( + blockState: BlockState?, blockGetter: BlockGetter?, blockPos: BlockPos?, collisionContext: CollisionContext? + ): VoxelShape { + return Shapes.empty() + } + + override fun getShadeBrightness(blockState: BlockState?, blockGetter: BlockGetter?, blockPos: BlockPos?): Float { + return 1.0f + } + + override fun propagatesSkylightDown( + blockState: BlockState?, blockGetter: BlockGetter?, blockPos: BlockPos? + ): Boolean { + return true + } +} 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 d0e7bbfcb..c7279eb88 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 @@ -29,6 +29,7 @@ import org.valkyrienskies.core.impl.game.ships.ShipInertiaDataImpl import org.valkyrienskies.core.impl.util.serialization.VSJacksonUtil import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.shipObjectWorld +import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toMinecraft class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity(type, level) { @@ -38,10 +39,14 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( // The physics entity, transient, only exists server side after this entity has been added to a world private var physicsEntityServer: PhysicsEntityServer? = null - private var clientPos: Vector3dc? = null - private var clientRotation: Quaternionfc? = null + private var lastTickRotation: Quaternionfc? = null + private var rotation: Quaternionfc? = null - val rotation: Quaternionfc + private var lerpPos: Vector3dc? = null + private var lerpRot: Quaternionfc? = null + private var lerpSteps = 0 + + private val serverRotation: Quaternionfc get() { val rotationRaw = entityData.get(ROTATION_DATA) return Quaternionf().rotateXYZ(rotationRaw.x, rotationRaw.y, rotationRaw.z) @@ -52,22 +57,76 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( throw IllegalStateException("Cannot define physicsEntityData, its already defined!") } this.physicsEntityData = physicsEntityData + if (!this.level.isClientSide) { + var defaultRot = Rotations(0.0f, 0.0f, 0.0f) + if (!this.level.isClientSide) { + val eulerAngles = physicsEntityData.transform.shipToWorldRotation.getEulerAnglesXYZ(Vector3d()) + defaultRot = Rotations(eulerAngles.x.toFloat(), eulerAngles.y.toFloat(), eulerAngles.z.toFloat()) + } + this.entityData.set(ROTATION_DATA, defaultRot) + } + lastTickRotation = Quaternionf(physicsEntityData.transform.shipToWorldRotation) + rotation = lastTickRotation } override fun tick() { + if (lerpPos == null) { + lerpPos = position().toJOML() + lerpRot = serverRotation + rotation = serverRotation + } + lastTickRotation = rotation if (!this.level.isClientSide) { val physicsEntityServerCopy = physicsEntityServer if (physicsEntityServerCopy != null) { - this.setPos(physicsEntityServerCopy.shipTransform.positionInWorld.toMinecraft()) - val eulerAngles = physicsEntityServerCopy.shipTransform.shipToWorldRotation.getEulerAnglesXYZ(Vector3d()) + val transform = physicsEntityServerCopy.shipTransform + this.setPos(transform.positionInWorld.toMinecraft()) + val eulerAngles = transform.shipToWorldRotation.getEulerAnglesXYZ(Vector3d()) this.entityData.set( ROTATION_DATA, Rotations(eulerAngles.x.toFloat(), eulerAngles.y.toFloat(), eulerAngles.z.toFloat()) ) + rotation = Quaternionf(transform.shipToWorldRotation) + this.physicsEntityData!!.transform = transform } + } else { + tickLerp() } super.tick() } + override fun lerpTo(d: Double, e: Double, f: Double, g: Float, h: Float, i: Int, bl: Boolean) { + this.lerpPos = Vector3d(d, e, f) + this.lerpRot = serverRotation + this.lerpSteps = CLIENT_INTERP_STEPS + } + + private fun tickLerp() { + if (this.lerpSteps <= 0) { + return + } else if (this.lerpSteps == 1) { + setPos(lerpPos!!.x(), lerpPos!!.y(), lerpPos!!.z()) + rotation = lerpRot + lerpSteps = 0 + return + } + + val d: Double = this.x + (this.lerpPos!!.x() - this.x) / this.lerpSteps.toDouble() + val e: Double = this.y + (this.lerpPos!!.y() - this.y) / this.lerpSteps.toDouble() + val f: Double = this.z + (this.lerpPos!!.z() - this.z) / this.lerpSteps.toDouble() + + rotation = rotation!!.slerp(this.lerpRot, (1.0 - (1.0 / this.lerpSteps.toDouble())).toFloat(), Quaternionf()) + + --this.lerpSteps + this.setPos(d, e, f) + } + + fun getRenderRotation(partialTick: Float): Quaternionfc { + if (lastTickRotation == null) { + return serverRotation + } + return lastTickRotation!!.slerp(rotation!!, partialTick, Quaternionf()) + } + override fun defineSynchedData() { entityData.define(ROTATION_DATA, Rotations(0.0f, 0.0f, 0.0f)) } @@ -127,8 +186,18 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( } } + override fun shouldRenderAtSqrDistance(d: Double): Boolean { + var e = this.boundingBox.size + if (java.lang.Double.isNaN(e)) { + e = 1.0 + } + e *= 1024.0 + return d < e * e + } + companion object { private const val PHYS_DATA_NBT_KEY = "phys_entity_data" + private const val CLIENT_INTERP_STEPS = 3 private val ROTATION_DATA: EntityDataAccessor<Rotations> = SynchedEntityData.defineId(VSPhysicsEntity::class.java, EntityDataSerializers.ROTATIONS) 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 7b432e8fa..5ae9cea1f 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 @@ -23,8 +23,6 @@ import net.minecraft.world.item.BlockItem import net.minecraft.world.item.CreativeModeTab import net.minecraft.world.item.Item.Properties import net.minecraft.world.level.block.Block -import net.minecraft.world.level.block.state.BlockBehaviour -import net.minecraft.world.level.material.Material import org.valkyrienskies.core.apigame.VSCoreFactory import org.valkyrienskies.mod.client.EmptyRenderer import org.valkyrienskies.mod.client.VSPhysicsEntityRenderer @@ -32,6 +30,7 @@ import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestFlapBlock import org.valkyrienskies.mod.common.block.TestHingeBlock +import org.valkyrienskies.mod.common.block.TestSphereBlock import org.valkyrienskies.mod.common.block.TestWingBlock import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.command.VSCommands @@ -63,7 +62,7 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_HINGE = TestHingeBlock ValkyrienSkiesMod.TEST_FLAP = TestFlapBlock ValkyrienSkiesMod.TEST_WING = TestWingBlock - ValkyrienSkiesMod.TEST_SPHERE = Block(BlockBehaviour.Properties.of(Material.STONE)) + ValkyrienSkiesMod.TEST_SPHERE = TestSphereBlock ValkyrienSkiesMod.SHIP_CREATOR_ITEM = ShipCreatorItem( Properties().tab(CreativeModeTab.TAB_MISC), { 1.0 }, @@ -88,6 +87,7 @@ class ValkyrienSkiesModFabric : ModInitializer { MobCategory.MISC ).sized(.3f, .3f) .updateInterval(1) + .clientTrackingRange(10) .build(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "vs_physics_entity").toString()) ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE = 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 dfea1eede..1906df862 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.commands.Commands.CommandSelection.ALL +import net.minecraft.commands.Commands.CommandSelection.INTEGRATED import net.minecraft.resources.ResourceLocation import net.minecraft.world.entity.EntityType import net.minecraft.world.entity.MobCategory @@ -10,14 +11,12 @@ 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.minecraft.world.level.block.state.BlockBehaviour -import net.minecraft.world.level.material.Material import net.minecraftforge.client.ClientRegistry import net.minecraftforge.client.ConfigGuiHandler.ConfigGuiFactory import net.minecraftforge.client.event.EntityRenderersEvent 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 @@ -36,6 +35,7 @@ import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.block.TestChairBlock import org.valkyrienskies.mod.common.block.TestFlapBlock import org.valkyrienskies.mod.common.block.TestHingeBlock +import org.valkyrienskies.mod.common.block.TestSphereBlock import org.valkyrienskies.mod.common.block.TestWingBlock import org.valkyrienskies.mod.common.blockentity.TestHingeBlockEntity import org.valkyrienskies.mod.common.command.VSCommands @@ -113,7 +113,7 @@ class ValkyrienSkiesModForge { TEST_HINGE_REGISTRY = registerBlockAndItem("test_hinge") { TestHingeBlock } TEST_FLAP_REGISTRY = registerBlockAndItem("test_flap") { TestFlapBlock } TEST_WING_REGISTRY = registerBlockAndItem("test_wing") { TestWingBlock } - TEST_SPHERE_REGISTRY = registerBlockAndItem("test_sphere") { Block(BlockBehaviour.Properties.of(Material.STONE)) } + TEST_SPHERE_REGISTRY = registerBlockAndItem("test_sphere") { TestSphereBlock } SHIP_CREATOR_ITEM_REGISTRY = ITEMS.register("ship_creator") { ShipCreatorItem(Properties().tab(CreativeModeTab.TAB_MISC), @@ -150,6 +150,7 @@ class ValkyrienSkiesModForge { MobCategory.MISC ).sized(.3f, .3f) .setUpdateInterval(1) + .clientTrackingRange(10) .build(ResourceLocation(ValkyrienSkiesMod.MOD_ID, "vs_physics_entity").toString()) } From c31b258ce1e20d1d5c4c1887424be74665a4f0f6 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 16 Aug 2023 23:35:15 -0600 Subject: [PATCH 173/437] Made teleporting physics entities work --- .../mod/common/entity/VSPhysicsEntity.kt | 18 ++++++++++++++++++ .../mod/common/world/DummyShipWorldServer.kt | 4 ++++ vs-core | 2 +- 3 files changed, 23 insertions(+), 1 deletion(-) 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 c7279eb88..2cbadb4bc 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 @@ -25,7 +25,9 @@ import org.valkyrienskies.core.apigame.physics.PhysicsEntityData import org.valkyrienskies.core.apigame.physics.PhysicsEntityServer import org.valkyrienskies.core.apigame.physics.VSSphereCollisionShapeData 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.ShipObjectServerWorld import org.valkyrienskies.core.impl.util.serialization.VSJacksonUtil import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.shipObjectWorld @@ -195,6 +197,22 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( return d < e * e } + override fun moveTo(d: Double, e: Double, f: Double, g: Float, h: Float) { + super.moveTo(d, e, f, g, h) + if (!this.level.isClientSide) { + val physicsEntityServerCopy = physicsEntityServer + if (physicsEntityServerCopy != null) { + val newPos = Vector3d(d, e, f) + this.entityData.set( + ROTATION_DATA, Rotations(0.0f, 0.0f, 0.0f) + ) + val teleportData = ShipTeleportDataImpl(newPos = newPos) + rotation = Quaternionf() + (this.level.shipObjectWorld as ShipObjectServerWorld).teleportPhysicsEntity(this.physicsEntityServer!!, teleportData) + } + } + } + companion object { private const val PHYS_DATA_NBT_KEY = "phys_entity_data" private const val CLIENT_INTERP_STEPS = 3 diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt index 32206edb6..da7cf361a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt @@ -93,6 +93,10 @@ object DummyShipWorldServer : ServerShipWorldCore { TODO("Not yet implemented") } + override fun teleportPhysicsEntity(physicsEntityServer: PhysicsEntityServer, teleportData: ShipTeleportData) { + TODO("Not yet implemented") + } + override val dimensionToGroundBodyIdImmutable: Map<DimensionId, ShipId> get() = TODO("Not yet implemented") diff --git a/vs-core b/vs-core index 4d514bc98..5417497c1 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 4d514bc987ac0639b9758816bb9e0715a6d50075 +Subproject commit 5417497c15d15971f0d3a7b55699496766872e38 From 50d80c8a43064b0dc7130f1998054bf87e53a90c Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 17 Aug 2023 01:22:32 -0600 Subject: [PATCH 174/437] Made physics entities go through nether portals --- .../accessors/entity/EntityAccessor.java | 10 +++- .../mod/common/entity/VSPhysicsEntity.kt | 46 +++++++++++++++++-- vs-core | 2 +- 3 files changed, 51 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/entity/EntityAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/entity/EntityAccessor.java index 69f0ea951..68b9739ad 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/entity/EntityAccessor.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/entity/EntityAccessor.java @@ -21,5 +21,13 @@ public interface EntityAccessor { @Accessor("feetBlockState") void setFeetBlockState(BlockState feetBlockState); - + + @Accessor("portalCooldown") + void setPortalCooldown(int portalCooldown); + + @Accessor("portalCooldown") + int getPortalCooldown(); + + @Accessor("portalEntrancePos") + BlockPos getPortalEntrancePos(); } 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 2cbadb4bc..9ec42889a 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 @@ -28,11 +28,13 @@ 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.ShipObjectServerWorld +import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl import org.valkyrienskies.core.impl.util.serialization.VSJacksonUtil import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toMinecraft +import org.valkyrienskies.mod.mixin.accessors.entity.EntityAccessor class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity(type, level) { // Physics data, persistent @@ -90,6 +92,7 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( rotation = Quaternionf(transform.shipToWorldRotation) this.physicsEntityData!!.transform = transform } + this.tryCheckInsideBlocks() } else { tickLerp() } @@ -134,14 +137,9 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( } override fun readAdditionalSaveData(compoundTag: CompoundTag) { - val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY) - val physicsEntityData = getMapper().readValue<PhysicsEntityData>(physicsEntityDataAsBytes) - setPhysicsEntityData(physicsEntityData) } override fun addAdditionalSaveData(compoundTag: CompoundTag) { - val physicsEntityDataAsBytes = getMapper().writeValueAsBytes(physicsEntityData) - compoundTag.putByteArray(PHYS_DATA_NBT_KEY, physicsEntityDataAsBytes) } override fun getAddEntityPacket(): Packet<*> { @@ -154,6 +152,29 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( return super.saveWithoutId(compoundTag) } + // 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) { + throw IllegalStateException("This entity is already loaded!") + } + val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY) + val oldPhysicsEntityData = getMapper().readValue<PhysicsEntityData>(physicsEntityDataAsBytes) + val newShipId = (level.shipObjectWorld as ShipObjectServerWorld).allocateShipId(level.dimensionId) + val newPhysicsEntityData = PhysicsEntityData( + shipId = newShipId, + transform = oldPhysicsEntityData.transform, + inertiaData = oldPhysicsEntityData.inertiaData, + linearVelocity = oldPhysicsEntityData.linearVelocity, + angularVelocity = oldPhysicsEntityData.angularVelocity, + collisionShapeData = oldPhysicsEntityData.collisionShapeData, + isStatic = oldPhysicsEntityData.isStatic, + ) + // Change the shipId to be something new + setPhysicsEntityData(newPhysicsEntityData) + super.load(compoundTag) + } + override fun load(compoundTag: CompoundTag) { if (!this.level.isClientSide && physicsEntityData != null) { throw IllegalStateException("This entity is already loaded!") @@ -209,10 +230,25 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( val teleportData = ShipTeleportDataImpl(newPos = newPos) rotation = Quaternionf() (this.level.shipObjectWorld as ShipObjectServerWorld).teleportPhysicsEntity(this.physicsEntityServer!!, teleportData) + } else { + physicsEntityData!!.transform = ShipTransformImpl.create( + Vector3d(d, e, f), + Vector3d(), + physicsEntityData!!.transform.shipToWorldRotation, + ) } } } + // Used when teleporting through nether portals to create a new entity that's almost the same as this one + override fun restoreFrom(entity: Entity) { + val compoundTag = entity.saveWithoutId(CompoundTag()) + compoundTag.remove("Dimension") + loadForTeleport(compoundTag) + ((this as EntityAccessor).portalCooldown) = (entity as EntityAccessor).portalCooldown + portalEntrancePos = entity.portalEntrancePos + } + companion object { private const val PHYS_DATA_NBT_KEY = "phys_entity_data" private const val CLIENT_INTERP_STEPS = 3 diff --git a/vs-core b/vs-core index 5417497c1..3c8d9347d 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 5417497c15d15971f0d3a7b55699496766872e38 +Subproject commit 3c8d9347dd3b9300baa98be44bf54aefc4603ec8 From 3179b6769de418d761469d4d983a55b93481f9fd Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 17 Aug 2023 01:53:35 -0600 Subject: [PATCH 175/437] Fixed worlds not unloading properly --- .../org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt index da7cf361a..f52b24c4d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt @@ -55,7 +55,7 @@ object DummyShipWorldServer : ServerShipWorldCore { } override fun deletePhysicsEntity(id: ShipId) { - TODO("Not yet implemented") + // This is implemented because physics entities get deleted after the vs pipeline? } override fun allocateShipId(dimensionId: DimensionId): ShipId { From 36c886d4a17e45ee1c35ef0637df33c4b7b3ace6 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 17 Aug 2023 03:36:16 -0600 Subject: [PATCH 176/437] Fixed ships falling through the ground when using nether portals --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 3c8d9347d..2eba0d5ed 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 3c8d9347dd3b9300baa98be44bf54aefc4603ec8 +Subproject commit 2eba0d5ed497c27e013fcc0419d7f8c53db3741e From c563ed0cd36d02c6da294beba89953d886590ff5 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 17 Aug 2023 21:37:12 -0600 Subject: [PATCH 177/437] Fixed scaling, fixed physics settings not applied --- .../mod/common/item/PhysicsEntityCreatorItem.kt | 10 +++++++--- vs-core | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt index ad1d12394..a376fb73a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt @@ -12,6 +12,7 @@ import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.entity.VSPhysicsEntity import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.toJOML +import org.valkyrienskies.mod.common.util.toJOMLD class PhysicsEntityCreatorItem( properties: Properties @@ -26,10 +27,13 @@ class PhysicsEntityCreatorItem( if (!level.isClientSide) { val entity = ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE.create(level)!! val shipId = level.shipObjectWorld.allocateShipId(level.dimensionId) - val transform = Companion.create(ctx.clickLocation.toJOML(), Vector3d()) - val physicsEntityData = VSPhysicsEntity.createBasicSphereData(shipId, transform) + val sphereRadius = 0.5 + val offset = ctx.clickedFace.normal.toJOMLD().mul(sphereRadius) + val entityPos = ctx.clickLocation.toJOML().add(offset) + val transform = Companion.create(entityPos, Vector3d()) + val physicsEntityData = VSPhysicsEntity.createBasicSphereData(shipId, transform, sphereRadius) entity.setPhysicsEntityData(physicsEntityData) - entity.setPos(ctx.clickLocation) + entity.setPos(entityPos.x, entityPos.y, entityPos.z) level.addFreshEntity(entity) } diff --git a/vs-core b/vs-core index 2eba0d5ed..9921cd863 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 2eba0d5ed497c27e013fcc0419d7f8c53db3741e +Subproject commit 9921cd863603dd8998eaf38e7217ccaa682b90f5 From 6df2674f5a46cb06835e7777c7f870681e2124bf Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 17 Aug 2023 21:37:44 -0600 Subject: [PATCH 178/437] Fixed null pointer error --- .../valkyrienskies/mod/common/entity/VSPhysicsEntity.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 9ec42889a..62d81ea04 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 @@ -119,7 +119,12 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( val e: Double = this.y + (this.lerpPos!!.y() - this.y) / this.lerpSteps.toDouble() val f: Double = this.z + (this.lerpPos!!.z() - this.z) / this.lerpSteps.toDouble() - rotation = rotation!!.slerp(this.lerpRot, (1.0 - (1.0 / this.lerpSteps.toDouble())).toFloat(), Quaternionf()) + if (rotation != null) { + rotation = rotation!!.slerp(this.lerpRot, (1.0 - (1.0 / this.lerpSteps.toDouble())).toFloat(), Quaternionf()) + } else { + rotation = serverRotation + lastTickRotation = rotation + } --this.lerpSteps this.setPos(d, e, f) From 8bf68305f2789f72123bda957089183d82eee98f Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 17 Aug 2023 21:40:15 -0600 Subject: [PATCH 179/437] Changed vs-core to be main --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 9921cd863..566fa550a 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 9921cd863603dd8998eaf38e7217ccaa682b90f5 +Subproject commit 566fa550ae25f8ff2b42601b77751bf767da906b From 9cf1406ad1f727dc0674b0c1dc1edc785b8a932b Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 17 Aug 2023 22:39:18 -0600 Subject: [PATCH 180/437] Fixed weird crash --- .../org/valkyrienskies/mod/common/world/RaycastUtils.kt | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) 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..6e1699db8 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 @@ -222,17 +222,14 @@ fun Level.raytraceEntities( val start = Vector3d() val end = Vector3d() - if (shipObjectWorld == null) logger.error("rayTraceEntities shipObjectWorld was null! this should never happen!") - shipObjectWorld?.loadedShips?.getIntersecting(origBoundingBoxM.toJOML())?.forEach { + shipObjectWorld.loadedShips.getIntersecting(origBoundingBoxM.toJOML()).forEach { it.worldToShip.transformPosition(origStartVec, start) it.worldToShip.transformPosition(origEndVec, end) - // Shouldn't we have a double for scale in transform? - val scale = it.shipTransform.worldToShipMatrix.getScale(Vector3d()) - assert(scale.x == scale.y && scale.y == scale.z) + val scale = 1.0 / it.transform.shipToWorldScaling.x() - checkEntities(entities, start.toMinecraft(), end.toMinecraft(), scale.x) + checkEntities(entities, start.toMinecraft(), end.toMinecraft(), scale) } return if (resultEntity == null) { From 5791e1013bb99be78082880bad8324fa986b905c Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Fri, 18 Aug 2023 00:30:42 -0600 Subject: [PATCH 181/437] Fixed build errors --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 566fa550a..64ae5f455 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 566fa550ae25f8ff2b42601b77751bf767da906b +Subproject commit 64ae5f455cb33904e6efbbfd01300cb70e4ee01e From 939d466d7dc3d32c89064291534823fd65ba03d1 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 19 Aug 2023 03:56:35 -0600 Subject: [PATCH 182/437] Got dimension tp working --- .../server/world/ChunkMapAccessor.java | 4 ++ .../mixin/server/MixinMinecraftServer.java | 40 ++++++++++++++++++- .../mod/common/command/VSCommands.kt | 22 +++++++--- .../mod/common/world/DummyShipWorldServer.kt | 4 ++ vs-core | 2 +- 5 files changed, 63 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/world/ChunkMapAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/world/ChunkMapAccessor.java index c91c849ae..dfede67ff 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/world/ChunkMapAccessor.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/world/ChunkMapAccessor.java @@ -5,6 +5,7 @@ import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.chunk.ChunkAccess; import org.apache.commons.lang3.mutable.MutableObject; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Invoker; @@ -21,4 +22,7 @@ void callUpdateChunkTracking(ServerPlayer player, ChunkPos pos, @Invoker("getVisibleChunkIfPresent") ChunkHolder callGetVisibleChunkIfPresent(long l); + + @Invoker("save") + boolean callSave(ChunkAccess chunkAccess); } 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 3c81ec086..74433294a 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 @@ -10,6 +10,8 @@ import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.players.PlayerList; +import net.minecraft.world.level.chunk.LevelChunk; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -18,6 +20,8 @@ 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.properties.IShipActiveChunksSet; +import org.valkyrienskies.core.apigame.GameServer; import org.valkyrienskies.core.apigame.world.IPlayer; import org.valkyrienskies.core.apigame.world.ServerShipWorldCore; import org.valkyrienskies.core.apigame.world.VSPipeline; @@ -28,10 +32,11 @@ import org.valkyrienskies.mod.common.hooks.VSGameEvents; import org.valkyrienskies.mod.common.util.EntityDragger; import org.valkyrienskies.mod.common.world.ChunkManagement; +import org.valkyrienskies.mod.mixin.accessors.server.world.ChunkMapAccessor; import org.valkyrienskies.mod.util.KrunchSupport; @Mixin(MinecraftServer.class) -public abstract class MixinMinecraftServer implements IShipObjectWorldServerProvider { +public abstract class MixinMinecraftServer implements IShipObjectWorldServerProvider, GameServer { @Shadow private PlayerList playerList; @@ -47,8 +52,12 @@ public abstract class MixinMinecraftServer implements IShipObjectWorldServerProv @Unique private VSPipeline vsPipeline; + @Unique private Set<String> loadedLevels = new HashSet<>(); + @Unique + private final Map<String, ServerLevel> dimensionToLevelMap = new HashMap<>(); + @Inject( at = @At(value = "INVOKE", target = "Lnet/minecraft/server/MinecraftServer;initServer()Z"), method = "runServer" @@ -116,6 +125,7 @@ private void postCreateLevels(final CallbackInfo ci) { KrunchSupport.INSTANCE.setKrunchSupported(!vsPipeline.isUsingDummyPhysics()); shipWorld = vsPipeline.getShipWorld(); + shipWorld.setGameServer(this); VSGameEvents.INSTANCE.getRegistriesCompleted().emit(Unit.INSTANCE); @@ -133,7 +143,9 @@ private void preTick(final CallbackInfo ci) { // region Tell the VS world to load new levels, and unload deleted ones final Map<String, ServerLevel> newLoadedLevels = new HashMap<>(); for (final ServerLevel level : getAllLevels()) { - newLoadedLevels.put(VSGameUtilsKt.getDimensionId(level), level); + final String dimensionId = VSGameUtilsKt.getDimensionId(level); + newLoadedLevels.put(dimensionId, level); + dimensionToLevelMap.put(dimensionId, level); } /* for (final var entry : newLoadedLevels.entrySet()) { @@ -147,6 +159,7 @@ private void preTick(final CallbackInfo ci) { for (final String oldLoadedLevelId : loadedLevels) { if (!newLoadedLevels.containsKey(oldLoadedLevelId)) { shipWorld.removeDimension(oldLoadedLevelId); + dimensionToLevelMap.remove(oldLoadedLevelId); } } loadedLevels = newLoadedLevels.keySet(); @@ -191,6 +204,29 @@ private void preStopServer(final CallbackInfo ci) { vsPipeline.setDeleteResources(true); vsPipeline.setArePhysicsRunning(true); } + dimensionToLevelMap.clear(); + shipWorld.setGameServer(null); shipWorld = null; } + + @NotNull + private ServerLevel getLevelFromDimensionId(@NotNull final String dimensionId) { + return dimensionToLevelMap.get(dimensionId); + } + + @Override + public void moveTerrainAcrossDimensions( + @NotNull final IShipActiveChunksSet shipChunks, + @NotNull final String srcDimension, + @NotNull final String destDimension + ) { + final ServerLevel srcLevel = getLevelFromDimensionId(srcDimension); + final ServerLevel destLevel = getLevelFromDimensionId(destDimension); + // TODO: We can run this async, so run it async! + shipChunks.forEach((final int x, final int z) -> { + final LevelChunk srcChunk = srcLevel.getChunk(x, z); + // Save the ship chunks to dest level + ((ChunkMapAccessor) destLevel.getChunkSource().chunkMap).callSave(srcChunk); + }); + } } 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 a4ae3076c..dc939fe6f 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 @@ -28,6 +28,7 @@ import org.valkyrienskies.core.impl.game.ships.ShipObject import org.valkyrienskies.core.impl.util.x import org.valkyrienskies.core.impl.util.y import org.valkyrienskies.core.impl.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 @@ -117,8 +118,9 @@ object VSCommands { val r = ShipArgument.getShips(it, "ships").toList() as List<ServerShip> val position = Vec3Argument.getVec3(it as CommandContext<CommandSourceStack>, "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<VSCommandSource>).source.shipWorld as ServerShipWorld, @@ -146,12 +148,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( @@ -185,13 +189,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( @@ -230,6 +236,7 @@ object VSCommands { ) val source = it.source as CommandSourceStack + val dimensionId = (it.source as CommandSourceStack).level.dimensionId val shipTeleportData: ShipTeleportData = ShipTeleportDataImpl( newPos = position.toJOML(), @@ -237,7 +244,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( @@ -372,9 +380,10 @@ object VSCommands { val entity = EntityArgument.getEntity(it as CommandContext<CommandSourceStack>, "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)) + ShipTeleportDataImpl(newPos = Vector3d(entity.x, entity.y, entity.z), newDimension = dimensionId) ) } (it as CommandContext<VSCommandSource>).source.sendVSMessage( @@ -389,9 +398,10 @@ 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()) + ShipTeleportDataImpl(newPos = pos.toJOMLD(), newDimension = dimensionId) ) } (it as CommandContext<VSCommandSource>).source.sendVSMessage( diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt index f52b24c4d..c7c878e13 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt @@ -7,6 +7,7 @@ import org.valkyrienskies.core.api.ships.QueryableShipData import org.valkyrienskies.core.api.ships.ServerShip import org.valkyrienskies.core.api.ships.properties.ShipId import org.valkyrienskies.core.api.world.LevelYRange +import org.valkyrienskies.core.apigame.GameServer import org.valkyrienskies.core.apigame.ShipTeleportData import org.valkyrienskies.core.apigame.constraints.VSConstraint import org.valkyrienskies.core.apigame.constraints.VSConstraintId @@ -24,6 +25,9 @@ import org.valkyrienskies.core.impl.game.ships.QueryableShipDataImpl object DummyShipWorldServer : ServerShipWorldCore { override var players: Set<IPlayer> = emptySet() + override fun setGameServer(gameServer: GameServer?) { + TODO("Not yet implemented") + } override fun addTerrainUpdates(dimensionId: DimensionId, terrainUpdates: List<TerrainUpdate>) { TODO("Not yet implemented") diff --git a/vs-core b/vs-core index 64ae5f455..f385dc7ae 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 64ae5f455cb33904e6efbbfd01300cb70e4ee01e +Subproject commit f385dc7aee3eb42e99d59f31a963066f41b8c39c From 7d16a1442817fd39436f0798d0e0b28ce8aa70ce Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 19 Aug 2023 05:17:24 -0600 Subject: [PATCH 183/437] Fixed ships falling through the ground on super-flat worlds --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index f385dc7ae..9b0eff593 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit f385dc7aee3eb42e99d59f31a963066f41b8c39c +Subproject commit 9b0eff59390734097add8127f0fe8c38e2dd297e From 42d5a1c650d045160d83eac9e18003dd81e6e31b Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 19 Aug 2023 05:53:17 -0600 Subject: [PATCH 184/437] Fixed ships not unloading when all blocks are destroyed --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 9b0eff593..c701b2e75 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 9b0eff59390734097add8127f0fe8c38e2dd297e +Subproject commit c701b2e759e6424868c71fdca5ce9884dfc2cb82 From 5ce87260f031fa479b3522e03a7ca5cbb57c2c9b Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 19 Aug 2023 08:25:52 -0600 Subject: [PATCH 185/437] Ships tp through nether portals, but fall through the floor --- .../mixin/server/MixinMinecraftServer.java | 167 ++++++++++++++++-- vs-core | 2 +- 2 files changed, 156 insertions(+), 13 deletions(-) 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 74433294a..83822c289 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 @@ -1,18 +1,37 @@ package org.valkyrienskies.mod.mixin.server; +import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.Map; +import java.util.Optional; import java.util.Set; -import java.util.function.BooleanSupplier; import java.util.stream.Collectors; import kotlin.Unit; +import net.minecraft.BlockUtil; +import net.minecraft.BlockUtil.FoundRectangle; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.players.PlayerList; +import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.level.Level; +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; @@ -20,17 +39,21 @@ 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; import org.valkyrienskies.mod.common.ValkyrienSkiesMod; import org.valkyrienskies.mod.common.hooks.VSGameEvents; import org.valkyrienskies.mod.common.util.EntityDragger; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.common.world.ChunkManagement; import org.valkyrienskies.mod.mixin.accessors.server.world.ChunkMapAccessor; import org.valkyrienskies.mod.util.KrunchSupport; @@ -71,17 +94,6 @@ private void afterStopServer(final CallbackInfo ci) { ValkyrienSkiesMod.setCurrentServer(null); } - @Inject( - at = @At("HEAD"), - method = "tickServer" - ) - public void onTick(final BooleanSupplier booleanSupplier, final CallbackInfo ci) { - final Set<IPlayer> vsPlayers = playerList.getPlayers().stream() - .map(VSGameUtilsKt::getPlayerWrapper).collect(Collectors.toSet()); - - shipWorld.setPlayers(vsPlayers); - } - @Nullable @Override public ServerShipWorldCore getShipObjectWorld() { @@ -140,6 +152,11 @@ private void postCreateLevels(final CallbackInfo ci) { at = @At("HEAD") ) private void preTick(final CallbackInfo ci) { + final Set<IPlayer> vsPlayers = playerList.getPlayers().stream() + .map(VSGameUtilsKt::getPlayerWrapper).collect(Collectors.toSet()); + + shipWorld.setPlayers(vsPlayers); + // region Tell the VS world to load new levels, and unload deleted ones final Map<String, ServerLevel> newLoadedLevels = new HashMap<>(); for (final ServerLevel level : getAllLevels()) { @@ -183,6 +200,12 @@ private void preConnectionTick(final CallbackInfo ci) { ChunkManagement.tickChunkLoading(shipWorld, MinecraftServer.class.cast(this)); } + @Shadow + public abstract ServerLevel getLevel(ResourceKey<Level> resourceKey); + + @Shadow + public abstract boolean isNetherEnabled(); + @Inject( method = "tickServer", at = @At("TAIL") @@ -193,6 +216,125 @@ private void postTick(final CallbackInfo ci) { for (final ServerLevel level : getAllLevels()) { EntityDragger.INSTANCE.dragEntitiesWithShips(level.getAllEntities()); } + + handleShipPortals(); + } + + @Unique + private void handleShipPortals() { + // Teleport ships that touch portals + final ArrayList<LoadedServerShip> loadedShipsCopy = new ArrayList<>(shipWorld.getLoadedShips()); + for (final LoadedServerShip shipObject : loadedShipsCopy) { + 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); + // Only run this code if the chunks between blockPos and blockPos2 are loaded + if (level.hasChunksAt(blockPos, blockPos2)) { + shipObject.decayPortalCoolDown(); + + final BlockPos.MutableBlockPos mutableBlockPos = new BlockPos.MutableBlockPos(); + for (int i = blockPos.getX(); i <= blockPos2.getX(); ++i) { + for (int j = blockPos.getY(); j <= blockPos2.getY(); ++j) { + for (int k = blockPos.getZ(); k <= blockPos2.getZ(); ++k) { + mutableBlockPos.set(i, j, k); + final BlockState blockState = level.getBlockState(mutableBlockPos); + if (blockState.getBlock() == Blocks.NETHER_PORTAL) { + // Handle nether portal teleport + if (!shipObject.isOnPortalCoolDown()) { + // Move the ship between dimensions + final ServerLevel destLevel = getLevel(level.dimension() == Level.NETHER ? Level.OVERWORLD : Level.NETHER); + // TODO: Do we want portal time? + if (destLevel != null && isNetherEnabled()) { // && this.portalTime++ >= i) { + level.getProfiler().push("portal"); + shipChangeDimension(level, destLevel, mutableBlockPos, shipObject); + level.getProfiler().pop(); + } + } + shipObject.handleInsidePortal(); + } else if (blockState.getBlock() == Blocks.END_PORTAL) { + // Handle end portal teleport + final ServerLevel destLevel = level.getServer().getLevel(level.dimension() == Level.END ? Level.OVERWORLD : Level.END); + if (destLevel == null) { + return; + } + shipChangeDimension(level, destLevel, null, shipObject); + } + } + } + } + } + } + } + + @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()); + if (portalInfo == null) { + // Getting portal info failed? Don't teleport. + return; + } + final ShipTeleportData shipTeleportData = new ShipTeleportDataImpl( + VectorConversionsMCKt.toJOML(portalInfo.pos), + shipObject.getTransform().getShipToWorldRotation(), + new Vector3d(), + new Vector3d(), + VSGameUtilsKt.getDimensionId(destLevel) + ); + shipWorld.teleportShip(shipObject, shipTeleportData); + } + + @Unique + @Nullable + private PortalInfo findDimensionEntryPoint(@NotNull final ServerLevel srcLevel, @NotNull final ServerLevel destLevel, @Nullable final BlockPos portalEntrancePos, @NotNull final Vector3dc shipPos) { + final boolean bl = srcLevel.dimension() == Level.END && destLevel.dimension() == Level.OVERWORLD; + final boolean bl2 = destLevel.dimension() == Level.END; + final Vec3 deltaMovement = Vec3.ZERO; + final EntityDimensions entityDimensions = new EntityDimensions(1.0f, 1.0f, true); + if (bl || bl2) { + final BlockPos blockPos = bl2 ? ServerLevel.END_SPAWN_POINT : destLevel.getHeightmapPos(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES, destLevel.getSharedSpawnPos()); + return new PortalInfo(new Vec3((double)blockPos.getX() + 0.5, blockPos.getY(), (double)blockPos.getZ() + 0.5), deltaMovement, 0f, 0f); + } + final boolean bl3 = destLevel.dimension() == Level.NETHER; + if (srcLevel.dimension() != Level.NETHER && !bl3) { + return null; + } + final WorldBorder worldBorder = destLevel.getWorldBorder(); + final double d = DimensionType.getTeleportationScale(srcLevel.dimensionType(), destLevel.dimensionType()); + final BlockPos blockPos2 = worldBorder.clampToBounds(shipPos.x() * d, shipPos.y(), shipPos.z() * d); + return this.getExitPortal(destLevel, blockPos2, bl3, worldBorder).map(foundRectangle -> { + final Vec3 vec3; + final Direction.Axis axis; + if (portalEntrancePos != null) { + final BlockState blockState = srcLevel.getBlockState(portalEntrancePos); + if (blockState.hasProperty(BlockStateProperties.HORIZONTAL_AXIS)) { + axis = blockState.getValue(BlockStateProperties.HORIZONTAL_AXIS); + final BlockUtil.FoundRectangle foundRectangle2 = + BlockUtil.getLargestRectangleAround(portalEntrancePos, axis, 21, Direction.Axis.Y, 21, + blockPos -> srcLevel.getBlockState(blockPos) == blockState); + vec3 = this.getRelativePortalPosition(axis, foundRectangle2, entityDimensions, + VectorConversionsMCKt.toMinecraft(shipPos)); + } else { + axis = Direction.Axis.X; + vec3 = new Vec3(0.5, 0.0, 0.0); + } + } else { + axis = Direction.Axis.X; + vec3 = new Vec3(0.5, 0.0, 0.0); + } + return PortalShape.createPortalInfo(destLevel, foundRectangle, axis, vec3, entityDimensions, deltaMovement, 0.0f, 0.0f); + }).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); + } + + @Unique + private Optional<FoundRectangle> getExitPortal(final ServerLevel serverLevel, final BlockPos blockPos, final boolean bl, final WorldBorder worldBorder) { + return serverLevel.getPortalForcer().findPortalAround(blockPos, bl, worldBorder); } @Inject( @@ -228,5 +370,6 @@ public void moveTerrainAcrossDimensions( // Save the ship chunks to dest level ((ChunkMapAccessor) destLevel.getChunkSource().chunkMap).callSave(srcChunk); }); + // TODO: Delete old terrain } } diff --git a/vs-core b/vs-core index c701b2e75..ac7b61287 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit c701b2e759e6424868c71fdca5ce9884dfc2cb82 +Subproject commit ac7b61287441fb1276448ed318f25fbe8df6ee89 From c9e06ae977733338d6bbe2566b2bddf3125b4b0c Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 19 Aug 2023 18:23:30 -0600 Subject: [PATCH 186/437] Added collision mask, restitution, and friction to physics entities --- .../mod/common/entity/VSPhysicsEntity.kt | 10 +--------- .../mod/common/item/PhysicsEntityCreatorItem.kt | 3 +++ forge/build.gradle | 2 +- vs-core | 2 +- 4 files changed, 6 insertions(+), 11 deletions(-) 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 62d81ea04..3b06dd6ac 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 @@ -166,15 +166,7 @@ class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity( val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY) val oldPhysicsEntityData = getMapper().readValue<PhysicsEntityData>(physicsEntityDataAsBytes) val newShipId = (level.shipObjectWorld as ShipObjectServerWorld).allocateShipId(level.dimensionId) - val newPhysicsEntityData = PhysicsEntityData( - shipId = newShipId, - transform = oldPhysicsEntityData.transform, - inertiaData = oldPhysicsEntityData.inertiaData, - linearVelocity = oldPhysicsEntityData.linearVelocity, - angularVelocity = oldPhysicsEntityData.angularVelocity, - collisionShapeData = oldPhysicsEntityData.collisionShapeData, - isStatic = oldPhysicsEntityData.isStatic, - ) + val newPhysicsEntityData = oldPhysicsEntityData.copyPhysicsEntityDataWithNewId(newShipId) // Change the shipId to be something new setPhysicsEntityData(newPhysicsEntityData) super.load(compoundTag) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt index a376fb73a..2c2782e5f 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt @@ -32,6 +32,9 @@ class PhysicsEntityCreatorItem( val entityPos = ctx.clickLocation.toJOML().add(offset) val transform = Companion.create(entityPos, Vector3d()) val physicsEntityData = VSPhysicsEntity.createBasicSphereData(shipId, transform, sphereRadius) + physicsEntityData.dynamicFrictionCoefficient = 1.0 + physicsEntityData.staticFrictionCoefficient = 1.0 + physicsEntityData.restitutionCoefficient = 0.0 entity.setPhysicsEntityData(physicsEntityData) entity.setPos(entityPos.x, entityPos.y, entityPos.z) level.addFreshEntity(entity) diff --git a/forge/build.gradle b/forge/build.gradle index 7168170b5..669ac6c97 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -100,7 +100,7 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+61e725b93e") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+f053c720c5") { transitive = false } diff --git a/vs-core b/vs-core index 64ae5f455..2c0be2ddb 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 64ae5f455cb33904e6efbbfd01300cb70e4ee01e +Subproject commit 2c0be2ddb50a3a65ac042e75c545e3e1b15ef3e3 From 89c964003b29cea4765391d8b857c5bd6cd49097 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 19 Aug 2023 18:25:30 -0600 Subject: [PATCH 187/437] Don't make default physics entity high friction --- .../valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt | 3 --- 1 file changed, 3 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt index 2c2782e5f..a376fb73a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt @@ -32,9 +32,6 @@ class PhysicsEntityCreatorItem( val entityPos = ctx.clickLocation.toJOML().add(offset) val transform = Companion.create(entityPos, Vector3d()) val physicsEntityData = VSPhysicsEntity.createBasicSphereData(shipId, transform, sphereRadius) - physicsEntityData.dynamicFrictionCoefficient = 1.0 - physicsEntityData.staticFrictionCoefficient = 1.0 - physicsEntityData.restitutionCoefficient = 0.0 entity.setPhysicsEntityData(physicsEntityData) entity.setPos(entityPos.x, entityPos.y, entityPos.z) level.addFreshEntity(entity) From 226003da466603ed3b0b1a6c0bf0b28817381ce7 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 21 Aug 2023 04:32:27 -0600 Subject: [PATCH 188/437] More work on tp --- .../{world => level}/ChunkMapAccessor.java | 23 +++++++- .../server/level/DistanceManagerAccessor.java | 14 +++++ .../level/ServerChunkCacheAccessor.java | 11 ++++ .../mixin/server/MixinMinecraftServer.java | 54 +++++++++++++++++-- .../mixin/server/world/MixinServerLevel.java | 12 ++++- .../mod/common/util/ChunkRemover.kt | 5 ++ .../mod/common/world/ChunkManagement.kt | 2 +- .../valkyrienskies-common.accesswidener | 2 + .../valkyrienskies-common.mixins.json | 4 +- vs-core | 2 +- 10 files changed, 119 insertions(+), 10 deletions(-) rename common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/{world => level}/ChunkMapAccessor.java (56%) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/level/DistanceManagerAccessor.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/level/ServerChunkCacheAccessor.java create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/util/ChunkRemover.kt diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/world/ChunkMapAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/level/ChunkMapAccessor.java similarity index 56% rename from common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/world/ChunkMapAccessor.java rename to common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/level/ChunkMapAccessor.java index dfede67ff..cd00116f3 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/world/ChunkMapAccessor.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/level/ChunkMapAccessor.java @@ -1,13 +1,19 @@ -package org.valkyrienskies.mod.mixin.accessors.server.world; +package org.valkyrienskies.mod.mixin.accessors.server.level; +import it.unimi.dsi.fastutil.longs.LongSet; +import java.util.function.BooleanSupplier; import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkMap; +import net.minecraft.server.level.ChunkMap.DistanceManager; import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.entity.ai.village.poi.PoiManager; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkStatus; import org.apache.commons.lang3.mutable.MutableObject; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Invoker; @Mixin(ChunkMap.class) @@ -25,4 +31,19 @@ void callUpdateChunkTracking(ServerPlayer player, ChunkPos pos, @Invoker("save") boolean callSave(ChunkAccess chunkAccess); + + @Accessor("toDrop") + LongSet getToDrop(); + + @Invoker("processUnloads") + void callProcessUnloads(BooleanSupplier booleanSupplier); + + @Accessor("poiManager") + PoiManager getPoiManager(); + + @Invoker("markPosition") + byte callMarkPosition(ChunkPos chunkPos, ChunkStatus.ChunkType chunkType); + + @Accessor("distanceManager") + DistanceManager getDistanceManager(); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/level/DistanceManagerAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/level/DistanceManagerAccessor.java new file mode 100644 index 000000000..87c7229c5 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/level/DistanceManagerAccessor.java @@ -0,0 +1,14 @@ +package org.valkyrienskies.mod.mixin.accessors.server.level; + +import it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap; +import net.minecraft.server.level.DistanceManager; +import net.minecraft.server.level.Ticket; +import net.minecraft.util.SortedArraySet; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(DistanceManager.class) +public interface DistanceManagerAccessor { + @Accessor("tickets") + Long2ObjectOpenHashMap<SortedArraySet<Ticket<?>>> getTickets(); +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/level/ServerChunkCacheAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/level/ServerChunkCacheAccessor.java new file mode 100644 index 000000000..1dc027ff8 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/server/level/ServerChunkCacheAccessor.java @@ -0,0 +1,11 @@ +package org.valkyrienskies.mod.mixin.accessors.server.level; + +import net.minecraft.server.level.ServerChunkCache; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(ServerChunkCache.class) +public interface ServerChunkCacheAccessor { + @Invoker("clearCache") + void callClearCache(); +} 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 83822c289..e3c197ff4 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 @@ -12,17 +12,22 @@ import net.minecraft.BlockUtil.FoundRectangle; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; +import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.players.PlayerList; import net.minecraft.world.entity.EntityDimensions; +import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.Level; 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.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.storage.ChunkSerializer; import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.portal.PortalInfo; @@ -52,10 +57,13 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.ValkyrienSkiesMod; import org.valkyrienskies.mod.common.hooks.VSGameEvents; +import org.valkyrienskies.mod.common.util.ChunkRemover; import org.valkyrienskies.mod.common.util.EntityDragger; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.common.world.ChunkManagement; -import org.valkyrienskies.mod.mixin.accessors.server.world.ChunkMapAccessor; +import org.valkyrienskies.mod.mixin.accessors.server.level.ChunkMapAccessor; +import org.valkyrienskies.mod.mixin.accessors.server.level.DistanceManagerAccessor; +import org.valkyrienskies.mod.mixin.accessors.server.level.ServerChunkCacheAccessor; import org.valkyrienskies.mod.util.KrunchSupport; @Mixin(MinecraftServer.class) @@ -364,12 +372,50 @@ public void moveTerrainAcrossDimensions( ) { final ServerLevel srcLevel = getLevelFromDimensionId(srcDimension); final ServerLevel destLevel = getLevelFromDimensionId(destDimension); - // TODO: We can run this async, so run it async! + + // Copy ship chunks from srcLevel to destLevel shipChunks.forEach((final int x, final int z) -> { final LevelChunk srcChunk = srcLevel.getChunk(x, z); // Save the ship chunks to dest level - ((ChunkMapAccessor) destLevel.getChunkSource().chunkMap).callSave(srcChunk); + + final ChunkMap chunkMapRaw = destLevel.getChunkSource().chunkMap; + final ChunkMapAccessor srcChunkMap = (ChunkMapAccessor) chunkMapRaw; + srcChunkMap.getPoiManager().flush(srcChunk.getPos()); + final ChunkPos chunkPos = srcChunk.getPos(); + final ChunkStatus chunkStatus = srcChunk.getStatus(); + srcLevel.getProfiler().incrementCounter("chunkSave"); + + final CompoundTag compoundTag = ChunkSerializer.write(srcLevel, srcChunk); + + // Write the chunk compoundTag to the map files + chunkMapRaw.write(chunkPos, compoundTag); + srcChunkMap.callMarkPosition(chunkPos, chunkStatus.getChunkType()); + }); + + // Unload ship chunks from srcLevel + shipChunks.forEach((final int x, final int z) -> { + final LevelChunk srcChunk = srcLevel.getChunk(x, z); + + final ChunkPos chunkPos = srcChunk.getPos(); + srcLevel.unload(srcChunk); + ((ChunkMapAccessor) srcLevel.getChunkSource().chunkMap).getToDrop().add(chunkPos.toLong()); }); - // TODO: Delete old terrain + ((ChunkMapAccessor) srcLevel.getChunkSource().chunkMap).callProcessUnloads(() -> true); + + // Delete ship chunks from srcLevel + shipChunks.forEach((final int x, final int z) -> { + final ChunkPos chunkPos = new ChunkPos(x, z); + srcLevel.getChunkSource().chunkMap.write(chunkPos, null); + // Remove old tickets + // ((DistanceManagerAccessor) ((ChunkMapAccessor) srcLevel.getChunkSource().chunkMap).getDistanceManager()).getTickets().remove(chunkPos.toLong()); + // Stop tracking chunks in VS2 code + ((ChunkRemover) srcLevel).removeChunk(x, z); + }); + + // Clear cache to remove the deleted chunks + ((ServerChunkCacheAccessor) srcLevel.getChunkSource()).callClearCache(); + + // Save the chunk deletions + srcLevel.getChunkSource().chunkMap.flushWorker(); } } 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 c3afd9c00..96a2a2138 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 @@ -38,6 +38,7 @@ 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; @@ -49,11 +50,12 @@ import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.block.WingBlock; +import org.valkyrienskies.mod.common.util.ChunkRemover; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import org.valkyrienskies.mod.mixin.accessors.server.world.ChunkMapAccessor; +import org.valkyrienskies.mod.mixin.accessors.server.level.ChunkMapAccessor; @Mixin(ServerLevel.class) -public abstract class MixinServerLevel implements IShipObjectWorldServerProvider { +public abstract class MixinServerLevel implements IShipObjectWorldServerProvider, ChunkRemover { @Shadow @Final @@ -64,6 +66,7 @@ public abstract class MixinServerLevel implements IShipObjectWorldServerProvider public abstract MinecraftServer getServer(); // Map from ChunkPos to the list of voxel chunks that chunk owns + @Unique private final Map<ChunkPos, List<Vector3ic>> knownChunks = new HashMap<>(); @Nullable @@ -214,4 +217,9 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf ); } + @Override + public void removeChunk(final int chunkX, final int chunkZ) { + final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ); + knownChunks.remove(chunkPos); + } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ChunkRemover.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ChunkRemover.kt new file mode 100644 index 000000000..c09c3ceae --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ChunkRemover.kt @@ -0,0 +1,5 @@ +package org.valkyrienskies.mod.common.util + +interface ChunkRemover { + fun removeChunk(chunkX: Int, chunkZ: Int) +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/ChunkManagement.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/ChunkManagement.kt index cc464c42d..281d80b20 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/ChunkManagement.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/ChunkManagement.kt @@ -12,7 +12,7 @@ import org.valkyrienskies.mod.common.getLevelFromDimensionId import org.valkyrienskies.mod.common.isTickingChunk import org.valkyrienskies.mod.common.mcPlayer import org.valkyrienskies.mod.common.util.MinecraftPlayer -import org.valkyrienskies.mod.mixin.accessors.server.world.ChunkMapAccessor +import org.valkyrienskies.mod.mixin.accessors.server.level.ChunkMapAccessor import org.valkyrienskies.mod.util.logger object ChunkManagement { diff --git a/common/src/main/resources/valkyrienskies-common.accesswidener b/common/src/main/resources/valkyrienskies-common.accesswidener index 2f5276228..f9e167710 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/server/level/ChunkMap$DistanceManager diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 7218459c0..7c7fac796 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -7,7 +7,9 @@ "accessors.entity.EntityAccessor", "accessors.network.protocol.game.ClientboundSectionBlocksUpdatePacketAccessor", "accessors.resource.ResourceKeyAccessor", - "accessors.server.world.ChunkMapAccessor", + "accessors.server.level.ChunkMapAccessor", + "accessors.server.level.DistanceManagerAccessor", + "accessors.server.level.ServerChunkCacheAccessor", "accessors.util.math.Matrix4fAccessor", "accessors.world.level.pathfinder.PathAccessor", "entity.MixinEntity", diff --git a/vs-core b/vs-core index ac7b61287..01c2a635a 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit ac7b61287441fb1276448ed318f25fbe8df6ee89 +Subproject commit 01c2a635a12cd4e69cbfeb7a9936ab76bfef07f7 From 1edd5c67029bd5ceac9852505119f8599827acb0 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 21 Aug 2023 19:44:16 -0600 Subject: [PATCH 189/437] Got ships through portals fully working --- .../mixin/server/MixinMinecraftServer.java | 50 ++------ .../mixin/server/world/MixinServerLevel.java | 4 +- .../mixin/world/chunk/MixinLevelChunk.java | 120 +++++++++++++++++- .../mod/common/util/ChunkRemover.kt | 5 - .../mod/common/util/VSServerLevel.kt | 13 ++ vs-core | 2 +- 6 files changed, 145 insertions(+), 49 deletions(-) delete mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/util/ChunkRemover.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/util/VSServerLevel.kt 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 e3c197ff4..5f945eeb9 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 @@ -12,10 +12,8 @@ import net.minecraft.BlockUtil.FoundRectangle; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; -import net.minecraft.nbt.CompoundTag; import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; -import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.players.PlayerList; import net.minecraft.world.entity.EntityDimensions; @@ -25,9 +23,7 @@ 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.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraft.world.level.chunk.storage.ChunkSerializer; import net.minecraft.world.level.dimension.DimensionType; import net.minecraft.world.level.levelgen.Heightmap; import net.minecraft.world.level.portal.PortalInfo; @@ -57,13 +53,11 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.ValkyrienSkiesMod; import org.valkyrienskies.mod.common.hooks.VSGameEvents; -import org.valkyrienskies.mod.common.util.ChunkRemover; import org.valkyrienskies.mod.common.util.EntityDragger; +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.mixin.accessors.server.level.ChunkMapAccessor; -import org.valkyrienskies.mod.mixin.accessors.server.level.DistanceManagerAccessor; -import org.valkyrienskies.mod.mixin.accessors.server.level.ServerChunkCacheAccessor; import org.valkyrienskies.mod.util.KrunchSupport; @Mixin(MinecraftServer.class) @@ -376,46 +370,22 @@ public void moveTerrainAcrossDimensions( // Copy ship chunks from srcLevel to destLevel shipChunks.forEach((final int x, final int z) -> { final LevelChunk srcChunk = srcLevel.getChunk(x, z); - // Save the ship chunks to dest level - final ChunkMap chunkMapRaw = destLevel.getChunkSource().chunkMap; - final ChunkMapAccessor srcChunkMap = (ChunkMapAccessor) chunkMapRaw; - srcChunkMap.getPoiManager().flush(srcChunk.getPos()); - final ChunkPos chunkPos = srcChunk.getPos(); - final ChunkStatus chunkStatus = srcChunk.getStatus(); - srcLevel.getProfiler().incrementCounter("chunkSave"); - - final CompoundTag compoundTag = ChunkSerializer.write(srcLevel, srcChunk); + // This is a hack, but it fixes destLevel being in the wrong state + ((VSServerLevel) destLevel).removeChunk(x, z); - // Write the chunk compoundTag to the map files - chunkMapRaw.write(chunkPos, compoundTag); - srcChunkMap.callMarkPosition(chunkPos, chunkStatus.getChunkType()); + final LevelChunk destChunk = destLevel.getChunk(x, z); + ((VSLevelChunk) destChunk).copyChunkFromOtherDimension((VSLevelChunk) srcChunk); }); - // Unload ship chunks from srcLevel + // Delete ship chunks from srcLevel shipChunks.forEach((final int x, final int z) -> { final LevelChunk srcChunk = srcLevel.getChunk(x, z); + ((VSLevelChunk) srcChunk).clearChunk(); final ChunkPos chunkPos = srcChunk.getPos(); - srcLevel.unload(srcChunk); - ((ChunkMapAccessor) srcLevel.getChunkSource().chunkMap).getToDrop().add(chunkPos.toLong()); + srcLevel.getChunkSource().updateChunkForced(chunkPos, false); + ((VSServerLevel) srcLevel).removeChunk(x, z); }); - ((ChunkMapAccessor) srcLevel.getChunkSource().chunkMap).callProcessUnloads(() -> true); - - // Delete ship chunks from srcLevel - shipChunks.forEach((final int x, final int z) -> { - final ChunkPos chunkPos = new ChunkPos(x, z); - srcLevel.getChunkSource().chunkMap.write(chunkPos, null); - // Remove old tickets - // ((DistanceManagerAccessor) ((ChunkMapAccessor) srcLevel.getChunkSource().chunkMap).getDistanceManager()).getTickets().remove(chunkPos.toLong()); - // Stop tracking chunks in VS2 code - ((ChunkRemover) srcLevel).removeChunk(x, z); - }); - - // Clear cache to remove the deleted chunks - ((ServerChunkCacheAccessor) srcLevel.getChunkSource()).callClearCache(); - - // Save the chunk deletions - srcLevel.getChunkSource().chunkMap.flushWorker(); } } 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 96a2a2138..e62a5a37b 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 @@ -50,12 +50,12 @@ import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.block.WingBlock; -import org.valkyrienskies.mod.common.util.ChunkRemover; +import org.valkyrienskies.mod.common.util.VSServerLevel; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.mixin.accessors.server.level.ChunkMapAccessor; @Mixin(ServerLevel.class) -public abstract class MixinServerLevel implements IShipObjectWorldServerProvider, ChunkRemover { +public abstract class MixinServerLevel implements IShipObjectWorldServerProvider, VSServerLevel { @Shadow @Final 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 fa35410b0..fbbd797fd 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 @@ -1,27 +1,145 @@ package org.valkyrienskies.mod.mixin.world.chunk; +import java.util.Arrays; +import java.util.Map; import net.minecraft.core.BlockPos; +import net.minecraft.core.Registry; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; +import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.entity.BlockEntity; import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; +import net.minecraft.world.level.chunk.LevelChunkSection; +import net.minecraft.world.level.chunk.ProtoChunk; +import net.minecraft.world.level.chunk.storage.ChunkSerializer; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.material.Fluid; +import net.minecraft.world.ticks.LevelChunkTicks; +import org.jetbrains.annotations.NotNull; 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.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.BlockStateInfo; +import org.valkyrienskies.mod.common.util.VSLevelChunk; @Mixin(LevelChunk.class) -public class MixinLevelChunk { +public abstract class MixinLevelChunk extends ChunkAccess implements VSLevelChunk { @Shadow @Final Level level; + @Shadow + @Mutable + private LevelChunkTicks<Block> blockTicks; + @Shadow + @Mutable + private LevelChunkTicks<Fluid> fluidTicks; + + // Dummy constructor + public MixinLevelChunk(final Ship ship) { + super(null, null, null, null, 0, null, null); + throw new IllegalStateException("This should never be called!"); + } + @Inject(method = "setBlockState", at = @At("TAIL")) public void postSetBlockState(final BlockPos pos, final BlockState state, final boolean moved, final CallbackInfoReturnable<BlockState> cir) { final BlockState prevState = cir.getReturnValue(); BlockStateInfo.INSTANCE.onSetBlock(level, pos, prevState, state); } + + @Shadow + public abstract void clearAllBlockEntities(); + + @Shadow + public abstract void registerTickContainerInLevel(ServerLevel serverLevel); + + @Shadow + public abstract void unregisterTickContainerFromLevel(ServerLevel serverLevel); + + @Override + public void clearChunk() { + clearAllBlockEntities(); + unregisterTickContainerFromLevel((ServerLevel) level); + + // Set terrain to empty + heightmaps.clear(); + Arrays.fill(sections, null); + final Registry<Biome> registry = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); + for (int i = 0; i < sections.length; ++i) { + if (sections[i] != null) continue; + sections[i] = new LevelChunkSection(levelHeightAccessor.getSectionYFromSectionIndex(i), registry); + } + this.setLightCorrect(false); + + registerTickContainerInLevel((ServerLevel) level); + this.unsaved = true; + } + + @Override + public void copyChunkFromOtherDimension(@NotNull final VSLevelChunk srcChunkVS) { + clearAllBlockEntities(); + unregisterTickContainerFromLevel((ServerLevel) level); + + // Set terrain to empty + heightmaps.clear(); + Arrays.fill(sections, null); + + // Copy heightmap and sections and block entities from srcChunk + final LevelChunk srcChunk = (LevelChunk) srcChunkVS; + final CompoundTag compoundTag = ChunkSerializer.write((ServerLevel) srcChunk.getLevel(), srcChunk); + // Set status to be ProtoChunk to fix block entities not saving + compoundTag.putString("Status", ChunkStatus.ChunkType.PROTOCHUNK.name()); + final ProtoChunk protoChunk = ChunkSerializer.read((ServerLevel) level, ((ServerLevel) level).getPoiManager(), chunkPos, compoundTag); + + this.blockTicks = protoChunk.unpackBlockTicks(); + this.fluidTicks = protoChunk.unpackFluidTicks(); + // Copy data from the protoChunk + // this.chunkPos = chunkPos; + // this.upgradeData = upgradeData; + // this.levelHeightAccessor = levelHeightAccessor; + + for (int i = 0; i < sections.length; i++) { + sections[i] = protoChunk.getSection(i); + } + final Registry<Biome> registry = level.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY); + for (int i = 0; i < sections.length; ++i) { + if (sections[i] != null) continue; + sections[i] = new LevelChunkSection(levelHeightAccessor.getSectionYFromSectionIndex(i), registry); + } + + // this.inhabitedTime = l; + // this.postProcessing = new ShortList[levelHeightAccessor.getSectionsCount()]; + this.blendingData = protoChunk.getBlendingData(); + + for (final BlockEntity blockEntity : protoChunk.getBlockEntities().values()) { + this.setBlockEntity(blockEntity); + } + this.pendingBlockEntities.putAll(protoChunk.getBlockEntityNbts()); + System.out.println("this.pendingBlockEntities has size of " + this.pendingBlockEntities.size()); + for (int i = 0; i < protoChunk.getPostProcessing().length; ++i) { + this.postProcessing[i] = protoChunk.getPostProcessing()[i]; + } + this.setAllStarts(protoChunk.getAllStarts()); + this.setAllReferences(protoChunk.getAllReferences()); + for (final Map.Entry<Heightmap.Types, Heightmap> entry : protoChunk.getHeightmaps()) { + if (!ChunkStatus.FULL.heightmapsAfter().contains(entry.getKey())) continue; + this.setHeightmap(entry.getKey(), entry.getValue().getRawData()); + } + this.setLightCorrect(false); + + registerTickContainerInLevel((ServerLevel) level); + + this.unsaved = true; + } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ChunkRemover.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ChunkRemover.kt deleted file mode 100644 index c09c3ceae..000000000 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ChunkRemover.kt +++ /dev/null @@ -1,5 +0,0 @@ -package org.valkyrienskies.mod.common.util - -interface ChunkRemover { - fun removeChunk(chunkX: Int, chunkZ: Int) -} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/VSServerLevel.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/VSServerLevel.kt new file mode 100644 index 000000000..d80293ea5 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/VSServerLevel.kt @@ -0,0 +1,13 @@ +package org.valkyrienskies.mod.common.util + +// Used on Level to get a Level to remove a chunk from its tracking +interface VSServerLevel { + fun removeChunk(chunkX: Int, chunkZ: Int) +} + +// Used on LevelChunk to delete all blocks and block entities in a LevelChunk +interface VSLevelChunk { + fun clearChunk() + + fun copyChunkFromOtherDimension(srcChunk: VSLevelChunk) +} diff --git a/vs-core b/vs-core index 01c2a635a..fbec3360d 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 01c2a635a12cd4e69cbfeb7a9936ab76bfef07f7 +Subproject commit fbec3360d57a10f5b76dea948f4c09d0b5a35ab6 From 4dfc042a2258317efee670e1e595ab0a102d4f7a Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 21 Aug 2023 21:11:29 -0600 Subject: [PATCH 190/437] Fixed ships not showing up when using tp command to other dimensions --- .../mod/mixin/world/chunk/MixinLevelChunk.java | 16 ++++++++++------ vs-core | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) 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 fbbd797fd..ad158569f 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 @@ -1,7 +1,8 @@ package org.valkyrienskies.mod.mixin.world.chunk; import java.util.Arrays; -import java.util.Map; +import java.util.HashSet; +import java.util.Set; import net.minecraft.core.BlockPos; import net.minecraft.core.Registry; import net.minecraft.nbt.CompoundTag; @@ -18,6 +19,7 @@ import net.minecraft.world.level.chunk.ProtoChunk; import net.minecraft.world.level.chunk.storage.ChunkSerializer; import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.levelgen.Heightmap.Types; import net.minecraft.world.level.material.Fluid; import net.minecraft.world.ticks.LevelChunkTicks; import org.jetbrains.annotations.NotNull; @@ -25,6 +27,7 @@ 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; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @@ -45,6 +48,9 @@ public abstract class MixinLevelChunk extends ChunkAccess implements VSLevelChun @Mutable private LevelChunkTicks<Fluid> fluidTicks; + @Unique + private static final Set<Types> ALL_HEIGHT_MAP_TYPES = new HashSet<>(Arrays.asList((Heightmap.Types.values()))); + // Dummy constructor public MixinLevelChunk(final Ship ship) { super(null, null, null, null, 0, null, null); @@ -126,16 +132,14 @@ public void copyChunkFromOtherDimension(@NotNull final VSLevelChunk srcChunkVS) this.setBlockEntity(blockEntity); } this.pendingBlockEntities.putAll(protoChunk.getBlockEntityNbts()); - System.out.println("this.pendingBlockEntities has size of " + this.pendingBlockEntities.size()); for (int i = 0; i < protoChunk.getPostProcessing().length; ++i) { this.postProcessing[i] = protoChunk.getPostProcessing()[i]; } this.setAllStarts(protoChunk.getAllStarts()); this.setAllReferences(protoChunk.getAllReferences()); - for (final Map.Entry<Heightmap.Types, Heightmap> entry : protoChunk.getHeightmaps()) { - if (!ChunkStatus.FULL.heightmapsAfter().contains(entry.getKey())) continue; - this.setHeightmap(entry.getKey(), entry.getValue().getRawData()); - } + + // Recompute height maps instead of getting them from protoChunk (This fixes crashes from missing height maps) + Heightmap.primeHeightmaps(this, ALL_HEIGHT_MAP_TYPES); this.setLightCorrect(false); registerTickContainerInLevel((ServerLevel) level); diff --git a/vs-core b/vs-core index fbec3360d..e375e7dc4 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit fbec3360d57a10f5b76dea948f4c09d0b5a35ab6 +Subproject commit e375e7dc4535944644c44783642ed07322b7c8ef From e3e5a8a70627481ef47d3f97a9e633af7bb99b56 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 22 Aug 2023 01:57:08 -0600 Subject: [PATCH 191/437] Updated vs-core to main --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index e375e7dc4..30e0cccd4 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit e375e7dc4535944644c44783642ed07322b7c8ef +Subproject commit 30e0cccd4b88c7ce19d915fe691fac245b1fec15 From 0fe7f854ded254e1dd1a2c874ce7fc37e861aebd Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 22 Aug 2023 02:01:01 -0600 Subject: [PATCH 192/437] Updated vs-core to main --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 2c0be2ddb..30e0cccd4 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 2c0be2ddb50a3a65ac042e75c545e3e1b15ef3e3 +Subproject commit 30e0cccd4b88c7ce19d915fe691fac245b1fec15 From ebd0b2f61f48e82e8966ed34de7ccb3653f672ec Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 22 Aug 2023 02:19:16 -0600 Subject: [PATCH 193/437] Fixed PhysicsEntityCreatorItem not working on ships --- .../mod/common/item/PhysicsEntityCreatorItem.kt | 5 +++++ .../main/resources/assets/valkyrienskies/lang/en_us.json | 1 + .../valkyrienskies/models/item/physics_entity_creator.json | 6 ++++++ 3 files changed, 12 insertions(+) create mode 100644 common/src/main/resources/assets/valkyrienskies/models/item/physics_entity_creator.json diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt index a376fb73a..4f0b5a73f 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt @@ -10,6 +10,7 @@ import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl.Companion import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.entity.VSPhysicsEntity +import org.valkyrienskies.mod.common.getShipManagingPos import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toJOMLD @@ -30,6 +31,10 @@ class PhysicsEntityCreatorItem( val sphereRadius = 0.5 val offset = ctx.clickedFace.normal.toJOMLD().mul(sphereRadius) val entityPos = ctx.clickLocation.toJOML().add(offset) + + val shipOn = ctx.level.getShipManagingPos(ctx.clickedPos) + shipOn?.transform?.shipToWorld?.transformPosition(entityPos) + val transform = Companion.create(entityPos, Vector3d()) val physicsEntityData = VSPhysicsEntity.createBasicSphereData(shipId, transform, sphereRadius) entity.setPhysicsEntityData(physicsEntityData) 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 746c85fa4..64fd2981b 100644 --- a/common/src/main/resources/assets/valkyrienskies/lang/en_us.json +++ b/common/src/main/resources/assets/valkyrienskies/lang/en_us.json @@ -8,6 +8,7 @@ "block.valkyrienskies.test_wing": "Debug Wing", "item.valkyrienskies.ship_creator": "Ship Creator", "item.valkyrienskies.ship_creator_smaller": "Mini Ship Creator", + "item.valkyrienskies.physics_entity_creator": "Physics Entity Creator", "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/common/src/main/resources/assets/valkyrienskies/models/item/physics_entity_creator.json b/common/src/main/resources/assets/valkyrienskies/models/item/physics_entity_creator.json new file mode 100644 index 000000000..f0dc3b971 --- /dev/null +++ b/common/src/main/resources/assets/valkyrienskies/models/item/physics_entity_creator.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "minecraft:item/stick" + } +} \ No newline at end of file From 6ae504e65be9855eb3b3ae654e44599ff6bb0e3a Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 22 Aug 2023 02:57:16 -0600 Subject: [PATCH 194/437] Scale ship mass and inertia based on collision scale --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 30e0cccd4..31ca715d4 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 30e0cccd4b88c7ce19d915fe691fac245b1fec15 +Subproject commit 31ca715d40d1f421ec0cb8787364f378bb27ca8a From 975083bc6281db3c7e9ac93b10d65292cd871965 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 22 Aug 2023 03:58:28 -0600 Subject: [PATCH 195/437] Implemented ship scaling command --- .../mixin/server/MixinMinecraftServer.java | 3 +- .../mod/common/command/VSCommands.kt | 42 +++++++++---------- .../assets/valkyrienskies/lang/en_us.json | 3 +- vs-core | 2 +- 4 files changed, 26 insertions(+), 24 deletions(-) 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 5f945eeb9..6a4594fc5 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 @@ -282,7 +282,8 @@ private void shipChangeDimension(@NotNull final ServerLevel srcLevel, @NotNull f shipObject.getTransform().getShipToWorldRotation(), new Vector3d(), new Vector3d(), - VSGameUtilsKt.getDimensionId(destLevel) + VSGameUtilsKt.getDimensionId(destLevel), + null ); shipWorld.teleportShip(shipObject, shipTeleportData); } 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 dc939fe6f..793bc41fd 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,6 +3,7 @@ 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 @@ -46,6 +47,7 @@ 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" fun bootstrap() { ArgumentTypes.register("valkyrienskies:ship", @@ -302,7 +304,25 @@ 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<VSCommandSource>).source.shipWorld as ServerShipWorld + val newScale = DoubleArgumentType.getDouble(it, "newScale") + val r = ShipArgument.getShips(it, "ships").toList() as List<ServerShip> + r.forEach { ship -> vsCore.scaleShip(world, ship, newScale) } + it.source.sendVSMessage(TranslatableComponent(SCALED_SHIPS_MESSAGE, r.size)) + r.size + } catch (e: Exception) { + if (e !is CommandRuntimeException) LOGGER.throwing(e) + throw e + } + }) + ) + ) // Single ship commands .then( literal("ship").then( @@ -339,26 +359,6 @@ 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 - } - }) - ) - */ ) ) ) 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 64fd2981b..ddd33df22 100644 --- a/common/src/main/resources/assets/valkyrienskies/lang/en_us.json +++ b/common/src/main/resources/assets/valkyrienskies/lang/en_us.json @@ -19,5 +19,6 @@ "command.valkyrienskies.get_ship.success": "Found ship with slug %s", "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" + "tooltip.valkyrienskies.mass": "Mass", + "command.valkyrienskies.scale.success": "Scaled %d ships!" } diff --git a/vs-core b/vs-core index 31ca715d4..5945080cf 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 31ca715d40d1f421ec0cb8787364f378bb27ca8a +Subproject commit 5945080cf6c5929295a5493375f6bf3b7df07f70 From 906540f8a447dd74007d1b55278339ba29911162 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 22 Aug 2023 03:59:57 -0600 Subject: [PATCH 196/437] Lower default lodDetail to 512 --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 5945080cf..5cbb643c4 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 5945080cf6c5929295a5493375f6bf3b7df07f70 +Subproject commit 5cbb643c49a66675fbc3bae9ad18bd669b306759 From e47563d3805d213af40f7e97ed20ad3fc84c907f Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 22 Aug 2023 18:49:24 -0600 Subject: [PATCH 197/437] Fixed null pointer exception --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 5cbb643c4..5b7949ef8 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 5cbb643c49a66675fbc3bae9ad18bd669b306759 +Subproject commit 5b7949ef89a956a171daaf6c0fc7c5e93261f55a From e5a3666359928ed6deee560cde20828585321988 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 22 Aug 2023 22:59:36 -0600 Subject: [PATCH 198/437] Made VSPhysicsEntity open --- .../org/valkyrienskies/mod/common/entity/VSPhysicsEntity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 3b06dd6ac..2fa397a5a 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 @@ -36,7 +36,7 @@ import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toMinecraft import org.valkyrienskies.mod.mixin.accessors.entity.EntityAccessor -class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity(type, level) { +open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity(type, level) { // Physics data, persistent private var physicsEntityData: PhysicsEntityData? = null From bd95a699b2a12cd2ce822a78ea5f6e3fb3b2e532 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 23 Aug 2023 18:34:59 -0600 Subject: [PATCH 199/437] Made constraints work on Physics Entities --- .../common/item/PhysicsEntityCreatorItem.kt | 47 +++++++++++++++++-- vs-core | 2 +- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt index 4f0b5a73f..d6f02bcc4 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/PhysicsEntityCreatorItem.kt @@ -5,7 +5,13 @@ import net.minecraft.world.InteractionResult import net.minecraft.world.item.Item import net.minecraft.world.item.ItemStack import net.minecraft.world.item.context.UseOnContext +import org.joml.Quaterniond import org.joml.Vector3d +import org.joml.Vector3dc +import org.valkyrienskies.core.apigame.constraints.VSAttachmentConstraint +import org.valkyrienskies.core.apigame.constraints.VSPosDampingConstraint +import org.valkyrienskies.core.apigame.constraints.VSRotDampingAxes +import org.valkyrienskies.core.apigame.constraints.VSRotDampingConstraint import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl.Companion import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.dimensionId @@ -29,17 +35,50 @@ class PhysicsEntityCreatorItem( val entity = ValkyrienSkiesMod.PHYSICS_ENTITY_TYPE.create(level)!! val shipId = level.shipObjectWorld.allocateShipId(level.dimensionId) val sphereRadius = 0.5 - val offset = ctx.clickedFace.normal.toJOMLD().mul(sphereRadius) - val entityPos = ctx.clickLocation.toJOML().add(offset) + val offsetInLocal: Vector3dc = ctx.clickedFace.normal.toJOMLD().mul(sphereRadius) val shipOn = ctx.level.getShipManagingPos(ctx.clickedPos) - shipOn?.transform?.shipToWorld?.transformPosition(entityPos) + val offsetInGlobal = if (shipOn != null) { + shipOn.transform.shipToWorldRotation.transform(offsetInLocal, Vector3d()) + } else { + offsetInLocal + } + + val entityPos: Vector3dc = if (shipOn != null) { + shipOn.transform.shipToWorld.transformPosition(ctx.clickLocation.toJOML()).add(offsetInGlobal) + } else { + ctx.clickLocation.toJOML().add(offsetInGlobal) + } val transform = Companion.create(entityPos, Vector3d()) val physicsEntityData = VSPhysicsEntity.createBasicSphereData(shipId, transform, sphereRadius) entity.setPhysicsEntityData(physicsEntityData) - entity.setPos(entityPos.x, entityPos.y, entityPos.z) + entity.setPos(entityPos.x(), entityPos.y(), entityPos.z()) level.addFreshEntity(entity) + + // Example of adding a constraint to a physics entity + if (shipOn != null) { + val attachCompliance = 1e-8 + val attachMaxForce = 1e10 + // Attach the click position of the ship to the surface of the physics entity + val attachConstraint = VSAttachmentConstraint( + shipOn.id, physicsEntityData.shipId, attachCompliance, ctx.clickLocation.toJOML(), offsetInGlobal.mul(-1.0, Vector3d()), + attachMaxForce, 0.0 + ) + val posDampingConstraint = VSPosDampingConstraint( + shipOn.id, physicsEntityData.shipId, attachCompliance, ctx.clickLocation.toJOML(), offsetInGlobal.mul(-1.0, Vector3d()), + attachMaxForce, 0.1 + ) + val rotDampingConstraint = VSRotDampingConstraint( + shipOn.id, physicsEntityData.shipId, attachCompliance, shipOn.transform.shipToWorldRotation.invert( + Quaterniond() + ), + Quaterniond(), 1e10, 0.1, VSRotDampingAxes.ALL_AXES + ) + level.shipObjectWorld.createNewConstraint(attachConstraint) + level.shipObjectWorld.createNewConstraint(posDampingConstraint) + level.shipObjectWorld.createNewConstraint(rotDampingConstraint) + } } return super.useOn(ctx) diff --git a/vs-core b/vs-core index 5b7949ef8..decf5ff13 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 5b7949ef89a956a171daaf6c0fc7c5e93261f55a +Subproject commit decf5ff13bfd34abdb5a70dc13ebcc1af52908a0 From 01c04291fe44557980c089c4677fa5e9f3ac29be Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 23 Aug 2023 22:49:53 -0600 Subject: [PATCH 200/437] Got slab and stair shapes working! --- .../world/level/block/SlabBlockAccessor.java | 19 ++ .../world/level/block/StairBlockAccessor.java | 19 ++ .../mixin/server/MixinMinecraftServer.java | 15 ++ .../mod/common/BlockStateInfoProvider.kt | 10 + .../common/DefaultBlockStateInfoProvider.kt | 244 +++++++++++++++++- .../mod/common/config/VSMassDataLoader.kt | 12 + .../valkyrienskies-common.mixins.json | 2 + vs-core | 2 +- 8 files changed, 321 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/accessors/world/level/block/SlabBlockAccessor.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/accessors/world/level/block/StairBlockAccessor.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/world/level/block/SlabBlockAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/world/level/block/SlabBlockAccessor.java new file mode 100644 index 000000000..e59b5075f --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/world/level/block/SlabBlockAccessor.java @@ -0,0 +1,19 @@ +package org.valkyrienskies.mod.mixin.accessors.world.level.block; + +import net.minecraft.world.level.block.SlabBlock; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(SlabBlock.class) +public interface SlabBlockAccessor { + @Accessor("BOTTOM_AABB") + static VoxelShape getBottomAABB() { + throw new AssertionError(); + } + + @Accessor("TOP_AABB") + static VoxelShape getTopAABB() { + throw new AssertionError(); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/world/level/block/StairBlockAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/world/level/block/StairBlockAccessor.java new file mode 100644 index 000000000..63cac9bad --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/accessors/world/level/block/StairBlockAccessor.java @@ -0,0 +1,19 @@ +package org.valkyrienskies.mod.mixin.accessors.world.level.block; + +import net.minecraft.world.level.block.StairBlock; +import net.minecraft.world.phys.shapes.VoxelShape; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(StairBlock.class) +public interface StairBlockAccessor { + @Accessor("TOP_SHAPES") + static VoxelShape[] getTopShapes() { + throw new AssertionError(); + } + + @Accessor("BOTTOM_SHAPES") + static VoxelShape[] getBottomShapes() { + throw new AssertionError(); + } +} 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 6a4594fc5..6dd7a4797 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 @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Set; @@ -19,6 +20,7 @@ import net.minecraft.world.entity.EntityDimensions; 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; @@ -48,6 +50,7 @@ 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.DefaultBlockStateInfoProvider; import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.ShipSavedData; import org.valkyrienskies.mod.common.VSGameUtilsKt; @@ -136,6 +139,18 @@ private void postCreateLevels(final CallbackInfo ci) { // Create ship world and VS Pipeline vsPipeline = shipSavedData.getPipeline(); + // Register blocks + if (!DefaultBlockStateInfoProvider.INSTANCE.getRegisteredBlocks()) { + final List<BlockState> blockStateList = new ArrayList<>(Block.BLOCK_STATE_REGISTRY.size()); + Block.BLOCK_STATE_REGISTRY.forEach((blockStateList::add)); + DefaultBlockStateInfoProvider.INSTANCE.registerAllBlockStates(blockStateList); + } + vsPipeline.registerBlocks( + DefaultBlockStateInfoProvider.INSTANCE.getSolidBlockStates(), + DefaultBlockStateInfoProvider.INSTANCE.getLiquidBlockStates(), + DefaultBlockStateInfoProvider.INSTANCE.getBlockStateData() + ); + KrunchSupport.INSTANCE.setKrunchSupported(!vsPipeline.isUsingDummyPhysics()); shipWorld = vsPipeline.getShipWorld(); 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..4a6ce7419 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -17,6 +17,11 @@ 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 @@ -28,7 +33,12 @@ interface BlockStateInfoProvider { fun getBlockStateMass(blockState: BlockState): Double? + // Get the id of the block state fun getBlockStateType(blockState: BlockState): BlockType? + + val solidBlockStates: List<Lod1SolidBlockState> + val liquidBlockStates: List<Lod1LiquidBlockState> + val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> } 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 476c17c2e..b06ba95f2 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt @@ -1,24 +1,266 @@ package org.valkyrienskies.mod.common +import net.minecraft.core.BlockPos +import net.minecraft.world.level.BlockGetter +import net.minecraft.world.level.block.Blocks +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.valkyrienskies.core.apigame.world.chunks.BlockType +import org.valkyrienskies.core.impl.game.BlockTypeImpl +import org.valkyrienskies.mod.mixin.accessors.world.level.block.SlabBlockAccessor +import org.valkyrienskies.mod.mixin.accessors.world.level.block.StairBlockAccessor +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 kotlin.math.max +import kotlin.math.min object DefaultBlockStateInfoProvider : BlockStateInfoProvider { + private val _solidBlockStates: MutableList<Lod1SolidBlockState> = ArrayList() + private val _liquidBlockStates: MutableList<Lod1LiquidBlockState> = ArrayList() + private val _blockStateData: MutableList<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> = ArrayList() + private val blockStateToId: MutableMap<BlockState, BlockType> = HashMap() + override val priority: Int get() = Int.MIN_VALUE + override val solidBlockStates: List<Lod1SolidBlockState> + get() = _solidBlockStates + override val liquidBlockStates: List<Lod1LiquidBlockState> + get() = _liquidBlockStates + override val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> + get() = _blockStateData + + var registeredBlocks = false + private set override fun getBlockStateMass(blockState: BlockState): Double { if (blockState.isAir) return 0.0 - return 100.0 + // By default make blocks weight 1000 kg + return 1000.0 } 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 + */ + return blockStateToId[blockState]!! + } + + private fun generateStairCollisionShapes(stairShapes: Array<VoxelShape>): Map<VoxelShape, Lod1SolidCollisionShape> { + 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), + ) + + 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), + ) + + val map: MutableMap<VoxelShape, Lod1SolidCollisionShape> = HashMap() + stairShapes.forEach { stairShape -> + val points: MutableList<CollisionPoint> = ArrayList() + val positiveBoxes: MutableList<LodBlockBoundingBox> = ArrayList() + val negativeBoxes: MutableList<LodBlockBoundingBox> = 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) { + points.add(testPoint) + added = true + return@forAllBoxes + } + } + if (added) { + positiveBoxes.add(testBoxes[index]) + } else { + 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() + ) + // TODO: Merge boxes (later) + val collisionShape = Lod1SolidBoxesCollisionShape( + overallBoundingBox = overallBox, + collisionPoints = points, + solidBoxes = positiveBoxes, + negativeBoxes = negativeBoxes, + ) + map[stairShape] = collisionShape + } + return map + } + + fun registerAllBlockStates(blockStates: Iterable<BlockState>) { + val fullLodBoundingBox = LodBlockBoundingBox.createVSBoundingBox(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 solidBlockState = Lod1SolidBlockState( + collisionShape = Lod1SolidBoxesCollisionShape( + overallBoundingBox = fullLodBoundingBox, + collisionPoints = fullBlockCollisionPoints, + solidBoxes = listOf(fullLodBoundingBox), + negativeBoxes = listOf(), + ), + elasticity = 0.3f, + friction = 1.0f, + hardness = 1.0f, + lod1SolidBlockStateId = BlockTypeImpl.SOLID.toInt(), + ) + + /* + val botHalfLodBoundingBox = LodBlockBoundingBox.createVSBoundingBox(0, 0, 0, 15, 7, 15) + val botHalfBlockCollisionPoints = listOf( + CollisionPoint(Vector3f(.25f, .25f, .25f), .25f), + CollisionPoint(Vector3f(.25f, .25f, .75f), .25f), + CollisionPoint(Vector3f(.75f, .25f, .25f), .25f), + CollisionPoint(Vector3f(.75f, .25f, .75f), .25f), + ) + + val topHalfLodBoundingBox = LodBlockBoundingBox.createVSBoundingBox(0, 8, 0, 15, 15, 15) + val topHalfBlockCollisionPoints = listOf( + CollisionPoint(Vector3f(.25f, .75f, .25f), .25f), + CollisionPoint(Vector3f(.25f, .75f, .75f), .25f), + CollisionPoint(Vector3f(.75f, .75f, .25f), .25f), + CollisionPoint(Vector3f(.75f, .75f, .75f), .25f), + ) + */ + + val moreCollisionShapes = generateStairCollisionShapes( + StairBlockAccessor.getTopShapes() + StairBlockAccessor.getBottomShapes() + SlabBlockAccessor.getBottomAABB() + SlabBlockAccessor.getTopAABB() + ) + + var nextSolidId = 4 + + val voxelShapeToSolidIdMap: MutableMap<VoxelShape, BlockType> = HashMap() + moreCollisionShapes.forEach { (voxelShape, lod1SolidCollisionShape) -> + val id = nextSolidId++ + val newSolidBlockState = Lod1SolidBlockState( + collisionShape = lod1SolidCollisionShape, + elasticity = 0.3f, + friction = 1.0f, + hardness = 1.0f, + lod1SolidBlockStateId = id, + ) + _solidBlockStates.add(newSolidBlockState) + _blockStateData.add(Triple(id, BlockTypeImpl.AIR.toInt(), id)) + voxelShapeToSolidIdMap[voxelShape] = BlockTypeImpl(id) + } + + 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 = 0.3f, + fluidVel = Vector3f(), + lod1LiquidBlockStateId = BlockTypeImpl.LAVA.toInt(), + ) + + _solidBlockStates.add(solidBlockState) + + + + _liquidBlockStates.add(waterBlockState) + _liquidBlockStates.add(lavaBlockState) + + _blockStateData.add(Triple(BlockTypeImpl.SOLID.toInt(), BlockTypeImpl.AIR.toInt(), BlockTypeImpl.SOLID.toInt())) + _blockStateData.add(Triple(BlockTypeImpl.AIR.toInt(), BlockTypeImpl.WATER.toInt(), BlockTypeImpl.WATER.toInt())) + _blockStateData.add(Triple(BlockTypeImpl.AIR.toInt(), BlockTypeImpl.LAVA.toInt(), BlockTypeImpl.LAVA.toInt())) + + + val dummyBlockGetter = object: BlockGetter { + override fun getHeight(): Int = 255 + + override fun getMinBuildHeight(): Int = 0 + + override fun getBlockEntity(blockPos: BlockPos): BlockEntity? = null + + override fun getBlockState(blockPos: BlockPos): BlockState = Blocks.VOID_AIR.defaultBlockState() + + override fun getFluidState(blockPos: BlockPos): FluidState = Fluids.EMPTY.defaultFluidState() + } + + // Manually define stairs/slab shapes, because VoxelShapes sus T_T + + blockStates.forEach { blockState: BlockState -> + val blockType: BlockType + if (blockState.isAir) { + blockType = vsCore.blockTypes.air + } else { + val blockMaterial = blockState.material + blockType = if (blockMaterial.isLiquid) { + if (blockMaterial == Material.LAVA) { + vsCore.blockTypes.lava + } else { + vsCore.blockTypes.water + } + } else if (blockMaterial.isSolid) { + val voxelShape = blockState.getShape(dummyBlockGetter, BlockPos.ZERO) + voxelShapeToSolidIdMap[voxelShape] ?: vsCore.blockTypes.solid + } else { + vsCore.blockTypes.air + } + } + blockStateToId[blockState] = blockType + } + + registeredBlocks = true } } 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..7357541d0 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 @@ -15,6 +15,11 @@ import org.valkyrienskies.core.game.VSBlockType import org.valkyrienskies.mod.common.BlockStateInfoProvider import org.valkyrienskies.mod.common.hooks.VSGameEvents 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.Lod1LiquidBlockState +import org.valkyrienskies.physics_api.voxel.Lod1SolidBlockState import java.util.Optional private data class VSBlockStateInfo( @@ -34,6 +39,13 @@ object MassDatapackResolver : BlockStateInfoProvider { override fun getBlockStateType(blockState: BlockState): VSBlockType? = map[Registry.BLOCK.getKey(blockState.block)]?.type + override val solidBlockStates: List<Lod1SolidBlockState> + get() = TODO("Not yet implemented") + override val liquidBlockStates: List<Lod1LiquidBlockState> + get() = TODO("Not yet implemented") + override val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> + get() = TODO("Not yet implemented") + class VSMassDataLoader : SimpleJsonResourceReloadListener(Gson(), "vs_mass") { private val tags = mutableListOf<VSBlockStateInfo>() diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 7c7fac796..78ed9cb67 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -11,6 +11,8 @@ "accessors.server.level.DistanceManagerAccessor", "accessors.server.level.ServerChunkCacheAccessor", "accessors.util.math.Matrix4fAccessor", + "accessors.world.level.block.SlabBlockAccessor", + "accessors.world.level.block.StairBlockAccessor", "accessors.world.level.pathfinder.PathAccessor", "entity.MixinEntity", "feature.ai.node_evaluator.PathNavigationRegionAccessor", diff --git a/vs-core b/vs-core index 5b7949ef8..35855a188 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 5b7949ef89a956a171daaf6c0fc7c5e93261f55a +Subproject commit 35855a188dc07e1cf4be227beffc300aebb5d03a From 96a8332881367e659ead455694ecd39b4a1c9ed5 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 24 Aug 2023 00:00:59 -0600 Subject: [PATCH 201/437] Allow force inducers to be attached to physics entities --- .../org/valkyrienskies/mod/common/util/GameTickForceApplier.kt | 2 +- vs-core | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/GameTickForceApplier.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/GameTickForceApplier.kt index e2a623aa4..ed3f66fef 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/GameTickForceApplier.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/GameTickForceApplier.kt @@ -2,7 +2,7 @@ package org.valkyrienskies.mod.common.util import org.joml.Vector3dc import org.valkyrienskies.core.api.ships.PhysShip -import org.valkyrienskies.core.impl.api.ShipForcesInducer +import org.valkyrienskies.core.api.ships.ShipForcesInducer import org.valkyrienskies.core.impl.util.pollUntilEmpty import java.util.concurrent.ConcurrentLinkedQueue diff --git a/vs-core b/vs-core index decf5ff13..58b83a213 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit decf5ff13bfd34abdb5a70dc13ebcc1af52908a0 +Subproject commit 58b83a2131d56c32bcfd8c56254af10610c94a9d From 75dcbc2a6b5932f50d487974b3726fd8baab0096 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Fri, 25 Aug 2023 04:47:00 -0600 Subject: [PATCH 202/437] Initial work sending physics entities to client --- .../mod/common/entity/VSPhysicsEntity.kt | 20 ++++++++++++++++--- vs-core | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) 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 2fa397a5a..022a8e051 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 @@ -2,6 +2,7 @@ package org.valkyrienskies.mod.common.entity import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.readValue +import net.minecraft.client.Minecraft import net.minecraft.core.Rotations import net.minecraft.nbt.CompoundTag import net.minecraft.network.protocol.Packet @@ -27,9 +28,11 @@ import org.valkyrienskies.core.apigame.physics.VSSphereCollisionShapeData 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.IShipObjectWorldClientProvider import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.toJOML @@ -68,6 +71,7 @@ open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : En defaultRot = Rotations(eulerAngles.x.toFloat(), eulerAngles.y.toFloat(), eulerAngles.z.toFloat()) } this.entityData.set(ROTATION_DATA, defaultRot) + this.entityData.set(SHIP_ID_DATA, physicsEntityData.shipId.toString()) } lastTickRotation = Quaternionf(physicsEntityData.transform.shipToWorldRotation) rotation = lastTickRotation @@ -131,14 +135,20 @@ open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : En } fun getRenderRotation(partialTick: Float): Quaternionfc { - if (lastTickRotation == null) { - return serverRotation + val shipIdString = entityData.get(SHIP_ID_DATA) + if (shipIdString == "") { + return Quaternionf() } - return lastTickRotation!!.slerp(rotation!!, partialTick, Quaternionf()) + val shipIdLong = shipIdString.toLong() + val physEntityClient = + ((Minecraft.getInstance() as IShipObjectWorldClientProvider).shipObjectWorld as ShipObjectClientWorld).physicsEntities[shipIdLong] + ?: return Quaternionf() + return Quaternionf(physEntityClient.renderTransform.shipToWorldRotation) } override fun defineSynchedData() { entityData.define(ROTATION_DATA, Rotations(0.0f, 0.0f, 0.0f)) + entityData.define(SHIP_ID_DATA, "") } override fun readAdditionalSaveData(compoundTag: CompoundTag) { @@ -253,6 +263,10 @@ open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : En private val ROTATION_DATA: EntityDataAccessor<Rotations> = SynchedEntityData.defineId(VSPhysicsEntity::class.java, EntityDataSerializers.ROTATIONS) + // Use string because there is no LONG serializer by default SMH my head! + private val SHIP_ID_DATA: EntityDataAccessor<String> = + SynchedEntityData.defineId(VSPhysicsEntity::class.java, EntityDataSerializers.STRING) + private fun getMapper(): ObjectMapper { return VSJacksonUtil.defaultMapper } diff --git a/vs-core b/vs-core index 58b83a213..0768ef3a4 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 58b83a2131d56c32bcfd8c56254af10610c94a9d +Subproject commit 0768ef3a41dd56442771e447a5380ba2a88effa8 From e791fbfe69609a0e502c373dcbc0ef395a618e12 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Fri, 25 Aug 2023 05:43:40 -0600 Subject: [PATCH 203/437] Finished phys entity tracking --- .../mod/client/VSPhysicsEntityRenderer.kt | 20 +++++++- .../mod/common/entity/VSPhysicsEntity.kt | 51 ++----------------- vs-core | 2 +- 3 files changed, 24 insertions(+), 49 deletions(-) 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 3339af1ce..9cd062721 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/client/VSPhysicsEntityRenderer.kt @@ -12,6 +12,8 @@ import net.minecraft.resources.ResourceLocation import net.minecraft.world.inventory.InventoryMenu import net.minecraft.world.level.block.RenderShape.INVISIBLE import net.minecraft.world.level.block.RenderShape.MODEL +import org.valkyrienskies.core.impl.game.ships.ShipObjectClientWorld +import org.valkyrienskies.mod.common.IShipObjectWorldClientProvider import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.entity.VSPhysicsEntity import org.valkyrienskies.mod.common.util.toMinecraft @@ -33,9 +35,25 @@ class VSPhysicsEntityRenderer(context: EntityRendererProvider.Context) : EntityR ) { return } + + val renderTransform = fallingBlockEntity.getRenderTransform( + ((Minecraft.getInstance() as IShipObjectWorldClientProvider).shipObjectWorld as ShipObjectClientWorld) + ) ?: return + + val expectedX = fallingBlockEntity.xo + (fallingBlockEntity.x - fallingBlockEntity.xo) * partialTick + val expectedY = fallingBlockEntity.yo + (fallingBlockEntity.y - fallingBlockEntity.yo) * partialTick + val expectedZ = fallingBlockEntity.zo + (fallingBlockEntity.z - fallingBlockEntity.zo) * partialTick + + // Replace the default transform applied by mc with these offsets + val offsetX = renderTransform.positionInWorld.x() - expectedX + val offsetY = renderTransform.positionInWorld.y() - expectedY + val offsetZ = renderTransform.positionInWorld.z() - expectedZ + poseStack.pushPose() val blockPos = BlockPos(fallingBlockEntity.x, fallingBlockEntity.boundingBox.maxY, fallingBlockEntity.z) - poseStack.mulPose(fallingBlockEntity.getRenderRotation(partialTick).toMinecraft()) + + poseStack.translate(offsetX, offsetY, offsetZ) + poseStack.mulPose(renderTransform.shipToWorldRotation.toMinecraft()) 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/entity/VSPhysicsEntity.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/VSPhysicsEntity.kt index 022a8e051..41f31eff6 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 @@ -2,7 +2,6 @@ package org.valkyrienskies.mod.common.entity import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.module.kotlin.readValue -import net.minecraft.client.Minecraft import net.minecraft.core.Rotations import net.minecraft.nbt.CompoundTag import net.minecraft.network.protocol.Packet @@ -15,8 +14,6 @@ import net.minecraft.world.entity.EntityType import net.minecraft.world.level.Level import net.minecraft.world.level.entity.EntityInLevelCallback import org.joml.Matrix3d -import org.joml.Quaternionf -import org.joml.Quaternionfc import org.joml.Vector3d import org.joml.Vector3dc import org.valkyrienskies.core.api.ships.properties.ShipId @@ -32,7 +29,6 @@ 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.IShipObjectWorldClientProvider import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.toJOML @@ -46,19 +42,9 @@ open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : En // The physics entity, transient, only exists server side after this entity has been added to a world private var physicsEntityServer: PhysicsEntityServer? = null - private var lastTickRotation: Quaternionfc? = null - private var rotation: Quaternionfc? = null - private var lerpPos: Vector3dc? = null - private var lerpRot: Quaternionfc? = null private var lerpSteps = 0 - private val serverRotation: Quaternionfc - get() { - val rotationRaw = entityData.get(ROTATION_DATA) - return Quaternionf().rotateXYZ(rotationRaw.x, rotationRaw.y, rotationRaw.z) - } - fun setPhysicsEntityData(physicsEntityData: PhysicsEntityData) { if (this.physicsEntityData != null) { throw IllegalStateException("Cannot define physicsEntityData, its already defined!") @@ -70,30 +56,20 @@ open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : En val eulerAngles = physicsEntityData.transform.shipToWorldRotation.getEulerAnglesXYZ(Vector3d()) defaultRot = Rotations(eulerAngles.x.toFloat(), eulerAngles.y.toFloat(), eulerAngles.z.toFloat()) } - this.entityData.set(ROTATION_DATA, defaultRot) this.entityData.set(SHIP_ID_DATA, physicsEntityData.shipId.toString()) } - lastTickRotation = Quaternionf(physicsEntityData.transform.shipToWorldRotation) - rotation = lastTickRotation } override fun tick() { if (lerpPos == null) { lerpPos = position().toJOML() - lerpRot = serverRotation - rotation = serverRotation } - lastTickRotation = rotation if (!this.level.isClientSide) { val physicsEntityServerCopy = physicsEntityServer if (physicsEntityServerCopy != null) { val transform = physicsEntityServerCopy.shipTransform this.setPos(transform.positionInWorld.toMinecraft()) val eulerAngles = transform.shipToWorldRotation.getEulerAnglesXYZ(Vector3d()) - this.entityData.set( - ROTATION_DATA, Rotations(eulerAngles.x.toFloat(), eulerAngles.y.toFloat(), eulerAngles.z.toFloat()) - ) - rotation = Quaternionf(transform.shipToWorldRotation) this.physicsEntityData!!.transform = transform } this.tryCheckInsideBlocks() @@ -105,7 +81,6 @@ open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : En override fun lerpTo(d: Double, e: Double, f: Double, g: Float, h: Float, i: Int, bl: Boolean) { this.lerpPos = Vector3d(d, e, f) - this.lerpRot = serverRotation this.lerpSteps = CLIENT_INTERP_STEPS } @@ -114,7 +89,6 @@ open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : En return } else if (this.lerpSteps == 1) { setPos(lerpPos!!.x(), lerpPos!!.y(), lerpPos!!.z()) - rotation = lerpRot lerpSteps = 0 return } @@ -123,31 +97,21 @@ open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : En val e: Double = this.y + (this.lerpPos!!.y() - this.y) / this.lerpSteps.toDouble() val f: Double = this.z + (this.lerpPos!!.z() - this.z) / this.lerpSteps.toDouble() - if (rotation != null) { - rotation = rotation!!.slerp(this.lerpRot, (1.0 - (1.0 / this.lerpSteps.toDouble())).toFloat(), Quaternionf()) - } else { - rotation = serverRotation - lastTickRotation = rotation - } - --this.lerpSteps this.setPos(d, e, f) } - fun getRenderRotation(partialTick: Float): Quaternionfc { + fun getRenderTransform(shipObjectClientWorld: ShipObjectClientWorld): ShipTransform? { val shipIdString = entityData.get(SHIP_ID_DATA) if (shipIdString == "") { - return Quaternionf() + return null } val shipIdLong = shipIdString.toLong() - val physEntityClient = - ((Minecraft.getInstance() as IShipObjectWorldClientProvider).shipObjectWorld as ShipObjectClientWorld).physicsEntities[shipIdLong] - ?: return Quaternionf() - return Quaternionf(physEntityClient.renderTransform.shipToWorldRotation) + val physEntityClient = shipObjectClientWorld.physicsEntities[shipIdLong] + return physEntityClient?.renderTransform } override fun defineSynchedData() { - entityData.define(ROTATION_DATA, Rotations(0.0f, 0.0f, 0.0f)) entityData.define(SHIP_ID_DATA, "") } @@ -231,11 +195,7 @@ open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : En val physicsEntityServerCopy = physicsEntityServer if (physicsEntityServerCopy != null) { val newPos = Vector3d(d, e, f) - this.entityData.set( - ROTATION_DATA, Rotations(0.0f, 0.0f, 0.0f) - ) val teleportData = ShipTeleportDataImpl(newPos = newPos) - rotation = Quaternionf() (this.level.shipObjectWorld as ShipObjectServerWorld).teleportPhysicsEntity(this.physicsEntityServer!!, teleportData) } else { physicsEntityData!!.transform = ShipTransformImpl.create( @@ -260,9 +220,6 @@ open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : En private const val PHYS_DATA_NBT_KEY = "phys_entity_data" private const val CLIENT_INTERP_STEPS = 3 - private val ROTATION_DATA: EntityDataAccessor<Rotations> = - SynchedEntityData.defineId(VSPhysicsEntity::class.java, EntityDataSerializers.ROTATIONS) - // Use string because there is no LONG serializer by default SMH my head! private val SHIP_ID_DATA: EntityDataAccessor<String> = SynchedEntityData.defineId(VSPhysicsEntity::class.java, EntityDataSerializers.STRING) diff --git a/vs-core b/vs-core index 0768ef3a4..bc05b626f 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 0768ef3a41dd56442771e447a5380ba2a88effa8 +Subproject commit bc05b626f9dd380cae6b16ce5b1fb46959ad16d3 From 7b9a49bdb72e202a6d1e18fac25d68967e9cb067 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Fri, 25 Aug 2023 05:47:48 -0600 Subject: [PATCH 204/437] Updated vs-core to main --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index bc05b626f..ca1852c8d 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit bc05b626f9dd380cae6b16ce5b1fb46959ad16d3 +Subproject commit ca1852c8d06eeadebc28bf9f1914cdae30419750 From fa2e69931ed2251c98c55f218be26393940b874b Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 26 Aug 2023 02:29:17 -0600 Subject: [PATCH 205/437] Fixed physics entity tracking --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index ca1852c8d..0cb6cf031 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit ca1852c8d06eeadebc28bf9f1914cdae30419750 +Subproject commit 0cb6cf0311c985b9fdf8f7dd6ac748666436a582 From 1421ab3c2dc0154d8b6c1dd6c834253c50d2e183 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 26 Aug 2023 18:07:31 -0600 Subject: [PATCH 206/437] Make a new voxel state for each block state --- .../common/DefaultBlockStateInfoProvider.kt | 86 +++++++------------ .../mod/common/config/VSMassDataLoader.kt | 19 +++- .../data/valkyrienskies/vs_mass/ground.json | 4 +- .../data/valkyrienskies/vs_mass/misc.json | 18 ++-- vs-core | 2 +- 5 files changed, 64 insertions(+), 65 deletions(-) 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 b06ba95f2..84b3cf228 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt @@ -144,59 +144,17 @@ object DefaultBlockStateInfoProvider : BlockStateInfoProvider { CollisionPoint(Vector3f(.75f, .75f, .25f), .25f), CollisionPoint(Vector3f(.75f, .75f, .75f), .25f), ) - - val solidBlockState = Lod1SolidBlockState( - collisionShape = Lod1SolidBoxesCollisionShape( - overallBoundingBox = fullLodBoundingBox, - collisionPoints = fullBlockCollisionPoints, - solidBoxes = listOf(fullLodBoundingBox), - negativeBoxes = listOf(), - ), - elasticity = 0.3f, - friction = 1.0f, - hardness = 1.0f, - lod1SolidBlockStateId = BlockTypeImpl.SOLID.toInt(), - ) - - /* - val botHalfLodBoundingBox = LodBlockBoundingBox.createVSBoundingBox(0, 0, 0, 15, 7, 15) - val botHalfBlockCollisionPoints = listOf( - CollisionPoint(Vector3f(.25f, .25f, .25f), .25f), - CollisionPoint(Vector3f(.25f, .25f, .75f), .25f), - CollisionPoint(Vector3f(.75f, .25f, .25f), .25f), - CollisionPoint(Vector3f(.75f, .25f, .75f), .25f), - ) - - val topHalfLodBoundingBox = LodBlockBoundingBox.createVSBoundingBox(0, 8, 0, 15, 15, 15) - val topHalfBlockCollisionPoints = listOf( - CollisionPoint(Vector3f(.25f, .75f, .25f), .25f), - CollisionPoint(Vector3f(.25f, .75f, .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(), ) - */ - val moreCollisionShapes = generateStairCollisionShapes( + val voxelShapeToCollisionShapeMap = generateStairCollisionShapes( StairBlockAccessor.getTopShapes() + StairBlockAccessor.getBottomShapes() + SlabBlockAccessor.getBottomAABB() + SlabBlockAccessor.getTopAABB() ) - var nextSolidId = 4 - - val voxelShapeToSolidIdMap: MutableMap<VoxelShape, BlockType> = HashMap() - moreCollisionShapes.forEach { (voxelShape, lod1SolidCollisionShape) -> - val id = nextSolidId++ - val newSolidBlockState = Lod1SolidBlockState( - collisionShape = lod1SolidCollisionShape, - elasticity = 0.3f, - friction = 1.0f, - hardness = 1.0f, - lod1SolidBlockStateId = id, - ) - _solidBlockStates.add(newSolidBlockState) - _blockStateData.add(Triple(id, BlockTypeImpl.AIR.toInt(), id)) - voxelShapeToSolidIdMap[voxelShape] = BlockTypeImpl(id) - } - val waterBlockState = Lod1LiquidBlockState( boundingBox = fullLodBoundingBox, density = 1000.0f, @@ -213,17 +171,17 @@ object DefaultBlockStateInfoProvider : BlockStateInfoProvider { lod1LiquidBlockStateId = BlockTypeImpl.LAVA.toInt(), ) - _solidBlockStates.add(solidBlockState) - - - + // Add water/lava block states _liquidBlockStates.add(waterBlockState) _liquidBlockStates.add(lavaBlockState) - _blockStateData.add(Triple(BlockTypeImpl.SOLID.toInt(), BlockTypeImpl.AIR.toInt(), BlockTypeImpl.SOLID.toInt())) _blockStateData.add(Triple(BlockTypeImpl.AIR.toInt(), BlockTypeImpl.WATER.toInt(), BlockTypeImpl.WATER.toInt())) _blockStateData.add(Triple(BlockTypeImpl.AIR.toInt(), BlockTypeImpl.LAVA.toInt(), BlockTypeImpl.LAVA.toInt())) + // Setup initial conditions for future ids + var nextSolidId = 1 + var nextFluidId = 4 + var nextVoxelStateId = 4 val dummyBlockGetter = object: BlockGetter { override fun getHeight(): Int = 255 @@ -253,7 +211,27 @@ object DefaultBlockStateInfoProvider : BlockStateInfoProvider { } } else if (blockMaterial.isSolid) { val voxelShape = blockState.getShape(dummyBlockGetter, BlockPos.ZERO) - voxelShapeToSolidIdMap[voxelShape] ?: vsCore.blockTypes.solid + + val collisionShape: Lod1SolidCollisionShape = if (voxelShapeToCollisionShapeMap.contains(voxelShape)) { + voxelShapeToCollisionShapeMap[voxelShape]!! + } else { + fullBlockCollisionShape + } + + val solidStateId = nextSolidId++ + val newSolidBlockState = Lod1SolidBlockState( + collisionShape = collisionShape, + elasticity = 0.3f, + friction = 1.0f, + hardness = 1.0f, + lod1SolidBlockStateId = solidStateId, + ) + _solidBlockStates.add(newSolidBlockState) + + val blockStateId = nextVoxelStateId++ + // TODO: For now don't waterlog, in the future add the fluid state id here + _blockStateData.add(Triple(solidStateId, BlockTypeImpl.AIR.toInt(), blockStateId)) + BlockTypeImpl(blockStateId) } else { vsCore.blockTypes.air } 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 7357541d0..ff3272ab1 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 @@ -23,13 +23,21 @@ import org.valkyrienskies.physics_api.voxel.Lod1SolidBlockState import java.util.Optional private data class VSBlockStateInfo( - val id: ResourceLocation, val priority: Int, val mass: Double, val type: VSBlockType? + val id: ResourceLocation, + val priority: Int, + val mass: Double, + val friction: Double, + val elasticity: Double, + val type: VSBlockType?, ) object MassDatapackResolver : BlockStateInfoProvider { private val map = hashMapOf<ResourceLocation, VSBlockStateInfo>() val loader get() = VSMassDataLoader() + private const val DEFAULT_FRICTION = 1.0 + private const val DEFAULT_ELASTICITY = 0.3 + override val priority: Int get() = 100 @@ -86,7 +94,8 @@ object MassDatapackResolver : BlockStateInfoProvider { tag.get().forEach { add( VSBlockStateInfo( - Registry.BLOCK.getKey(it.value()), tagInfo.priority, tagInfo.mass, tagInfo.type + Registry.BLOCK.getKey(it.value()), tagInfo.priority, tagInfo.mass, tagInfo.friction, + tagInfo.elasticity, tagInfo.type ) ) } @@ -115,16 +124,18 @@ object MassDatapackResolver : BlockStateInfoProvider { val tag = element.asJsonObject["tag"]?.asString val weight = element.asJsonObject["mass"]?.asDouble ?: throw IllegalArgumentException("No mass in file $origin") + val friction = element.asJsonObject["friction"]?.asDouble ?: DEFAULT_FRICTION + val elasticity = element.asJsonObject["elasticity"]?.asDouble ?: DEFAULT_ELASTICITY val priority = element.asJsonObject["priority"]?.asInt ?: 100 if (tag != null) { - addToBeAddedTags(VSBlockStateInfo(ResourceLocation(tag), priority, weight, null)) + addToBeAddedTags(VSBlockStateInfo(ResourceLocation(tag), priority, weight, friction, elasticity, null)) } else { val block = element.asJsonObject["block"]?.asString ?: throw IllegalArgumentException("No block or tag in file $origin") - add(VSBlockStateInfo(ResourceLocation(block), priority, weight, null)) + add(VSBlockStateInfo(ResourceLocation(block), priority, weight, friction, elasticity, null)) } } } 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 7077e525f..7f420ebd5 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/ground.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/ground.json @@ -1,7 +1,9 @@ [ { "block": "minecraft:dirt", - "mass": 1220.0 + "mass": 1220.0, + "friction": 1.0, + "elasticity": 0.3 }, { "block": "minecraft:coarse_dirt", 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 065453df3..7182e3be1 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json @@ -53,7 +53,7 @@ }, { "block": "minecraft:netherite_block", - "mass": 19280.0 + "mass": 89680.0 }, { "block": "minecraft:lapis_block", @@ -345,15 +345,21 @@ }, { "block": "minecraft:ice", - "mass": 830.0 + "mass": 830.0, + "friction": 0.0, + "elasticity": 0.3 }, { "block": "minecraft:packed_ice", - "mass": 875.0 + "mass": 875.0, + "friction": 0.0, + "elasticity": 0.3 }, { "block": "minecraft:blue_ice", - "mass": 920.0 + "mass": 920.0, + "friction": 0.0, + "elasticity": 0.3 }, { "block": "minecraft:jukebox", @@ -377,7 +383,9 @@ }, { "block": "minecraft:slime_block", - "mass": 1100.0 + "mass": 1100.0, + "friction": 1.0, + "elasticity": 1.0 }, { "block": "minecraft:honey_block", diff --git a/vs-core b/vs-core index 35855a188..c9f627641 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 35855a188dc07e1cf4be227beffc300aebb5d03a +Subproject commit c9f627641c03423ac01851c9b5f62c218b8cff2a From 6a116a685af19f6bd4fd4db2f89bd4ff1b3db5d9 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 26 Aug 2023 19:29:16 -0600 Subject: [PATCH 207/437] Added data-pack configurable elasticity and friction values --- .../mixin/server/MixinMinecraftServer.java | 12 +- .../common/DefaultBlockStateInfoProvider.kt | 214 +-------------- .../mod/common/config/VSMassDataLoader.kt | 243 +++++++++++++++++- 3 files changed, 247 insertions(+), 222 deletions(-) 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 6dd7a4797..e69c7bd36 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 @@ -50,11 +50,11 @@ 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.DefaultBlockStateInfoProvider; import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.ShipSavedData; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.ValkyrienSkiesMod; +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.VSLevelChunk; @@ -140,15 +140,15 @@ private void postCreateLevels(final CallbackInfo ci) { vsPipeline = shipSavedData.getPipeline(); // Register blocks - if (!DefaultBlockStateInfoProvider.INSTANCE.getRegisteredBlocks()) { + if (!MassDatapackResolver.INSTANCE.getRegisteredBlocks()) { final List<BlockState> blockStateList = new ArrayList<>(Block.BLOCK_STATE_REGISTRY.size()); Block.BLOCK_STATE_REGISTRY.forEach((blockStateList::add)); - DefaultBlockStateInfoProvider.INSTANCE.registerAllBlockStates(blockStateList); + MassDatapackResolver.INSTANCE.registerAllBlockStates(blockStateList); } vsPipeline.registerBlocks( - DefaultBlockStateInfoProvider.INSTANCE.getSolidBlockStates(), - DefaultBlockStateInfoProvider.INSTANCE.getLiquidBlockStates(), - DefaultBlockStateInfoProvider.INSTANCE.getBlockStateData() + MassDatapackResolver.INSTANCE.getSolidBlockStates(), + MassDatapackResolver.INSTANCE.getLiquidBlockStates(), + MassDatapackResolver.INSTANCE.getBlockStateData() ); KrunchSupport.INSTANCE.setKrunchSupported(!vsPipeline.isUsingDummyPhysics()); 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 84b3cf228..373b4254c 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt @@ -1,49 +1,23 @@ package org.valkyrienskies.mod.common -import net.minecraft.core.BlockPos -import net.minecraft.world.level.BlockGetter -import net.minecraft.world.level.block.Blocks -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.valkyrienskies.core.apigame.world.chunks.BlockType -import org.valkyrienskies.core.impl.game.BlockTypeImpl -import org.valkyrienskies.mod.mixin.accessors.world.level.block.SlabBlockAccessor -import org.valkyrienskies.mod.mixin.accessors.world.level.block.StairBlockAccessor 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 kotlin.math.max -import kotlin.math.min object DefaultBlockStateInfoProvider : BlockStateInfoProvider { - private val _solidBlockStates: MutableList<Lod1SolidBlockState> = ArrayList() - private val _liquidBlockStates: MutableList<Lod1LiquidBlockState> = ArrayList() - private val _blockStateData: MutableList<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> = ArrayList() - private val blockStateToId: MutableMap<BlockState, BlockType> = HashMap() - override val priority: Int get() = Int.MIN_VALUE override val solidBlockStates: List<Lod1SolidBlockState> - get() = _solidBlockStates + get() = TODO() override val liquidBlockStates: List<Lod1LiquidBlockState> - get() = _liquidBlockStates + get() = TODO() override val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> - get() = _blockStateData - - var registeredBlocks = false - private set + get() = TODO() override fun getBlockStateMass(blockState: BlockState): Double { if (blockState.isAir) return 0.0 @@ -52,193 +26,11 @@ 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 - */ - return blockStateToId[blockState]!! - } - - private fun generateStairCollisionShapes(stairShapes: Array<VoxelShape>): Map<VoxelShape, Lod1SolidCollisionShape> { - 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), - ) - - 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), - ) - - val map: MutableMap<VoxelShape, Lod1SolidCollisionShape> = HashMap() - stairShapes.forEach { stairShape -> - val points: MutableList<CollisionPoint> = ArrayList() - val positiveBoxes: MutableList<LodBlockBoundingBox> = ArrayList() - val negativeBoxes: MutableList<LodBlockBoundingBox> = 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) { - points.add(testPoint) - added = true - return@forAllBoxes - } - } - if (added) { - positiveBoxes.add(testBoxes[index]) - } else { - 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() - ) - // TODO: Merge boxes (later) - val collisionShape = Lod1SolidBoxesCollisionShape( - overallBoundingBox = overallBox, - collisionPoints = points, - solidBoxes = positiveBoxes, - negativeBoxes = negativeBoxes, - ) - map[stairShape] = collisionShape - } - return map - } - - fun registerAllBlockStates(blockStates: Iterable<BlockState>) { - val fullLodBoundingBox = LodBlockBoundingBox.createVSBoundingBox(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(), - ) - - val voxelShapeToCollisionShapeMap = generateStairCollisionShapes( - StairBlockAccessor.getTopShapes() + StairBlockAccessor.getBottomShapes() + SlabBlockAccessor.getBottomAABB() + SlabBlockAccessor.getTopAABB() - ) - - 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 = 0.3f, - fluidVel = Vector3f(), - lod1LiquidBlockStateId = BlockTypeImpl.LAVA.toInt(), - ) - - // Add water/lava block states - _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())) - - // Setup initial conditions for future ids - var nextSolidId = 1 - var nextFluidId = 4 - var nextVoxelStateId = 4 - - val dummyBlockGetter = object: BlockGetter { - override fun getHeight(): Int = 255 - - override fun getMinBuildHeight(): Int = 0 - - override fun getBlockEntity(blockPos: BlockPos): BlockEntity? = null - - override fun getBlockState(blockPos: BlockPos): BlockState = Blocks.VOID_AIR.defaultBlockState() - - override fun getFluidState(blockPos: BlockPos): FluidState = Fluids.EMPTY.defaultFluidState() - } - - // Manually define stairs/slab shapes, because VoxelShapes sus T_T - - blockStates.forEach { blockState: BlockState -> - val blockType: BlockType - if (blockState.isAir) { - blockType = vsCore.blockTypes.air - } else { - val blockMaterial = blockState.material - blockType = if (blockMaterial.isLiquid) { - if (blockMaterial == Material.LAVA) { - vsCore.blockTypes.lava - } else { - vsCore.blockTypes.water - } - } else if (blockMaterial.isSolid) { - val voxelShape = blockState.getShape(dummyBlockGetter, BlockPos.ZERO) - - val collisionShape: Lod1SolidCollisionShape = if (voxelShapeToCollisionShapeMap.contains(voxelShape)) { - voxelShapeToCollisionShapeMap[voxelShape]!! - } else { - fullBlockCollisionShape - } - - val solidStateId = nextSolidId++ - val newSolidBlockState = Lod1SolidBlockState( - collisionShape = collisionShape, - elasticity = 0.3f, - friction = 1.0f, - hardness = 1.0f, - lod1SolidBlockStateId = solidStateId, - ) - _solidBlockStates.add(newSolidBlockState) - - val blockStateId = nextVoxelStateId++ - // TODO: For now don't waterlog, in the future add the fluid state id here - _blockStateData.add(Triple(solidStateId, BlockTypeImpl.AIR.toInt(), blockStateId)) - BlockTypeImpl(blockStateId) - } else { - vsCore.blockTypes.air - } - } - blockStateToId[blockState] = blockType - } - - registeredBlocks = true } } 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 ff3272ab1..ccdc8eb03 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 @@ -2,6 +2,7 @@ package org.valkyrienskies.mod.common.config 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.resources.ResourceLocation @@ -9,18 +10,38 @@ import net.minecraft.server.packs.resources.ResourceManager import net.minecraft.server.packs.resources.SimpleJsonResourceReloadListener import net.minecraft.tags.TagKey import net.minecraft.util.profiling.ProfilerFiller +import net.minecraft.world.level.BlockGetter import net.minecraft.world.level.block.Block +import net.minecraft.world.level.block.Blocks +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.valkyrienskies.core.apigame.world.chunks.BlockType import org.valkyrienskies.core.game.VSBlockType +import org.valkyrienskies.core.impl.game.BlockTypeImpl import org.valkyrienskies.mod.common.BlockStateInfoProvider 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 private data class VSBlockStateInfo( val id: ResourceLocation, @@ -33,10 +54,17 @@ private data class VSBlockStateInfo( object MassDatapackResolver : BlockStateInfoProvider { private val map = hashMapOf<ResourceLocation, VSBlockStateInfo>() + private val _solidBlockStates: MutableList<Lod1SolidBlockState> = ArrayList() + private val _liquidBlockStates: MutableList<Lod1LiquidBlockState> = ArrayList() + private val _blockStateData: MutableList<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> = ArrayList() + private val blockStateToId: MutableMap<BlockState, BlockType> = HashMap() + val loader get() = VSMassDataLoader() - private const val DEFAULT_FRICTION = 1.0 private const val DEFAULT_ELASTICITY = 0.3 + private const val DEFAULT_FRICTION = 0.5 + // Unused for now, placeholder for later + private const val DEFAULT_HARDNESS = 1.0 override val priority: Int get() = 100 @@ -45,14 +73,17 @@ object MassDatapackResolver : BlockStateInfoProvider { map[Registry.BLOCK.getKey(blockState.block)]?.mass override fun getBlockStateType(blockState: BlockState): VSBlockType? = - map[Registry.BLOCK.getKey(blockState.block)]?.type + blockStateToId[blockState]!! + + var registeredBlocks = false + private set override val solidBlockStates: List<Lod1SolidBlockState> - get() = TODO("Not yet implemented") + get() = _solidBlockStates override val liquidBlockStates: List<Lod1LiquidBlockState> - get() = TODO("Not yet implemented") + get() = _liquidBlockStates override val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> - get() = TODO("Not yet implemented") + get() = _blockStateData class VSMassDataLoader : SimpleJsonResourceReloadListener(Gson(), "vs_mass") { private val tags = mutableListOf<VSBlockStateInfo>() @@ -125,6 +156,10 @@ object MassDatapackResolver : BlockStateInfoProvider { val weight = element.asJsonObject["mass"]?.asDouble ?: throw IllegalArgumentException("No mass in file $origin") val friction = element.asJsonObject["friction"]?.asDouble ?: DEFAULT_FRICTION + val elasticityOriginal = element.asJsonObject["elasticity"] + if (elasticityOriginal != null) { + println("amogus") + } val elasticity = element.asJsonObject["elasticity"]?.asDouble ?: DEFAULT_ELASTICITY val priority = element.asJsonObject["priority"]?.asInt ?: 100 @@ -140,5 +175,203 @@ object MassDatapackResolver : BlockStateInfoProvider { } } + private fun generateStairCollisionShapes(stairShapes: Array<VoxelShape>): Map<VoxelShape, Lod1SolidCollisionShape> { + 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), + ) + + 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), + ) + + val map: MutableMap<VoxelShape, Lod1SolidCollisionShape> = HashMap() + stairShapes.forEach { stairShape -> + val points: MutableList<CollisionPoint> = ArrayList() + val positiveBoxes: MutableList<LodBlockBoundingBox> = ArrayList() + val negativeBoxes: MutableList<LodBlockBoundingBox> = 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) { + points.add(testPoint) + added = true + return@forAllBoxes + } + } + if (added) { + positiveBoxes.add(testBoxes[index]) + } else { + 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() + ) + // TODO: Merge boxes (later) + val collisionShape = Lod1SolidBoxesCollisionShape( + overallBoundingBox = overallBox, + collisionPoints = points, + solidBoxes = positiveBoxes, + negativeBoxes = negativeBoxes, + ) + map[stairShape] = collisionShape + } + return map + } + + fun registerAllBlockStates(blockStates: Iterable<BlockState>) { + val fullLodBoundingBox = LodBlockBoundingBox.createVSBoundingBox(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(), + ) + + // 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 = 0.3f, + 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 + } + + // A dummy world used to get the VoxelShape for each block state + val dummyBlockGetter = object: BlockGetter { + override fun getHeight(): Int = 255 + + override fun getMinBuildHeight(): Int = 0 + + override fun getBlockEntity(blockPos: BlockPos): BlockEntity? = null + + override fun getBlockState(blockPos: BlockPos): BlockState = Blocks.VOID_AIR.defaultBlockState() + + override fun getFluidState(blockPos: BlockPos): FluidState = Fluids.EMPTY.defaultFluidState() + } + + // Create a map of common VoxelShape to Lod1SolidCollisionShape + val voxelShapeToCollisionShapeMap = generateStairCollisionShapes( + StairBlockAccessor.getTopShapes() + StairBlockAccessor.getBottomShapes() + SlabBlockAccessor.getBottomAABB() + SlabBlockAccessor.getTopAABB() + ) + + // Setup initial conditions for future ids + var nextSolidId = 2 + var nextFluidId = 4 + var nextVoxelStateId = 4 + + blockStates.forEach { blockState: BlockState -> + val blockType: BlockType + if (blockState.isAir) { + blockType = vsCore.blockTypes.air + } else { + val blockMaterial = blockState.material + blockType = if (blockMaterial.isLiquid) { + if (blockMaterial == Material.LAVA) { + vsCore.blockTypes.lava + } else { + vsCore.blockTypes.water + } + } else if (blockMaterial.isSolid) { + val voxelShape = blockState.getShape(dummyBlockGetter, BlockPos.ZERO) + + val collisionShape: Lod1SolidCollisionShape = if (voxelShapeToCollisionShapeMap.contains(voxelShape)) { + voxelShapeToCollisionShapeMap[voxelShape]!! + } else { + fullBlockCollisionShape + } + + 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++ + // TODO: For now don't waterlog, in the future add the fluid state id here + _blockStateData.add(Triple(solidStateId, BlockTypeImpl.AIR.toInt(), blockStateId)) + BlockTypeImpl(blockStateId) + } else { + vsCore.blockTypes.air + } + } + blockStateToId[blockState] = blockType + } + + registeredBlocks = true + } + private val logger by logger() } From 62b6f9cdcc28841999744d2e5cf936a6a8c425de Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 27 Aug 2023 17:07:33 -0600 Subject: [PATCH 208/437] Got bouncing kind of working --- forge/build.gradle | 2 +- vs-core | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index 669ac6c97..a06443d25 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -100,7 +100,7 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+f053c720c5") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+2bfb3f8968") { transitive = false } diff --git a/vs-core b/vs-core index c9f627641..69e97f4dc 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit c9f627641c03423ac01851c9b5f62c218b8cff2a +Subproject commit 69e97f4dce64479ffc70c04754ec7c6a3a0fa3a8 From 7d94aa603828cc339c21502776e5dade5cab1a5d Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 28 Aug 2023 02:22:16 -0600 Subject: [PATCH 209/437] Got fence shapes working --- .../mod/common/config/VSMassDataLoader.kt | 327 +++++++++++++++++- 1 file changed, 324 insertions(+), 3 deletions(-) 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 ccdc8eb03..c5fce0e6e 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 @@ -21,6 +21,7 @@ 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.primitives.AABBi import org.valkyrienskies.core.apigame.world.chunks.BlockType import org.valkyrienskies.core.game.VSBlockType import org.valkyrienskies.core.impl.game.BlockTypeImpl @@ -39,9 +40,11 @@ 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 org.valkyrienskies.physics_api.voxel.LodBlockBoundingBox.Companion import java.util.Optional import kotlin.math.max import kotlin.math.min +import kotlin.math.roundToInt private data class VSBlockStateInfo( val id: ResourceLocation, @@ -175,6 +178,315 @@ object MassDatapackResolver : BlockStateInfoProvider { } } + private fun mergeBoxes(boxes: MutableList<LodBlockBoundingBox>): MutableList<LodBlockBoundingBox> { + fun tryMerging(box0: LodBlockBoundingBox, box1: LodBlockBoundingBox): LodBlockBoundingBox? { + // Check x-axis + if (box0.minY == box1.minY && box0.maxY == box1.maxY && box0.minZ == box1.minZ && box0.maxZ == box1.maxZ) { + val box0MinX = box0.minX + val box0MaxX = box0.maxX + 1 + val box1MinX = box1.minX + val box1MaxX = box1.maxX + 1 + + if (box0MinX <= box1MaxX && box0MaxX >= box1MinX) { + return LodBlockBoundingBox.createVSBoundingBox( + min(box0.minX.toInt(), box1.minX.toInt()).toByte(), + box0.minY, + box0.minZ, + max(box0.maxX.toInt(), box1.maxX.toInt()).toByte(), + box0.maxY, + box0.maxZ, + ) + } + } + + // Check y-axis + if (box0.minX == box1.minX && box0.maxX == box1.maxX && box0.minZ == box1.minZ && box0.maxZ == box1.maxZ) { + val box0MinY = box0.minY + val box0MaxY = box0.maxY + 1 + val box1MinY = box1.minY + val box1MaxY = box1.maxY + 1 + + if (box0MinY <= box1MaxY && box0MaxY >= box1MinY) { + return LodBlockBoundingBox.createVSBoundingBox( + box0.minX, + min(box0.minY.toInt(), box1.minY.toInt()).toByte(), + box0.minZ, + box0.maxX, + max(box0.maxY.toInt(), box1.maxY.toInt()).toByte(), + box0.maxZ, + ) + } + } + + // Check z-axis + if (box0.minX == box1.minX && box0.maxX == box1.maxX && box0.minY == box1.minY && box0.maxY == box1.maxY) { + val box0MinZ = box0.minZ + val box0MaxZ = box0.maxZ + 1 + val box1MinZ = box1.minZ + val box1MaxZ = box1.maxZ + 1 + + if (box0MinZ <= box1MaxZ && box0MaxZ >= box1MinZ) { + return LodBlockBoundingBox.createVSBoundingBox( + box0.minX, + box0.minY, + min(box0.minZ.toInt(), box1.minZ.toInt()).toByte(), + box0.maxX, + box0.maxY, + max(box0.maxZ.toInt(), box1.maxZ.toInt()).toByte(), + ) + } + } + + return null + } + + if (boxes.size < 2) return boxes + var done = false + loop@while (!done) { + for (i in 0 until boxes.size) { + for (j in i + 1 until boxes.size) { + val merged = tryMerging(boxes[i], boxes[j]) + if (merged != null) { + boxes.removeAt(j) + boxes.removeAt(i) + boxes.add(merged) + continue@loop + } + } + } + done = true + } + return boxes + } + + private fun cutBoxes(boxes: MutableList<LodBlockBoundingBox>, cut: LodBlockBoundingBox): MutableList<LodBlockBoundingBox> { + val box0BB = AABBi() + val box1BB = AABBi() + + fun intersects(box0: LodBlockBoundingBox, box1: LodBlockBoundingBox): Boolean { + box0BB.setMin(box0.minX.toInt(), box0.minY.toInt(), box0.minZ.toInt()) + box0BB.setMax(box0.maxX.toInt(), box0.maxY.toInt(), box0.maxZ.toInt()) + box1BB.setMin(box1.minX.toInt(), box1.minY.toInt(), box1.minZ.toInt()) + box1BB.setMax(box1.maxX.toInt(), box1.maxY.toInt(), box1.maxZ.toInt()) + return box0BB.intersectsAABB(box1BB) + } + + fun cutBox(box: LodBlockBoundingBox, cut: LodBlockBoundingBox, dest: MutableList<LodBlockBoundingBox>) { + // Make bottom-x box + if (box.minX < cut.minX) { + dest.add(Companion.createVSBoundingBox(box.minX, box.minY, box.minZ, (cut.minX - 1).toByte(), box.maxY, box.maxZ)) + } + // Make top-x box + if (box.maxX > cut.maxX) { + dest.add(Companion.createVSBoundingBox((cut.maxX + 1).toByte(), box.minY, box.minZ, box.maxX, box.maxY, box.maxZ)) + } + + // All boxes generated from this point will get minX/maxX from [cut] + + // Make bottom-y box + if (box.minY < cut.minY) { + dest.add(Companion.createVSBoundingBox(cut.minX, box.minY, box.minZ, cut.maxX, (cut.minY - 1).toByte(), box.maxZ)) + } + // Make top-y box + if (box.maxY > cut.maxY) { + dest.add(Companion.createVSBoundingBox(cut.minX, (cut.maxY + 1).toByte(), box.minZ, cut.maxX, box.maxY, box.maxZ)) + } + + // All boxes generated from this point will get minX/maxX/minY/maxY from [cut] + // Make bottom-z box + if (box.minZ < cut.minZ) { + dest.add(Companion.createVSBoundingBox(cut.minX, cut.minY, box.minZ, cut.maxX, cut.maxY, (cut.minZ - 1).toByte())) + } + // Make top-z box + if (box.maxZ > cut.maxZ) { + dest.add(Companion.createVSBoundingBox(cut.minX, cut.minY, (cut.maxZ + 1).toByte(), cut.maxX, cut.maxY, box.maxZ)) + } + } + + if (boxes.isEmpty()) return boxes + + var done = false + loop@while (!done) { + for (i in 0 until boxes.size) { + val box = boxes[i] + if (intersects(box, cut)) { + boxes.removeAt(i) + cutBox(box, cut, boxes) + continue@loop + } + } + done = true + } + + return boxes + } + + private fun generateCollisionPointsForBoxes(boxes: List<LodBlockBoundingBox>): List<CollisionPoint> { + // Near flat: 4 points + // Near post: 4 points + // Near cube: 1 points + + val collisionPoints = ArrayList<CollisionPoint>() + for (box in boxes) { + val xLen = box.maxX + 1 - box.minX + val yLen = box.maxY + 1 - box.minY + val zLen = box.maxZ + 1 - box.minZ + + if (xLen * 2 <= yLen && xLen * 2 <= zLen) { + // flat like along X + val radius = xLen / 2.0f + val xPos = (box.maxX + 1 + box.minX) / 2.0f + val minY = box.minY + radius + val minZ = box.minZ + radius + val maxY = box.maxY + 1 - radius + val maxZ = box.maxZ + 1 - radius + collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, minY / 16.0f, minZ / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, minY / 16.0f, maxZ / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, maxY / 16.0f, minZ / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, maxY / 16.0f, maxZ / 16.0f), radius / 16.0f)) + } else if (yLen * 2 <= xLen && yLen * 2 <= zLen) { + // flat like along Y + val radius = yLen / 2.0f + val yPos = (box.maxY + 1 + box.minY) / 2.0f + val minX = box.minX + radius + val minZ = box.minZ + radius + val maxX = box.maxX + 1 - radius + val maxZ = box.maxZ + 1 - radius + collisionPoints.add(CollisionPoint(Vector3f(minX / 16.0f, yPos / 16.0f, minZ / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(minX / 16.0f, yPos / 16.0f, maxZ / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(maxX / 16.0f, yPos / 16.0f, minZ / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(maxX / 16.0f, yPos / 16.0f, maxZ / 16.0f), radius / 16.0f)) + } else if (zLen * 2 <= xLen && zLen * 2 <= yLen) { + // fence like along Z + val radius = zLen / 2.0f + val zPos = (box.maxZ + 1 + box.minZ) / 2.0f + val minX = box.minX + radius + val minY = box.minY + radius + val maxX = box.maxX + 1 - radius + val maxY = box.maxY + 1 - radius + collisionPoints.add(CollisionPoint(Vector3f(minX / 16.0f, minY / 16.0f, zPos / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(minX / 16.0f, maxY / 16.0f, zPos / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(maxX / 16.0f, minY / 16.0f, zPos / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(maxX / 16.0f, maxY / 16.0f, zPos / 16.0f), radius / 16.0f)) + } else if (xLen >= 2 * yLen && xLen >= 2 * zLen) { + // post like along X + val radius = min(yLen, zLen) / 2.0f + val yPos = (box.maxY + 1 + box.minY) / 2.0f + val zPos = (box.maxZ + 1 + box.minZ) / 2.0f + collisionPoints.add(CollisionPoint(Vector3f((box.minX + radius) / 16.0f, yPos / 16.0f, zPos / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(((box.maxX + 1 + box.minX) / 2.0f) / 16.0f, yPos / 16.0f, zPos / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f((box.maxX + 1 - radius) / 16.0f, yPos / 16.0f, zPos / 16.0f), radius / 16.0f)) + } else if (yLen >= 2 * xLen && yLen >= 2 * zLen) { + // post like along Y + val radius = min(xLen, zLen) / 2.0f + val xPos = (box.maxX + 1 + box.minX) / 2.0f + val zPos = (box.maxZ + 1 + box.minZ) / 2.0f + collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, (box.minY + radius) / 16.0f, zPos / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, ((box.maxY + 1 + box.minY) / 2.0f) / 16.0f, zPos / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, (box.maxY + 1 - radius) / 16.0f, zPos / 16.0f), radius / 16.0f)) + } else if (zLen >= 2 * xLen && zLen >= 2 * yLen) { + // post like along Z + val radius = min(xLen, yLen) / 2.0f + val xPos = (box.maxX + 1 + box.minX) / 2.0f + val yPos = (box.maxY + 1 + box.minY) / 2.0f + collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, yPos / 16.0f, (box.minZ + radius) / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, yPos / 16.0f, ((box.maxZ + 1 + box.minZ) / 2.0f) / 16.0f), radius / 16.0f)) + collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, yPos / 16.0f, (box.maxZ + 1 - radius) / 16.0f), radius / 16.0f)) + } else { + // box + val radius = min(xLen, min(yLen, zLen)) / 2.0f + val centerX = (box.maxX + 1 + box.minX) / 2.0f + val centerY = (box.maxY + 1 + box.minY) / 2.0f + val centerZ = (box.maxZ + 1 + box.minZ) / 2.0f + collisionPoints.add(CollisionPoint(Vector3f(centerX / 16.0f, centerY / 16.0f, centerZ / 16.0f), radius / 16.0f)) + } + } + return collisionPoints + } + + private fun generateShapeFromVoxel(voxelShape: VoxelShape): Lod1SolidBoxesCollisionShape? { + val posBoxes = ArrayList<LodBlockBoundingBox>() + 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() + 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(Companion.createVSBoundingBox(lodMinX, lodMinY, lodMinZ, lodMaxX, lodMaxY, lodMaxZ)) + } + if (maxBoxesToTest == 0) { + failed = true + } else { + maxBoxesToTest-- + } + } + + if (failed) { + return null + } + + if (posBoxes.isEmpty()) { + // No boxes? It's the empty shape + return Lod1SolidBoxesCollisionShape(Companion.createEmptyVSBoundingBox(), emptyList(), emptyList(), listOf(Companion.createFullVSBoundingBox())) + } + + mergeBoxes(posBoxes) + + if (posBoxes.size > 10) { + return null + } + + var negBoxes = mutableListOf(Companion.createFullVSBoundingBox()) + for (posBox in posBoxes) { + negBoxes = cutBoxes(negBoxes, posBox) + } + + mergeBoxes(negBoxes) + + if (negBoxes.size > 10) { + return null + } + + val collisionPoints = generateCollisionPointsForBoxes(posBoxes) + + if (collisionPoints.size > 20) { + return null + } + + val minTotalAABB = Vector3i(posBoxes[0].minX.toInt(), posBoxes[0].minY.toInt(), posBoxes[0].minZ.toInt()) + val maxTotalAABB = Vector3i(posBoxes[0].maxX.toInt(), posBoxes[0].maxY.toInt(), posBoxes[0].maxZ.toInt()) + for (i in 1 until posBoxes.size) { + minTotalAABB.x = min(minTotalAABB.x, posBoxes[i].minX.toInt()) + minTotalAABB.y = min(minTotalAABB.y, posBoxes[i].minY.toInt()) + minTotalAABB.z = min(minTotalAABB.z, posBoxes[i].minZ.toInt()) + maxTotalAABB.x = max(maxTotalAABB.x, posBoxes[i].maxX.toInt()) + maxTotalAABB.y = max(maxTotalAABB.y, posBoxes[i].maxY.toInt()) + maxTotalAABB.z = max(maxTotalAABB.z, posBoxes[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() + ) + + return Lod1SolidBoxesCollisionShape( + overallBox, + collisionPoints, + posBoxes, + negBoxes, + ) + } + private fun generateStairCollisionShapes(stairShapes: Array<VoxelShape>): Map<VoxelShape, Lod1SolidCollisionShape> { val testPoints = listOf( CollisionPoint(Vector3f(.25f, .25f, .25f), .25f), @@ -236,8 +548,8 @@ object MassDatapackResolver : BlockStateInfoProvider { val collisionShape = Lod1SolidBoxesCollisionShape( overallBoundingBox = overallBox, collisionPoints = points, - solidBoxes = positiveBoxes, - negativeBoxes = negativeBoxes, + solidBoxes = mergeBoxes(positiveBoxes), + negativeBoxes = mergeBoxes(negativeBoxes), ) map[stairShape] = collisionShape } @@ -324,6 +636,7 @@ object MassDatapackResolver : BlockStateInfoProvider { var nextFluidId = 4 var nextVoxelStateId = 4 + val generatedCollisionShapesMap = HashMap<VoxelShape, Lod1SolidCollisionShape?>() blockStates.forEach { blockState: BlockState -> val blockType: BlockType if (blockState.isAir) { @@ -341,8 +654,16 @@ object MassDatapackResolver : BlockStateInfoProvider { val collisionShape: Lod1SolidCollisionShape = if (voxelShapeToCollisionShapeMap.contains(voxelShape)) { voxelShapeToCollisionShapeMap[voxelShape]!! + } else if (generatedCollisionShapesMap.contains(voxelShape)) { + if (generatedCollisionShapesMap[voxelShape] != null) { + generatedCollisionShapesMap[voxelShape]!! + } else { + fullBlockCollisionShape + } } else { - fullBlockCollisionShape + val generated = generateShapeFromVoxel(voxelShape) + generatedCollisionShapesMap[voxelShape] = generated + generated ?: fullBlockCollisionShape } val vsBlockStateInfo = map[Registry.BLOCK.getKey(blockState.block)] From 63d35f84d63ad28e0aeff4172b3c9fb4093e115f Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 28 Aug 2023 03:34:33 -0600 Subject: [PATCH 210/437] Replaced some magic numbers with constants --- .../mod/common/config/VSMassDataLoader.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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 c5fce0e6e..afbacd996 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 @@ -69,6 +69,10 @@ object MassDatapackResolver : BlockStateInfoProvider { // Unused for now, placeholder for later private const val DEFAULT_HARDNESS = 1.0 + // Limits set by Krunch + private const val MAX_BOXES = 10 + private const val MAX_POINTS = 20 + override val priority: Int get() = 100 @@ -443,7 +447,7 @@ object MassDatapackResolver : BlockStateInfoProvider { mergeBoxes(posBoxes) - if (posBoxes.size > 10) { + if (posBoxes.size > MAX_BOXES) { return null } @@ -454,13 +458,13 @@ object MassDatapackResolver : BlockStateInfoProvider { mergeBoxes(negBoxes) - if (negBoxes.size > 10) { + if (negBoxes.size > MAX_BOXES) { return null } val collisionPoints = generateCollisionPointsForBoxes(posBoxes) - if (collisionPoints.size > 20) { + if (collisionPoints.size > MAX_POINTS) { return null } @@ -544,7 +548,6 @@ object MassDatapackResolver : BlockStateInfoProvider { minTotalAABB.x.toByte(), minTotalAABB.y.toByte(), minTotalAABB.z.toByte(), maxTotalAABB.x.toByte(), maxTotalAABB.y.toByte(), maxTotalAABB.z.toByte() ) - // TODO: Merge boxes (later) val collisionShape = Lod1SolidBoxesCollisionShape( overallBoundingBox = overallBox, collisionPoints = points, From a11f42109964353823818480c2358f62f75fe531 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 28 Aug 2023 04:04:18 -0600 Subject: [PATCH 211/437] Moved box cutting code to Lod1SolidShapeUtils --- .../mod/common/config/VSMassDataLoader.kt | 356 ++---------------- vs-core | 2 +- 2 files changed, 40 insertions(+), 318 deletions(-) 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 afbacd996..af129e3ac 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 @@ -21,9 +21,9 @@ 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.primitives.AABBi 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.hooks.VSGameEvents @@ -40,7 +40,6 @@ 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 org.valkyrienskies.physics_api.voxel.LodBlockBoundingBox.Companion import java.util.Optional import kotlin.math.max import kotlin.math.min @@ -69,10 +68,6 @@ object MassDatapackResolver : BlockStateInfoProvider { // Unused for now, placeholder for later private const val DEFAULT_HARDNESS = 1.0 - // Limits set by Krunch - private const val MAX_BOXES = 10 - private const val MAX_POINTS = 20 - override val priority: Int get() = 100 @@ -182,315 +177,6 @@ object MassDatapackResolver : BlockStateInfoProvider { } } - private fun mergeBoxes(boxes: MutableList<LodBlockBoundingBox>): MutableList<LodBlockBoundingBox> { - fun tryMerging(box0: LodBlockBoundingBox, box1: LodBlockBoundingBox): LodBlockBoundingBox? { - // Check x-axis - if (box0.minY == box1.minY && box0.maxY == box1.maxY && box0.minZ == box1.minZ && box0.maxZ == box1.maxZ) { - val box0MinX = box0.minX - val box0MaxX = box0.maxX + 1 - val box1MinX = box1.minX - val box1MaxX = box1.maxX + 1 - - if (box0MinX <= box1MaxX && box0MaxX >= box1MinX) { - return LodBlockBoundingBox.createVSBoundingBox( - min(box0.minX.toInt(), box1.minX.toInt()).toByte(), - box0.minY, - box0.minZ, - max(box0.maxX.toInt(), box1.maxX.toInt()).toByte(), - box0.maxY, - box0.maxZ, - ) - } - } - - // Check y-axis - if (box0.minX == box1.minX && box0.maxX == box1.maxX && box0.minZ == box1.minZ && box0.maxZ == box1.maxZ) { - val box0MinY = box0.minY - val box0MaxY = box0.maxY + 1 - val box1MinY = box1.minY - val box1MaxY = box1.maxY + 1 - - if (box0MinY <= box1MaxY && box0MaxY >= box1MinY) { - return LodBlockBoundingBox.createVSBoundingBox( - box0.minX, - min(box0.minY.toInt(), box1.minY.toInt()).toByte(), - box0.minZ, - box0.maxX, - max(box0.maxY.toInt(), box1.maxY.toInt()).toByte(), - box0.maxZ, - ) - } - } - - // Check z-axis - if (box0.minX == box1.minX && box0.maxX == box1.maxX && box0.minY == box1.minY && box0.maxY == box1.maxY) { - val box0MinZ = box0.minZ - val box0MaxZ = box0.maxZ + 1 - val box1MinZ = box1.minZ - val box1MaxZ = box1.maxZ + 1 - - if (box0MinZ <= box1MaxZ && box0MaxZ >= box1MinZ) { - return LodBlockBoundingBox.createVSBoundingBox( - box0.minX, - box0.minY, - min(box0.minZ.toInt(), box1.minZ.toInt()).toByte(), - box0.maxX, - box0.maxY, - max(box0.maxZ.toInt(), box1.maxZ.toInt()).toByte(), - ) - } - } - - return null - } - - if (boxes.size < 2) return boxes - var done = false - loop@while (!done) { - for (i in 0 until boxes.size) { - for (j in i + 1 until boxes.size) { - val merged = tryMerging(boxes[i], boxes[j]) - if (merged != null) { - boxes.removeAt(j) - boxes.removeAt(i) - boxes.add(merged) - continue@loop - } - } - } - done = true - } - return boxes - } - - private fun cutBoxes(boxes: MutableList<LodBlockBoundingBox>, cut: LodBlockBoundingBox): MutableList<LodBlockBoundingBox> { - val box0BB = AABBi() - val box1BB = AABBi() - - fun intersects(box0: LodBlockBoundingBox, box1: LodBlockBoundingBox): Boolean { - box0BB.setMin(box0.minX.toInt(), box0.minY.toInt(), box0.minZ.toInt()) - box0BB.setMax(box0.maxX.toInt(), box0.maxY.toInt(), box0.maxZ.toInt()) - box1BB.setMin(box1.minX.toInt(), box1.minY.toInt(), box1.minZ.toInt()) - box1BB.setMax(box1.maxX.toInt(), box1.maxY.toInt(), box1.maxZ.toInt()) - return box0BB.intersectsAABB(box1BB) - } - - fun cutBox(box: LodBlockBoundingBox, cut: LodBlockBoundingBox, dest: MutableList<LodBlockBoundingBox>) { - // Make bottom-x box - if (box.minX < cut.minX) { - dest.add(Companion.createVSBoundingBox(box.minX, box.minY, box.minZ, (cut.minX - 1).toByte(), box.maxY, box.maxZ)) - } - // Make top-x box - if (box.maxX > cut.maxX) { - dest.add(Companion.createVSBoundingBox((cut.maxX + 1).toByte(), box.minY, box.minZ, box.maxX, box.maxY, box.maxZ)) - } - - // All boxes generated from this point will get minX/maxX from [cut] - - // Make bottom-y box - if (box.minY < cut.minY) { - dest.add(Companion.createVSBoundingBox(cut.minX, box.minY, box.minZ, cut.maxX, (cut.minY - 1).toByte(), box.maxZ)) - } - // Make top-y box - if (box.maxY > cut.maxY) { - dest.add(Companion.createVSBoundingBox(cut.minX, (cut.maxY + 1).toByte(), box.minZ, cut.maxX, box.maxY, box.maxZ)) - } - - // All boxes generated from this point will get minX/maxX/minY/maxY from [cut] - // Make bottom-z box - if (box.minZ < cut.minZ) { - dest.add(Companion.createVSBoundingBox(cut.minX, cut.minY, box.minZ, cut.maxX, cut.maxY, (cut.minZ - 1).toByte())) - } - // Make top-z box - if (box.maxZ > cut.maxZ) { - dest.add(Companion.createVSBoundingBox(cut.minX, cut.minY, (cut.maxZ + 1).toByte(), cut.maxX, cut.maxY, box.maxZ)) - } - } - - if (boxes.isEmpty()) return boxes - - var done = false - loop@while (!done) { - for (i in 0 until boxes.size) { - val box = boxes[i] - if (intersects(box, cut)) { - boxes.removeAt(i) - cutBox(box, cut, boxes) - continue@loop - } - } - done = true - } - - return boxes - } - - private fun generateCollisionPointsForBoxes(boxes: List<LodBlockBoundingBox>): List<CollisionPoint> { - // Near flat: 4 points - // Near post: 4 points - // Near cube: 1 points - - val collisionPoints = ArrayList<CollisionPoint>() - for (box in boxes) { - val xLen = box.maxX + 1 - box.minX - val yLen = box.maxY + 1 - box.minY - val zLen = box.maxZ + 1 - box.minZ - - if (xLen * 2 <= yLen && xLen * 2 <= zLen) { - // flat like along X - val radius = xLen / 2.0f - val xPos = (box.maxX + 1 + box.minX) / 2.0f - val minY = box.minY + radius - val minZ = box.minZ + radius - val maxY = box.maxY + 1 - radius - val maxZ = box.maxZ + 1 - radius - collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, minY / 16.0f, minZ / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, minY / 16.0f, maxZ / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, maxY / 16.0f, minZ / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, maxY / 16.0f, maxZ / 16.0f), radius / 16.0f)) - } else if (yLen * 2 <= xLen && yLen * 2 <= zLen) { - // flat like along Y - val radius = yLen / 2.0f - val yPos = (box.maxY + 1 + box.minY) / 2.0f - val minX = box.minX + radius - val minZ = box.minZ + radius - val maxX = box.maxX + 1 - radius - val maxZ = box.maxZ + 1 - radius - collisionPoints.add(CollisionPoint(Vector3f(minX / 16.0f, yPos / 16.0f, minZ / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(minX / 16.0f, yPos / 16.0f, maxZ / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(maxX / 16.0f, yPos / 16.0f, minZ / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(maxX / 16.0f, yPos / 16.0f, maxZ / 16.0f), radius / 16.0f)) - } else if (zLen * 2 <= xLen && zLen * 2 <= yLen) { - // fence like along Z - val radius = zLen / 2.0f - val zPos = (box.maxZ + 1 + box.minZ) / 2.0f - val minX = box.minX + radius - val minY = box.minY + radius - val maxX = box.maxX + 1 - radius - val maxY = box.maxY + 1 - radius - collisionPoints.add(CollisionPoint(Vector3f(minX / 16.0f, minY / 16.0f, zPos / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(minX / 16.0f, maxY / 16.0f, zPos / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(maxX / 16.0f, minY / 16.0f, zPos / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(maxX / 16.0f, maxY / 16.0f, zPos / 16.0f), radius / 16.0f)) - } else if (xLen >= 2 * yLen && xLen >= 2 * zLen) { - // post like along X - val radius = min(yLen, zLen) / 2.0f - val yPos = (box.maxY + 1 + box.minY) / 2.0f - val zPos = (box.maxZ + 1 + box.minZ) / 2.0f - collisionPoints.add(CollisionPoint(Vector3f((box.minX + radius) / 16.0f, yPos / 16.0f, zPos / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(((box.maxX + 1 + box.minX) / 2.0f) / 16.0f, yPos / 16.0f, zPos / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f((box.maxX + 1 - radius) / 16.0f, yPos / 16.0f, zPos / 16.0f), radius / 16.0f)) - } else if (yLen >= 2 * xLen && yLen >= 2 * zLen) { - // post like along Y - val radius = min(xLen, zLen) / 2.0f - val xPos = (box.maxX + 1 + box.minX) / 2.0f - val zPos = (box.maxZ + 1 + box.minZ) / 2.0f - collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, (box.minY + radius) / 16.0f, zPos / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, ((box.maxY + 1 + box.minY) / 2.0f) / 16.0f, zPos / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, (box.maxY + 1 - radius) / 16.0f, zPos / 16.0f), radius / 16.0f)) - } else if (zLen >= 2 * xLen && zLen >= 2 * yLen) { - // post like along Z - val radius = min(xLen, yLen) / 2.0f - val xPos = (box.maxX + 1 + box.minX) / 2.0f - val yPos = (box.maxY + 1 + box.minY) / 2.0f - collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, yPos / 16.0f, (box.minZ + radius) / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, yPos / 16.0f, ((box.maxZ + 1 + box.minZ) / 2.0f) / 16.0f), radius / 16.0f)) - collisionPoints.add(CollisionPoint(Vector3f(xPos / 16.0f, yPos / 16.0f, (box.maxZ + 1 - radius) / 16.0f), radius / 16.0f)) - } else { - // box - val radius = min(xLen, min(yLen, zLen)) / 2.0f - val centerX = (box.maxX + 1 + box.minX) / 2.0f - val centerY = (box.maxY + 1 + box.minY) / 2.0f - val centerZ = (box.maxZ + 1 + box.minZ) / 2.0f - collisionPoints.add(CollisionPoint(Vector3f(centerX / 16.0f, centerY / 16.0f, centerZ / 16.0f), radius / 16.0f)) - } - } - return collisionPoints - } - - private fun generateShapeFromVoxel(voxelShape: VoxelShape): Lod1SolidBoxesCollisionShape? { - val posBoxes = ArrayList<LodBlockBoundingBox>() - 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() - 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(Companion.createVSBoundingBox(lodMinX, lodMinY, lodMinZ, lodMaxX, lodMaxY, lodMaxZ)) - } - if (maxBoxesToTest == 0) { - failed = true - } else { - maxBoxesToTest-- - } - } - - if (failed) { - return null - } - - if (posBoxes.isEmpty()) { - // No boxes? It's the empty shape - return Lod1SolidBoxesCollisionShape(Companion.createEmptyVSBoundingBox(), emptyList(), emptyList(), listOf(Companion.createFullVSBoundingBox())) - } - - mergeBoxes(posBoxes) - - if (posBoxes.size > MAX_BOXES) { - return null - } - - var negBoxes = mutableListOf(Companion.createFullVSBoundingBox()) - for (posBox in posBoxes) { - negBoxes = cutBoxes(negBoxes, posBox) - } - - mergeBoxes(negBoxes) - - if (negBoxes.size > MAX_BOXES) { - return null - } - - val collisionPoints = generateCollisionPointsForBoxes(posBoxes) - - if (collisionPoints.size > MAX_POINTS) { - return null - } - - val minTotalAABB = Vector3i(posBoxes[0].minX.toInt(), posBoxes[0].minY.toInt(), posBoxes[0].minZ.toInt()) - val maxTotalAABB = Vector3i(posBoxes[0].maxX.toInt(), posBoxes[0].maxY.toInt(), posBoxes[0].maxZ.toInt()) - for (i in 1 until posBoxes.size) { - minTotalAABB.x = min(minTotalAABB.x, posBoxes[i].minX.toInt()) - minTotalAABB.y = min(minTotalAABB.y, posBoxes[i].minY.toInt()) - minTotalAABB.z = min(minTotalAABB.z, posBoxes[i].minZ.toInt()) - maxTotalAABB.x = max(maxTotalAABB.x, posBoxes[i].maxX.toInt()) - maxTotalAABB.y = max(maxTotalAABB.y, posBoxes[i].maxY.toInt()) - maxTotalAABB.z = max(maxTotalAABB.z, posBoxes[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() - ) - - return Lod1SolidBoxesCollisionShape( - overallBox, - collisionPoints, - posBoxes, - negBoxes, - ) - } - private fun generateStairCollisionShapes(stairShapes: Array<VoxelShape>): Map<VoxelShape, Lod1SolidCollisionShape> { val testPoints = listOf( CollisionPoint(Vector3f(.25f, .25f, .25f), .25f), @@ -551,14 +237,50 @@ object MassDatapackResolver : BlockStateInfoProvider { val collisionShape = Lod1SolidBoxesCollisionShape( overallBoundingBox = overallBox, collisionPoints = points, - solidBoxes = mergeBoxes(positiveBoxes), - negativeBoxes = mergeBoxes(negativeBoxes), + solidBoxes = Lod1SolidShapeUtils.mergeBoxes(positiveBoxes), + negativeBoxes = Lod1SolidShapeUtils.mergeBoxes(negativeBoxes), ) map[stairShape] = collisionShape } return map } + private fun generateShapeFromVoxel(voxelShape: VoxelShape): Lod1SolidBoxesCollisionShape? { + val posBoxes = ArrayList<LodBlockBoundingBox>() + 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() + 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) + ) + } + if (maxBoxesToTest == 0) { + failed = true + } else { + maxBoxesToTest-- + } + } + return if (!failed) { + Lod1SolidShapeUtils.generateShapeFromBoxes(posBoxes) + } else { + null + } + } + fun registerAllBlockStates(blockStates: Iterable<BlockState>) { val fullLodBoundingBox = LodBlockBoundingBox.createVSBoundingBox(0, 0, 0, 15, 15, 15) val fullBlockCollisionPoints = listOf( diff --git a/vs-core b/vs-core index 69e97f4dc..56948e308 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 69e97f4dce64479ffc70c04754ec7c6a3a0fa3a8 +Subproject commit 56948e308b4358aa8c3ad7704b18bebd61fa32e8 From 6cc8b4aabb2a46fca0271d41effade76677f7b92 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 29 Aug 2023 01:51:30 -0600 Subject: [PATCH 212/437] Implement VSConstraint serialization --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 0cb6cf031..f7c9aa400 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 0cb6cf0311c985b9fdf8f7dd6ac748666436a582 +Subproject commit f7c9aa4001ff00067b61048e6329b1bd20893ff5 From 4d86f4cab1603abb07d1ad84edad1261d57d5c49 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 29 Aug 2023 02:36:38 -0600 Subject: [PATCH 213/437] Implemented fluid height and water-logging --- .../mod/common/config/VSMassDataLoader.kt | 52 ++++++++++++++----- 1 file changed, 40 insertions(+), 12 deletions(-) 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 af129e3ac..a40f37daf 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 @@ -158,10 +158,6 @@ object MassDatapackResolver : BlockStateInfoProvider { val weight = element.asJsonObject["mass"]?.asDouble ?: throw IllegalArgumentException("No mass in file $origin") val friction = element.asJsonObject["friction"]?.asDouble ?: DEFAULT_FRICTION - val elasticityOriginal = element.asJsonObject["elasticity"] - if (elasticityOriginal != null) { - println("amogus") - } val elasticity = element.asJsonObject["elasticity"]?.asDouble ?: DEFAULT_ELASTICITY val priority = element.asJsonObject["priority"]?.asInt ?: 100 @@ -326,7 +322,7 @@ object MassDatapackResolver : BlockStateInfoProvider { val lavaBlockState = Lod1LiquidBlockState( boundingBox = fullLodBoundingBox, density = 10000.0f, - dragCoefficient = 0.3f, + dragCoefficient = 1.0f, fluidVel = Vector3f(), lod1LiquidBlockStateId = BlockTypeImpl.LAVA.toInt(), ) @@ -362,6 +358,37 @@ object MassDatapackResolver : BlockStateInfoProvider { var nextVoxelStateId = 4 val generatedCollisionShapesMap = HashMap<VoxelShape, Lod1SolidCollisionShape?>() + 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<FluidState, Pair<Lod1LiquidBlockStateId, BlockType>>() + + // Get the id of the fluid state/create a new fluid state if necessary + fun getFluidState(fluidState: FluidState): Pair<Lod1LiquidBlockStateId, BlockType> { + 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 (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 + } else { + // Default + return BlockTypeImpl.WATER.toInt() to BlockTypeImpl.WATER + } + } + blockStates.forEach { blockState: BlockState -> val blockType: BlockType if (blockState.isAir) { @@ -369,11 +396,7 @@ object MassDatapackResolver : BlockStateInfoProvider { } else { val blockMaterial = blockState.material blockType = if (blockMaterial.isLiquid) { - if (blockMaterial == Material.LAVA) { - vsCore.blockTypes.lava - } else { - vsCore.blockTypes.water - } + getFluidState(blockState.fluidState).second } else if (blockMaterial.isSolid) { val voxelShape = blockState.getShape(dummyBlockGetter, BlockPos.ZERO) @@ -406,8 +429,13 @@ object MassDatapackResolver : BlockStateInfoProvider { // Create new voxel state val blockStateId = nextVoxelStateId++ - // TODO: For now don't waterlog, in the future add the fluid state id here - _blockStateData.add(Triple(solidStateId, BlockTypeImpl.AIR.toInt(), blockStateId)) + + var fluidId = BlockTypeImpl.AIR.toInt() + if (!blockState.fluidState.isEmpty) { + fluidId = getFluidState(blockState.fluidState).first + } + + _blockStateData.add(Triple(solidStateId, fluidId, blockStateId)) BlockTypeImpl(blockStateId) } else { vsCore.blockTypes.air From 46f094f4934f49dd35682bf9b608d4997f71e55a Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 29 Aug 2023 02:42:38 -0600 Subject: [PATCH 214/437] Updated vs-core to main --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 56948e308..3bcba1a23 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 56948e308b4358aa8c3ad7704b18bebd61fa32e8 +Subproject commit 3bcba1a2382e01f39d7010bd530646093e53c5da From 3dfb6b3daabe16ae453fc7dd782fb6853bd1379d Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 29 Aug 2023 05:44:36 -0600 Subject: [PATCH 215/437] Fixed Chest collision shape --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index 3bcba1a23..1a7b5863c 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit 3bcba1a2382e01f39d7010bd530646093e53c5da +Subproject commit 1a7b5863c1596b0b84a447622cabff89dac69968 From 8e4bc5923462fc2e14693fbe5068caa2f1fa11bf Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 29 Aug 2023 05:46:44 -0600 Subject: [PATCH 216/437] Updated vs-core --- vs-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vs-core b/vs-core index f7c9aa400..1a7b5863c 160000 --- a/vs-core +++ b/vs-core @@ -1 +1 @@ -Subproject commit f7c9aa4001ff00067b61048e6329b1bd20893ff5 +Subproject commit 1a7b5863c1596b0b84a447622cabff89dac69968 From ff2f775e37d22ab483a1336659a775d1e73fe95c Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 29 Aug 2023 06:10:44 -0600 Subject: [PATCH 217/437] Added 1.20 to GitHub issue templates --- .github/ISSUE_TEMPLATE/bug_report.yml | 1 + .github/ISSUE_TEMPLATE/compatibility_issue.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 5d9341bbf..53b704ac0 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -18,6 +18,7 @@ body: - 1.16 - 1.18 - 1.19 + - 1.20 validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/compatibility_issue.yml b/.github/ISSUE_TEMPLATE/compatibility_issue.yml index 1fa48e826..c9a4c78e2 100644 --- a/.github/ISSUE_TEMPLATE/compatibility_issue.yml +++ b/.github/ISSUE_TEMPLATE/compatibility_issue.yml @@ -29,6 +29,7 @@ body: - 1.16 - 1.18 - 1.19 + - 1.20 validations: required: true - type: dropdown From 1de370d6da2841e2cf6c85efdca6a2398e5e515f Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 29 Aug 2023 06:19:14 -0600 Subject: [PATCH 218/437] Changed 1.20 to 1.20.x in GitHub issue templates --- .github/ISSUE_TEMPLATE/bug_report.yml | 2 +- .github/ISSUE_TEMPLATE/compatibility_issue.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml index 53b704ac0..6b541cd89 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.yml +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -18,7 +18,7 @@ body: - 1.16 - 1.18 - 1.19 - - 1.20 + - 1.20.x validations: required: true - type: dropdown diff --git a/.github/ISSUE_TEMPLATE/compatibility_issue.yml b/.github/ISSUE_TEMPLATE/compatibility_issue.yml index c9a4c78e2..6a29e9206 100644 --- a/.github/ISSUE_TEMPLATE/compatibility_issue.yml +++ b/.github/ISSUE_TEMPLATE/compatibility_issue.yml @@ -29,7 +29,7 @@ body: - 1.16 - 1.18 - 1.19 - - 1.20 + - 1.20.x validations: required: true - type: dropdown From 55992420aa4b5324b30ef8827d13f636bcb5d619 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 2 Sep 2023 16:07:50 -0600 Subject: [PATCH 219/437] Fixed C2Me compat --- .../mod/mixin/server/world/MixinChunkMap.java | 12 +-- .../level/chunk/MixinChunkGenerator.java | 64 +++++++++++++++ .../level/levelgen/MixinFlatLevelSource.java | 25 ++++++ .../MixinNoiseBasedChunkGenerator.java | 79 +++++++++++++++++++ .../mod/common/VS2ChunkAllocator.kt | 14 ++++ .../valkyrienskies-common.mixins.json | 3 + 6 files changed, 187 insertions(+), 10 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/world/level/chunk/MixinChunkGenerator.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinFlatLevelSource.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinNoiseBasedChunkGenerator.java create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/VS2ChunkAllocator.kt 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 225f1a315..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 @@ -1,23 +1,15 @@ package org.valkyrienskies.mod.mixin.server.world; -import java.io.IOException; import java.util.ArrayList; import java.util.HashSet; import java.util.Iterator; import java.util.List; -import java.util.Optional; import java.util.Set; import java.util.function.Supplier; -import net.minecraft.core.Registry; -import net.minecraft.nbt.CompoundTag; import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.level.ChunkPos; -import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraft.world.level.chunk.ProtoChunk; -import net.minecraft.world.level.chunk.UpgradeData; -import net.minecraft.world.level.chunk.storage.ChunkSerializer; import net.minecraft.world.level.storage.DimensionDataStorage; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -25,11 +17,9 @@ 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.ServerShip; import org.valkyrienskies.core.apigame.world.IPlayer; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.MinecraftPlayer; -import org.valkyrienskies.mod.common.util.ShipSettingsKt; @Mixin(ChunkMap.class) public abstract class MixinChunkMap { @@ -50,6 +40,7 @@ public abstract class MixinChunkMap { * * @author Tri0de */ + /* @Inject(method = "readChunk", at = @At("HEAD"), cancellable = true) private void preReadChunk(final ChunkPos chunkPos, final CallbackInfoReturnable<CompoundTag> cir) throws IOException { @@ -74,6 +65,7 @@ private void preReadChunk(final ChunkPos chunkPos, final CallbackInfoReturnable< } } } + */ /** * Force the game send chunk update packets to players watching ship chunks. 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 new file mode 100644 index 000000000..0b32dcda1 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/chunk/MixinChunkGenerator.java @@ -0,0 +1,64 @@ +package org.valkyrienskies.mod.mixin.world.level.chunk; + +import com.mojang.datafixers.util.Pair; +import net.minecraft.core.BlockPos; +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.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.structure.StructureSet; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager; +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.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.valkyrienskies.mod.common.VS2ChunkAllocator; + +@Mixin(ChunkGenerator.class) +public class MixinChunkGenerator { + @Inject(method = "findNearestMapFeature", at = @At("HEAD"), cancellable = true) + private void preFindNearestMapFeature(ServerLevel serverLevel, HolderSet<ConfiguredStructureFeature<?, ?>> holderSet, BlockPos blockPos, int i, boolean bl, final CallbackInfoReturnable<Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>>> 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) { + 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<StructureSet> resourceKey, long l, int chunkX, int chunkZ, int k, final CallbackInfoReturnable<Boolean> 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) { + final ChunkPos chunkPos = chunkAccess.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + callbackInfo.cancel(); + } + } + + @Inject(method = "createReferences", at = @At("HEAD"), cancellable = true) + private void preCreateReferences(WorldGenLevel worldGenLevel, StructureFeatureManager structureFeatureManager, 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 new file mode 100644 index 000000000..4fa338f9b --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinFlatLevelSource.java @@ -0,0 +1,25 @@ +package org.valkyrienskies.mod.mixin.world.level.levelgen; + +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.chunk.ChunkAccess; +import net.minecraft.world.level.levelgen.FlatLevelSource; +import net.minecraft.world.level.levelgen.blending.Blender; +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.CallbackInfoReturnable; +import org.valkyrienskies.mod.common.VS2ChunkAllocator; + +@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<CompletableFuture<ChunkAccess>> 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 new file mode 100644 index 000000000..79fb8acb0 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/levelgen/MixinNoiseBasedChunkGenerator.java @@ -0,0 +1,79 @@ +package org.valkyrienskies.mod.mixin.world.level.levelgen; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import net.minecraft.core.Holder; +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.StructureFeatureManager; +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.NoiseBasedChunkGenerator; +import net.minecraft.world.level.levelgen.NoiseGeneratorSettings; +import net.minecraft.world.level.levelgen.NoiseSettings; +import net.minecraft.world.level.levelgen.blending.Blender; +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.core.impl.game.ChunkAllocator; +import org.valkyrienskies.mod.common.VS2ChunkAllocator; + +@Mixin(NoiseBasedChunkGenerator.class) +public class MixinNoiseBasedChunkGenerator { + @Shadow + @Final + protected Holder<NoiseGeneratorSettings> 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<NoiseColumn> cir) { + 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)); + } + } + + @Inject(method = "buildSurface", at = @At("HEAD"), cancellable = true) + private void preBuildSurface(WorldGenRegion worldGenRegion, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess, CallbackInfo ci) { + final ChunkPos chunkPos = chunkAccess.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + ci.cancel(); + } + } + + @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) { + final ChunkPos chunkPos = chunkAccess.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, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess, CallbackInfoReturnable<CompletableFuture<ChunkAccess>> cir) { + final ChunkPos chunkPos = chunkAccess.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + cir.setReturnValue(CompletableFuture.completedFuture(chunkAccess)); + } + } + + @Inject(method = "spawnOriginalMobs", at = @At("HEAD"), cancellable = true) + private void preSpawnOriginalMobs(WorldGenRegion worldGenRegion, CallbackInfo ci) { + final ChunkPos chunkPos = worldGenRegion.getCenter(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + ci.cancel(); + } + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/VS2ChunkAllocator.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/VS2ChunkAllocator.kt new file mode 100644 index 000000000..ccaf6dff4 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VS2ChunkAllocator.kt @@ -0,0 +1,14 @@ +package org.valkyrienskies.mod.common + +import org.valkyrienskies.core.api.ships.properties.ChunkClaim +import org.valkyrienskies.core.impl.game.ChunkAllocator + +object VS2ChunkAllocator { + // TODO: Move this to ChunkAllocator eventually + fun isChunkInShipyardCompanion(chunkX: Int, chunkZ: Int): Boolean { + val claimXIndex = ChunkClaim.getClaimXIndex(chunkX) + val claimZIndex = ChunkClaim.getClaimZIndex(chunkZ) + + return (claimXIndex in ChunkAllocator.X_INDEX_START..ChunkAllocator.X_INDEX_END) and (claimZIndex in ChunkAllocator.Z_INDEX_START..ChunkAllocator.Z_INDEX_END) + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 78ed9cb67..ee3748a6e 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -69,6 +69,9 @@ "world.chunk.MixinLevelChunk", "world.entity.MixinPlayer", "world.entity.projectile.ProjectileUtilMixin", + "world.level.chunk.MixinChunkGenerator", + "world.level.levelgen.MixinFlatLevelSource", + "world.level.levelgen.MixinNoiseBasedChunkGenerator", "world.level.MixinLevel" ], "client": [ From 7d84b434a55efdffc1bc0c564c0e64f473a0ef09 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Sun, 3 Sep 2023 17:56:32 -0400 Subject: [PATCH 220/437] update gradle, kotlin, refactor core dependency --- .gitmodules | 3 -- build.gradle | 51 ++++++++++++++++++++---- common/build.gradle | 2 + fabric/build.gradle | 9 +++-- forge/build.gradle | 6 +-- gradle.properties | 1 + gradle/wrapper/gradle-wrapper.properties | 2 +- settings.gradle | 8 +++- vs-core | 1 - 9 files changed, 62 insertions(+), 21 deletions(-) delete mode 160000 vs-core diff --git a/.gitmodules b/.gitmodules index 6dad4381c..e69de29bb 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "vs-core"] - path = vs-core - url = https://github.com/ValkyrienSkies/vs-core diff --git a/build.gradle b/build.gradle index a271cfecd..ebb3e7da6 100644 --- a/build.gradle +++ b/build.gradle @@ -7,11 +7,11 @@ 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.3.355" 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 + id "org.jetbrains.kotlin.jvm" version "1.9.10" apply false // Kotlin linter id "org.jlleitschuh.gradle.ktlint" version "10.3.0" @@ -42,9 +42,29 @@ dependencyLocking { lockAllConfigurations() } -// Determine the version of vs-core -String vsCoreGitRevision = "git rev-parse HEAD".execute(null, gradle.includedBuild("vs-core").projectDir).text.trim() -ext.vs_core_version = "1.1.0+" + vsCoreGitRevision.substring(0, 10) +tasks.register("updateVsCore") { + File versionFile = null + File gradleProperties = file("gradle.properties") + + try { + def vsCoreBuild = gradle.includedBuild("vs-core") + versionFile = new File(vsCoreBuild.projectDir, "api-game/build/version.txt") + + inputs.file(versionFile) + outputs.file(gradleProperties) + dependsOn(vsCoreBuild.task(":api-game:writeVersion")) + } catch (UnknownDomainObjectException ignore) {} + + onlyIf { + versionFile != null + } + + doLast { + def vsCoreVersion = versionFile.text + def newGradleProperties = gradleProperties.text.replaceFirst("(?m)^vs_core_version=.*", "vs_core_version=" + vsCoreVersion) + gradleProperties.write(newGradleProperties) + } +} subprojects { apply plugin: "dev.architectury.loom" @@ -54,7 +74,22 @@ subprojects { apply plugin: "org.jetbrains.kotlin.jvm" apply plugin: "io.github.juuxel.loom-quiltflower" + configurations.each { it.resolutionStrategy.useGlobalDependencySubstitutionRules.set(false) } + repositories { + try { + def vsCoreBuild = gradle.includedBuild("vs-core") + mavenLocal { + content { + includeGroup("org.valkyrienskies.core") + } + } + + [':impl', ':api', ':api-game'].each { + compileJava.dependsOn(vsCoreBuild.task("${it}:publishToMavenLocal")) + } + } catch (UnknownDomainObjectException ignore) {} + mavenCentral() maven { name = "Valkyrien Skies Internal" @@ -125,9 +160,9 @@ subprojects { tasks.withType(Checkstyle) { reports { // Do not output html reports - html.enabled = false + html.required.set(false) // Output xml reports - xml.enabled = true + xml.required.set(true) } } diff --git a/common/build.gradle b/common/build.gradle index ecc6dbbd5..6e0512c5b 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -1,3 +1,4 @@ + dependencies { annotationProcessor(implementation("com.github.LlamaLad7:MixinExtras:0.1.1")) @@ -26,6 +27,7 @@ dependencies { 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-33") + modCompileOnly("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") } architectury { diff --git a/fabric/build.gradle b/fabric/build.gradle index 20b16bd33..0251fbbf3 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -37,7 +37,7 @@ dependencies { } // Depend on the fabric kotlin mod - include(modImplementation("net.fabricmc:fabric-language-kotlin:1.8.5+kotlin.1.7.20")) + 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") @@ -103,7 +103,7 @@ processResources { shadowJar { configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" + archiveClassifier.set "dev-shadow" duplicatesStrategy DuplicatesStrategy.EXCLUDE // Ignore duplicate valkyrienskies-common.accesswidener files dependencies { exclude(dependency("org.jetbrains.kotlin:.*:.*")) // Don't shade kotlin! @@ -115,16 +115,17 @@ shadowJar { remapJar { input.set shadowJar.archiveFile dependsOn shadowJar - classifier null + archiveClassifier.set null duplicatesStrategy DuplicatesStrategy.EXCLUDE // Ignore duplicate valkyrienskies-common.accesswidener files } jar { - classifier "dev" + archiveClassifier.set "dev" duplicatesStrategy DuplicatesStrategy.EXCLUDE // Ignore duplicate valkyrienskies-common.accesswidener files } sourcesJar { + dependsOn "copyAccessWidener" duplicatesStrategy DuplicatesStrategy.EXCLUDE // Ignore duplicate valkyrienskies-common.accesswidener files def commonSources = project(":common").sourcesJar dependsOn commonSources diff --git a/forge/build.gradle b/forge/build.gradle index a06443d25..946087b82 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -157,13 +157,13 @@ shadowJar { exclude "net/optifine/**" configurations = [project.configurations.shadowCommon] - classifier "dev-shadow" + archiveClassifier.set "dev-shadow" } remapJar { input.set shadowJar.archiveFile dependsOn shadowJar - classifier null + archiveClassifier.set null } compileKotlin { @@ -171,7 +171,7 @@ compileKotlin { } jar { - classifier "dev" + archiveClassifier.set "dev" } sourcesJar { diff --git a/gradle.properties b/gradle.properties index c638a1010..5c17857c9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,6 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 +vs_core_version=1.1.0+22a5fcd037 # 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/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 00e33edef..27313fbc8 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/settings.gradle b/settings.gradle index d61563cbc..e4f82deee 100644 --- a/settings.gradle +++ b/settings.gradle @@ -42,6 +42,12 @@ dependencyResolutionManagement { include("common") include("fabric") include("forge") -includeBuild("vs-core") + +try { + def core = file("../vs-core") + if (core.isDirectory()) { + includeBuild(core) + } +} catch (SecurityException ignore) {} rootProject.name = "valkyrienskies" diff --git a/vs-core b/vs-core deleted file mode 160000 index 1a7b5863c..000000000 --- a/vs-core +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1a7b5863c1596b0b84a447622cabff89dac69968 From 7d44621460e325e792afa3c41b39f17d3957b41d Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Sun, 3 Sep 2023 18:22:08 -0400 Subject: [PATCH 221/437] add gradle.properties --- common/gradle.properties | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 common/gradle.properties diff --git a/common/gradle.properties b/common/gradle.properties new file mode 100644 index 000000000..574b0f2ab --- /dev/null +++ b/common/gradle.properties @@ -0,0 +1,2 @@ +port_lib_version=1.2.677-beta +port_lib_hash=cca931b From 772fb2852471d6ede58a7a50d85d26cd236bc3a3 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Sun, 3 Sep 2023 22:06:19 -0400 Subject: [PATCH 222/437] remove checkstyle+ktlint --- build.gradle | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/build.gradle b/build.gradle index ebb3e7da6..862158fb4 100644 --- a/build.gradle +++ b/build.gradle @@ -12,14 +12,8 @@ plugins { id 'io.github.juuxel.loom-quiltflower' version '1.8.0' apply false // Kotlin id "org.jetbrains.kotlin.jvm" version "1.9.10" apply false - // Kotlin linter - id "org.jlleitschuh.gradle.ktlint" version "10.3.0" - id 'com.matthewprenger.cursegradle' version '1.4.0' apply false id "com.modrinth.minotaur" version "2.4.3" apply false - - // Java linter - id "checkstyle" } // Determine the version @@ -69,8 +63,6 @@ tasks.register("updateVsCore") { subprojects { apply plugin: "dev.architectury.loom" // Apply checkstyle and ktlint to check the code style of every sub project - apply plugin: "org.jlleitschuh.gradle.ktlint" - apply plugin: "checkstyle" apply plugin: "org.jetbrains.kotlin.jvm" apply plugin: "io.github.juuxel.loom-quiltflower" @@ -144,37 +136,6 @@ subprojects { compileOnly("com.google.code.findbugs:jsr305:3.0.2") } - - // configure checkstyle - checkstyle { - // configure to use checkstyle v8.41 - toolVersion "8.45.1" - // Gradle should fail builds on checkstyle errors (not warnings) - ignoreFailures = true - // Checkstyle config file is in .checkstyle/checkstyle.xml - configFile = file("${rootDir}/.checkstyle/checkstyle.xml") - } - - // configure checkstyle, but different - // https://docs.gradle.org/current/userguide/checkstyle_plugin.html - tasks.withType(Checkstyle) { - reports { - // Do not output html reports - html.required.set(false) - // Output xml reports - xml.required.set(true) - } - } - - // configure ktlint - ktlint { - reporters { - // configure to output in checkstyle XML format - reporter "checkstyle" - } - ignoreFailures = true - disabledRules = ["parameter-list-wrapping"] - } } allprojects { From 5bba21c0398c328d84164623328ab258f7f3d6c5 Mon Sep 17 00:00:00 2001 From: alex_s168 <63254202+SuperCraftAlex@users.noreply.github.com> Date: Mon, 18 Sep 2023 18:48:33 +0200 Subject: [PATCH 223/437] biome foilage (#572) * biome foilage and stuff * moved into seperate feature package and added config to disable --- .../mixin/client/world/MixinClientLevel.java | 1 + .../mod/mixin/feature/block_tint/FEATURE.md | 8 +++ .../feature/block_tint/MixinClientLevel.java | 68 +++++++++++++++++++ .../mod/common/config/VSGameConfig.kt | 9 +++ .../valkyrienskies-common.mixins.json | 5 +- 5 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_tint/FEATURE.md create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_tint/MixinClientLevel.java 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 bb4184ec4..7b77a62a7 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 @@ -201,4 +201,5 @@ private SimpleSoundInstance redirectNewSoundInstance(final SoundEvent soundEvent return new SimpleSoundInstance(soundEvent, soundSource, volume, pitch, x, y, z); } + } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_tint/FEATURE.md b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_tint/FEATURE.md new file mode 100644 index 000000000..1b2adb1ff --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_tint/FEATURE.md @@ -0,0 +1,8 @@ +# Block Tinting + +These mixins fix block tinting for blocks on ships. + +(Only updates if the chunk render buffer is updated) + +Adds a client side option in the config (called "fixBlockTinting" in the category "BlockTinting") to enable this feature. +(default off!) 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 new file mode 100644 index 000000000..5b459f99e --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/block_tint/MixinClientLevel.java @@ -0,0 +1,68 @@ +package org.valkyrienskies.mod.mixin.feature.block_tint; + +import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; +import net.minecraft.client.color.block.BlockTintCache; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ColorResolver; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.gen.Accessor; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.config.VSGameConfig; + +@Mixin(ClientLevel.class) +public abstract class MixinClientLevel { + + @ModifyVariable( + method = "calculateBlockTint(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/ColorResolver;)I", + ordinal = 0, + at = @At("HEAD"), + argsOnly = true + ) + private BlockPos fixBlockPos(final BlockPos old) { + if (!VSGameConfig.CLIENT.getBlockTinting().getFixBlockTinting()) + return old; + + final Vector3d newPos = + VSGameUtilsKt.toWorldCoordinates( + ClientLevel.class.cast(this), + new Vector3d( + old.getX(), + old.getY(), + old.getZ() + ) + ); + + return new BlockPos( + newPos.x, + newPos.y, + newPos.z + ); + } + + @Accessor( + "tintCaches" + ) + public abstract Object2ObjectArrayMap<ColorResolver, BlockTintCache> getTintCaches(); + + /** + * @author SuperCraftAlex + * @reason Fix block tinting for ships + */ + @Overwrite + public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) { + if (VSGameConfig.CLIENT.getBlockTinting().getFixBlockTinting() && + VSGameUtilsKt.isBlockInShipyard(ClientLevel.class.cast(this), blockPos) + ) { + return ClientLevel.class.cast(this).calculateBlockTint(blockPos, colorResolver); + } + final BlockTintCache blockTintCache = getTintCaches().get(colorResolver); + return blockTintCache.getColor(blockPos); + } + + +} 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 ff408f762..fe225d812 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 @@ -17,6 +17,8 @@ object VSGameConfig { class Client { val Tooltip = TOOLTIP() + val BlockTinting = BLOCKTINT() + @JsonSchema(description = "Renders the VS2 debug HUD with TPS") var renderDebugText = false @@ -36,6 +38,13 @@ object VSGameConfig { ) var useImperialUnits = false } + + class BLOCKTINT { + @JsonSchema( + description = "Partly fixes the block tinting issue with blocks on ships" + ) + var fixBlockTinting = false + } } class Server { diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index ee3748a6e..0c7f6a382 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -69,10 +69,10 @@ "world.chunk.MixinLevelChunk", "world.entity.MixinPlayer", "world.entity.projectile.ProjectileUtilMixin", + "world.level.MixinLevel", "world.level.chunk.MixinChunkGenerator", "world.level.levelgen.MixinFlatLevelSource", - "world.level.levelgen.MixinNoiseBasedChunkGenerator", - "world.level.MixinLevel" + "world.level.levelgen.MixinNoiseBasedChunkGenerator" ], "client": [ "accessors.client.multiplayer.ClientLevelAccessor", @@ -91,6 +91,7 @@ "client.renderer.MixinLevelRenderer", "client.world.MixinClientChunkCache", "client.world.MixinClientLevel", + "feature.block_tint.MixinClientLevel", "feature.commands.MixinClientSuggestionProvider", "feature.fix_render_chunk_sorting.MixinRenderChunk", "feature.fluid_camera_fix.MixinCamera", From 58550dec2e59a25de2f3dccf29a32b5c64cb1efb Mon Sep 17 00:00:00 2001 From: alex_s168 <63254202+SuperCraftAlex@users.noreply.github.com> Date: Mon, 18 Sep 2023 21:20:51 +0200 Subject: [PATCH 224/437] replaced override in block tinting mixin (#578) --- .../feature/block_tint/MixinClientLevel.java | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) 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 5b459f99e..7142276d8 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 @@ -1,16 +1,14 @@ package org.valkyrienskies.mod.mixin.feature.block_tint; -import it.unimi.dsi.fastutil.objects.Object2ObjectArrayMap; -import net.minecraft.client.color.block.BlockTintCache; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; import net.minecraft.world.level.ColorResolver; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.gen.Accessor; 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.CallbackInfoReturnable; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.config.VSGameConfig; @@ -44,24 +42,22 @@ private BlockPos fixBlockPos(final BlockPos old) { ); } - @Accessor( - "tintCaches" + @Inject( + method = "getBlockTint(Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/ColorResolver;)I", + at = @At("HEAD"), + cancellable = true ) - public abstract Object2ObjectArrayMap<ColorResolver, BlockTintCache> getTintCaches(); - - /** - * @author SuperCraftAlex - * @reason Fix block tinting for ships - */ - @Overwrite - public int getBlockTint(BlockPos blockPos, ColorResolver colorResolver) { + public void getBlockTint( + final BlockPos blockPos, + final ColorResolver colorResolver, + final CallbackInfoReturnable<Integer> cir + ) { if (VSGameConfig.CLIENT.getBlockTinting().getFixBlockTinting() && VSGameUtilsKt.isBlockInShipyard(ClientLevel.class.cast(this), blockPos) ) { - return ClientLevel.class.cast(this).calculateBlockTint(blockPos, colorResolver); + cir.setReturnValue(ClientLevel.class.cast(this) + .calculateBlockTint(blockPos, colorResolver)); } - final BlockTintCache blockTintCache = getTintCaches().get(colorResolver); - return blockTintCache.getColor(blockPos); } From b86112bc67b1b8b60df55216dd0ceb557b568237 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Wed, 20 Sep 2023 23:00:42 -0400 Subject: [PATCH 225/437] update gradle, update core, update quiltflower to vineflower --- build.gradle | 8 +- common/build.gradle | 2 + .../mod/mixin/client/MixinMinecraft.java | 3 +- .../mixin/client/world/MixinClientLevel.java | 4 +- .../feature/get_entities/MixinLevel.java | 2 +- .../MixinNoiseBasedChunkGenerator.java | 1 - .../mod/common/VS2ChunkAllocator.kt | 8 +- .../valkyrienskies/mod/common/VSGameUtils.kt | 12 +- .../common/assembly/SeamlessChunksManager.kt | 2 +- .../mod/common/assembly/ShipAssembly.kt | 2 +- .../mod/common/block/TestChairBlock.kt | 6 +- .../mod/common/command/VSCommands.kt | 6 +- .../entity/handling/WorldEntityHandler.kt | 6 +- .../mod/common/item/ShipAssemblerItem.kt | 2 +- .../common/util/EntityShipCollisionUtils.kt | 14 +- .../mod/common/util/GameTickForceApplier.kt | 2 +- .../mod/common/world/DummyShipWorldClient.kt | 53 ------- .../mod/common/world/DummyShipWorldServer.kt | 129 ------------------ .../mod/compat/clothconfig/VSClothConfig.kt | 6 +- gradle.properties | 2 +- 20 files changed, 45 insertions(+), 225 deletions(-) delete mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldClient.kt delete mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt diff --git a/build.gradle b/build.gradle index 862158fb4..566b13c1d 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ plugins { // Needed for Forge+Fabric id "architectury-plugin" version "3.4.146" id "dev.architectury.loom" version "1.3.355" apply false - id 'io.github.juuxel.loom-quiltflower' version '1.8.0' apply false + id 'io.github.juuxel.loom-vineflower' version '1.11.0' apply false // Kotlin id "org.jetbrains.kotlin.jvm" version "1.9.10" apply false id 'com.matthewprenger.cursegradle' version '1.4.0' apply false @@ -47,6 +47,10 @@ tasks.register("updateVsCore") { inputs.file(versionFile) outputs.file(gradleProperties) dependsOn(vsCoreBuild.task(":api-game:writeVersion")) + + [':impl', ':api', ':api-game', ':util'].each { + dependsOn(vsCoreBuild.task("${it}:publishToMavenLocal")) + } } catch (UnknownDomainObjectException ignore) {} onlyIf { @@ -64,7 +68,7 @@ subprojects { apply plugin: "dev.architectury.loom" // Apply checkstyle and ktlint to check the code style of every sub project apply plugin: "org.jetbrains.kotlin.jvm" - apply plugin: "io.github.juuxel.loom-quiltflower" + apply plugin: "io.github.juuxel.loom-vineflower" configurations.each { it.resolutionStrategy.useGlobalDependencySubstitutionRules.set(false) } diff --git a/common/build.gradle b/common/build.gradle index 6e0512c5b..419913a26 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -17,6 +17,8 @@ dependencies { exclude module: "fastutil" } + implementation("org.valkyrienskies.core:util:${rootProject.vs_core_version}") + // FTB Stuffs modCompileOnly("curse.maven:ftb-util-404465:4210935") modCompileOnly("curse.maven:ftb-teams-404468:4229138") 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 dc5955c30..a61a30f5d 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 @@ -30,7 +30,6 @@ import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.ValkyrienSkiesMod; import org.valkyrienskies.mod.common.util.EntityDragger; -import org.valkyrienskies.mod.common.world.DummyShipWorldClient; import org.valkyrienskies.mod.mixinducks.client.MinecraftDuck; @Mixin(Minecraft.class) @@ -88,7 +87,7 @@ public ClientShipWorldCore getShipObjectWorld() { if (shipObjectWorldCopy == null) { log.warn("Requested getShipObjectWorld() when shipObjectWorld was null!"); - return DummyShipWorldClient.INSTANCE; + return ValkyrienSkiesMod.getVsCore().getDummyShipWorldClient(); } return shipObjectWorldCopy; } 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 7b77a62a7..2f532c166 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 @@ -33,8 +33,8 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.core.apigame.world.ClientShipWorldCore; -import org.valkyrienskies.core.impl.util.AABBdUtilKt; -import org.valkyrienskies.core.impl.util.VectorConversionsKt; +import org.valkyrienskies.core.util.AABBdUtilKt; +import org.valkyrienskies.core.util.VectorConversionsKt; import org.valkyrienskies.mod.client.audio.SimpleSoundInstanceOnShip; import org.valkyrienskies.mod.common.IShipObjectWorldClientProvider; import org.valkyrienskies.mod.common.VSGameUtilsKt; diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/get_entities/MixinLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/get_entities/MixinLevel.java index 93b73da51..863abae56 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/get_entities/MixinLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/get_entities/MixinLevel.java @@ -17,7 +17,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.valkyrienskies.core.impl.util.RateLimiter; +import org.valkyrienskies.core.util.RateLimiter; import org.valkyrienskies.mod.common.VSGameUtilsKt; @Mixin(Level.class) 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 79fb8acb0..08183a391 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 @@ -23,7 +23,6 @@ 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.impl.game.ChunkAllocator; import org.valkyrienskies.mod.common.VS2ChunkAllocator; @Mixin(NoiseBasedChunkGenerator.class) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/VS2ChunkAllocator.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/VS2ChunkAllocator.kt index ccaf6dff4..ded9b6c93 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VS2ChunkAllocator.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VS2ChunkAllocator.kt @@ -1,14 +1,8 @@ package org.valkyrienskies.mod.common -import org.valkyrienskies.core.api.ships.properties.ChunkClaim -import org.valkyrienskies.core.impl.game.ChunkAllocator - object VS2ChunkAllocator { // TODO: Move this to ChunkAllocator eventually fun isChunkInShipyardCompanion(chunkX: Int, chunkZ: Int): Boolean { - val claimXIndex = ChunkClaim.getClaimXIndex(chunkX) - val claimZIndex = ChunkClaim.getClaimZIndex(chunkZ) - - return (claimXIndex in ChunkAllocator.X_INDEX_START..ChunkAllocator.X_INDEX_END) and (claimZIndex in ChunkAllocator.Z_INDEX_START..ChunkAllocator.Z_INDEX_END) + return vsCore.isChunkInShipyard(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 2bb4b6347..a315d0125 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -35,15 +35,13 @@ 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.impl.util.expand +import org.valkyrienskies.core.util.expand import org.valkyrienskies.mod.common.util.DimensionIdProvider import org.valkyrienskies.mod.common.util.MinecraftPlayer import org.valkyrienskies.mod.common.util.set import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toJOMLD import org.valkyrienskies.mod.common.util.toMinecraft -import org.valkyrienskies.mod.common.world.DummyShipWorldClient -import org.valkyrienskies.mod.common.world.DummyShipWorldServer import org.valkyrienskies.mod.mixin.accessors.resource.ResourceKeyAccessor import org.valkyrienskies.mod.mixinducks.world.entity.PlayerDuck import java.util.function.Consumer @@ -59,15 +57,15 @@ val Level?.shipWorldNullable: ShipWorldCore? } val Level?.shipObjectWorld - get() = shipWorldNullable ?: DummyShipWorldClient + get() = shipWorldNullable ?: vsCore.dummyShipWorldClient val Level?.allShips get() = this.shipObjectWorld.allShips val MinecraftServer.shipObjectWorld: ServerShipWorldCore - get() = (this as IShipObjectWorldServerProvider).shipObjectWorld ?: DummyShipWorldServer + get() = (this as IShipObjectWorldServerProvider).shipObjectWorld ?: vsCore.dummyShipWorldServer val MinecraftServer.vsPipeline get() = (this as IShipObjectWorldServerProvider).vsPipeline!! -val ServerLevel?.shipObjectWorld: ServerShipWorldCore get() = this?.server?.shipObjectWorld ?: DummyShipWorldServer +val ServerLevel?.shipObjectWorld: ServerShipWorldCore get() = this?.server?.shipObjectWorld ?: vsCore.dummyShipWorldServer val Level.dimensionId: DimensionId get() { @@ -106,7 +104,7 @@ fun MinecraftServer.getLevelFromDimensionId(dimensionId: DimensionId): ServerLev return getLevel(getResourceKey(dimensionId)) } -val Minecraft.shipObjectWorld get() = (this as IShipObjectWorldClientProvider).shipObjectWorld ?: DummyShipWorldClient +val Minecraft.shipObjectWorld get() = (this as IShipObjectWorldClientProvider).shipObjectWorld ?: vsCore.dummyShipWorldClient val ClientLevel?.shipObjectWorld get() = Minecraft.getInstance().shipObjectWorld val IPlayer.mcPlayer: Player get() = (this as MinecraftPlayer).playerEntityReference.get()!! 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 2ea311d60..bb8aac7ab 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 @@ -13,7 +13,7 @@ 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.impl.util.pollUntilEmpty +import org.valkyrienskies.core.util.pollUntilEmpty import org.valkyrienskies.mod.common.getShipManagingPos import org.valkyrienskies.mod.common.isChunkInShipyard import org.valkyrienskies.mod.common.networking.PacketRestartChunkUpdates 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 81b7a4ce7..8df8aea74 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,7 +5,7 @@ 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.impl.datastructures.DenseBlockPosSet +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 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..0a12f90c5 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 @@ -20,9 +20,9 @@ import net.minecraft.world.phys.shapes.CollisionContext import net.minecraft.world.phys.shapes.VoxelShape import org.joml.Vector3d import org.joml.Vector3dc -import org.valkyrienskies.core.impl.util.x -import org.valkyrienskies.core.impl.util.y -import org.valkyrienskies.core.impl.util.z +import org.valkyrienskies.core.util.x +import org.valkyrienskies.core.util.y +import org.valkyrienskies.core.util.z import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.util.toDoubles 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 793bc41fd..f84a360c7 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 @@ -26,9 +26,9 @@ 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.impl.util.x -import org.valkyrienskies.core.impl.util.y -import org.valkyrienskies.core.impl.util.z +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 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..295792c93 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 @@ -8,9 +8,9 @@ import net.minecraft.world.entity.projectile.AbstractHurtingProjectile import org.joml.Vector3d import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.Ship -import org.valkyrienskies.core.impl.util.component1 -import org.valkyrienskies.core.impl.util.component2 -import org.valkyrienskies.core.impl.util.component3 +import org.valkyrienskies.core.util.component1 +import org.valkyrienskies.core.util.component2 +import org.valkyrienskies.core.util.component3 import org.valkyrienskies.mod.common.toWorldCoordinates import org.valkyrienskies.mod.common.util.toJOML import org.valkyrienskies.mod.common.util.toMinecraft 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 437058e18..69a39780b 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 @@ -7,7 +7,7 @@ import net.minecraft.world.InteractionResult import net.minecraft.world.item.Item import net.minecraft.world.item.context.UseOnContext import net.minecraft.world.level.block.state.BlockState -import org.valkyrienskies.core.impl.datastructures.DenseBlockPosSet +import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet import org.valkyrienskies.mod.common.assembly.createNewShipWithBlocks import org.valkyrienskies.mod.common.isChunkInShipyard 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..eb5172f0a 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 @@ -12,16 +12,18 @@ import net.minecraft.world.phys.shapes.VoxelShape import org.joml.primitives.AABBd import org.joml.primitives.AABBdc import org.valkyrienskies.core.api.ships.Ship -import org.valkyrienskies.core.impl.collision.ConvexPolygonc -import org.valkyrienskies.core.impl.collision.EntityPolygonCollider -import org.valkyrienskies.core.impl.collision.EntityPolygonCollider.createPolygonFromAABB -import org.valkyrienskies.core.impl.util.extend +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 +import org.valkyrienskies.mod.common.vsCore import kotlin.math.max object EntityShipCollisionUtils { + private val collider = vsCore.entityPolygonCollider + @JvmStatic fun isCollidingWithUnloadedShips(entity: Entity): Boolean { val level = entity.level @@ -86,7 +88,7 @@ object EntityShipCollisionUtils { return movement } - val (newMovement, shipCollidingWith) = EntityPolygonCollider.adjustEntityMovementForPolygonCollisions( + val (newMovement, shipCollidingWith) = collider.adjustEntityMovementForPolygonCollisions( movement.toJOML(), entityBoundingBox.toJOML(), stepHeight, collidingShipPolygons ) if (entity != null) { @@ -109,7 +111,7 @@ object EntityShipCollisionUtils { val entityBoundingBoxExtended = entityBoundingBox.toJOML().extend(movement.toJOML()) for (shipObject in world.shipObjectWorld.loadedShips.getIntersecting(entityBoundingBoxExtended)) { val shipTransform = shipObject.transform - val entityPolyInShipCoordinates: ConvexPolygonc = createPolygonFromAABB( + val entityPolyInShipCoordinates: ConvexPolygonc = collider.createPolygonFromAABB( entityBoxWithMovement.toJOML(), shipTransform.worldToShip ) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/GameTickForceApplier.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/GameTickForceApplier.kt index ed3f66fef..bef91b2b6 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/GameTickForceApplier.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/GameTickForceApplier.kt @@ -3,7 +3,7 @@ package org.valkyrienskies.mod.common.util import org.joml.Vector3dc import org.valkyrienskies.core.api.ships.PhysShip import org.valkyrienskies.core.api.ships.ShipForcesInducer -import org.valkyrienskies.core.impl.util.pollUntilEmpty +import org.valkyrienskies.core.util.pollUntilEmpty import java.util.concurrent.ConcurrentLinkedQueue class GameTickForceApplier : ShipForcesInducer { diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldClient.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldClient.kt deleted file mode 100644 index 2e096d22d..000000000 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldClient.kt +++ /dev/null @@ -1,53 +0,0 @@ -package org.valkyrienskies.mod.common.world - -import org.joml.primitives.AABBdc -import org.valkyrienskies.core.api.ships.ClientShip -import org.valkyrienskies.core.api.ships.QueryableShipData -import org.valkyrienskies.core.apigame.world.ClientShipWorldCore -import org.valkyrienskies.core.apigame.world.chunks.BlockType -import org.valkyrienskies.core.apigame.world.properties.DimensionId -import org.valkyrienskies.core.impl.game.ships.QueryableShipDataImpl -import java.net.SocketAddress - -object DummyShipWorldClient : ClientShipWorldCore { - override fun tickNetworking(server: SocketAddress) { - throw UnsupportedOperationException() - } - - override fun postTick() { - throw UnsupportedOperationException() - } - - override fun updateRenderTransforms(partialTicks: Double) { - throw UnsupportedOperationException() - } - - override fun destroyWorld() { - throw UnsupportedOperationException() - } - - override val isSyncedWithServer: Boolean - get() = throw UnsupportedOperationException() - - override fun onSetBlock( - posX: Int, posY: Int, posZ: Int, dimensionId: DimensionId, oldBlockType: BlockType, newBlockType: BlockType, - oldBlockMass: Double, newBlockMass: Double - ) { - } - - override val allShips: QueryableShipData<ClientShip> get() = loadedShips - override val loadedShips: QueryableShipData<ClientShip> = QueryableShipDataImpl() - - override fun isChunkInShipyard(chunkX: Int, chunkZ: Int, dimensionId: DimensionId): Boolean { - return false - } - - override fun isBlockInShipyard(blockX: Int, blockY: Int, blockZ: Int, dimensionId: DimensionId): Boolean { - return false - } - - @Deprecated("redundant", replaceWith = ReplaceWith("loadedShips.getIntersecting(aabb)")) - override fun getShipObjectsIntersecting(aabb: AABBdc): List<ClientShip> { - return emptyList() - } -} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt deleted file mode 100644 index c7c878e13..000000000 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/world/DummyShipWorldServer.kt +++ /dev/null @@ -1,129 +0,0 @@ -package org.valkyrienskies.mod.common.world - -import org.joml.Vector3ic -import org.joml.primitives.AABBdc -import org.valkyrienskies.core.api.ships.LoadedServerShip -import org.valkyrienskies.core.api.ships.QueryableShipData -import org.valkyrienskies.core.api.ships.ServerShip -import org.valkyrienskies.core.api.ships.properties.ShipId -import org.valkyrienskies.core.api.world.LevelYRange -import org.valkyrienskies.core.apigame.GameServer -import org.valkyrienskies.core.apigame.ShipTeleportData -import org.valkyrienskies.core.apigame.constraints.VSConstraint -import org.valkyrienskies.core.apigame.constraints.VSConstraintId -import org.valkyrienskies.core.apigame.physics.PhysicsEntityData -import org.valkyrienskies.core.apigame.physics.PhysicsEntityServer -import org.valkyrienskies.core.apigame.world.IPlayer -import org.valkyrienskies.core.apigame.world.ServerShipWorldCore -import org.valkyrienskies.core.apigame.world.chunks.BlockType -import org.valkyrienskies.core.apigame.world.chunks.ChunkUnwatchTask -import org.valkyrienskies.core.apigame.world.chunks.ChunkWatchTask -import org.valkyrienskies.core.apigame.world.chunks.ChunkWatchTasks -import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate -import org.valkyrienskies.core.apigame.world.properties.DimensionId -import org.valkyrienskies.core.impl.game.ships.QueryableShipDataImpl - -object DummyShipWorldServer : ServerShipWorldCore { - override var players: Set<IPlayer> = emptySet() - override fun setGameServer(gameServer: GameServer?) { - TODO("Not yet implemented") - } - - override fun addTerrainUpdates(dimensionId: DimensionId, terrainUpdates: List<TerrainUpdate>) { - TODO("Not yet implemented") - } - - override fun getIPlayersWatchingShipChunk(chunkX: Int, chunkZ: Int, dimensionId: DimensionId): Iterator<IPlayer> { - TODO("Not yet implemented") - } - - override fun getChunkWatchTasks(): ChunkWatchTasks { - TODO("Not yet implemented") - } - - override fun setExecutedChunkWatchTasks( - watchTasks: Iterable<ChunkWatchTask>, unwatchTasks: Iterable<ChunkUnwatchTask> - ) { - TODO("Not yet implemented") - } - - override fun createNewShipAtBlock( - blockPosInWorldCoordinates: Vector3ic, createShipObjectImmediately: Boolean, scaling: Double, - dimensionId: DimensionId - ): ServerShip { - TODO("Not yet implemented") - } - - override fun createPhysicsEntity(physicsEntityData: PhysicsEntityData, dimensionId: DimensionId): PhysicsEntityServer { - TODO("Not yet implemented") - } - - override fun deletePhysicsEntity(id: ShipId) { - // This is implemented because physics entities get deleted after the vs pipeline? - } - - override fun allocateShipId(dimensionId: DimensionId): ShipId { - TODO("Not yet implemented") - } - - override fun createNewConstraint(vsConstraint: VSConstraint): VSConstraintId? { - TODO("Not yet implemented") - } - - override fun updateConstraint(constraintId: VSConstraintId, updatedVSConstraint: VSConstraint): Boolean { - TODO("Not yet implemented") - } - - override fun removeConstraint(constraintId: VSConstraintId): Boolean { - TODO("Not yet implemented") - } - - override fun addDimension(dimensionId: DimensionId, yRange: LevelYRange) { - TODO("Not yet implemented") - } - - override fun removeDimension(dimensionId: DimensionId) { - TODO("Not yet implemented") - } - - override fun onDisconnect(player: IPlayer) { - } - - override fun deleteShip(ship: ServerShip) { - TODO("Not yet implemented") - } - - override fun teleportShip(ship: ServerShip, teleportData: ShipTeleportData) { - TODO("Not yet implemented") - } - - override fun teleportPhysicsEntity(physicsEntityServer: PhysicsEntityServer, teleportData: ShipTeleportData) { - TODO("Not yet implemented") - } - - override val dimensionToGroundBodyIdImmutable: Map<DimensionId, ShipId> - get() = TODO("Not yet implemented") - - override fun onSetBlock( - posX: Int, posY: Int, posZ: Int, dimensionId: DimensionId, oldBlockType: BlockType, newBlockType: BlockType, - oldBlockMass: Double, newBlockMass: Double - ) { - } - - override val allShips: QueryableShipData<ServerShip> - get() = loadedShips - override val loadedShips: QueryableShipData<LoadedServerShip> = QueryableShipDataImpl() - - override fun isChunkInShipyard(chunkX: Int, chunkZ: Int, dimensionId: DimensionId): Boolean { - return false - } - - override fun isBlockInShipyard(blockX: Int, blockY: Int, blockZ: Int, dimensionId: DimensionId): Boolean { - return false - } - - @Deprecated("redundant", replaceWith = ReplaceWith("loadedShips.getIntersecting(aabb)")) - override fun getShipObjectsIntersecting(aabb: AABBdc): List<LoadedServerShip> { - return emptyList() - } -} 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 f87c9e86e..e5fed4518 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 @@ -15,10 +15,10 @@ 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 import org.valkyrienskies.core.impl.util.serialization.VSJacksonUtil -import org.valkyrienskies.core.impl.util.splitCamelCaseAndCapitalize import java.util.Optional object VSClothConfig { @@ -69,6 +69,10 @@ object VSClothConfig { } } + private fun String.splitCamelCaseAndCapitalize(): String { + return StringUtils.capitalize(StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(this), " ")) + } + private fun getEntriesForProperty( key: String, currentValue: JsonNode, diff --git a/gradle.properties b/gradle.properties index 5c17857c9..e6a3aa07c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+22a5fcd037 +vs_core_version=1.1.0+4cc7d6e38d # 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 0bf1ea9b2eab7043aeebd03ea533503bb396ca80 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Thu, 21 Sep 2023 01:27:17 -0400 Subject: [PATCH 226/437] update core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index e6a3aa07c..da8240f34 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+4cc7d6e38d +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 f0c1f760ae6f3b1ea0d4307daf8f5c99aeb1beda Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 24 Sep 2023 05:03:53 -0600 Subject: [PATCH 227/437] New terrain loading --- .../mixin/feature/vs2_alpha_hud/MixinGui.java | 4 + .../mixin/server/world/MixinServerLevel.java | 136 ++++++++++-------- .../mod/common/util/MinecraftPlayer.kt | 21 +++ forge/build.gradle | 4 +- gradle.properties | 2 +- 5 files changed, 104 insertions(+), 63 deletions(-) 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..961c41325 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 @@ -45,15 +45,19 @@ private void preRenderStatusEffectOverlay(final PoseStack matrices, final Callba final IntegratedServer integratedServer = this.minecraft.getSingleplayerServer(); if (integratedServer != null) { String physicsTPS = "Error"; + String loadedVoxelChunks = "Error"; try { // This is dangerous because we have to reach into the Server state from the Client, which can fail. // So, put this in a try/catch block to catch any errors that may occur. physicsTPS = " " + Math.round(VSGameUtilsKt.getVsPipeline(integratedServer).computePhysTps()); + loadedVoxelChunks = " " + VSGameUtilsKt.getVsPipeline(integratedServer).getLoadedVoxelChunks(); } catch (final Exception e) { e.printStackTrace(); } final String worldPhysicsDebugText = "VS PhysTPS: " + physicsTPS; debugText.add(worldPhysicsDebugText); + final String loadedVoxelChunkDebugText = "VS VoxelChunks: " + loadedVoxelChunks; + debugText.add(loadedVoxelChunkDebugText); } debugText.add("Using UDP: " + ValkyrienSkiesMod.getVsCore().getClientUsesUDP()); 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 e62a5a37b..01f1cfd30 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 @@ -22,9 +22,11 @@ import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; +import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.world.level.ChunkPos; 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; @@ -53,6 +55,7 @@ import org.valkyrienskies.mod.common.util.VSServerLevel; 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; @Mixin(ServerLevel.class) public abstract class MixinServerLevel implements IShipObjectWorldServerProvider, VSServerLevel { @@ -61,6 +64,10 @@ public abstract class MixinServerLevel implements IShipObjectWorldServerProvider @Final private ServerChunkCache chunkSource; + @Shadow + @Final + List<ServerPlayer> players; + @Shadow @NotNull public abstract MinecraftServer getServer(); @@ -119,6 +126,68 @@ private boolean includeShipsInParticleDistanceCheck( return posInWorld.distanceSquared(player.getX(), player.getY(), player.getZ()) < distance * distance; } + @Unique + private void loadChunk(@NotNull final ChunkAccess worldChunk, final List<TerrainUpdate> voxelShapeUpdates) { + if (!knownChunks.containsKey(worldChunk.getPos())) { + final List<Vector3ic> voxelChunkPositions = new ArrayList<>(); + + final int chunkX = worldChunk.getPos().x; + final int chunkZ = worldChunk.getPos().z; + + final LevelChunkSection[] chunkSections = worldChunk.getSections(); + + for (int sectionY = 0; sectionY < chunkSections.length; sectionY++) { + final LevelChunkSection chunkSection = chunkSections[sectionY]; + final Vector3ic chunkPos = + new Vector3i(chunkX, worldChunk.getSectionYFromSectionIndex(sectionY), chunkZ); + voxelChunkPositions.add(chunkPos); + + if (chunkSection != null && !chunkSection.hasOnlyAir()) { + // Add this chunk to the ground rigid body + final TerrainUpdate voxelShapeUpdate = + VSGameUtilsKt.toDenseVoxelUpdate(chunkSection, chunkPos); + voxelShapeUpdates.add(voxelShapeUpdate); + + // region Detect wings + final ServerLevel thisAsLevel = ServerLevel.class.cast(this); + final LoadedServerShip + ship = VSGameUtilsKt.getShipObjectManagingPos(thisAsLevel, chunkX, chunkZ); + if (ship != null) { + // Sussy cast, but I don't want to expose this directly through the vs-core api + final WingManager shipAsWingManager = ship.getAttachment(WingManager.class); + final MutableBlockPos mutableBlockPos = new MutableBlockPos(); + for (int x = 0; x < 16; x++) { + for (int y = 0; y < 16; y++) { + 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 posZ = (chunkZ << 4) + z; + if (blockState.getBlock() instanceof WingBlock) { + mutableBlockPos.set(posX, posY, posZ); + final Wing wing = + ((WingBlock) blockState.getBlock()).getWing(thisAsLevel, + mutableBlockPos, blockState); + if (wing != null) { + shipAsWingManager.setWing(shipAsWingManager.getFirstWingGroupId(), + posX, posY, posZ, wing); + } + } + } + } + } + } + // endregion + } else { + final TerrainUpdate emptyVoxelShapeUpdate = getVsCore() + .newEmptyVoxelShapeUpdate(chunkPos.x(), chunkPos.y(), chunkPos.z(), true); + voxelShapeUpdates.add(emptyVoxelShapeUpdate); + } + } + knownChunks.put(worldChunk.getPos(), voxelChunkPositions); + } + } + @Inject(method = "tick", at = @At("TAIL")) private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInfo ci) { final ServerLevel self = ServerLevel.class.cast(this); @@ -129,77 +198,24 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf // Create DenseVoxelShapeUpdate for new loaded chunks // Also mark the chunks as loaded in the ship objects final List<TerrainUpdate> voxelShapeUpdates = new ArrayList<>(); + final DistanceManagerAccessor distanceManagerAccessor = (DistanceManagerAccessor) chunkSource.chunkMap.getDistanceManager(); for (final ChunkHolder chunkHolder : chunkMapAccessor.callGetChunks()) { final Optional<LevelChunk> worldChunkOptional = chunkHolder.getTickingChunkFuture().getNow(ChunkHolder.UNLOADED_LEVEL_CHUNK).left(); - if (worldChunkOptional.isPresent()) { + // Only load chunks that are present and that have tickets + if (worldChunkOptional.isPresent() && distanceManagerAccessor.getTickets().containsKey(chunkHolder.getPos().toLong())) { + // Only load chunks that have a ticket final LevelChunk worldChunk = worldChunkOptional.get(); - if (!knownChunks.containsKey(worldChunk.getPos())) { - final List<Vector3ic> voxelChunkPositions = new ArrayList<>(); - - final int chunkX = worldChunk.getPos().x; - final int chunkZ = worldChunk.getPos().z; - - final LevelChunkSection[] chunkSections = worldChunk.getSections(); - - for (int sectionY = 0; sectionY < chunkSections.length; sectionY++) { - final LevelChunkSection chunkSection = chunkSections[sectionY]; - final Vector3ic chunkPos = - new Vector3i(chunkX, worldChunk.getSectionYFromSectionIndex(sectionY), chunkZ); - voxelChunkPositions.add(chunkPos); - - if (chunkSection != null && !chunkSection.hasOnlyAir()) { - // Add this chunk to the ground rigid body - final TerrainUpdate voxelShapeUpdate = - VSGameUtilsKt.toDenseVoxelUpdate(chunkSection, chunkPos); - voxelShapeUpdates.add(voxelShapeUpdate); - - // region Detect wings - final ServerLevel thisAsLevel = ServerLevel.class.cast(this); - final LoadedServerShip - ship = VSGameUtilsKt.getShipObjectManagingPos(thisAsLevel, chunkX, chunkZ); - if (ship != null) { - // Sussy cast, but I don't want to expose this directly through the vs-core api - final WingManager shipAsWingManager = ship.getAttachment(WingManager.class); - final MutableBlockPos mutableBlockPos = new MutableBlockPos(); - for (int x = 0; x < 16; x++) { - for (int y = 0; y < 16; y++) { - 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 posZ = (chunkZ << 4) + z; - if (blockState.getBlock() instanceof WingBlock) { - mutableBlockPos.set(posX, posY, posZ); - final Wing wing = - ((WingBlock) blockState.getBlock()).getWing(thisAsLevel, - mutableBlockPos, blockState); - if (wing != null) { - shipAsWingManager.setWing(shipAsWingManager.getFirstWingGroupId(), - posX, posY, posZ, wing); - } - } - } - } - } - } - // endregion - } else { - final TerrainUpdate emptyVoxelShapeUpdate = getVsCore() - .newEmptyVoxelShapeUpdate(chunkPos.x(), chunkPos.y(), chunkPos.z(), true); - voxelShapeUpdates.add(emptyVoxelShapeUpdate); - } - } - knownChunks.put(worldChunk.getPos(), voxelChunkPositions); - } + loadChunk(worldChunk, voxelShapeUpdates); } } final Iterator<Entry<ChunkPos, List<Vector3ic>>> knownChunkPosIterator = knownChunks.entrySet().iterator(); while (knownChunkPosIterator.hasNext()) { final Entry<ChunkPos, List<Vector3ic>> knownChunkPosEntry = knownChunkPosIterator.next(); - if (chunkMapAccessor.callGetVisibleChunkIfPresent(knownChunkPosEntry.getKey().toLong()) == null) { + // Unload chunks if they don't have tickets or if they're not in the visible chunks + if ((!distanceManagerAccessor.getTickets().containsKey(knownChunkPosEntry.getKey().toLong()) || chunkMapAccessor.callGetVisibleChunkIfPresent(knownChunkPosEntry.getKey().toLong()) == null)) { // Delete this chunk for (final Vector3ic unloadedChunk : knownChunkPosEntry.getValue()) { final TerrainUpdate deleteVoxelShapeUpdate = 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..9a0397035 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 @@ -2,9 +2,14 @@ package org.valkyrienskies.mod.common.util import net.minecraft.world.entity.player.Player import org.joml.Vector3d +import org.joml.Vector3dc +import org.valkyrienskies.core.api.ships.properties.ShipId import org.valkyrienskies.core.apigame.world.IPlayer +import org.valkyrienskies.core.apigame.world.PlayerState import org.valkyrienskies.core.apigame.world.properties.DimensionId import org.valkyrienskies.mod.common.dimensionId +import org.valkyrienskies.mod.common.getPassengerPos +import org.valkyrienskies.mod.common.getShipObjectEntityMountedTo import org.valkyrienskies.mod.common.vsCore import java.lang.ref.WeakReference import java.util.UUID @@ -34,6 +39,22 @@ class MinecraftPlayer(playerObject: Player) : IPlayer { return dest.set(player.x, player.y, player.z) } + override fun getPlayerState(): PlayerState { + var mountedShip: ShipId? = null + var mountedPos: Vector3dc? = null + player.level.getShipObjectEntityMountedTo(player)?.let { + mountedShip = it.id + mountedPos = player.vehicle!!.getPassengerPos(player.myRidingOffset, 0.0f) + } + return PlayerState( + Vector3d(player.x, player.y, player.z), + Vector3d(Vector3d(player.x - player.xo, player.y - player.yo, player.z - player.zo)), + dimension, + mountedShip, + mountedPos, + ) + } + override fun hashCode(): Int { return uuid.hashCode() } diff --git a/forge/build.gradle b/forge/build.gradle index 946087b82..f694b8b3f 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -100,11 +100,11 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+2bfb3f8968") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+14214f4ff8") { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+63b53cc647") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+216620077e") { transitive = false } diff --git a/gradle.properties b/gradle.properties index da8240f34..0f47c9c40 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+c366a39369 +vs_core_version=1.1.0+d9d153f463 # 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 869ce065251b8cb496f0853b43ba11d1eebd396b Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Mon, 25 Sep 2023 13:35:27 +0200 Subject: [PATCH 228/437] Update 1_18_blocks.json idk kind of weird to define friction --- .../valkyrienskies/vs_mass/1_18_blocks.json | 316 ++++++++++++------ 1 file changed, 209 insertions(+), 107 deletions(-) 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 9b692c487..023e8219b 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,51 +5,63 @@ }, { "block": "minecraft:rooted_dirt", - "mass": 1100.0 + "mass": 1100.0, + "friction": 0.7 }, { "block": "minecraft:calcite", - "mass": 2700.0 + "mass": 2700.0, + "friction": 0.5 }, { "block": "minecraft:dripstone_block", - "mass": 2700.0 + "mass": 2700.0, + "friction": 0.5 }, { "block": "minecraft:pointed_dripstone", - "mass": 1900.0 + "mass": 1900.0, + "friction": 0.5 }, { "block": "minecraft:tuff", - "mass": 1800.0 + "mass": 1800.0, + "friction": 0.7 }, { "block": "minecraft:budding_amethyst", - "mass": 2650.0 + "mass": 2650.0, + "friction": 1.0 }, { "block": "minecraft:amethyst_block", - "mass": 2650.0 + "mass": 2650.0, + "friction": 1.0 }, { "block": "minecraft:small_amethyst_bud", - "mass": 100.0 + "mass": 100.0, + "friction": 0.7 }, { "block": "minecraft:medium_amethyst_bud", - "mass": 300.0 + "mass": 300.0, + "friction": 0.8 }, { "block": "minecraft:large_amethyst_bud", - "mass": 600.0 + "mass": 600.0, + "friction": 0.9 }, { "block": "minecraft:azalea", - "mass": 120.0 + "mass": 120.0, + "elasticity": 0.1 }, { "block": "minecraft:flowering_azalea", - "mass": 120.0 + "mass": 120.0, + "elasticity": 0.1 }, { "block": "minecraft:hanging_roots", @@ -57,7 +69,9 @@ }, { "block": "minecraft:big_dripleaf", - "mass": 8.0 + "mass": 8.0, + "friction": 0.3, + "elasticity": 0.3 }, { "block": "minecraft:big_dripleaf_stem", @@ -85,366 +99,454 @@ }, { "block": "minecraft:moss_block", - "mass": 250.0 + "mass": 250.0, + "friction": 0.5, + "elasticity": 0.05 }, { "block": "minecraft:moss_carpet", - "mass": 15.0 + "mass": 15.0, + "friction": 0.5 }, { "block": "minecraft:lightning_rod", - "mass": 1800.0 + "mass": 1800.0, + "friction": 0.2 }, { "block": "minecraft:copper_block", - "mass": 8960.0 + "mass": 8960.0, + "friction": 0.2 }, { "block": "minecraft:exposed_copper", - "mass": 8960.0 + "mass": 8960.0, + "friction": 0.25 }, { "block": "minecraft:weathered_copper", - "mass": 8960.0 + "mass": 8960.0, + "friction": 0.3 }, { "block": "minecraft:oxidized_copper", - "mass": 8960.0 + "mass": 8960.0, + "friction": 0.35 }, { "block": "minecraft:waxed_copper_block", - "mass": 8960.0 + "mass": 8960.0, + "friction": 0.15 }, { "block": "minecraft:waxed_exposed_copper", - "mass": 8960.0 + "mass": 8960.0, + "friction": 0.2 }, { "block": "minecraft:waxed_weathered_copper", - "mass": 8960.0 + "mass": 8960.0, + "friction": 0.25 }, { "block": "minecraft:waxed_oxidized_copper", - "mass": 8960.0 + "mass": 8960.0, + "friction": 0.3 }, { "block": "minecraft:cut_copper", - "mass": 2240.0 + "mass": 2240.0, + "friction": 0.2 }, { "block": "minecraft:exposed_cut_copper", - "mass": 2240.0 + "mass": 2240.0, + "friction": 0.25 }, { "block": "minecraft:weathered_cut_copper", - "mass": 2240.0 + "mass": 2240.0, + "friction": 0.3 }, { "block": "minecraft:oxidized_cut_copper", - "mass": 2240.0 + "mass": 2240.0, + "friction": 0.35 }, { "block": "minecraft:waxed_cut_copper", - "mass": 2240.0 + "mass": 2240.0, + "friction": 0.15 }, { "block": "minecraft:waxed_exposed_cut_copper", - "mass": 2240.0 + "mass": 2240.0, + "friction": 0.2 }, { "block": "minecraft:waxed_weathered_cut_copper", - "mass": 2240.0 + "mass": 2240.0, + "friction": 0.25 }, { "block": "minecraft:waxed_oxidized_cut_copper", - "mass": 2240.0 + "mass": 2240.0, + "friction": 0.3 }, { "block": "minecraft:cut_copper_slab", - "mass": 1120.0 + "mass": 1120.0, + "friction": 0.2 }, { "block": "minecraft:exposed_cut_copper_slab", - "mass": 1120.0 + "mass": 1120.0, + "friction": 0.25 }, { "block": "minecraft:weathered_cut_copper_slab", - "mass": 1120.0 + "mass": 1120.0, + "friction": 0.3 }, { "block": "minecraft:oxidized_cut_copper_slab", - "mass": 1120.0 + "mass": 1120.0, + "friction": 0.35 }, { "block": "minecraft:waxed_cut_copper_slab", - "mass": 1120.0 + "mass": 1120.0, + "friction": 0.15 }, { "block": "minecraft:waxed_exposed_cut_copper_slab", - "mass": 1120.0 + "mass": 1120.0, + "friction": 0.2 }, { "block": "minecraft:waxed_weathered_cut_copper_slab", - "mass": 1120.0 + "mass": 1120.0, + "friction": 0.25 }, { "block": "minecraft:waxed_oxidized_cut_copper_slab", - "mass": 1120.0 + "mass": 1120.0, + "friction": 0.3 }, { "block": "minecraft:cut_copper_stairs", - "mass": 1680.0 + "mass": 1680.0, + "friction": 0.2 }, { "block": "minecraft:exposed_cut_copper_stairs", - "mass": 1680.0 + "mass": 1680.0, + "friction": 0.25 }, { "block": "minecraft:weathered_cut_copper_stairs", - "mass": 1680.0 + "mass": 1680.0, + "friction": 0.3 }, { "block": "minecraft:oxidized_cut_copper_stairs", - "mass": 1680.0 + "mass": 1680.0, + "friction": 0.35 }, { "block": "minecraft:waxed_cut_copper_stairs", - "mass": 1680.0 + "mass": 1680.0, + "friction": 0.15 }, { "block": "minecraft:waxed_exposed_cut_copper_stairs", - "mass": 1680.0 + "mass": 1680.0, + "friction": 0.2 }, { "block": "minecraft:waxed_weathered_cut_copper_stairs", - "mass": 1680.0 + "mass": 1680.0, + "friction": 0.25 }, { "block": "minecraft:waxed_oxidized_cut_copper_stairs", - "mass": 1680.0 + "mass": 1680.0, + "friction": 0.3 }, { "block": "minecraft:raw_copper_block", - "mass": 8960.0 + "mass": 8960.0, + "friction": 0.8 }, { "block": "minecraft:raw_iron_block", - "mass": 7840.0 + "mass": 7840.0, + "friction": 0.8 }, { "block": "minecraft:raw_gold_block", - "mass": 19280.0 + "mass": 19280.0, + "friction": 0.8 }, { "block": "minecraft:candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:white_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:orange_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:magenta_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:light_blue_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:yellow_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:lime_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:pink_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:gray_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:light_gray_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:cyan_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:purple_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:blue_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:brown_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:green_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:red_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:black_candle", - "mass": 2.0 + "mass": 2.0, + "friction": 0.1 }, { "block": "minecraft:deepslate", - "mass": 2900.0 + "mass": 2900.0, + "friction": 0.5 }, { "block": "minecraft:infested_deepslate", - "mass": 2900.0 + "mass": 2900.0, + "friction": 0.5 }, { "block": "minecraft:cobbled_deepslate", - "mass": 2720.0 + "mass": 2720.0, + "friction": 0.8 }, { "block": "minecraft:chiseled_deepslate", - "mass": 2720.0 + "mass": 2720.0, + "friction": 0.6 }, { "block": "minecraft:polished_deepslate", - "mass": 2720.0 + "mass": 2720.0, + "friction": 0.35 }, { "block": "minecraft:deepslate_bricks", - "mass": 2720.0 + "mass": 2720.0, + "friction": 0.5 }, { "block": "minecraft:cracked_deepslate_bricks", - "mass": 2720.0 + "mass": 2720.0, + "friction": 0.6 }, { "block": "minecraft:deepslate_tiles", - "mass": 2720.0 + "mass": 2720.0, + "friction": 0.6 }, { "block": "minecraft:cracked_deepslate_tiles", - "mass": 2720.0 + "mass": 2720.0, + "friction": 0.7 }, { "block": "minecraft:cobbled_deepslate_slab", - "mass": 1360.0 + "mass": 1360.0, + "friction": 0.8 }, { "block": "minecraft:polished_deepslate_slab", - "mass": 1360.0 + "mass": 1360.0, + "friction": 0.35 }, { "block": "minecraft:deepslate_brick_slab", - "mass": 1360.0 + "mass": 1360.0, + "friction": 0.5 }, { "block": "minecraft:deepslate_tile_slab", - "mass": 1360.0 + "mass": 1360.0, + "friction": 0.6 }, { "block": "minecraft:cobbled_deepslate_stairs", - "mass": 2040.0 + "mass": 2040.0, + "friction": 0.8 }, { "block": "minecraft:polished_deepslate_stairs", - "mass": 2040.0 + "mass": 2040.0, + "friction": 0.35 }, { "block": "minecraft:deepslate_brick_stairs", - "mass": 2040.0 + "mass": 2040.0, + "friction": 0.5 }, { "block": "minecraft:deepslate_tile_stairs", - "mass": 2040.0 + "mass": 2040.0, + "friction": 0.6 }, { "block": "minecraft:cobbled_deepslate_wall", - "mass": 1360.0 + "mass": 1360.0, + "friction": 0.8 }, { "block": "minecraft:polished_deepslate_wall", - "mass": 1360.0 + "mass": 1360.0, + "friction": 0.45 }, { "block": "minecraft:deepslate_brick_wall", - "mass": 1360.0 + "mass": 1360.0, + "friction": 0.5 }, { "block": "minecraft:deepslate_tile_wall", - "mass": 1360.0 + "mass": 1360.0, + "friction": 0.6 }, { "block": "minecraft:copper_ore", - "mass": 3260.0 + "mass": 3260.0, + "friction": 0.6 }, { "block": "minecraft:deepslate_copper_ore", - "mass": 3510.0 + "mass": 3510.0, + "friction": 0.5 }, { "block": "minecraft:deepslate_coal_ore", - "mass": 2715.0 + "mass": 2715.0, + "friction": 0.5 }, { "block": "minecraft:deepslate_lapis_ore", - "mass": 2950.0 + "mass": 2950.0, + "friction": 0.5 }, { "block": "minecraft:deepslate_iron_ore", - "mass": 3430.0 + "mass": 3430.0, + "friction": 0.5 }, { "block": "minecraft:deepslate_gold_ore", - "mass": 4700.0 + "mass": 4700.0, + "friction": 0.5 }, { "block": "minecraft:deepslate_redstone_ore", - "mass": 2225.0 + "mass": 2225.0, + "friction": 0.5 }, { "block": "minecraft:deepslate_diamond_ore", - "mass": 2950.0 + "mass": 2950.0, + "friction": 0.5 }, { "block": "minecraft:deepslate_emerald_ore", - "mass": 2855.0 + "mass": 2855.0, + "friction": 0.5 }, { "block": "minecraft:powder_snow", - "mass": 120.0 + "mass": 120.0, + "friction": 0.3 }, { "block": "minecraft:sculk_sensor", - "mass": 200.0 + "mass": 200.0, + "friction": 0.2, + "elasticity": 0.3 }, { "block": "minecraft:smooth_basalt", - "mass": 3010.0 + "mass": 3010.0, + "friction": 0.35 }, { "block": "minecraft:tinted_glass", - "mass": 2200.0 - }, - { - "block": "minecraft:tuff", - "mass": 2400.0 + "mass": 2200.0, + "friction": 0.2 }, { "tag": "minecraft:candle_cakes", - "mass": 702.0 + "mass": 702.0, + "friction": 0.1 } ] From d9456cafefb0cc1f162f8019c2a7fa1762923cd1 Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Mon, 25 Sep 2023 13:46:55 +0200 Subject: [PATCH 229/437] Update crafting_stations.json --- .../vs_mass/crafting_stations.json | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) 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 64db9e16d..23d96b4dc 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,23 +1,28 @@ [ { "block": "minecraft:crafting_table", - "mass": 800.0 + "mass": 800.0, + "friction": 0.6 }, { "block": "minecraft:furnace", - "mass": 2800.0 + "mass": 2800.0, + "friction": 0.5 }, { "block": "minecraft:blast_furnace", - "mass": 3000.0 + "mass": 3000.0, + "friction": 0.5 }, { "block": "minecraft:smoker", - "mass": 2800.0 + "mass": 2800.0, + "friction": 0.5 }, { "block": "minecraft:stonecutter", - "mass": 2000.0 + "mass": 2000.0,, + "friction": 0.5 }, { "tag": "minecraft:campfires", @@ -29,15 +34,18 @@ }, { "tag": "minecraft:anvil", - "mass": 7000.0 + "mass": 7000.0, + "friction": 0.2 }, { "block": "minecraft:cauldron", - "mass": 5400.0 + "mass": 5400.0, + "friction": 0.2 }, { "block": "minecraft:water_cauldron", - "mass": 5900.0 + "mass": 5900.0, + "friction": 0.2 }, { "block": "minecraft:brewing_stand", @@ -45,15 +53,18 @@ }, { "block": "minecraft:grindstone", - "mass": 1500.0 + "mass": 1500.0, + "friction": 0.2 }, { "block": "minecraft:fletching_table", - "mass": 900.0 + "mass": 900.0, + "friction": 0.6 }, { "block": "minecraft:smithing_table", - "mass": 1800.0 + "mass": 1800.0, + "friction": 0.6 }, { "block": "minecraft:loom", @@ -61,10 +72,12 @@ }, { "block": "minecraft:cartography_table", - "mass": 800.0 + "mass": 800.0, + "friction": 0.5 }, { "block": "minecraft:composter", - "mass": 700.0 + "mass": 700.0, + "friction": 0.5 } ] From 1b5c8229b016b82e62bf4148ef07b04b7364c20a Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:01:45 +0200 Subject: [PATCH 230/437] Update plants.json --- .../data/valkyrienskies/vs_mass/plants.json | 99 +++++++++++++------ 1 file changed, 67 insertions(+), 32 deletions(-) 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 96bfbcea6..5fd3bdb1b 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,8 @@ }, { "tag": "minecraft:leaves", - "mass": 200.0 + "mass": 200.0, + "elasticity": 0.15 }, { "tag": "minecraft:small_flowers", @@ -89,95 +90,118 @@ }, { "block": "minecraft:sea_pickle", - "mass": 2.0 + "mass": 2.0, + "elasticity": 0.1 }, { "tag": "minecraft:coral_blocks", - "mass": 1500.0 + "mass": 1500.0", + "friction": 0.7 }, { "block": "minecraft:dead_tube_coral_block", - "mass": 1500.0 + "mass": 1500.0, + "friction": 0.7 }, { "block": "minecraft:dead_brain_coral_block", - "mass": 1500.0 + "mass": 1500.0, + "friction": 0.7 }, { "block": "minecraft:dead_bubble_coral_block", - "mass": 1500.0 + "mass": 1500.0, + "friction": 0.7 }, { "block": "minecraft:dead_fire_coral_block", - "mass": 1500.0 + "mass": 1500.0, + "friction": 0.7 }, { "block": "minecraft:dead_horn_coral_block", - "mass": 1500.0 + "mass": 1500.0, + "friction": 0.7 }, { "tag": "minecraft:corals", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_tube_coral", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_brain_coral", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_bubble_coral", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_fire_coral", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_horn_coral", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_tube_coral_fan", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_brain_coral_fan", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_bubble_coral_fan", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_fire_coral_fan", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_horn_coral_fan", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_tube_coral_wall_fan", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_brain_coral_wall_fan", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_bubble_coral_wall_fan", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_fire_coral_wall_fan", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_horn_coral_wall_fan", - "mass": 5.0 + "mass": 5.0, + "friction": 0.7 }, { "block": "minecraft:dead_bush", @@ -197,7 +221,8 @@ }, { "block": "minecraft:melon", - "mass": 600.0 + "mass": 600.0, + "friction": 0.2 }, { "block": "minecraft:pumpkin_stem", @@ -209,7 +234,8 @@ }, { "block": "minecraft:pumpkin", - "mass": 600.0 + "mass": 600.0, + "friction": 0.3 }, { "block": "minecraft:warped_fungus", @@ -253,7 +279,8 @@ }, { "tag": "minecraft:wart_blocks", - "mass": 600.0 + "mass": 600.0, + "elasticity": 0.1 }, { "block": "minecraft:shroomlight", @@ -261,23 +288,31 @@ }, { "block": "minecraft:chorus_plant", - "mass": 30.0 + "mass": 30.0, + "friction": 0.6 }, { "block": "minecraft:chorus_flower", - "mass": 50.0 + "mass": 50.0, + "friction": 0.4 }, { "block": "minecraft:brown_mushroom_block", - "mass": 400.0 + "mass": 400.0, + "friction": 0.2, + "elasticity": 0.1 }, { "block": "minecraft:red_mushroom_block", - "mass": 400.0 + "mass": 400.0, + "friction": 0.2, + "elasticity": 0.1 }, { "block": "minecraft:mushroom_stem", - "mass": 600.0 + "mass": 600.0, + "friction": 0.2 + "elasticity": 0.1 }, { "block": "minecraft:brown_mushroom", From a1928f596e4a1d2187e4e3fc370c39670dd04aa0 Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Mon, 25 Sep 2023 14:14:57 +0200 Subject: [PATCH 231/437] Update redstone_components.json --- .../vs_mass/redstone_components.json | 66 ++++++++++++------- 1 file changed, 44 insertions(+), 22 deletions(-) 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 1e0424176..f3063a408 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 @@ -5,47 +5,58 @@ }, { "block": "minecraft:dispenser", - "mass": 2800.0 + "mass": 2800.0, + "friction": 0.5 }, { "block": "minecraft:dropper", - "mass": 2800.0 + "mass": 2800.0, + "friction": 0.5 }, { "block": "minecraft:note_block", - "mass": 1200.0 + "mass": 1200.0, + "friction": 0.6 }, { "block": "minecraft:detector_rail", - "mass": 380.0 + "mass": 380.0, + "friction": 0.7 }, { "block": "minecraft:powered_rail", - "mass": 800.0 + "mass": 800.0, + "friction": 0.7 }, { "block": "minecraft:rail", - "mass": 330.0 + "mass": 330.0, + "friction": 0.7 }, { "block": "minecraft:activator_rail", - "mass": 330.0 + "mass": 330.0, + "friction": 0.7 }, { "block": "minecraft:piston", - "mass": 2800.0 + "mass": 2800.0, + "friction": 0.5 }, { "block": "minecraft:sticky_piston", - "mass": 2800.0 + "mass": 2800.0, + "friction": 0.5 }, { "block": "minecraft:piston_head", - "mass": 0.1 + "mass": 0.1, + "friction": 0.5 }, { "block": "minecraft:moving_piston", - "mass": 0.1 + "mass": 0.1, + "friction": 0.5 }, { "block": "minecraft:tnt", @@ -101,19 +112,23 @@ }, { "block": "minecraft:daylight_detector", - "mass": 1200.0 + "mass": 1200.0, + "friction": 0.2 }, { "block": "minecraft:redstone_block", - "mass": 1350.0 + "mass": 1350.0, + "friction": 0.4 }, { "block": "minecraft:observer", - "mass": 2800.0 + "mass": 2800.0, + "friction": 0.5 }, { "block": "minecraft:target", - "mass": 200.0 + "mass": 200.0, + "elasticity": 0.3 }, { "block": "minecraft:lectern", @@ -125,23 +140,28 @@ }, { "block": "minecraft:redstone_lamp", - "mass": 1200.0 + "mass": 1200.0, + "friction": 0.2 }, { "block": "minecraft:comparator", - "mass": 250.0 + "mass": 250.0, + "friction": 0.3 }, { "block": "minecraft:repeater", - "mass": 250.0 + "mass": 250.0, + "friction": 0.3 }, { "block": "minecraft:hopper", - "mass": 3800.0 + "mass": 3800.0, + "friction": 0.3 }, { "tag": "minecraft:shulker_boxes", - "mass": 800.0 + "mass": 800.0, + "friction": 0.1 }, { "tag": "minecraft:fence_gates", @@ -149,11 +169,12 @@ }, { "tag": "minecraft:wooden_doors", - "mass": 25.0 + "mass": 25.0, }, { "block": "minecraft:iron_door", - "mass": 1000.0 + "mass": 1000.0, + "friction": 0.35 }, { "tag": "minecraft:wooden_trapdoors", @@ -162,5 +183,6 @@ { "block": "minecraft:iron_trapdoor", "mass": 1000.0 + "friction": 0.35 } ] From 49d6c286a296c2e42384912dba3fbdd968f89cb9 Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Tue, 26 Sep 2023 12:43:03 +0200 Subject: [PATCH 232/437] Update misc.json --- .../data/valkyrienskies/vs_mass/misc.json | 284 ++++++++++++------ 1 file changed, 188 insertions(+), 96 deletions(-) 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 7182e3be1..0e0060bd8 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json @@ -9,7 +9,8 @@ }, { "block": "minecraft:bedrock", - "mass": 3000.0 + "mass": 3000.0, + "friction": 0.8 }, { "block": "minecraft:barrier", @@ -33,95 +34,119 @@ }, { "block": "minecraft:gold_block", - "mass": 19280.0 + "mass": 19280.0, + "friction": 0.2 }, { "block": "minecraft:iron_block", - "mass": 7840.0 + "mass": 7840.0, + "friction": 0.2 }, { "block": "minecraft:diamond_block", - "mass": 3520.0 + "mass": 3520.0, + "friction": 0.1 }, { "block": "minecraft:emerald_block", - "mass": 2670.0 + "mass": 2670.0, + "friction": 0.1 }, { "block": "minecraft:coal_block", - "mass": 1400.0 + "mass": 1400.0, + "friction": 0.7 }, { "block": "minecraft:netherite_block", - "mass": 89680.0 + "mass": 89680.0, + "friction": 0.2 }, { "block": "minecraft:lapis_block", - "mass": 2750.0 + "mass": 2750.0, + "friction": 0.5 }, { "block": "minecraft:coal_ore", - "mass": 2465.0 + "mass": 2465.0, + "friction": 0.6 }, { "block": "minecraft:diamond_ore", - "mass": 2700.0 + "mass": 2700.0, + "friction": 0.6 }, { "block": "minecraft:emerald_ore", - "mass": 2605.0 + "mass": 2605.0, + "friction": 0.6 }, { "block": "minecraft:ancient_debris", - "mass": 3140.0 + "mass": 3140.0, + "friction": 0.8 }, { "block": "minecraft:iron_ore", - "mass": 3180.0 + "mass": 3180.0, + "friction": 0.6 }, { "block": "minecraft:gold_ore", - "mass": 4450.0 + "mass": 4450.0, + "friction": 0.6 }, { "block": "minecraft:lapis_ore", - "mass": 2700.0 + "mass": 2700.0, + "friction": 0.6 }, { "block": "minecraft:redstone_ore", - "mass": 1975.0 + "mass": 1975.0, + "friction": 0.6 }, { "block": "minecraft:nether_quartz_ore", - "mass": 1405.0 + "mass": 1405.0, + "friction": 0.4 }, { "block": "minecraft:nether_gold_ore", - "mass": 2210.0 + "mass": 2210.0, + "friction": 0.4 }, { "block": "minecraft:bone_block", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:cobweb", - "mass": 0.1 + "mass": 0.1, + "friction": 1.0 }, { "block": "minecraft:hay_block", - "mass": 200.0 + "mass": 200.0, + "friction": 0.6, + "elasticity": 0.3 }, { "block": "minecraft:carved_pumpkin", - "mass": 100.0 + "mass": 100.0, + "friction": 0.3 }, { "block": "minecraft:jack_o_lantern", - "mass": 105.0 + "mass": 105.0, + "friction": 0.3 }, { "block": "minecraft:beacon", - "mass": 930.0 + "mass": 930.0, + "friction": 0.2 }, { "block": "minecraft:conduit", @@ -129,11 +154,15 @@ }, { "block": "minecraft:sponge", - "mass": 170.0 + "mass": 170.0, + "friction": 0.6, + "elasticity": 0.2 }, { "block": "minecraft:wet_sponge", - "mass": 1050.0 + "mass": 1050.0, + "friction": 0.3, + "elasticity": 0.6 }, { "block": "minecraft:torch", @@ -153,179 +182,224 @@ }, { "block": "minecraft:lantern", - "mass": 25.0 + "mass": 25.0, }, { "block": "minecraft:soul_lantern", - "mass": 25.0 + "mass": 25.0, }, { "block": "minecraft:end_rod", - "mass": 10.0 + "mass": 10.0, + "friction": 0.1 }, { "block": "minecraft:sea_lantern", - "mass": 2500.0 + "mass": 2500.0, + "friction": 0.2 }, { "block": "minecraft:glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:white_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:orange_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:magenta_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:light_blue_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:yellow_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:lime_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:pink_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:gray_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:light_gray_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:cyan_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:purple_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:blue_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:brown_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:green_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:red_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:black_stained_glass", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:white_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:orange_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:magenta_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:light_blue_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:yellow_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:lime_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:pink_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:gray_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:light_gray_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:cyan_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:purple_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:blue_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:brown_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:green_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:red_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:black_stained_glass_pane", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "tag": "minecraft:beds", - "mass": 125.0 + "mass": 125.0, + "friction": 0.6, + "elasticity": 0.5 }, { "tag": "minecraft:carpets", - "mass": 20.0 + "mass": 20.0, + "friction": 0.6, + "elasticity": 0.05 }, { "tag": "minecraft:wool", - "mass": 450.0 + "mass": 450.0, + "friction": 0.6, + "elasticity": 0.5 }, { "block": "minecraft:bookshelf", - "mass": 650.0 + "mass": 650.0, + "friction": 0.5 }, { "block": "minecraft:chest", - "mass": 400.0 + "mass": 400.0, + "friction": 0.4 }, { "block": "minecraft:barrel", - "mass": 375.0 + "mass": 375.0, + "friction": 0.4 }, { "block": "minecraft:ladder", @@ -337,49 +411,53 @@ }, { "block": "minecraft:snow", - "mass": 25.0 + "mass": 25.0, + "friction": 0.2 }, { "block": "minecraft:snow_block", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:ice", "mass": 830.0, - "friction": 0.0, - "elasticity": 0.3 + "friction": 0.05 }, { "block": "minecraft:packed_ice", "mass": 875.0, - "friction": 0.0, - "elasticity": 0.3 + "friction": 0.02 }, { "block": "minecraft:blue_ice", "mass": 920.0, - "friction": 0.0, - "elasticity": 0.3 + "friction": 0.0 }, { "block": "minecraft:jukebox", - "mass": 800.0 + "mass": 800.0, + "friction": 0.6 }, { "block": "minecraft:iron_bars", - "mass": 250.0 + "mass": 250.0, + "friction": 0.2 }, { "block": "minecraft:chain", - "mass": 50.0 + "mass": 50.0, + "friction": 0.7 }, { "block": "minecraft:end_portal_frame", - "mass": 3000.0 + "mass": 3000.0, + "friction": 0.4 }, { "block": "minecraft:ender_chest", - "mass": 800.0 + "mass": 800.0, + "friction": 0.4 }, { "block": "minecraft:slime_block", @@ -389,19 +467,23 @@ }, { "block": "minecraft:honey_block", - "mass": 1400.0 + "mass": 1400.0, + "friction": 1.0 }, { "block": "minecraft:honeycomb_block", - "mass": 900.0 + "mass": 900.0, + "friction": 0.8 }, { "block": "minecraft:bee_nest", - "mass": 400.0 + "mass": 400.0, + "friction": 0.5 }, { "block": "minecraft:beehive", - "mass": 450.0 + "mass": 450.0, + "friction": 0.4 }, { "block": "minecraft:turtle_egg", @@ -413,7 +495,9 @@ }, { "block": "minecraft:dried_kelp_block", - "mass": 1000.0 + "mass": 1000.0, + "friction": 0.6, + "elasticity": 0.3 }, { "tag": "minecraft:signs", @@ -425,15 +509,18 @@ }, { "block": "minecraft:cake", - "mass": 700.0 + "mass": 700.0, + "friction": 0.1 }, { "block": "minecraft:skeleton_skull", - "mass": 2.0 + "mass": 2.0, + "friction": 0.2 }, { "block": "minecraft:wither_skeleton_skull", - "mass": 2.0 + "mass": 2.0, + "friction": 0.2 }, { "block": "minecraft:zombie_head", @@ -453,11 +540,13 @@ }, { "block": "minecraft:skeleton_wall_skull", - "mass": 2.0 + "mass": 2.0, + "friction": 0.2 }, { "block": "minecraft:wither_skeleton_wall_skull", - "mass": 2.0 + "mass": 2.0, + "friction": 0.2 }, { "block": "minecraft:zombie_wall_head", @@ -477,15 +566,18 @@ }, { "block": "minecraft:lodestone", - "mass": 4450.0 + "mass": 4450.0, + "friction": 0.5 }, { "block": "minecraft:bell", - "mass": 1000.0 + "mass": 1000.0, + "friction": 0.2 }, { "block": "minecraft:respawn_anchor", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.7 }, { "tag": "minecraft:banners", From 69f4c97eca1f7af3e311babca0c505a446afbde2 Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Tue, 26 Sep 2023 13:01:48 +0200 Subject: [PATCH 233/437] Update ground.json --- .../data/valkyrienskies/vs_mass/ground.json | 141 ++++++++++++------ 1 file changed, 93 insertions(+), 48 deletions(-) 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 7f420ebd5..139a148a2 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/ground.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/ground.json @@ -2,191 +2,236 @@ { "block": "minecraft:dirt", "mass": 1220.0, - "friction": 1.0, - "elasticity": 0.3 + "friction": 0.6 }, { "block": "minecraft:coarse_dirt", - "mass": 1500.0 + "mass": 1500.0, + "friction": 0.7 }, { "block": "minecraft:dirt_path", - "mass": 1200.0 + "mass": 1200.0, + "friction": 0.5 }, { "block": "minecraft:farmland", - "mass": 1220.0 + "mass": 1220.0, + "friction": 0.6 }, { "block": "minecraft:grass", - "mass": 1300.0 + "mass": 1300.0, + "friction": 0.5 }, { "block": "minecraft:clay", - "mass": 1700.0 + "mass": 1700.0, + "friction": 0.4 }, { "block": "minecraft:gravel", - "mass": 1680.0 + "mass": 1680.0, + "friction": 0.7 }, { "block": "minecraft:mycelium", - "mass": 1300.0 + "mass": 1300.0, + "friction": 0.5 }, { "tag": "minecraft:nylium", - "mass": 1180.0 + "mass": 1180.0, + "friction": 0.5 }, { "block": "minecraft:podzol", - "mass": 1300.0 + "mass": 1300.0, + "friction": 0.6 }, { "tag": "minecraft:sand", - "mass": 1560.0 + "mass": 1560.0, + "friction": 0.4 }, { "block": "minecraft:soul_sand", - "mass": 1000.0 + "mass": 1000.0, + "friction": 0.9 }, { "block": "minecraft:soul_soil", - "mass": 900.0 + "mass": 900.0, + "friction": 0.8 }, { "block": "minecraft:andesite", - "mass": 2770.0 + "mass": 2770.0, + "friction": 0.6 }, { "block": "minecraft:basalt", - "mass": 3010.0 + "mass": 3010.0, + "friction": 0.6 }, { "block": "minecraft:smooth_basalt", - "mass": 3010.0 + "mass": 3010.0, + "friction": 0.5 }, { "block": "minecraft:blackstone", - "mass": 3400.0 + "mass": 3400.0, + "friction": 0.7 }, { "block": "minecraft:cobblestone", - "mass": 2480.0 + "mass": 2480.0, + "friction": 0.8 }, { "block": "minecraft:mossy_cobblestone", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.8 }, { "block": "minecraft:diorite", - "mass": 2900.0 + "mass": 2900.0, + "friction": 0.6 }, { "block": "minecraft:end_stone", - "mass": 2800.0 + "mass": 2800.0, + "friction": 0.6 }, { "block": "minecraft:glowstone", - "mass": 1000.0 + "mass": 1000.0, + "friction": 0.7 }, { "block": "minecraft:granite", - "mass": 2700.0 + "mass": 2700.0, + "friction": 0.6 }, { "block": "minecraft:magma_block", - "mass": 3200.0 + "mass": 3200.0, + "friction": 0.4 }, { "block": "minecraft:netherrack", - "mass": 1100.0 + "mass": 1100.0, + "friction": 0.4 }, { "block": "minecraft:obsidian", - "mass": 2350.0 + "mass": 2350.0, + "friction": 0.8 }, { "block": "minecraft:crying_obsidian", - "mass": 2350.0 + "mass": 2350.0, + "friction": 0.8 }, { "block": "minecraft:sandstone", - "mass": 2300.0 + "mass": 2300.0, + "friction": 0.6 }, { "block": "minecraft:red_sandstone", - "mass": 2300.0 + "mass": 2300.0, + "friction": 0.6 }, { "block": "minecraft:stone", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.6 }, { "block": "minecraft:terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:white_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:orange_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:magenta_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:light_blue_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:yellow_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:lime_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:pink_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:gray_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:light_gray_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:cyan_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:purple_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:blue_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:brown_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:green_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:red_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 }, { "block": "minecraft:black_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.6 } ] From 2c854cd008c1601ec32041f463ba1401a44ee9d7 Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Tue, 26 Sep 2023 18:34:30 +0200 Subject: [PATCH 234/437] Update masonry.json --- .../data/valkyrienskies/vs_mass/masonry.json | 499 ++++++++++++------ 1 file changed, 330 insertions(+), 169 deletions(-) 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 ddd635cc0..bd5e2a265 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/masonry.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/masonry.json @@ -1,666 +1,827 @@ [ { "block": "minecraft:stone_slab", - "mass": 1300.0 + "mass": 1300.0, + "friction": 0.6 }, { "block": "minecraft:smooth_stone_slab", - "mass": 1300.0 + "mass": 1300.0, + "friction": 0.4 }, { "block": "minecraft:granite_slab", - "mass": 1350.0 + "mass": 1350.0, + "friction": 0.6 }, { "block": "minecraft:polished_granite_slab", - "mass": 1350.0 + "mass": 1350.0, + "friction": 0.4 }, { "block": "minecraft:diorite_slab", - "mass": 1450.0 + "mass": 1450.0, + "friction": 0.6 }, { "block": "minecraft:polished_diorite_slab", - "mass": 1450.0 + "mass": 1450.0, + "friction": 0.4 }, { "block": "minecraft:andesite_slab", - "mass": 1385.0 + "mass": 1385.0, + "friction": 0.6 }, { "block": "minecraft:polished_andesite_slab", - "mass": 1385.0 + "mass": 1385.0, + "friction": 0.4 }, { "block": "minecraft:cobblestone_slab", - "mass": 1240.0 + "mass": 1240.0, + "friction": 0.8 }, { "block": "minecraft:mossy_cobblestone_slab", - "mass": 1300.0 + "mass": 1300.0, + "friction": 0.8 }, { "block": "minecraft:stone_brick_slab", - "mass": 1300.0 + "mass": 1300.0, + "friction": 0.5 }, { "block": "minecraft:mossy_stone_brick_slab", - "mass": 1300.0 + "mass": 1300.0, + "friction": 0.3 }, { "block": "minecraft:brick_slab", - "mass": 950.0 + "mass": 950.0, + "friction": 0.6 }, { "block": "minecraft:end_stone_brick_slab", - "mass": 1400.0 + "mass": 1400.0, + "friction": 0.5 }, { "block": "minecraft:nether_brick_slab", - "mass": 950.0 + "mass": 950.0, + "friction": 0.6 }, { "block": "minecraft:red_nether_brick_slab", - "mass": 950.0 + "mass": 950.0, + "friction": 0.6 }, { "block": "minecraft:sandstone_slab", - "mass": 1150.0 + "mass": 1150.0, + "friction": 0.6 }, { "block": "minecraft:cut_sandstone_slab", - "mass": 1150.0 + "mass": 1150.0, + "friction": 0.6 }, { "block": "minecraft:smooth_sandstone_slab", - "mass": 1150.0 + "mass": 1150.0, + "friction": 0.5 }, { "block": "minecraft:red_sandstone_slab", - "mass": 1150.0 + "mass": 1150.0, + "friction": 0.6 }, { "block": "minecraft:cut_red_sandstone_slab", - "mass": 1150.0 + "mass": 1150.0, + "friction": 0.6 }, { "block": "minecraft:smooth_red_sandstone_slab", - "mass": 1150.0 + "mass": 1150.0, + "friction": 0.5 }, { "block": "minecraft:quartz_slab", - "mass": 1160.0 + "mass": 1160.0, + "friction": 0.5 }, { "block": "minecraft:smooth_quartz_slab", - "mass": 1160.0 + "mass": 1160.0, + "friction": 0.3 }, { "block": "minecraft:purpur_slab", - "mass": 60.0 + "mass": 60.0, + "friction": 0.6 }, { "block": "minecraft:prismarine_slab", - "mass": 1000.0 + "mass": 1000.0, + "friction": 0.8 }, { "block": "minecraft:prismarine_brick_slab", - "mass": 1600.0 + "mass": 1600.0, + "friction": 0.5 }, { "block": "minecraft:dark_prismarine_slab", - "mass": 1600.0 + "mass": 1600.0, + "friction": 0.6 }, { "block": "minecraft:blackstone_slab", - "mass": 1700.0 + "mass": 1700.0, + "friction": 0.7 }, { "block": "minecraft:polished_blackstone_slab", - "mass": 1700.0 + "mass": 1700.0, + "friction": 0.5 }, { "block": "minecraft:polished_blackstone_brick_slab", - "mass": 1700.0 + "mass": 1700.0, + "friction": 0.5 }, { "block": "minecraft:stone_stairs", - "mass": 1950.0 + "mass": 1950.0, + "friction": 0.6 }, { "block": "minecraft:granite_stairs", - "mass": 2025.0 + "mass": 2025.0, + "friction": 0.6 }, { "block": "minecraft:polished_granite_stairs", - "mass": 2025.0 + "mass": 2025.0, + "friction": 0.5 }, { "block": "minecraft:diorite_stairs", - "mass": 2175.0 + "mass": 2175.0, + "friction": 0.6 }, { "block": "minecraft:polished_diorite_stairs", - "mass": 2175.0 + "mass": 2175.0, + "friction": 0.5 }, { "block": "minecraft:andesite_stairs", - "mass": 2080.0 + "mass": 2080.0, + "friction": 0.6 }, { "block": "minecraft:polished_andesite_stairs", - "mass": 2080.0 + "mass": 2080.0, + "friction": 0.5 }, { "block": "minecraft:cobblestone_stairs", - "mass": 1860.0 + "mass": 1860.0, + "friction": 0.8 }, { "block": "minecraft:mossy_cobblestone_stairs", - "mass": 1950.0 + "mass": 1950.0, + "friction": 0.8 }, { "block": "minecraft:stone_brick_stairs", - "mass": 1950.0 + "mass": 1950.0, + "friction": 0.5 }, { "block": "minecraft:mossy_stone_brick_stairs", - "mass": 1950.0 + "mass": 1950.0, + "friction": 0.3 }, { "block": "minecraft:brick_stairs", - "mass": 1425.0 + "mass": 1425.0, + "friction": 0.6 }, { "block": "minecraft:end_stone_brick_stairs", - "mass": 2100.0 + "mass": 2100.0, + "friction": 0.5 }, { "block": "minecraft:nether_brick_stairs", - "mass": 1425.0 + "mass": 1425.0, + "friction": 0.6 }, { "block": "minecraft:red_nether_brick_stairs", - "mass": 1425.0 + "mass": 1425.0, + "friction": 0.6 }, { "block": "minecraft:sandstone_stairs", - "mass": 1725.0 + "mass": 1725.0, + "friction": 0.6 }, { "block": "minecraft:smooth_sandstone_stairs", - "mass": 1725.0 + "mass": 1725.0, + "friction": 0.5 }, { "block": "minecraft:red_sandstone_stairs", - "mass": 1725.0 + "mass": 1725.0, + "friction": 0.6 }, { "block": "minecraft:smooth_red_sandstone_stairs", - "mass": 1725.0 + "mass": 1725.0, + "friction": 0.5 }, { "block": "minecraft:quartz_stairs", - "mass": 1740.0 + "mass": 1740.0, + "friction": 0.5 }, { "block": "minecraft:smooth_quartz_stairs", - "mass": 1740.0 + "mass": 1740.0, + "friction": 0.3 }, { "block": "minecraft:purpur_stairs", - "mass": 90.0 + "mass": 90.0, + "friction": 0.6 }, { "block": "minecraft:prismarine_stairs", - "mass": 1500.0 + "mass": 1500.0, + "friction": 0.8 }, { "block": "minecraft:prismarine_brick_stairs", - "mass": 2400.0 + "mass": 2400.0, + "friction": 0.5 }, { "block": "minecraft:dark_prismarine_stairs", - "mass": 2400.0 + "mass": 2400.0, + "friction": 0.6 }, { "block": "minecraft:blackstone_stairs", - "mass": 2550.0 + "mass": 2550.0, + "friction": 0.7 }, { "block": "minecraft:polished_blackstone_stairs", - "mass": 2550.0 + "mass": 2550.0, + "friction": 0.5 }, { "block": "minecraft:polished_blackstone_brick_stairs", - "mass": 2550.0 + "mass": 2550.0, + "friction": 0.4 }, { "block": "minecraft:granite_wall", - "mass": 1350.0 + "mass": 1350.0, + "friction": 0.6 }, { "block": "minecraft:diorite_wall", - "mass": 1450.0 + "mass": 1450.0, + "friction": 0.6 }, { "block": "minecraft:andesite_wall", - "mass": 1385.0 + "mass": 1385.0, + "friction": 0.6 }, { "block": "minecraft:cobblestone_wall", - "mass": 1240.0 + "mass": 1240.0, + "friction": 0.8 }, { "block": "minecraft:mossy_cobblestone_wall", - "mass": 1300.0 + "mass": 1300.0, + "friction": 0.8 }, { "block": "minecraft:stone_brick_wall", - "mass": 1300.0 + "mass": 1300.0, + "friction": 0.5 }, { "block": "minecraft:mossy_stone_brick_wall", - "mass": 1300.0 + "mass": 1300.0, + "friction": 0.3 }, { "block": "minecraft:brick_wall", - "mass": 950.0 + "mass": 950.0, + "friction": 0.6 }, { "block": "minecraft:end_stone_brick_wall", - "mass": 1400.0 + "mass": 1400.0, + "friction": 0.5 }, { "block": "minecraft:nether_brick_wall", - "mass": 950.0 + "mass": 950.0, + "friction": 0.6 }, { "block": "minecraft:red_nether_brick_wall", - "mass": 950.0 + "mass": 950.0, + "friction": 0.6 }, { "block": "minecraft:sandstone_wall", - "mass": 1150.0 + "mass": 1150.0, + "friction": 0.6 }, { "block": "minecraft:red_sandstone_wall", - "mass": 1150.0 + "mass": 1150.0, + "friction": 0.6 }, { "block": "minecraft:prismarine_wall", - "mass": 1000.0 + "mass": 1000.0, + "friction": 0.8 }, { "block": "minecraft:blackstone_wall", - "mass": 1700.0 + "mass": 1700.0, + "friction": 0.7 }, { "block": "minecraft:polished_blackstone_wall", - "mass": 1700.0 + "mass": 1700.0, + "friction": 0.5 }, { "block": "minecraft:polished_blackstone_brick_wall", - "mass": 1700.0 + "mass": 1700.0, + "friction": 0.4 }, { "block": "minecraft:polished_granite", - "mass": 2700.0 + "mass": 2700.0, + "friction": 0.4 }, { "block": "minecraft:polished_diorite", - "mass": 2900.0 + "mass": 2900.0, + "friction": 0.4 }, { "block": "minecraft:polished_andesite", - "mass": 2770.0 + "mass": 2770.0, + "friction": 0.4 }, { "block": "minecraft:polished_basalt", - "mass": 3010.0 + "mass": 3010.0, + "friction": 0.4 }, { "block": "minecraft:polished_blackstone", - "mass": 3400.0 + "mass": 3400.0, + "friction": 0.5 }, { "block": "minecraft:polished_blackstone_bricks", - "mass": 3400.0 + "mass": 3400.0, + "friction": 0.4 }, { "block": "minecraft:smooth_quartz", - "mass": 2320.0 + "mass": 2320.0, + "friction": 0.3 }, { "block": "minecraft:smooth_sandstone", - "mass": 2300.0 + "mass": 2300.0, + "friction": 0.5 }, { "block": "minecraft:smooth_red_sandstone", - "mass": 2300.0 + "mass": 2300.0, + "friction": 0.4 }, { "block": "minecraft:smooth_stone", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.4 }, { "block": "minecraft:cracked_stone_bricks", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.7 }, { "block": "minecraft:cracked_nether_bricks", - "mass": 1900.0 + "mass": 1900.0, + "friction": 0.7 }, { "block": "minecraft:cracked_polished_blackstone_bricks", - "mass": 3400.0 + "mass": 3400.0, + "friction": 0.6 }, { "block": "minecraft:chiseled_sandstone", - "mass": 2300.0 + "mass": 2300.0, + "friction": 0.6 }, { "block": "minecraft:chiseled_stone_bricks", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.6 }, { "block": "minecraft:chiseled_nether_bricks", - "mass": 1900.0 + "mass": 1900.0, + "friction": 0.6 }, { "block": "minecraft:chiseled_quartz_block", - "mass": 2320.0 + "mass": 2320.0, + "friction": 0.6 }, { "block": "minecraft:chiseled_red_sandstone", - "mass": 2300.0 + "mass": 2300.0, + "friction": 0.6 }, { "block": "minecraft:chiseled_polished_blackstone", - "mass": 3400.0 + "mass": 3400.0, + "friction": 0.6 }, { "block": "minecraft:quartz_pillar", - "mass": 2320.0 + "mass": 2320.0, + "friction": 0.5 }, { "block": "minecraft:purpur_pillar", - "mass": 120.0 + "mass": 120.0, + "friction": 0.6 }, { "block": "minecraft:purpur_block", - "mass": 120.0 + "mass": 120.0, + "friction": 0.6 }, { "block": "minecraft:quartz_block", - "mass": 2320.0 + "mass": 2320.0, + "friction": 0.6 }, { "block": "minecraft:mossy_stone_bricks", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.3 }, { "block": "minecraft:gilded_blackstone", - "mass": 3800.0 + "mass": 3800.0, + "friction": 0.7 }, { "block": "minecraft:nether_brick_fence", - "mass": 380.0 + "mass": 380.0, + "friction": 0.6 }, { "block": "minecraft:bricks", - "mass": 1900.0 + "mass": 1900.0, + "friction": 0.6 }, { "block": "minecraft:stone_bricks", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.5 }, { "block": "minecraft:nether_bricks", - "mass": 1900.0 + "mass": 1900.0, + "friction": 0.5 }, { "block": "minecraft:red_nether_bricks", - "mass": 1900.0 + "mass": 1900.0, + "friction": 0.5 }, { "block": "minecraft:end_stone_bricks", - "mass": 2800.0 + "mass": 2800.0, + "friction": 0.5 }, { "block": "minecraft:quartz_bricks", - "mass": 2320.0 + "mass": 2320.0, + "friction": 0.5 }, { "block": "minecraft:prismarine", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.8 }, { "block": "minecraft:prismarine_bricks", - "mass": 3200.0 + "mass": 3200.0, + "friction": 0.5 }, { "block": "minecraft:dark_prismarine", - "mass": 3200.0 - }, - { - "block": "minecraft:prismarine", - "mass": 2000.0 + "mass": 3200.0, + "friction": 0.6 }, { "block": "minecraft:white_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:orange_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:magenta_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:light_blue_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:yellow_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:lime_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:pink_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:gray_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:light_gray_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:cyan_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:purple_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:blue_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:brown_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:green_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:red_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:black_glazed_terracotta", - "mass": 2000.0 + "mass": 2000.0, + "friction": 0.2 }, { "block": "minecraft:white_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:orange_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:magenta_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:light_blue_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:yellow_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:lime_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:pink_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:gray_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:light_gray_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:cyan_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:purple_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:blue_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:brown_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:green_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:red_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:black_concrete_powder", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.6 }, { "block": "minecraft:white_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:orange_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:magenta_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:light_blue_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:yellow_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:lime_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:pink_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:gray_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:light_gray_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:cyan_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:purple_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:blue_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:brown_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:green_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:red_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:black_concrete", - "mass": 2360.0 + "mass": 2360.0, + "friction": 0.4 }, { "block": "minecraft:infested_stone", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.6 }, { "block": "minecraft:infested_cobblestone", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.8 }, { "block": "minecraft:infested_stone_bricks", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.5 }, { "block": "minecraft:infested_cracked_stone_bricks", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.6 }, { "block": "minecraft:infested_mossy_stone_bricks", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.3 }, { "block": "minecraft:infested_chiseled_stone_bricks", - "mass": 2600.0 + "mass": 2600.0, + "friction": 0.6 } ] From 31df0cbd2e45593fa191c96b1feed9fdfd21d6ee Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Tue, 26 Sep 2023 18:46:16 +0200 Subject: [PATCH 235/437] Update wood.json --- .../data/valkyrienskies/vs_mass/wood.json | 60 ++++++++++++------- 1 file changed, 40 insertions(+), 20 deletions(-) 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 25bac9acd..46cd948e4 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/wood.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/wood.json @@ -1,82 +1,102 @@ [ { "tag": "minecraft:wooden_stairs", - "mass": 525.0 + "mass": 525.0, + "friction": 0.5 }, { "tag": "minecraft:wooden_slabs", - "mass": 350.0 + "mass": 350.0, + "friction": 0.5 }, { "tag": "minecraft:oak_logs", - "mass": 900.0 + "mass": 900.0, + "friction": 0.6 }, { "block": "minecraft:oak_planks", - "mass": 600.0 + "mass": 600.0, + "friction": 0.5 }, { "tag": "minecraft:spruce_logs", - "mass": 780.0 + "mass": 780.0, + "friction": 0.6 }, { "block": "minecraft:spruce_planks", - "mass": 480.0 + "mass": 480.0, + "friction": 0.5 }, { "tag": "minecraft:birch_logs", - "mass": 770.0 + "mass": 770.0, + "friction": 0.6 }, { "block": "minecraft:birch_planks", - "mass": 510.0 + "mass": 510.0, + "friction": 0.5 }, { "tag": "minecraft:jungle_logs", - "mass": 850.0 + "mass": 850.0, + "friction": 0.6 }, { "block": "minecraft:jungle_planks", - "mass": 500.0 + "mass": 500.0, + "friction": 0.5 }, { "tag": "minecraft:acacia_logs", - "mass": 770.0 + "mass": 770.0, + "friction": 0.6 }, { "block": "minecraft:acacia_planks", - "mass": 650.0 + "mass": 650.0, + "friction": 0.5 }, { "tag": "minecraft:dark_oak_logs", - "mass": 800.0 + "mass": 800.0, + "friction": 0.6 }, { "block": "minecraft:dark_oak_planks", - "mass": 700.0 + "mass": 700.0, + "friction": 0.5 }, { "tag": "minecraft:warped_stems", - "mass": 980.0 + "mass": 980.0, + "friction": 0.6 }, { "block": "minecraft:warped_planks", - "mass": 910.0 + "mass": 910.0, + "friction": 0.5 }, { "tag": "minecraft:crimson_stems", - "mass": 1000.0 + "mass": 1000.0, + "friction": 0.6 }, { "block": "minecraft:crimson_planks", - "mass": 999.0 + "mass": 999.0, + "friction": 0.5 }, { "tag": "minecraft:logs", - "mass": 800.0 + "mass": 800.0, + "friction": 0.4 }, { "tag": "minecraft:planks", - "mass": 700.0 + "mass": 700.0, + "friction": 0.5 } ] From 66d53f32f7a6f2df2c23064c0f1db5c94e56a3d1 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 26 Sep 2023 23:49:22 -0600 Subject: [PATCH 236/437] Updated vs-core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 0f47c9c40..0dc04cc8b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+d9d153f463 +vs_core_version=1.1.0+94169f2520 # 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 e7338564514d1e18daa9b509476bf71c3583a64a Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 28 Sep 2023 02:25:34 -0600 Subject: [PATCH 237/437] Fixed ships getting stuck on top of the world --- .../mod_compat/flywheel/MixinBlockEntityInstanceManager.java | 3 +-- .../main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 2 +- gradle.properties | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) 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..8254b7be2 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 @@ -24,7 +24,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.valkyrienskies.core.api.ships.ClientShip; -import org.valkyrienskies.core.api.world.LevelYRange; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.mixinducks.MixinBlockEntityInstanceManagerDuck; @@ -60,7 +59,7 @@ void preCreateRaw(final BlockEntity blockEntity, final CallbackInfoReturnable<In final MaterialManager manager = shipMaterialManagers.computeIfAbsent(ship, k -> createMaterialManager()); final Vector3i c = - ship.getChunkClaim().getCenterBlockCoordinates(new LevelYRange(0, 0), new Vector3i()); + ship.getChunkClaim().getCenterBlockCoordinates(VSGameUtilsKt.getYRange(nullableLevel), new Vector3i()); ((InstancingEngineAccessor) manager).setOriginCoordinate(new BlockPos(c.x, c.y, c.z)); cir.setReturnValue(InstancedRenderRegistry.createInstance(manager, blockEntity)); 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 a315d0125..8c76a1ad3 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -94,7 +94,7 @@ fun MinecraftServer.executeIf(condition: () -> Boolean, toExecute: Runnable) { } } -val Level.yRange get() = LevelYRange(minBuildHeight, maxBuildHeight) +val Level.yRange get() = LevelYRange(minBuildHeight, maxBuildHeight - 1) fun Level.isTickingChunk(pos: ChunkPos) = isTickingChunk(pos.x, pos.z) fun Level.isTickingChunk(chunkX: Int, chunkZ: Int) = diff --git a/gradle.properties b/gradle.properties index 0dc04cc8b..4e3951230 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+94169f2520 +vs_core_version=1.1.0+6f373832e9 # 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 58665aa9452fbe7e66187f201dc4dba661607c62 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 28 Sep 2023 02:48:48 -0600 Subject: [PATCH 238/437] Updated forge Krunch --- forge/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index f694b8b3f..622d9844b 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -100,11 +100,11 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+14214f4ff8") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+c56602855f") { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+216620077e") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+94304c13aa") { transitive = false } From be901b8acd641c29de2301bec707182ff810f893 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 28 Sep 2023 02:56:05 -0600 Subject: [PATCH 239/437] Fixed forge not depending on vs-core util --- forge/build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/forge/build.gradle b/forge/build.gradle index 622d9844b..b6c8f435e 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -100,6 +100,10 @@ dependencies { transitive = false } + forgeRuntimeLibrary include("org.valkyrienskies.core:util:${rootProject.vs_core_version}") { + transitive = false + } + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+c56602855f") { transitive = false } From d8e64df0d1e2685b9bdb10f9add9fc9fa1ace9e6 Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Thu, 28 Sep 2023 12:21:20 +0200 Subject: [PATCH 240/437] Update plants.json --- .../src/main/resources/data/valkyrienskies/vs_mass/plants.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 5fd3bdb1b..14dfa2b8a 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/plants.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/plants.json @@ -95,7 +95,7 @@ }, { "tag": "minecraft:coral_blocks", - "mass": 1500.0", + "mass": 1500.0, "friction": 0.7 }, { From de4fa39d9ccdfa396d395e4332124b6106d3116f Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Thu, 28 Sep 2023 18:37:51 +0200 Subject: [PATCH 241/437] Update misc.json --- .../src/main/resources/data/valkyrienskies/vs_mass/misc.json | 5 +++++ 1 file changed, 5 insertions(+) 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 0e0060bd8..0bf9f5a8f 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json @@ -449,6 +449,11 @@ "mass": 50.0, "friction": 0.7 }, + { + "block": "minecraft:dragon_egg", + "mass": 1400.0, + "friction": 0.8 + }, { "block": "minecraft:end_portal_frame", "mass": 3000.0, From a9247baf74f009106665b9e44ae1e5b7e31f2dbb Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Thu, 28 Sep 2023 19:20:44 +0200 Subject: [PATCH 242/437] Update wood.json made wood weights more specific --- .../data/valkyrienskies/vs_mass/wood.json | 242 ++++++++++++++++-- 1 file changed, 221 insertions(+), 21 deletions(-) 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 46cd948e4..876f0b6f2 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/wood.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/wood.json @@ -1,18 +1,23 @@ [ { - "tag": "minecraft:wooden_stairs", - "mass": 525.0, - "friction": 0.5 + "block": "minecraft:oak_wood", + "mass": 900.0, + "friction": 0.6 }, { - "tag": "minecraft:wooden_slabs", - "mass": 350.0, - "friction": 0.5 + "block": "minecraft:oak_log", + "mass": 900.0, + "friction": 0.6 }, { - "tag": "minecraft:oak_logs", + "block": "minecraft:stripped_oak_wood", "mass": 900.0, - "friction": 0.6 + "friction": 0.4 + }, + { + "block": "minecraft:stripped_oak_log", + "mass": 900.0, + "friction": 0.4 }, { "block": "minecraft:oak_planks", @@ -20,83 +25,278 @@ "friction": 0.5 }, { - "tag": "minecraft:spruce_logs", + "block": "minecraft:oak_slab", + "mass": 300.0, + "friction": 0.5 + }, + { + "block": "minecraft:oak_slab", + "mass": 450.0, + "friction": 0.5 + }, + { + "block": "minecraft:spruce_wood", + "mass": 780.0, + "friction": 0.6 + }, + { + "block": "minecraft:spruce_log", "mass": 780.0, "friction": 0.6 }, + { + "block": "minecraft:stripped_spruce_wood", + "mass": 780.0, + "friction": 0.4 + }, + { + "block": "minecraft:stripped_spruce_log", + "mass": 780.0, + "friction": 0.4 + }, { "block": "minecraft:spruce_planks", "mass": 480.0, "friction": 0.5 }, { - "tag": "minecraft:birch_logs", + "block": "minecraft:spruce_slab", + "mass": 240.0, + "friction": 0.5 + }, + { + "block": "minecraft:spruce_stairs", + "mass": 360.0, + "friction": 0.5 + }, + { + "block": "minecraft:birch_wood", "mass": 770.0, "friction": 0.6 }, + { + "block": "minecraft:birch_log", + "mass": 770.0, + "friction": 0.6 + }, + { + "block": "minecraft:stripped_birch_wood", + "mass": 770.0, + "friction": 0.4 + }, + { + "block": "minecraft:stripped_birch_log", + "mass": 770.0, + "friction": 0.4 + }, { "block": "minecraft:birch_planks", "mass": 510.0, "friction": 0.5 }, { - "tag": "minecraft:jungle_logs", + "block": "minecraft:birch_slab", + "mass": 255.0, + "friction": 0.5 + }, + { + "block": "minecraft:birch_stairs", + "mass": 380.0, + "friction": 0.5 + }, + { + "block": "minecraft:jungle_wood", "mass": 850.0, "friction": 0.6 }, + { + "block": "minecraft:jungle_log", + "mass": 850.0, + "friction": 0.6 + }, + { + "block": "minecraft:stripped_jungle_wood", + "mass": 850.0, + "friction": 0.4 + }, + { + "block": "minecraft:stripped_jungle_log", + "mass": 850.0, + "friction": 0.4 + }, { "block": "minecraft:jungle_planks", "mass": 500.0, "friction": 0.5 }, { - "tag": "minecraft:acacia_logs", + "block": "minecraft:jungle_slab", + "mass": 250.0, + "friction": 0.5 + }, + { + "block": "minecraft:jungle_stairs", + "mass": 375.0, + "friction": 0.5 + }, + { + "block": "minecraft:acacia_wood", + "mass": 770.0, + "friction": 0.6 + }, + { + "block": "minecraft:acacia_log", "mass": 770.0, "friction": 0.6 }, + { + "block": "minecraft:stripped_acacia_wood", + "mass": 770.0, + "friction": 0.4 + }, + { + "block": "minecraft:stripped_acacia_log", + "mass": 770.0, + "friction": 0.4 + }, { "block": "minecraft:acacia_planks", - "mass": 650.0, + "mass": 550.0, "friction": 0.5 }, { - "tag": "minecraft:dark_oak_logs", + "block": "minecraft:acacia_slab", + "mass": 275.0, + "friction": 0.5 + }, + { + "block": "minecraft:acacia_stairs", + "mass": 410.0, + "friction": 0.5 + }, + { + "block": "minecraft:dark_oak_wood", + "mass": 800.0, + "friction": 0.6 + }, + { + "block": "minecraft:dark_oak_log", "mass": 800.0, "friction": 0.6 }, + { + "block": "minecraft:stripped_dark_oak_wood", + "mass": 800.0, + "friction": 0.4 + }, + { + "block": "minecraft:stripped_dark_oak_log", + "mass": 800.0, + "friction": 0.4 + }, { "block": "minecraft:dark_oak_planks", - "mass": 700.0, + "mass": 650.0, + "friction": 0.5 + }, + { + "block": "minecraft:dark_oak_slab", + "mass": 325.0, + "friction": 0.5 + }, + { + "block": "minecraft:dark_oak_stairs", + "mass": 485.0, "friction": 0.5 }, { - "tag": "minecraft:warped_stems", + "block": "minecraft:warped_hyphae", "mass": 980.0, "friction": 0.6 }, + { + "block": "minecraft:warped_stem", + "mass": 980.0, + "friction": 0.6 + }, + { + "block": "minecraft:stripped_warped_hyphae", + "mass": 980.0, + "friction": 0.4 + }, + { + "block": "minecraft:stripped_warped_stem", + "mass": 980.0, + "friction": 0.4 + }, { "block": "minecraft:warped_planks", "mass": 910.0, "friction": 0.5 }, { - "tag": "minecraft:crimson_stems", - "mass": 1000.0, + "block": "minecraft:warped_slab", + "mass": 455.0, + "friction": 0.5 + }, + { + "block": "minecraft:warped_stairs", + "mass": 680.0, + "friction": 0.5 + }, + { + "block": "minecraft:crimson_hyphae", + "mass": 980.0, "friction": 0.6 }, + { + "block": "minecraft:crimson_stem", + "mass": 980.0, + "friction": 0.6 + }, + { + "block": "minecraft:stripped_crimson_hyphae", + "mass": 980.0, + "friction": 0.4 + }, + { + "block": "minecraft:stripped_crimson_stem", + "mass": 980.0, + "friction": 0.4 + }, { "block": "minecraft:crimson_planks", - "mass": 999.0, + "mass": 910.0, + "friction": 0.5 + }, + { + "block": "minecraft:crimson_slab", + "mass": 455.0, + "friction": 0.5 + }, + { + "block": "minecraft:crimson_stairs", + "mass": 680.0, "friction": 0.5 }, { "tag": "minecraft:logs", "mass": 800.0, - "friction": 0.4 + "friction": 0.6 }, { "tag": "minecraft:planks", "mass": 700.0, "friction": 0.5 - } + }, + { + "tag": "minecraft:wooden_stairs", + "mass": 525.0, + "friction": 0.5 + }, + { + "tag": "minecraft:wooden_slabs", + "mass": 350.0, + "friction": 0.5 + }, ] From 5472229d41d88ce704b65bd1c14de7135206316e Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Thu, 28 Sep 2023 20:27:54 +0200 Subject: [PATCH 243/437] Create 1_19_blocks --- .../data/valkyrienskies/vs_mass/1_19_blocks | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 common/src/main/resources/data/valkyrienskies/vs_mass/1_19_blocks 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 new file mode 100644 index 000000000..cee29a304 --- /dev/null +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/1_19_blocks @@ -0,0 +1,132 @@ +[ + { + "block": "minecraft:pearlescent_froglight", + "mass": 3200.0, + "friction": 0.07, + "elasticity": 0.8 + }, + { + "block": "minecraft:verdant_froglight", + "mass": 3200.0, + "friction": 0.07, + "elasticity": 0.8 + }, + { + "block": "minecraft:ochre_froglight", + "mass": 3200.0, + "friction": 0.07, + "elasticity": 0.8 + }, + { + "block": "minecraft:frogspawn", + "mass": 1.0, + "friction": 0.03 + }, + { + "block": "minecraft:mangrove_log", + "mass": 900.0, + "friction": 0.6 + }, + { + "block": "minecraft:stripped_mangrove_log", + "mass": 900.0, + "friction": 0.4 + }, + { + "block": "minecraft:mangrove_wood", + "mass": 900.0, + "friction": 0.6 + }, + { + "block": "minecraft:stripped_mangrove_wood", + "mass": 900.0, + "friction": 0.4 + }, + { + "block": "minecraft:mangrove_planks", + "mass": 600.0, + "friction": 0.5 + }, + { + "block": "minecraft:mangrove_slab", + "mass": 300.0, + "friction": 0.5 + }, + { + "block": "minecraft:mangrove_stairs", + "mass": 450.0, + "friction": 0.5 + }, + { + "block": "minecraft:mangrove_propagule", + "mass": 15.0 + }, + { + "block": "minecraft:mangrove_roots", + "mass": 50.0, + "friction": 0.8 + }, + { + "block": "minecraft:muddy_mangrove_roots", + "mass": 1800.0, + "friction": 0.8 + }, + { + "block": "minecraft:mud", + "mass": 1800.0, + "friction": 0.9 + }, + { + "block": "minecraft:packed_mud", + "mass": 1450.0, + "friction": 0.7 + }, + { + "block": "minecraft:mud_bricks", + "mass": 1450.0, + "friction": 0.7 + }, + { + "block": "minecraft:mud_brick_wall", + "mass": 725.0, + "friction": 0.7 + }, + { + "block": "minecraft:mud_brick_slab", + "mass": 725.0, + "friction": 0.7 + }, + { + "block": "minecraft:mud_brick_stairs", + "mass": 1035.0, + "friction": 0.7 + }, + { + "block": "minecraft:reinforced_deepslate", + "mass": 3400.0, + "friction": 0.7 + }, + { + "block": "minecraft:sculk", + "mass": 400.0, + "friction": 0.2, + "elasticity": 0.3 + }, + { + "block": "minecraft:sculk_catalyst", + "mass": 600.0, + "friction": 0.2 + }, + { + "block": "minecraft:sculk_shrieker", + "mass": 200.0, + "friction": 0.2, + "elasticity": 0.3 + }, + { + "block": "minecraft:sculk_vein", + "mass": 8.0, + "friction": 0.2, + "elasticity": 0.03 + } +] From 4bc9c696970d3ec8b6886a951c3ac04d6e5f89d0 Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Thu, 28 Sep 2023 20:31:17 +0200 Subject: [PATCH 244/437] Create 1_20_blocks --- .../data/valkyrienskies/vs_mass/1_20_blocks | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 common/src/main/resources/data/valkyrienskies/vs_mass/1_20_blocks 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 new file mode 100644 index 000000000..4a443127c --- /dev/null +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/1_20_blocks @@ -0,0 +1,133 @@ +[ + { + "tag": "minecraft:all_hanging_signs", + "mass": 20.0, + "friction": 0.5 + }, + { + "block": "minecraft:bamboo_block", + "mass": 150.0, + "friction": 0.6 + }, + { + "block": "minecraft:stripped_bamboo_block", + "mass": 150.0, + "friction": 0.4 + }, + { + "block": "minecraft:bamboo_planks", + "mass": 100.0, + "friction": 0.5 + }, + { + "block": "minecraft:bamboo_mosaic", + "mass": 100.0, + "friction": 0.5 + }, + { + "block": "minecraft:bamboo_mosaic_slab", + "mass": 50.0, + "friction": 0.5 + }, + { + "block": "minecraft:bamboo_slab", + "mass": 50.0, + "friction": 0.5 + }, + { + "block": "minecraft:bamboo_stairs", + "mass": 75.0, + "friction": 0.5 + }, + { + "block": "minecraft:bamboo_mosaic_stairs", + "mass": 75.0, + "friction": 0.5 + }, + { + "block": "minecraft:calibrated_sculk_sensor", + "mass": 230.0, + "friction": 0.9, + "elasticity": 0.3 + }, + { + "block": "minecraft:cherry_wood", + "mass": 640.0, + "friction": 0.6 + }, + { + "block": "minecraft:cherry_log", + "mass": 640.0, + "friction": 0.6 + }, + { + "block": "minecraft:stripped_cherry_wood", + "mass": 640.0, + "friction": 0.4 + }, + { + "block": "minecraft:stripped_cherry_log", + "mass": 640.0, + "friction": 0.4 + }, + { + "block": "minecraft:cherry_planks", + "mass": 425.0, + "friction": 0.5 + }, + { + "block": "minecraft:cherry_slab", + "mass": 210.0, + "friction": 0.5 + }, + { + "block": "minecraft:cherry_stairs", + "mass": 315.0, + "friction": 0.5 + }, + { + "block": "minecraft:chiseled_bookshelf", + "mass": 650.0, + "friction": 0.5 + }, + { + "block": "minecraft:decorated_pot", + "mass": 250.0, + "friction": 0.35 + }, + { + "block": "minecraft:piglin_head", + "mass": 5.0 + }, + { + "block": "minecraft:piglin_wall_head", + "mass": 5.0 + }, + { + "block": "minecraft:pink_petals", + "mass": 1.0 + }, + { + "block": "minecraft:sniffer_egg", + "mass": 980.0, + "friction": 0.1 + }, + { + "block": "minecraft:suspicious_sand", + "mass": 1565.0, + "friction": 0.4 + }, + { + "block": "minecraft:suspicious_gravel", + "mass": 1685.0, + "friction": 0.7 + }, + { + "block": "minecraft:torchflower_crop", + "mass": 2.0 + }, + { + "block": "minecraft:pitcher_crop", + "mass": 2.0 + } +] From 3fd686019dd5dfaa69753a023c527d9a821b4dc2 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 30 Sep 2023 16:39:38 -0600 Subject: [PATCH 245/437] Added isStatic property to ServerShip --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 4e3951230..9164871fd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+6f373832e9 +vs_core_version=1.1.0+2daab9ad9f # 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 32bc9e026a1d686cb42879042da13bb6ed616da9 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 1 Oct 2023 03:05:22 -0600 Subject: [PATCH 246/437] Fixed malformed json --- .../data/valkyrienskies/vs_mass/crafting_stations.json | 2 +- .../src/main/resources/data/valkyrienskies/vs_mass/misc.json | 4 ++-- .../data/valkyrienskies/vs_mass/redstone_components.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) 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 23d96b4dc..a3c014bf8 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 @@ -21,7 +21,7 @@ }, { "block": "minecraft:stonecutter", - "mass": 2000.0,, + "mass": 2000.0, "friction": 0.5 }, { 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 0e0060bd8..fee3bbd2b 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json @@ -182,11 +182,11 @@ }, { "block": "minecraft:lantern", - "mass": 25.0, + "mass": 25.0 }, { "block": "minecraft:soul_lantern", - "mass": 25.0, + "mass": 25.0 }, { "block": "minecraft:end_rod", 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 f3063a408..65540b04b 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 @@ -169,7 +169,7 @@ }, { "tag": "minecraft:wooden_doors", - "mass": 25.0, + "mass": 25.0 }, { "block": "minecraft:iron_door", @@ -182,7 +182,7 @@ }, { "block": "minecraft:iron_trapdoor", - "mass": 1000.0 + "mass": 1000.0, "friction": 0.35 } ] From 7b13223ee501764617d27d50745b3f1ca4072967 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 1 Oct 2023 03:19:34 -0600 Subject: [PATCH 247/437] Fixed vs-core dependencies --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 9164871fd..d8c770c52 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+2daab9ad9f +vs_core_version=1.1.0+1523241a33 # 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 15518313c12a9997e8d646f062437bd4a7e3fcde Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 1 Oct 2023 03:47:27 -0600 Subject: [PATCH 248/437] Fixed vs-core dependencies (again) --- fabric/build.gradle | 1 + forge/build.gradle | 1 - gradle.properties | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fabric/build.gradle b/fabric/build.gradle index 0251fbbf3..1ede824c8 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -57,6 +57,7 @@ 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 + exclude module: "jsonschema.module.addon" } // CC Restitched diff --git a/forge/build.gradle b/forge/build.gradle index b6c8f435e..6542f090e 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -134,7 +134,6 @@ dependencies { forgeRuntimeLibrary include("com.networknt:json-schema-validator:1.0.71") { transitive = false } forgeRuntimeLibrary include("com.ethlo.time:itu:1.7.0") { transitive = false } - forgeRuntimeLibrary include("com.github.imifou:jsonschema-module-addon:1.2.1") { transitive = false } forgeRuntimeLibrary include("com.github.victools:jsonschema-module-jackson:4.25.0") { transitive = false } forgeRuntimeLibrary include("com.github.victools:jsonschema-generator:4.25.0") { transitive = false } forgeRuntimeLibrary include("com.fasterxml:classmate:1.5.1") { transitive = false } diff --git a/gradle.properties b/gradle.properties index d8c770c52..a1be3aa51 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+1523241a33 +vs_core_version=1.1.0+01023bdb65 # 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 57f9cc246813b30cb2897d671bee194969c3a3f4 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 1 Oct 2023 14:55:01 -0600 Subject: [PATCH 249/437] Fixed ship creator item not handling scale correctly --- .../org/valkyrienskies/mod/common/item/ShipCreatorItem.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 8ea2bfa07..d9335bc28 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 @@ -60,7 +60,7 @@ class ShipCreatorItem( val newShipPosInShipyard = blockPos.toJOMLD().add(0.5, 0.5, 0.5) val newShipRotation = parentShip.transform.shipToWorldRotation var newShipScaling = parentShip.transform.shipToWorldScaling.mul(scale, Vector3d()) - if (newShipScaling.x() < scale) { + if (newShipScaling.x() < minScaling) { // Do not allow scaling to go below minScaling newShipScaling = Vector3d(minScaling, minScaling, minScaling) } From c46ae361c1dbb586cb4efa483f64b1d2c41e6f90 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 1 Oct 2023 15:25:53 -0600 Subject: [PATCH 250/437] Added json/yaml validator to GitHub Actions --- .github/workflows/build-1.18.x.yml | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-1.18.x.yml b/.github/workflows/build-1.18.x.yml index 46464861e..92cbe7656 100644 --- a/.github/workflows/build-1.18.x.yml +++ b/.github/workflows/build-1.18.x.yml @@ -10,11 +10,26 @@ jobs: name: "Validate Gradle wrapper" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 with: submodules: true # Clone with vs-core submodule - uses: gradle/wrapper-validation-action@v1 + json-yaml-validate: + name: "Validate Json/Yaml files" + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write # enable write permissions for pull request comments + steps: + - uses: actions/checkout@v4 + + - name: json-yaml-validate + id: json-yaml-validate + uses: GrantBirki/json-yaml-validate@v2.3.1 + with: + comment: "true" # enable comment mode + test-server: name: Test Server strategy: @@ -24,7 +39,7 @@ jobs: timeout-minutes: 20 # Fail after 20 minutes steps: - name: Shallow Clone (--recurse-submodules) - uses: actions/checkout@v2 + uses: actions/checkout@v4 with: submodules: recursive From 0b7cf8a2a95f03ce2a9c22d31b410bb7ceb29745 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 4 Oct 2023 02:36:48 -0600 Subject: [PATCH 251/437] Updated Krunch --- forge/build.gradle | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index 6542f090e..ee802c3d9 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -104,7 +104,7 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+c56602855f") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+ae61d8d103") { transitive = false } diff --git a/gradle.properties b/gradle.properties index a1be3aa51..bc4512f4d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+01023bdb65 +vs_core_version=1.1.0+9ee747dfe8 # 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 3c9dc357c38980cbd39b000604174661eebf5344 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 8 Oct 2023 04:52:39 -0600 Subject: [PATCH 252/437] Updated vs-core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index bc4512f4d..883a81731 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+9ee747dfe8 +vs_core_version=1.1.0+7bdba50f69 # 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 c67a24f4dd29f3251f35e1a09cf991bd59770f8d Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 9 Oct 2023 22:14:14 -0600 Subject: [PATCH 253/437] =?UTF-8?q?Fixed=20invalid=20json=20=F0=9F=98=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/data/valkyrienskies/vs_mass/plants.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 14dfa2b8a..9ae1a5cf2 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/plants.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/plants.json @@ -311,7 +311,7 @@ { "block": "minecraft:mushroom_stem", "mass": 600.0, - "friction": 0.2 + "friction": 0.2, "elasticity": 0.1 }, { From 0c7fe94a746041e006772c1bc4d5265b53b07b2a Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 9 Oct 2023 22:17:33 -0600 Subject: [PATCH 254/437] =?UTF-8?q?Fixed=20another=20invalid=20json=20?= =?UTF-8?q?=F0=9F=A4=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/src/main/resources/data/valkyrienskies/vs_mass/wood.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 876f0b6f2..f1f037988 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/wood.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/wood.json @@ -298,5 +298,5 @@ "tag": "minecraft:wooden_slabs", "mass": 350.0, "friction": 0.5 - }, + } ] From 95d18bd1faa8a9ed928e2b4ad5d949c3a2993227 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 10 Oct 2023 03:11:04 -0600 Subject: [PATCH 255/437] Fixed ShipArgument @v always being suggested in teleport command --- .../mod/common/command/ShipArgument.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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 a969ab222..383a8f44e 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 @@ -24,7 +24,10 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType val reader = StringReader(builder.input) reader.cursor = builder.start - val startsWithAt = reader.canRead() && reader.peek() == '@' + var startsWithAtV = reader.canRead() && reader.peek() == '@' + if (reader.canRead(2)) { + startsWithAtV = startsWithAtV && reader.peek(1) == 'v' + } val parser = ShipArgumentParser(context.source as VSCommandSource, selectorOnly) @@ -35,14 +38,15 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType } // Reset cursor to fix suggestions - if (!startsWithAt) { + if (!startsWithAtV) { + // Don't suggest @v if this doesn't start with @ or @v 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 = From c8e9817b58941829a34e3a0a2f47fa09b6aea822 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 10 Oct 2023 03:32:58 -0600 Subject: [PATCH 256/437] Fixed EntitySelectorParser suggesting over @v ShipArgument --- .../selector/MixinEntitySelectorParser.java | 40 +++++++++++++++++++ .../valkyrienskies-common.mixins.json | 1 + 2 files changed, 41 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/commands/argument/selector/MixinEntitySelectorParser.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/commands/argument/selector/MixinEntitySelectorParser.java b/common/src/main/java/org/valkyrienskies/mod/mixin/commands/argument/selector/MixinEntitySelectorParser.java new file mode 100644 index 000000000..fe6bdfe90 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/commands/argument/selector/MixinEntitySelectorParser.java @@ -0,0 +1,40 @@ +package org.valkyrienskies.mod.mixin.commands.argument.selector; + +import com.mojang.brigadier.StringReader; +import net.minecraft.commands.arguments.selector.EntitySelector; +import net.minecraft.commands.arguments.selector.EntitySelectorParser; +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.CallbackInfoReturnable; + +/** + * This fixes EntitySelectorParser making suggestions in @v ShipArguments + */ +@Mixin(EntitySelectorParser.class) +public class MixinEntitySelectorParser { + @Shadow + @Final + private StringReader reader; + + @Shadow + private void finalizePredicates() { + throw new IllegalStateException(); + } + + @Shadow + public EntitySelector getSelector() { + return null; + } + + @Inject(method = "parse", at = @At("HEAD"), cancellable = true) + private void preParse(final CallbackInfoReturnable<EntitySelector> cir) { + // If this starts with '@v' then don't suggest anything + if (this.reader.canRead(2) && this.reader.peek() == '@' && this.reader.peek(1) == 'v') { + this.finalizePredicates(); + cir.setReturnValue(this.getSelector()); + } + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 0c7f6a382..bcd3bfed7 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -14,6 +14,7 @@ "accessors.world.level.block.SlabBlockAccessor", "accessors.world.level.block.StairBlockAccessor", "accessors.world.level.pathfinder.PathAccessor", + "commands.argument.selector.MixinEntitySelectorParser", "entity.MixinEntity", "feature.ai.node_evaluator.PathNavigationRegionAccessor", "feature.ai.node_evaluator.SwimNodeEvaluatorMixin", From a726ba3ce15b4a43b8e75b886d4b70a47e4f479e Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 10 Oct 2023 04:13:41 -0600 Subject: [PATCH 257/437] Made ShipArgument behave like EntityArgument --- .../mod/common/command/ShipArgument.kt | 12 +- .../mod/common/command/ShipArgumentParser.kt | 127 ++++++++++-------- 2 files changed, 80 insertions(+), 59 deletions(-) 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 383a8f44e..153e2faff 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 @@ -24,9 +24,13 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType val reader = StringReader(builder.input) reader.cursor = builder.start - var startsWithAtV = reader.canRead() && reader.peek() == '@' + // 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)) { - startsWithAtV = startsWithAtV && reader.peek(1) == 'v' + canThisBeShipArgument = canThisBeShipArgument && reader.peek(1) == 'v' } val parser = ShipArgumentParser(context.source as VSCommandSource, selectorOnly) @@ -38,8 +42,8 @@ class ShipArgument private constructor(val selectorOnly: Boolean) : ArgumentType } // Reset cursor to fix suggestions - if (!startsWithAtV) { - // Don't suggest @v if this doesn't start with @ or @v + if (!canThisBeShipArgument) { + // Don't suggest a ship argument if the contents of reader cannot be a ship argument reader.cursor = builder.start super.listSuggestions(context, builder) } else { 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 3eca4699e..d35d69003 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 @@ -24,62 +24,73 @@ class ShipArgumentParser(private val source: VSCommandSource?, private var selec // Read the selector type if (reader.read() == '@') { - reader.expectR('v') - - suggestOpenOptions() - if (reader.canRead() && reader.read() == '[') { - - // Read the selector arguments ex @v[slug=mogus,limit=1] - while (reader.canRead() && reader.peek() != ']') { - suggestOptions() - reader.skipWhitespace() - - val i = reader.cursor - val s = reader.readString() - - if (!isOption(s)) { - if (isForSuggestion) { - reader.cursor = i - throw ERROR_UNKNOWN_OPTION.createWithContext(reader, s) + if (!reader.canRead()) { + // Suggest "v" + suggest { builder, _ -> + builder.suggest("v") + } + } else { + reader.read() + + if (!reader.canRead()) { + suggestOpenOptions() + } else if (reader.read() == '[') { + if (!reader.canRead()) { + suggestOptions() + } else { + // Read the selector arguments ex @v[slug=mogus,limit=1] + while (reader.canRead() && reader.peek() != ']') { + val i = reader.cursor + val s = reader.readString() + + suggestOptions(s) + reader.skipWhitespace() + + if (!isOption(s)) { + if (isForSuggestion) { + reader.cursor = i + throw ERROR_UNKNOWN_OPTION.createWithContext(reader, s) + } + // If not for suggestion then we cannot throw an exception + // otherwise MC won't generate suggestions for this argument + return ShipSelector(null, null, 0) + } + + reader.skipWhitespace() + + suggestEquals() + + if (!reader.canRead() || reader.peek() != '=') { + throw ERROR_EXPECTED_OPTION_VALUE.createWithContext(reader, s) + } + + reader.skip() + reader.skipWhitespace() + + suggestionsOfOption(s) + + reader.skipWhitespace() + if (reader.canRead()) + parseOption(s, reader) + else throw ERROR_EXPECTED_OPTION_VALUE.createWithContext(reader, s) + reader.skipWhitespace() + + suggestOptionsNextOrClose() + reader.skipWhitespace() } - // If not for suggestion then we cannot throw an exception - // otherwise MC won't generate suggestions for this argument - return ShipSelector(null, null, 0) - } - - reader.skipWhitespace() - - suggestEquals() - - if (!reader.canRead() || reader.peek() != '=') { - throw ERROR_EXPECTED_OPTION_VALUE.createWithContext(reader, s) } - reader.skip() - reader.skipWhitespace() - - suggestionsOfOption(s) - - reader.skipWhitespace() - if (reader.canRead()) - parseOption(s, reader) - else throw ERROR_EXPECTED_OPTION_VALUE.createWithContext(reader, s) - reader.skipWhitespace() + if (!reader.canRead() || reader.read() != ']') + if (isForSuggestion) { + throw ERROR_EXPECTED_END_OF_OPTIONS.createWithContext(reader) + }else { + // If not for suggestion then we cannot throw an exception + // otherwise MC won't generate suggestions for this argument + return ShipSelector(null, null, 0) + } - suggestOptionsNextOrClose() - reader.skipWhitespace() + suggest { _, _ -> } } - - if (!reader.canRead() || reader.read() != ']') - if (isForSuggestion) { - throw ERROR_EXPECTED_END_OF_OPTIONS.createWithContext(reader) - }else { - // If not for suggestion then we cannot throw an exception - // otherwise MC won't generate suggestions for this argument - return ShipSelector(null, null, 0) - } - - suggest { _, _ -> } } } else if (!selectorOnly) { suggestionsOfOption("slug") @@ -97,10 +108,16 @@ class ShipArgumentParser(private val source: VSCommandSource?, private var selec } // TODO keep a dynamic list of options... - private fun suggestOptions() = suggest { builder, source -> - builder.suggest("slug=") - builder.suggest("limit=") - builder.suggest("id=") + private fun suggestOptions(textSoFar: String? = null) = suggest { builder, source -> + if (textSoFar == null) { + builder.suggest("slug=") + builder.suggest("limit=") + builder.suggest("id=") + } else { + if ("slug=".startsWith(textSoFar)) builder.suggest("slug=") + if ("limit=".startsWith(textSoFar)) builder.suggest("limit=") + if ("id=".startsWith(textSoFar)) builder.suggest("id=") + } } private fun suggestSelectorOrSlug() = suggest { builder, source -> From 7bcdf18e70c8b2d39256e0549a2d6deb7b6732cf Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 10 Oct 2023 04:20:39 -0600 Subject: [PATCH 258/437] Fixed EntitySelectorParser.getSelector() not throwing an exception --- .../commands/argument/selector/MixinEntitySelectorParser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/commands/argument/selector/MixinEntitySelectorParser.java b/common/src/main/java/org/valkyrienskies/mod/mixin/commands/argument/selector/MixinEntitySelectorParser.java index fe6bdfe90..4ac8ec653 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/commands/argument/selector/MixinEntitySelectorParser.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/commands/argument/selector/MixinEntitySelectorParser.java @@ -26,7 +26,7 @@ private void finalizePredicates() { @Shadow public EntitySelector getSelector() { - return null; + throw new IllegalStateException(); } @Inject(method = "parse", at = @At("HEAD"), cancellable = true) From 2dd59c65222f151791144049e04c8cf8faa0af91 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 10 Oct 2023 04:47:26 -0600 Subject: [PATCH 259/437] Made VSCommands require permission 2 --- .../mod/common/command/VSCommands.kt | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 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 f84a360c7..7d3adb0ff 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,8 +24,6 @@ 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 @@ -48,6 +46,7 @@ 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" private const val SCALED_SHIPS_MESSAGE = "command.valkyrienskies.scale.success" + private const val REQUIRED_PERMISSION = 2 fun bootstrap() { ArgumentTypes.register("valkyrienskies:ship", @@ -80,7 +79,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( @@ -88,16 +87,7 @@ object VSCommands { try { val r = ShipArgument.getShips(it, "ships").toList() as List<ServerShip> 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 - } - - } + r.forEach { ship -> ship.isStatic = isStatic } it.source.sendVSMessage( TranslatableComponent( SET_SHIP_STATIC_SUCCESS_MESSAGE, r.size, if (isStatic) "true" else "false" @@ -110,7 +100,7 @@ object VSCommands { } }) ) - ) + ).requires { (it as CommandSourceStack).hasPermission(REQUIRED_PERMISSION) } .then( literal("teleport").then( argument("ships", ShipArgument.ships()).then( @@ -269,7 +259,7 @@ object VSCommands { ) ) ) - ) + ).requires { (it as CommandSourceStack).hasPermission(REQUIRED_PERMISSION) } .then(literal("get-ship").executes { try { val mcCommandContext = it as CommandContext<CommandSourceStack> @@ -322,7 +312,7 @@ object VSCommands { } }) ) - ) + ).requires { (it as CommandSourceStack).hasPermission(REQUIRED_PERMISSION) } // Single ship commands .then( literal("ship").then( @@ -360,7 +350,7 @@ object VSCommands { }) ) ) - ) + ).requires { (it as CommandSourceStack).hasPermission(REQUIRED_PERMISSION) } ) dispatcher.root.children.first { it.name == "teleport" }.apply { From 60312f90ce4017935b03ebaf24613f9b5be84bd9 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 10 Oct 2023 04:48:49 -0600 Subject: [PATCH 260/437] Incremented version to 2.1.1-beta.1 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 883a81731..b663cb160 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.0-beta.15 +mod_version=2.1.1-beta.1 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From 9465f525875d16e13608075b1a65e6a2213a378d Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 11 Oct 2023 01:07:45 -0600 Subject: [PATCH 261/437] Added ServerTickListener interface --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index b663cb160..7015ca67e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+7bdba50f69 +vs_core_version=1.1.0+8a93383ce5 # 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 8b4f026cb39811fc5ff28f9c33c200a5a32e0949 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 11 Oct 2023 01:57:37 -0600 Subject: [PATCH 262/437] Use kotlinforforge 3.12.0 at runtime --- forge/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge/build.gradle b/forge/build.gradle index ee802c3d9..13a0b302c 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -79,7 +79,7 @@ dependencies { //modImplementation("curse.maven:markdownmanual-502485:3738124") // Add Kotlin for Forge. - forgeRuntimeLibrary('curse.maven:kotlinforforge-351264:3925887') + forgeRuntimeLibrary("thedarkcolour:kotlinforforge:3.12.0") // Cloth for config include(modImplementation("me.shedaniel.cloth:cloth-config-forge:6.3.81")) From 9445389ac19eed4f9bc0afab7485572313c6c1b6 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 11 Oct 2023 02:17:55 -0600 Subject: [PATCH 263/437] Get kotlinforforge from curse maven instead --- forge/build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index 13a0b302c..dbe555bbe 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -78,8 +78,8 @@ dependencies { //modImplementation("curse.maven:tis3d-238603:3738437") //modImplementation("curse.maven:markdownmanual-502485:3738124") - // Add Kotlin for Forge. - forgeRuntimeLibrary("thedarkcolour:kotlinforforge:3.12.0") + // Add Kotlin for Forge (3.12.0) + forgeRuntimeLibrary('curse.maven:kotlinforforge-351264:4513187') // Cloth for config include(modImplementation("me.shedaniel.cloth:cloth-config-forge:6.3.81")) From 328c4f4927456fbb04556f956a24acce19bed053 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 11 Oct 2023 03:57:15 -0600 Subject: [PATCH 264/437] =?UTF-8?q?More=20kotlinforforge=20madness!=20?= =?UTF-8?q?=F0=9F=99=84=F0=9F=99=84=F0=9F=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.gradle b/build.gradle index 566b13c1d..988433651 100644 --- a/build.gradle +++ b/build.gradle @@ -87,6 +87,12 @@ subprojects { } catch (UnknownDomainObjectException ignore) {} mavenCentral() + maven { + url "https://cursemaven.com" + content { + includeModule "curse.maven", "kotlinforforge-351264" + } + } maven { name = "Valkyrien Skies Internal" url = project.vs_maven_url ?: 'https://maven.valkyrienskies.org' From 2505880aae1f173dec16415983bb70dbc10a9503 Mon Sep 17 00:00:00 2001 From: rbasamoyai <b33gy0sh@gmail.com> Date: Wed, 11 Oct 2023 22:57:17 -0400 Subject: [PATCH 265/437] =?UTF-8?q?=F0=9F=94=A5=F0=9F=90=9B=20Remove=20out?= =?UTF-8?q?dated=20CBC=20mixin=20MixinAbstractCannonProjectile.java?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MixinAbstractCannonProjectile.java | 47 ------------------- .../valkyrienskies-common.mixins.json | 1 - 2 files changed, 48 deletions(-) delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinAbstractCannonProjectile.java 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 deleted file mode 100644 index 96439c2b4..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create_big_cannons/MixinAbstractCannonProjectile.java +++ /dev/null @@ -1,47 +0,0 @@ -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; -import org.joml.primitives.AABBdc; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Pseudo; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.Ship; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -/** - * 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 { - - @Shadow - protected abstract void clipAndDamage(Vec3 start, Vec3 end); - - @Unique - private void shipClipAndDamage(final Vec3 startInWorld, final Vec3 endInWorld, - final Projectile projectile) { - final AABBdc pathAABB = new AABBd(VectorConversionsMCKt.toJOML(startInWorld), - VectorConversionsMCKt.toJOML(endInWorld)).correctBounds(); - - for (final Ship ship : VSGameUtilsKt.getShipsIntersecting(projectile.level, pathAABB)) { - final Vec3 start = VectorConversionsMCKt.toMinecraft( - ship.getTransform().getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(startInWorld))); - final Vec3 end = VectorConversionsMCKt.toMinecraft( - ship.getTransform().getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(endInWorld))); - clipAndDamage(start, end); - } - } - - @Inject(method = "clipAndDamage", at = @At("HEAD"), remap = false) - protected void vsClipAndDamage(final Vec3 start, final Vec3 end, final CallbackInfo ci) { - shipClipAndDamage(start, end, Projectile.class.cast(this)); - } -} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index bcd3bfed7..2b9bfd0d0 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -51,7 +51,6 @@ "feature.water_in_ships_entity.MixinEntity", "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", From 0d985b3627f0264df482a93555c04f9721f6b885 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 11 Oct 2023 21:23:42 -0600 Subject: [PATCH 266/437] Increment version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 7015ca67e..297ee069a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.1-beta.1 +mod_version=2.1.1-beta.2 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From e225187eb3b7ad494de84456708ed03d6fe0125e Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 11 Oct 2023 21:27:58 -0600 Subject: [PATCH 267/437] Increment version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 297ee069a..6ff30fd2a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.1-beta.2 +mod_version=2.1.1-beta.3 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 From abe814eff64d3e83189a3fe50153ea2de47a0f5a Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 11 Oct 2023 22:30:57 -0600 Subject: [PATCH 268/437] Added some change logs --- changelogs/2.1.1-beta.1.md | 13 +++++++++++++ changelogs/2.1.1-beta.2.md | 5 +++++ 2 files changed, 18 insertions(+) create mode 100644 changelogs/2.1.1-beta.1.md create mode 100644 changelogs/2.1.1-beta.2.md diff --git a/changelogs/2.1.1-beta.1.md b/changelogs/2.1.1-beta.1.md new file mode 100644 index 000000000..ff52e1b6d --- /dev/null +++ b/changelogs/2.1.1-beta.1.md @@ -0,0 +1,13 @@ +# New Features +* LOD that adds collision shapes for stairs/slabs/ect, and adds friction/elasticity/density properties to blocks +* Multithreaded Krunch physics engine +* Multithreaded terrain loading (so physics doesn't lag from terrain loading) +* Allow ships to travel through Nether and End portals +* Allow ships to be teleported between dimensions +* Added physics entity support (currently only used to make balls with the Physics Entity Creator Item, but more coming soon 🙂) + +# Bugfixes +* Fixed ships randomly getting stuck in the air +* Fixed scaled ships not behaving correctly in water +* Fixed the @v command argument to behave correctly like the @e argument +* Fixed Ship Creator Item not scaling ships correctly diff --git a/changelogs/2.1.1-beta.2.md b/changelogs/2.1.1-beta.2.md new file mode 100644 index 000000000..8073deae6 --- /dev/null +++ b/changelogs/2.1.1-beta.2.md @@ -0,0 +1,5 @@ +# New Features +Nothing + +# Bugfixes +* Removed old CBC mixin that doesn't work on new versions From babd2876bd736efd060eaa4f8a7c48f219b1edb4 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 15 Oct 2023 04:17:53 -0600 Subject: [PATCH 269/437] Don't create render chunks for air sections --- .../vanilla_renderer/MixinLevelRendererVanilla.java | 8 ++++++++ .../mod_compat/vanilla_renderer/MixinViewAreaVanilla.java | 3 +++ 2 files changed, 11 insertions(+) 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..20b33b254 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 @@ -27,6 +27,8 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Vec3i; import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.chunk.LevelChunkSection; import org.jetbrains.annotations.Nullable; import org.joml.Vector3dc; import org.spongepowered.asm.mixin.Final; @@ -122,7 +124,13 @@ private void addShipVisibleChunks( } shipObject.getActiveChunksSet().forEach((x, z) -> { + final ChunkAccess chunk = level.getChunk(x, z); for (int y = level.getMinSection(); y < level.getMaxSection(); y++) { + final LevelChunkSection levelChunkSection = chunk.getSection(y - level.getMinSection()); + if (levelChunkSection.hasOnlyAir()) { + // Skip air sections + continue; + } tempPos.set(x << 4, y << 4, z << 4); final ChunkRenderDispatcher.RenderChunk renderChunk = chunkStorageAccessor.callGetRenderChunkAt(tempPos); 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..104e4db9f 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 @@ -14,6 +14,7 @@ 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; @@ -35,9 +36,11 @@ public class MixinViewAreaVanilla implements IVSViewAreaMethods { protected int chunkGridSizeY; // Maps chunk position to an array of BuiltChunk, indexed by the y value. + @Unique private final Long2ObjectMap<ChunkRenderDispatcher.RenderChunk[]> vs$shipRenderChunks = new Long2ObjectOpenHashMap<>(); // This creates render chunks + @Unique private ChunkRenderDispatcher vs$chunkBuilder; /** From 4861dfb2107eb2665873e998c69c650eeb268781 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 15 Oct 2023 05:01:59 -0600 Subject: [PATCH 270/437] Fix mounted players teleported to void when ship is destroyed #601 --- .../mod/common/entity/ShipMountingEntity.kt | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) 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..f8a64660f 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 @@ -6,19 +6,23 @@ import net.minecraft.network.protocol.Packet 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 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.getShipObjectEntityMountedTo import org.valkyrienskies.mod.common.getShipObjectManagingPos +import org.valkyrienskies.mod.common.isBlockInShipyard import org.valkyrienskies.mod.common.networking.PacketPlayerDriving open class ShipMountingEntity(type: EntityType<ShipMountingEntity>, level: Level) : Entity(type, level) { - - // Decides if this entity controlls the ship it is in. + // Decides if this entity controls the ship it is in. // Only needs to be set serverside var isController = false @@ -37,18 +41,36 @@ open class ShipMountingEntity(type: EntityType<ShipMountingEntity>, level: Level return } - if (level.getShipObjectManagingPos(blockPosition()!!) != null) + if (level.getShipObjectManagingPos(blockPosition()) != null) sendDrivingPacket() } - override fun readAdditionalSaveData(compound: CompoundTag?) { + // 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) { + // Stop rider positioning if we can't find the ship + entity.removeVehicle() + return + } + super.positionRider(entity) } - override fun addAdditionalSaveData(compound: CompoundTag?) { + // 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) { + // Don't teleport to the ship if we can't find the ship + return livingEntity.position() + } + return super.getDismountLocationForPassenger(livingEntity) } - override fun defineSynchedData() { - } + override fun readAdditionalSaveData(compound: CompoundTag) {} + + override fun addAdditionalSaveData(compound: CompoundTag) {} + + override fun defineSynchedData() {} override fun remove(removalReason: RemovalReason) { if (this.isController && !level.isClientSide) From 14196466723a15e56dfc1d70bc8ba3934befeee3 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 15 Oct 2023 05:02:19 -0600 Subject: [PATCH 271/437] Removed unused import --- .../org/valkyrienskies/mod/common/entity/ShipMountingEntity.kt | 1 - 1 file changed, 1 deletion(-) 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 f8a64660f..fb62268ca 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 @@ -16,7 +16,6 @@ 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.getShipObjectEntityMountedTo import org.valkyrienskies.mod.common.getShipObjectManagingPos import org.valkyrienskies.mod.common.isBlockInShipyard import org.valkyrienskies.mod.common.networking.PacketPlayerDriving From 247fdeead884164ed95240c77a14739a9f86cda2 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 15 Oct 2023 17:20:51 -0600 Subject: [PATCH 272/437] Updated vs-core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 6ff30fd2a..07c2cf0b1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+8a93383ce5 +vs_core_version=1.1.0+665c0ce908 # 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 2139deb31b8ce44da760d61d33de7eaf3f469e76 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 16 Oct 2023 04:49:31 -0600 Subject: [PATCH 273/437] Fixed PhysShip.transform scaling --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 07c2cf0b1..b30b56fff 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 create_fabric_version=0.5.0.i-934+1.18.2 -vs_core_version=1.1.0+665c0ce908 +vs_core_version=1.1.0+00bb578f02 # 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 33e03c54697125531e2ffe114bd61a828ce3c618 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 16 Oct 2023 05:30:39 -0600 Subject: [PATCH 274/437] Updated create to 0.5.1 --- common/build.gradle | 2 +- .../MixinPitchOrientedContraptionEntity.java | 3 +-- fabric/build.gradle | 6 ++++-- fabric/gradle.properties | 3 +-- .../mixin/compat/create/MixinAbstractContraptionEntity.java | 4 ++-- .../fabric/common/ContraptionShipyardEntityHandlerFabric.kt | 2 +- forge/gradle.properties | 4 ++-- .../mixin/compat/create/MixinAbstractContraptionEntity.java | 4 ++-- gradle.properties | 3 ++- 9 files changed, 16 insertions(+), 15 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index 419913a26..1f090cb92 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -28,7 +28,7 @@ dependencies { //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-33") + modCompileOnly("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version_fabric}") modCompileOnly("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") } 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..cd97ecbcc 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,6 +1,6 @@ package org.valkyrienskies.mod.mixin.mod_compat.create_big_cannons; -import com.simibubi.create.content.contraptions.components.structureMovement.OrientedContraptionEntity; +import com.simibubi.create.content.contraptions.OrientedContraptionEntity; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -18,7 +18,6 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - @Pseudo @Mixin(targets = "rbasamoyai.createbigcannons.cannon_control.contraption.PitchOrientedContraptionEntity") public abstract class MixinPitchOrientedContraptionEntity extends OrientedContraptionEntity { diff --git a/fabric/build.gradle b/fabric/build.gradle index 1ede824c8..06289659f 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -64,8 +64,10 @@ dependencies { modImplementation("curse.maven:cc-restitched-462672:3838648") // 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.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}") { + exclude group: 'com.github.AlphaMode', module: 'fakeconfigtoml' + } + modImplementation("com.jozufozu.flywheel:flywheel-fabric-${minecraft_version}:${flywheel_version_fabric}") modImplementation("com.tterrag.registrate_fabric:Registrate:${registrate_version}") modImplementation("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") modImplementation("me.alphamode:ForgeTags:${forge_tags_version}") diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 7973021b4..625cddbde 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -1,11 +1,10 @@ loader_platform=Fabric -create_version=0.5.0g-821 +create_version=0.5.1-c-build.1092+mc1.18.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 # 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 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..0b3f26275 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,6 +1,6 @@ package org.valkyrienskies.mod.fabric.mixin.compat.create; -import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; @@ -42,7 +42,7 @@ public void setWingGroupId(final int wingGroupId) { private void postTick(final CallbackInfo ci) { final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); final Level level = thisAsAbstractContraptionEntity.level; - if (wingGroupId != -1 && level instanceof ServerLevel serverLevel) { + if (wingGroupId != -1 && level instanceof final ServerLevel serverLevel) { final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(serverLevel, VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); if (ship != null) { 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..81b8f43ac 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,6 +1,6 @@ package org.valkyrienskies.mod.fabric.common -import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity +import com.simibubi.create.content.contraptions.AbstractContraptionEntity import net.minecraft.core.BlockPos import net.minecraft.world.entity.Entity import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate diff --git a/forge/gradle.properties b/forge/gradle.properties index d19154fc0..56f246d1f 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 +create_version=0.5.1.e-318 +flywheel_version=0.6.10-105 registrate_version=MC1.18.2-1.1.3 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..9a000267a 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,6 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create; -import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.level.Level; import org.jetbrains.annotations.NotNull; @@ -40,7 +40,7 @@ public void setWingGroupId(final int wingGroupId) { private void postTick(final CallbackInfo ci) { final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); final Level level = thisAsAbstractContraptionEntity.level; - if (wingGroupId != -1 && level instanceof ServerLevel serverLevel) { + if (wingGroupId != -1 && level instanceof final ServerLevel serverLevel) { final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(serverLevel, VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); ship.getAttachment(WingManager.class).setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); diff --git a/gradle.properties b/gradle.properties index b30b56fff..bddb97ae1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,8 @@ architectury_version=4.10.86 fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 forge_version=1.18.2-40.1.69 -create_fabric_version=0.5.0.i-934+1.18.2 +create_fabric_version=0.5.1-c-build.1092+mc1.18.2 +flywheel_version_fabric=0.6.9-38 vs_core_version=1.1.0+00bb578f02 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually From f95be0ea26664198b6573784a4a40126cae02d0a Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 16 Oct 2023 06:12:41 -0600 Subject: [PATCH 275/437] Fixed mixins --- .../create/MixinBlockBreakingKineticTileEntity.java | 8 ++++---- .../mod/forge/mixin/compat/create/MixinBlocks.java | 6 +++--- .../compat/create/client/MixinContraptionRenderInfo.java | 8 +++----- .../mixin/compat/create/client/MixinFlwContraption.java | 8 ++++---- .../compat/create/client/MixinScrollValueBehaviour.java | 3 +-- .../forge/mixin/compat/create/client/MixinValueBox.java | 4 +--- .../forge/common/ContraptionShipyardEntityHandlerForge.kt | 2 +- forge/src/main/resources/META-INF/mods.toml | 2 +- gradle.properties | 2 +- 9 files changed, 19 insertions(+), 24 deletions(-) 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..8a926d0fb 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,6 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create; -import com.simibubi.create.content.contraptions.components.actors.BlockBreakingKineticTileEntity; +import com.simibubi.create.content.kinetics.base.BlockBreakingKineticBlockEntity; import net.minecraft.core.BlockPos; import net.minecraft.world.level.ClipContext; import net.minecraft.world.phys.BlockHitResult; @@ -14,7 +14,7 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -@Mixin(BlockBreakingKineticTileEntity.class) +@Mixin(BlockBreakingKineticBlockEntity.class) public abstract class MixinBlockBreakingKineticTileEntity { @Shadow @@ -24,10 +24,10 @@ public abstract class MixinBlockBreakingKineticTileEntity { method = "tick", at = @At( value = "INVOKE", - target = "Lcom/simibubi/create/content/contraptions/components/actors/BlockBreakingKineticTileEntity;getBreakingPos()Lnet/minecraft/core/BlockPos;" + target = "Lcom/simibubi/create/content/kinetics/base/BlockBreakingKineticBlockEntity;getBreakingPos()Lnet/minecraft/core/BlockPos;" ), remap = false ) - private BlockPos getBreakingBlockPos(final BlockBreakingKineticTileEntity self) { + private BlockPos getBreakingBlockPos(final BlockBreakingKineticBlockEntity self) { final BlockPos orig = this.getBreakingPos(); final Vec3 origin; final Vec3 target; 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..685ee1b7c 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,8 +1,8 @@ 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; +import com.simibubi.create.content.kinetics.millstone.MillstoneBlock; +import com.simibubi.create.content.logistics.chute.AbstractChuteBlock; +import com.simibubi.create.content.processing.basin.BasinBlock; import java.util.Iterator; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; 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..8dc7af3b2 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,7 +1,7 @@ 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 com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.world.phys.AABB; import org.spongepowered.asm.mixin.Mixin; @@ -11,11 +11,10 @@ @Mixin(ContraptionRenderInfo.class) public class MixinContraptionRenderInfo { - @Redirect( at = @At( value = "INVOKE", - target = "Lcom/simibubi/create/content/contraptions/components/structureMovement/AbstractContraptionEntity;getBoundingBoxForCulling()Lnet/minecraft/world/phys/AABB;" + target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBoxForCulling()Lnet/minecraft/world/phys/AABB;" ), method = "beginFrame" ) @@ -24,4 +23,3 @@ 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..e96a27a1d 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 @@ -2,10 +2,10 @@ import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; import com.mojang.math.Matrix4f; -import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; -import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionRenderInfo; -import com.simibubi.create.content.contraptions.components.structureMovement.render.FlwContraption; +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.Contraption; +import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; +import com.simibubi.create.content.contraptions.render.FlwContraption; import net.minecraft.util.Mth; import net.minecraft.world.phys.AABB; import org.spongepowered.asm.mixin.Mixin; 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..dd4cc0125 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,6 +1,6 @@ package org.valkyrienskies.mod.forge.mixin.compat.create.client; -import com.simibubi.create.foundation.tileEntity.behaviour.scrollvalue.ScrollValueBehaviour; +import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; import net.minecraft.client.Minecraft; import net.minecraft.world.phys.Vec3; import org.spongepowered.asm.mixin.Mixin; @@ -22,5 +22,4 @@ private Vec3 transformHitToShip(final Vec3 hitPos, final Vec3 blockPos) { final Vec3 inShipHit = VSGameUtilsKt.toShipRenderCoordinates(Minecraft.getInstance().level, blockPos, hitPos); return inShipHit.subtract(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..cf0f8f2bb 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,7 +1,7 @@ package org.valkyrienskies.mod.forge.mixin.compat.create.client; import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.foundation.tileEntity.behaviour.ValueBox; +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; @@ -9,7 +9,6 @@ @Mixin(ValueBox.class) public class MixinValueBox { - @Redirect( method = "render", at = @At( @@ -21,5 +20,4 @@ public class MixinValueBox { 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/kotlin/org/valkyrienskies/mod/forge/common/ContraptionShipyardEntityHandlerForge.kt b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ContraptionShipyardEntityHandlerForge.kt index 531be51eb..2770a0b09 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,6 +1,6 @@ package org.valkyrienskies.mod.forge.common -import com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity +import com.simibubi.create.content.contraptions.AbstractContraptionEntity import net.minecraft.core.BlockPos import net.minecraft.world.entity.Entity import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate diff --git a/forge/src/main/resources/META-INF/mods.toml b/forge/src/main/resources/META-INF/mods.toml index 58b0a0433..d66740e54 100644 --- a/forge/src/main/resources/META-INF/mods.toml +++ b/forge/src/main/resources/META-INF/mods.toml @@ -16,7 +16,7 @@ logoFile = "icon.png" [[dependencies.valkyrienskies]] modId = "forge" mandatory = true -versionRange = "[40.1.69,)" +versionRange = "[40.2.4,)" ordering = "NONE" side = "BOTH" diff --git a/gradle.properties b/gradle.properties index bddb97ae1..552d2dd3b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.10 fabric_api_version=0.59.0+1.18.2 -forge_version=1.18.2-40.1.69 +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 vs_core_version=1.1.0+00bb578f02 From ba648814dde501e4e36e611ab6bc6494a59e139b Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 16 Oct 2023 06:26:57 -0600 Subject: [PATCH 276/437] Fixed wings not working on contraptions --- .../main/kotlin/org/valkyrienskies/mod/compat/CreateCompat.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateCompat.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateCompat.kt index 150308810..bb880bf56 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateCompat.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateCompat.kt @@ -5,7 +5,7 @@ import net.minecraft.world.entity.Entity object CreateCompat { private val contraptionClass = runCatching { - Class.forName("com.simibubi.create.content.contraptions.components.structureMovement.AbstractContraptionEntity") + Class.forName("com.simibubi.create.content.contraptions.AbstractContraptionEntity") }.getOrNull() @JvmStatic From dad25fc3b483b819ecf9b61800ba27f80f754a51 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 16 Oct 2023 07:48:33 -0600 Subject: [PATCH 277/437] Initial work moving create compat mixins --- build.gradle | 6 + common/build.gradle | 2 + .../create/IMixinDeployerHandler.java | 18 + .../IMixinDeployerMovementBehaviour.java | 12 + .../mod_compat/create/MixinAirCurrent.java | 152 +++++++ .../create/MixinAirFlowParticle.java | 85 ++++ .../create/MixinBeltMovementHandler.java | 148 ++++++ .../mod_compat/create/MixinContraption.java | 26 ++ .../create/MixinContraptionCollider.java | 342 ++++++++++++++ .../create/MixinEntityLauncher.java | 51 +++ .../MixinRedstoneLinkNetworkHandler.java | 51 +++ .../create/MixinSharedDepotBlockMethods.java | 28 ++ .../accessors/OutlineParamsAccessor.java | 22 + .../MixinBlockBreakingMovementBehaviour.java | 61 +++ .../behaviour/MixinFilteringBehaviour.java | 43 ++ .../create/behaviour/MixinLinkBehaviour.java | 43 ++ .../behaviour/MixinScrollValueBehaviour.java | 45 ++ .../MixinSidedFilteringBehaviour.java | 39 ++ .../create/block/MixinCrushingWheelBlock.java | 81 ++++ .../create/block/MixinEjectorBlock.java | 53 +++ .../block/MixinRedstoneContactBlock.java | 132 ++++++ .../create/block/MixinStickerBlock.java | 41 ++ .../IMixinMechanicalBearingTileEntity.java | 10 + ...ixinCrushingWheelControllerTileEntity.java | 114 +++++ .../blockentity/MixinEjectorTileEntity.java | 69 +++ .../MixinEncasedFanTileEntity.java | 35 ++ .../create/cannons/MixinCannonMount.java | 151 +++++++ .../create/client/MixinAABBOutline.java | 76 ++++ .../client/MixinBlockClusterOutline.java | 152 +++++++ .../MixinCarriageContraptionInstance.java | 66 +++ .../create/client/MixinCogwheelBlockItem.java | 37 ++ .../MixinCogwheelBlockItemHitOnShaft.java | 33 ++ .../client/MixinContraptionHandlerClient.java | 58 +++ .../MixinContraptionRenderDispatcher.java | 26 ++ .../client/MixinContraptionRenderInfo.java | 53 +++ .../create/client/MixinFilteringRenderer.java | 31 ++ .../client/MixinGhostBlockRenderer.java | 21 + .../create/client/MixinLinkRenderer.java | 21 + .../create/client/MixinMinecartInstance.java | 59 +++ .../client/MixinMultiplePlacementHelpers.java | 48 ++ .../MixinOrientedContraptionEntity.java | 66 +++ .../create/client/MixinOutline.java | 421 ++++++++++++++++++ .../create/client/MixinPlacementHelpers.java | 30 ++ .../create/client/MixinSoundScapes.java | 43 ++ .../client/MixinTileEntityRenderHelper.java | 25 ++ .../create/client/MixinTrackBlockOutline.java | 84 ++++ .../create/client/MixinTrainRelocator.java | 27 ++ .../MixinAbstractContraptionEntity.java | 259 +++++++++++ .../MixinCarriageContraptionEntity.java | 50 +++ .../MixinControlledContraptionEntity.java | 49 ++ .../create/entity/MixinSeatEntity.java | 44 ++ .../packets/MixinControlsInputPacket.java | 47 ++ .../MixinCurvedTrackDestroyPacket.java | 49 ++ .../packets/MixinSuperGlueRemovalPacket.java | 28 ++ .../MixinTileEntityConfigurationPacket.java | 48 ++ .../packets/MixinTrainRelocationPacket.java | 34 ++ .../mod_compat/create/pr/MixinSeatBlock.java | 30 ++ .../mod_compat/create/CWCluster.java | 73 +++ .../mod_compat/create/CWMergeEntry.java | 32 ++ .../create/IExtendedAirCurrentSource.java | 10 + .../IMixinControlledContraptionEntity.java | 7 + .../create/IMixinStickerTileEntity.java | 6 + .../MixinAbstractContraptionEntityDuck.java | 8 + .../valkyrienskies/mod/common/CompatUtil.kt | 41 ++ .../valkyrienskies-common.mixins.json | 34 ++ gradle.properties | 5 +- 66 files changed, 4089 insertions(+), 2 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerHandler.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerMovementBehaviour.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirFlowParticle.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinBeltMovementHandler.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraption.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraptionCollider.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinEntityLauncher.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinRedstoneLinkNetworkHandler.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinSharedDepotBlockMethods.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/OutlineParamsAccessor.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinBlockBreakingMovementBehaviour.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinFilteringBehaviour.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinLinkBehaviour.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinScrollValueBehaviour.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinSidedFilteringBehaviour.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinCrushingWheelBlock.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinEjectorBlock.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinRedstoneContactBlock.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinStickerBlock.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/IMixinMechanicalBearingTileEntity.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinCrushingWheelControllerTileEntity.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEjectorTileEntity.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEncasedFanTileEntity.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/cannons/MixinCannonMount.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinAABBOutline.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinBlockClusterOutline.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCarriageContraptionInstance.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItem.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItemHitOnShaft.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionHandlerClient.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderDispatcher.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderInfo.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinFilteringRenderer.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinGhostBlockRenderer.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinLinkRenderer.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMinecartInstance.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMultiplePlacementHelpers.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOrientedContraptionEntity.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOutline.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinPlacementHelpers.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSoundScapes.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTileEntityRenderHelper.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrainRelocator.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinAbstractContraptionEntity.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinCarriageContraptionEntity.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinControlledContraptionEntity.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinSeatEntity.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinControlsInputPacket.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinCurvedTrackDestroyPacket.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinSuperGlueRemovalPacket.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTileEntityConfigurationPacket.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTrainRelocationPacket.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/pr/MixinSeatBlock.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWCluster.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWMergeEntry.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IExtendedAirCurrentSource.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinControlledContraptionEntity.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinStickerTileEntity.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuck.java create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/CompatUtil.kt diff --git a/build.gradle b/build.gradle index 988433651..58eff658a 100644 --- a/build.gradle +++ b/build.gradle @@ -126,6 +126,12 @@ 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://maven.realrobotix.me/createbigcannons/" // Create Big Cannons + content { + includeGroup "com.rbasamoyai" + } + } } } diff --git a/common/build.gradle b/common/build.gradle index 1f090cb92..349552ef0 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -28,8 +28,10 @@ dependencies { //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("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}") } architectury { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerHandler.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerHandler.java new file mode 100644 index 000000000..5cbe5475b --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerHandler.java @@ -0,0 +1,18 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create; + +import com.simibubi.create.content.kinetics.deployer.DeployerHandler; +import javax.annotation.Nullable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(DeployerHandler.class) +public interface IMixinDeployerHandler { + @Invoker("shouldActivate") + static boolean invokeShouldActivate(ItemStack held, Level world, BlockPos targetPos, @Nullable Direction facing){ + throw new AssertionError(); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerMovementBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerMovementBehaviour.java new file mode 100644 index 000000000..821f697ea --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/IMixinDeployerMovementBehaviour.java @@ -0,0 +1,12 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create; + +import com.simibubi.create.content.contraptions.behaviour.MovementContext; +import com.simibubi.create.content.kinetics.deployer.DeployerMovementBehaviour; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Invoker; + +@Mixin(DeployerMovementBehaviour.class) +public interface IMixinDeployerMovementBehaviour { + @Invoker("tryGrabbingItem") + void invokeTryGrabbingItem(MovementContext movementContext); +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java new file mode 100644 index 000000000..52f9d86f8 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java @@ -0,0 +1,152 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create; + +import com.simibubi.create.content.kinetics.fan.AirCurrent; +import com.simibubi.create.content.kinetics.fan.IAirCurrentSource; +import com.simibubi.create.foundation.utility.VecHelper; +import java.util.Iterator; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Vec3i; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.joml.primitives.AABBd; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import org.valkyrienskies.mod.common.world.RaycastUtilsKt; +import org.valkyrienskies.mod.mixinducks.mod_compat.create.IExtendedAirCurrentSource; + +@Mixin(AirCurrent.class) +public abstract class MixinAirCurrent { + + @Unique + private final float maxAcceleration = 5; + @Shadow + @Final + public IAirCurrentSource source; + @Unique + private Vec3 transformedFlow = Vec3.ZERO; + @Unique + private float acceleration; + + @Unique + private Ship getShip() { + if (source instanceof IExtendedAirCurrentSource se) + return se.getShip(); + else if (source.getAirCurrentWorld() != null) + return VSGameUtilsKt.getShipManagingPos(source.getAirCurrentWorld(), source.getAirCurrentPos()); + else + return null; + } + + @Inject(method = "getFlowLimit", at = @At("HEAD"), cancellable = true) + private static void clipFlowLimit(Level level, BlockPos start, float max, Direction facing, CallbackInfoReturnable<Float> cir) { + Ship ship = VSGameUtilsKt.getShipManagingPos(level, start); + if (ship != null) { + Vector3d startVec = ship.getTransform().getShipToWorld().transformPosition(new Vector3d(start.getX() + 0.5, start.getY() + 0.5, start.getZ() + 0.5)); + Vector3d direction = ship.getTransform().getShipToWorld().transformDirection(VectorConversionsMCKt.toJOMLD(facing.getNormal())); + startVec.add(direction.x, direction.y, direction.z); + direction.mul(max); + Vec3 mcStart = VectorConversionsMCKt.toMinecraft(startVec); + BlockHitResult result = RaycastUtilsKt.clipIncludeShips(level, + new ClipContext( + mcStart, + VectorConversionsMCKt.toMinecraft(startVec.add(direction.x, direction.y, direction.z)), + ClipContext.Block.OUTLINE, + ClipContext.Fluid.NONE, + null)); + + // Distance from start to end but, its not squared so, slow -_- + cir.setReturnValue((float) result.getLocation().distanceTo(mcStart)); + } else { + BlockPos end = start.relative(facing, (int) max); + if (VSGameUtilsKt.getShipsIntersecting(level, + new AABB(start.getX(), start.getY(), start.getZ(), + end.getX() + 1.0, end.getY() + 1.0, end.getZ() + 1.0)).iterator().hasNext()) { + Vec3 centerStart = Vec3.atCenterOf(start); + BlockHitResult result = RaycastUtilsKt.clipIncludeShips(level, + new ClipContext( + centerStart.add(facing.getStepX(), facing.getStepY(), facing.getStepZ()), + Vec3.atCenterOf(end), + ClipContext.Block.OUTLINE, + ClipContext.Fluid.NONE, + null)); + + // Distance from start to end but, its not squared so, slow -_- + cir.setReturnValue((float) result.getLocation().distanceTo(centerStart)); + } + } + } + + @Redirect(method = "tickAffectedEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;intersects(Lnet/minecraft/world/phys/AABB;)Z")) + private boolean redirectIntersects(AABB instance, AABB other) { + Ship ship = getShip(); + if (ship != null) { + AABBd thisAABB = VectorConversionsMCKt.toJOML(instance); + thisAABB.transform(ship.getWorldToShip()); + return other.intersects(thisAABB.minX, thisAABB.minY, thisAABB.minZ, thisAABB.maxX, thisAABB.maxY, thisAABB.maxZ); + } else return instance.intersects(other); + } + + @Inject( + method = "tickAffectedEntities", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;" + ), + locals = LocalCapture.CAPTURE_FAILHARD + ) + private void harvester(Level world, Direction facing, CallbackInfo ci, Iterator<Entity> iterator, Entity entity, Vec3 center, Vec3i flow, float sneakModifier, float speed, double entityDistance, float acceleration) { + Ship ship = getShip(); + if (ship != null) { + Vector3d tempVec = new Vector3d(); + ship.getTransform().getShipToWorld().transformDirection(flow.getX(), flow.getY(), flow.getZ(), tempVec); + transformedFlow = VectorConversionsMCKt.toMinecraft(tempVec); + } + this.acceleration = acceleration; + } + + @Redirect(method = "tickAffectedEntities", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V") + ) + private void redirectSetDeltaMovement(Entity instance, Vec3 motion) { + Ship ship = getShip(); + if (ship != null) { + Vec3 previousMotion = instance.getDeltaMovement(); + double xIn = Mth.clamp(transformedFlow.x * acceleration - previousMotion.x, -maxAcceleration, maxAcceleration); + double yIn = Mth.clamp(transformedFlow.y * acceleration - previousMotion.y, -maxAcceleration, maxAcceleration); + double zIn = Mth.clamp(transformedFlow.z * acceleration - previousMotion.z, -maxAcceleration, maxAcceleration); + instance.setDeltaMovement(previousMotion.add(new Vec3(xIn, yIn, zIn).scale(1 / 8f))); + } else { + instance.setDeltaMovement(motion); + } + } + + @Redirect(method = "tickAffectedEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/VecHelper;getCenterOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;"), allow = 1) + private Vec3 redirectGetCenterOf(Vec3i pos) { + Ship ship = getShip(); + Vec3 result = VecHelper.getCenterOf(pos); + if (ship != null && this.source.getAirCurrentWorld() != null) { + Vector3d tempVec = new Vector3d(); + ship.getTransform().getShipToWorld().transformPosition(result.x, result.y, result.z, tempVec); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + return result; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirFlowParticle.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirFlowParticle.java new file mode 100644 index 000000000..623e7196c --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirFlowParticle.java @@ -0,0 +1,85 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create; + +import com.simibubi.create.content.kinetics.fan.AirCurrent; +import com.simibubi.create.content.kinetics.fan.AirFlowParticle; +import com.simibubi.create.content.kinetics.fan.IAirCurrentSource; +import com.simibubi.create.foundation.utility.VecHelper; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.client.particle.SimpleAnimatedParticle; +import net.minecraft.client.particle.SpriteSet; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import org.valkyrienskies.mod.mixinducks.mod_compat.create.IExtendedAirCurrentSource; + +@Mixin(AirFlowParticle.class) +public abstract class MixinAirFlowParticle extends SimpleAnimatedParticle { + + @Shadow + @Final + private IAirCurrentSource source; + + protected MixinAirFlowParticle(ClientLevel level, double x, double y, double z, SpriteSet sprites, float gravity) { + super(level, x, y, z, sprites, gravity); + } + + @Unique + private Ship getShip() { + if (source instanceof IExtendedAirCurrentSource se) + return se.getShip(); + else if (source.getAirCurrentWorld() != null) + return VSGameUtilsKt.getShipManagingPos(source.getAirCurrentWorld(), source.getAirCurrentPos()); + else + return null; + } + + @Redirect(method = "tick", at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/phys/AABB;contains(DDD)Z" + )) + private boolean redirectBounds(AABB instance, double x, double y, double z) { + AirCurrent current = source.getAirCurrent(); + Level level = source.getAirCurrentWorld(); + if (current != null && level != null) { + return VSGameUtilsKt.transformAabbToWorld(level, instance).contains(x, y, z); + } + + return instance.contains(x, y, z); + } + + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/VecHelper;getCenterOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;"), allow = 1) + private Vec3 redirectGetCenterOf(Vec3i pos) { + Ship ship = getShip(); + Vec3 result = VecHelper.getCenterOf(pos); + if (ship != null) { + Vector3d tempVec = new Vector3d(); + ship.getTransform().getShipToWorld().transformPosition(result.x, result.y, result.z, tempVec); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + return result; + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;atLowerCornerOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;"), allow = 1) + private Vec3 redirectToLowerCorner(Vec3i pos) { + Vec3 result = Vec3.atLowerCornerOf(pos); + Ship ship = getShip(); + if (ship != null) { + Vector3d tempVec = new Vector3d(); + ship.getTransform().getShipToWorld().transformDirection(result.x, result.y, result.z, tempVec); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + return result; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinBeltMovementHandler.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinBeltMovementHandler.java new file mode 100644 index 000000000..5ec2e0c3e --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinBeltMovementHandler.java @@ -0,0 +1,148 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create; + +import com.simibubi.create.content.kinetics.belt.BeltBlockEntity; +import com.simibubi.create.content.kinetics.belt.transport.BeltMovementHandler; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.core.Vec3i; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.MoverType; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.joml.Quaterniond; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(BeltMovementHandler.class) +public abstract class MixinBeltMovementHandler { + + @Unique + private static Vector3d blockPos; + + @Unique + private static Level level; + + @Unique + private static Ship ship; + + @Unique + private static Direction.Axis axis; + + @Unique + private static Entity entity; + + @Inject(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/Direction;fromAxisAndDirection(Lnet/minecraft/core/Direction$Axis;Lnet/minecraft/core/Direction$AxisDirection;)Lnet/minecraft/core/Direction;"), locals = LocalCapture.CAPTURE_FAILHARD) + private static void injectHead(BeltBlockEntity beltTe, Entity entityIn, BeltMovementHandler.TransportedEntityInfo info, CallbackInfo ci, BlockPos pos) { + blockPos = VectorConversionsMCKt.toJOMLD(pos); + entity = entityIn; + level = beltTe.getLevel(); + if (level != null) { + ship = VSGameUtilsKt.getShipManagingPos(level, blockPos); + } + } + + @ModifyVariable(method = "transportEntity", at = @At(value = "STORE"), name = "axis") + private static Direction.Axis injectHarvestAxis(Direction.Axis value) { + axis = value; + return value; + } + + @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V", ordinal = 2)) + private static void redirectMove1(Entity instance, MoverType type, Vec3 pos) { + if (ship != null) { + instance.move(type, new Vec3(pos.x * 3, 0.2, pos.z * 3)); + } else + instance.move(type, pos); + } + + @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;move(Lnet/minecraft/world/entity/MoverType;Lnet/minecraft/world/phys/Vec3;)V", ordinal = 1)) + private static void redirectMove2(Entity instance, MoverType type, Vec3 pos) { + if (ship != null) { + instance.move(type, new Vec3(pos.x * 3, 0, pos.z * 3)); + } else + instance.move(type, pos); + } + + @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/Direction$Axis;choose(DDD)D")) + private static double redirectChoose(Direction.Axis instance, double x, double y, double z) { + if (ship != null) { + Vec3 mul = new Vec3(0, 0, 0); + if (instance == Direction.Axis.X) { + mul = redirectGetNormal(new Vec3i(1, 0, 0)); + } + if (instance == Direction.Axis.Y) { + mul = redirectGetNormal(new Vec3i(0, 1, 0)); + } + if (instance == Direction.Axis.Z) { + mul = redirectGetNormal(new Vec3i(0, 0, 1)); + } + return Math.abs(x * mul.x) + Math.abs(y * mul.y) + Math.abs(z * mul.z); + } + return instance.choose(x, y, z); + } + + @ModifyVariable(method = "transportEntity", at = @At(value = "STORE"), name = "diffCenter") + private static double modDiffCenter(double value) { + //if (ship != null) value = value + Math.copySign(value) ); + return axis == Direction.Axis.Z ? (blockPos.x + .5 - getPos(entity).x) : (blockPos.z + .5 - getPos(entity).z); + } + + @Redirect( + method = "transportEntity", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;atLowerCornerOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;" + ) + ) + private static Vec3 redirectGetNormal(Vec3i toCopy) { + Vec3 result = Vec3.atLowerCornerOf(toCopy); + if (level != null) { + if (ship != null) { + Vector3d tempVec = VectorConversionsMCKt.toJOML(result); + Quaterniond tempQuat = new Quaterniond(); + ship.getTransform().getShipToWorld().getNormalizedRotation(tempQuat); + tempVec.rotate(tempQuat); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + } + return result; + } + + @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getX()D")) + private static double redirectGetX(Entity instance) { + return getPos(instance).x; + } + + @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getY()D")) + private static double redirectGetY(Entity instance) { + return getPos(instance).y; + } + + @Redirect(method = "transportEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getZ()D")) + private static double redirectGetZ(Entity instance) { + return getPos(instance).z; + } + + @Unique + private static Vec3 getPos(Entity entity) { + Vec3 result = entity.position(); + if (level != null) { + if (ship != null) { + Vector3d tempVec = VectorConversionsMCKt.toJOML(result); + ship.getTransform().getWorldToShip().transformPosition(tempVec); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + } + return result; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraption.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraption.java new file mode 100644 index 000000000..bd6125806 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraption.java @@ -0,0 +1,26 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create; + +import com.simibubi.create.content.contraptions.Contraption; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(Contraption.class) +public class MixinContraption { + @Redirect(method = "onEntityCreated", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z")) + private boolean wrapOp(Level level, Entity entity) { + // BlockPos anchor = blockFace.getConnectedPos(); + // movedContraption.setPos(anchor.getX() + .5f, anchor.getY(), anchor.getZ() + .5f); + // + // Derive anchor from the code above + final BlockPos anchor = new BlockPos((int) Math.floor(entity.getX()), (int) Math.floor(entity.getY()), (int) Math.floor(entity.getZ())); + boolean added = level.addFreshEntity(entity); + if (added) { + entity.moveTo(anchor.getX() + .5, anchor.getY(), anchor.getZ() + .5); + } + return added; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraptionCollider.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraptionCollider.java new file mode 100644 index 000000000..2b8910713 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinContraptionCollider.java @@ -0,0 +1,342 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create; + +import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; +import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toMinecraft; + +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.ContraptionCollider; +import com.simibubi.create.foundation.collision.Matrix3d; +import com.simibubi.create.foundation.utility.VecHelper; +import javax.annotation.Nullable; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.joml.Vector3d; +import org.joml.primitives.AABBd; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(ContraptionCollider.class) +public abstract class MixinContraptionCollider { + @Shadow + static Vec3 collide(Vec3 p_20273_, Entity e) { + return p_20273_; + } + + @Unique + private static final Logger LOGGER = LogManager.getLogger("Clockwork.MixinContraptionCollider"); + + @Unique + private static AbstractContraptionEntity contraptionEnt; + + @Unique + private static AABB entityGetBoundingBox(AbstractContraptionEntity abstractContraptionEntity, Entity instance) { + AABB tempAabb = instance.getBoundingBox(); + if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), instance.blockPosition()) && VSGameUtilsKt.isBlockInShipyard(contraptionEnt.getCommandSenderWorld(), new BlockPos(contraptionEnt.getAnchorVec()))) { + Ship ship = VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), contraptionEnt.getAnchorVec()); + if (ship != null) { + AABBd temp = new AABBd(); + temp.set(toJOML(tempAabb)).transform(ship.getWorldToShip()); + tempAabb = toMinecraft(temp); + } + } + return tempAabb; + } + + @Unique + private static Vec3 entityPosition(AbstractContraptionEntity abstractContraptionEntity, Entity instance, boolean old) { + Vec3 tempVec = old ? new Vec3(instance.xo, instance.yo, instance.zo) : instance.position(); + if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), instance.blockPosition()) && VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), new BlockPos(abstractContraptionEntity.getAnchorVec()))) { + Ship ship = VSGameUtilsKt.getShipManagingPos(abstractContraptionEntity.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor); + if (ship != null) { + Vector3d translatedPos = ship.getTransform().getWorldToShip().transformPosition(toJOML(tempVec)); + tempVec = toMinecraft(translatedPos); + } + } + return tempVec; + } + + @Unique + private static Vec3 getSetEntityDeltaMovement(AbstractContraptionEntity abstractContraptionEntity, Entity instance, @Nullable Vec3 motion) { + Vec3 tempVec = instance.getDeltaMovement(); + if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), instance.blockPosition()) && VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), new BlockPos(abstractContraptionEntity.getContraption().anchor))) { + Ship ship = VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor); + if (ship != null) { + if (motion != null) { + if (!VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), new BlockPos(abstractContraptionEntity.getAnchorVec()))) { + motion = toMinecraft(ship.getWorldToShip().transformDirection(toJOML(motion))); + } else { + motion = toMinecraft(ship.getShipToWorld().transformDirection(toJOML(motion))); + } + instance.setDeltaMovement(motion); + motion = null; + } + tempVec = toMinecraft(ship.getWorldToShip().transformDirection(toJOML(tempVec))); + } + } + if (motion != null) { + instance.setDeltaMovement(motion); + } + return tempVec; + } + + @Inject(method = "collideEntities", at = @At("HEAD"), remap = false) + private static void injectHead(AbstractContraptionEntity contraptionEntity, CallbackInfo ci) { + contraptionEnt = contraptionEntity; + } + + private static void warn1(Vector3d vec3) { + LOGGER.warn("Warning setPosDistance too high ignoring setPos request [" + vec3.x + "," + vec3.y + "," + vec3.z + "]"); + } + + private static void warn2(double x, double y, double z) { + LOGGER.warn("Warning DEFAULT setPosDistance too high ignoring setPos request [" + x + "," + y + "," + z + "]"); + } + + private static void setOfPos(AbstractContraptionEntity abstractContraptionEntity, Entity instance, double x, double y, double z) { + if (VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), new BlockPos(x, y, z)) && + !VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), instance.blockPosition())) { + Ship ship = VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor); + if (ship != null) { + Vector3d newPos = new Vector3d(x, y, z); + ship.getShipToWorld().transformPosition(newPos, newPos); + if (instance.position().distanceTo(toMinecraft(newPos)) < 20) { + instance.setPos(newPos.x, newPos.y, newPos.z); + } else + warn1(newPos); + } + } else { + + if (instance.position().distanceTo(new Vec3(x, y, z)) < 20) { + instance.setPos(x, y, z); + } else + warn2(x, y, z); + } + } + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setPos(DDD)V")) + private static void redirectSetPos(Entity instance, double x, double y, double z) { + setOfPos(contraptionEnt, instance, x, y, z); + } + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) + private static AABB redirectContraptionGetBoundingBox(AbstractContraptionEntity instance) { + return VSGameUtilsKt.transformAabbToWorld(instance.getCommandSenderWorld(), instance.getBoundingBox()); + } + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) + private static AABB redirectEntityGetBoundingBox(Entity instance) { + return entityGetBoundingBox(contraptionEnt, instance); + } + + /* + @Redirect(method="collideEntities",at = @At(value="INVOKE_ASSIGN",target = "Lnet/minecraft/world/phys/AABB;getCenter()Lnet/minecraft/world/phys/Vec3;",ordinal = 3)) + private static Vec3 redirectGetCenter(AABB instance){ + if(instance) + return instance.getCenter(); + }*/ + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 redirectEntityPosition(Entity instance) { + return entityPosition(contraptionEnt, instance, false); + } + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 redirectEntityGetDeltaMovement(Entity instance) { + return getSetEntityDeltaMovement(contraptionEnt, instance, null); + } + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V")) + private static void redirectEntitySetDeltaMovement(Entity instance, Vec3 motion) { + getSetEntityDeltaMovement(contraptionEnt, instance, motion); + } + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getX()D")) + private static double redirectEntityGetX(Entity instance) { + return entityPosition(contraptionEnt, instance, false).x; + } + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getY()D")) + private static double redirectEntityGetY(Entity instance) { + return entityPosition(contraptionEnt, instance, false).y; + } + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getZ()D")) + private static double redirectEntityGetZ(Entity instance) { + return entityPosition(contraptionEnt, instance, false).z; + } + + + @Redirect(method = "collideEntities", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/Entity;xo:D", opcode = Opcodes.GETFIELD)) + private static double redirectEntityGetXo(Entity instance) { + return entityPosition(contraptionEnt, instance, true).x; + } + + @Redirect(method = "collideEntities", at = @At(value = "FIELD", target = "Lnet/minecraft/world/entity/Entity;zo:D", opcode = Opcodes.GETFIELD)) + private static double redirectEntityGetZo(Entity instance) { + return entityPosition(contraptionEnt, instance, true).z; + } + + private static Vec3 aaaaaaaaaaaaaa(AbstractContraptionEntity abstractContraptionEntity, Entity entity, Vec3 anchorVec, Matrix3d rotationMatrix, float yawOffset) { + + if (VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor) + && !VSGameUtilsKt.isBlockInShipyard(abstractContraptionEntity.getCommandSenderWorld(), entity.blockPosition())) { + + Ship ship = VSGameUtilsKt.getShipManagingPos(abstractContraptionEntity.getCommandSenderWorld(), abstractContraptionEntity.getContraption().anchor); + if (ship != null) { + Vec3 entityPosition = entityPosition(abstractContraptionEntity, entity, false); + Vec3 centerY = new Vec3(0, entityGetBoundingBox(contraptionEnt, entity) + .getYsize() / 2, 0); + Vec3 position = entityPosition; + position = position.add(centerY); + position = position.subtract(VecHelper.CENTER_OF_ORIGIN); + position = position.subtract(anchorVec); + position = VecHelper.rotate(position, -yawOffset, Direction.Axis.Y); + position = rotationMatrix.transform(position); + position = position.add(VecHelper.CENTER_OF_ORIGIN); + position = position.subtract(centerY); + position = position.subtract(entityPosition); + + return position;//toMinecraft(ship.getShipToWorld().transformPosition(position.x, position.y, position.z, new Vector3d())); + } + } + return ContraptionCollider.getWorldToLocalTranslation(entity, anchorVec, rotationMatrix, yawOffset); + } + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getPrevPositionVec()Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 redirectGetPrevPositionVec(AbstractContraptionEntity instance) { + + Vec3 prevPos = instance.getPrevPositionVec(); + + if (VSGameUtilsKt.isBlockInShipyard(instance.level, new BlockPos(instance.getAnchorVec())) && !VSGameUtilsKt.isBlockInShipyard(instance.level, new BlockPos(instance.getPrevAnchorVec()))) { + Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, instance.getAnchorVec()); + if (ship != null) { + Vec3 result = toMinecraft(ship.getWorldToShip().transformPosition(toJOML(instance.getPrevPositionVec()))); + instance.xo = result.x; + instance.yo = result.y; + instance.zo = result.z; + prevPos = result; + } + } + + + if (!VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), new BlockPos(prevPos)) && VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), new BlockPos(instance.position()))) { + //instance.setOldPosAndRot(); + //prevPos = instance.position(); + /* + Ship ship = VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), instance.position()); + if (ship != null) { + Vec3 transformedPrevPos = toMinecraft(ship.getWorldToShip().transformPosition(toJOML(prevPos))); + prevPos = transformedPrevPos; + }*/ + } + return prevPos; + } + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/ContraptionCollider;getWorldToLocalTranslation(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lcom/simibubi/create/foundation/collision/Matrix3d;F)Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 redirectGetWorldToLocalTranslation(Entity entity, Vec3 anchorVec, Matrix3d rotationMatrix, float yawOffset) { + return aaaaaaaaaaaaaa(contraptionEnt, entity, anchorVec, rotationMatrix, yawOffset); + } + + @Unique + private static Vec3 adjustCollide(Vec3 contactPoint, Entity entity) { + Vec3 result = collide(contactPoint, entity); + + if (VSGameUtilsKt.isBlockInShipyard(entity.getCommandSenderWorld(), contactPoint.x, contactPoint.y, contactPoint.z) + && !VSGameUtilsKt.isBlockInShipyard(entity.getCommandSenderWorld(), entity.blockPosition())) { + Ship ship = VSGameUtilsKt.getShipManagingPos(entity.getCommandSenderWorld(), contactPoint); + if (ship != null) { + Vec3 temp = toMinecraft(ship.getShipToWorld().transformPosition(toJOML(contactPoint))); + result = collide(temp, entity); + result = toMinecraft(ship.getWorldToShip().transformPosition(toJOML(result))); + } + } else if (!VSGameUtilsKt.isBlockInShipyard(entity.getCommandSenderWorld(), contactPoint.x, contactPoint.y, contactPoint.z) + && VSGameUtilsKt.isBlockInShipyard(entity.getCommandSenderWorld(), entity.blockPosition())) { + Ship ship = VSGameUtilsKt.getShipManagingPos(entity.getCommandSenderWorld(), entity.blockPosition()); + if (ship != null) { + Vec3 temp = toMinecraft(ship.getWorldToShip().transformPosition(toJOML(contactPoint))); + result = collide(temp, entity); + result = toMinecraft(ship.getShipToWorld().transformPosition(toJOML(result))); + } + } + + return result; + } + + @Redirect(method = "collideEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/ContraptionCollider;collide(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/entity/Entity;)Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 redirectEntityGetBoundingBoxCollide(Vec3 contactPoint, Entity entity) { + return adjustCollide(contactPoint, entity); + } + + //@Redirect(method = "getWorldToLocalTranslation(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lcom/simibubi/create/foundation/collision/Matrix3d;F)Lnet/minecraft/world/phys/Vec3;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) + private static AABB redirectEntityGetBoundingBox2(Entity instance) { + return entityGetBoundingBox(contraptionEnt, instance); + } + + //@Redirect(method = "getWorldToLocalTranslation(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/Vec3;Lcom/simibubi/create/foundation/collision/Matrix3d;F)Lnet/minecraft/world/phys/Vec3;", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 redirectEntityPosition2(Entity instance) { + return entityPosition(contraptionEnt, instance, false); + } + + @Inject(method = "worldToLocalPos(Lnet/minecraft/world/phys/Vec3;Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;)Lnet/minecraft/world/phys/Vec3;", at = @At("HEAD"), cancellable = true) + private static void modPosition(Vec3 entity, AbstractContraptionEntity contraptionEntity, CallbackInfoReturnable<Vec3> cir) { + if (VSGameUtilsKt.isBlockInShipyard(contraptionEntity.getCommandSenderWorld(), new BlockPos(contraptionEntity.getContraption().anchor)) + && !VSGameUtilsKt.isBlockInShipyard(contraptionEntity.getCommandSenderWorld(), new BlockPos(entity))) { + + Ship ship = VSGameUtilsKt.getShipManagingPos(contraptionEntity.getCommandSenderWorld(), contraptionEntity.getContraption().anchor); + if (ship != null) { + cir.setReturnValue(ContraptionCollider.worldToLocalPos(entity, toMinecraft(ship.getShipToWorld().transformPosition(toJOML(contraptionEntity.getAnchorVec()))), contraptionEntity.getRotationState())); + } + } + } + + @Unique + private static AbstractContraptionEntity hDFTContraptionEntity; + + @ModifyVariable(method = "handleDamageFromTrain", at = @At("HEAD"), argsOnly = true) + private static AbstractContraptionEntity injectHandleDamageFromTrain(AbstractContraptionEntity abstractContraptionEntity) { + return hDFTContraptionEntity = abstractContraptionEntity; + } + + @Redirect(method = "handleDamageFromTrain", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 redirectEntityGetDeltaMovementFromTrain(Entity instance) { + return getSetEntityDeltaMovement(hDFTContraptionEntity, instance, null); + } + + @Unique + private static AbstractContraptionEntity bounceEntityContraptionEntity; + + @ModifyVariable(method = "bounceEntity", at = @At("HEAD"), argsOnly = true) + private static AbstractContraptionEntity injectBounceEntity(AbstractContraptionEntity abstractContraptionEntity) { + return bounceEntityContraptionEntity = abstractContraptionEntity; + } + + @Redirect(method = "bounceEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 redirectEntityPositionBounceEntity(Entity instance) { + return entityPosition(bounceEntityContraptionEntity, instance, false); + } + + @Redirect(method = "bounceEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 redirectEntityGetDeltaMovementBounceEntity(Entity instance) { + return getSetEntityDeltaMovement(bounceEntityContraptionEntity, instance, null); + } + + @Redirect(method = "bounceEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V")) + private static void redirectEntitySetDeltaMovementBounceEntity(Entity instance, Vec3 motion) { + getSetEntityDeltaMovement(bounceEntityContraptionEntity, instance, motion); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinEntityLauncher.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinEntityLauncher.java new file mode 100644 index 000000000..8d311cd22 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinEntityLauncher.java @@ -0,0 +1,51 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create; + +import com.simibubi.create.content.logistics.depot.EntityLauncher; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(EntityLauncher.class) +public abstract class MixinEntityLauncher { + + @Unique + private BlockPos launcher; + + @Inject(method = "getGlobalPos", at = @At("HEAD")) + private void harvestBlockPos(double t, Direction d, BlockPos launcher, CallbackInfoReturnable<Vec3> cir) { + this.launcher = launcher; + } + + @ModifyVariable(method = "getGlobalPos", at = @At("STORE"), name = "start") + private Vec3 modStart(Vec3 value) { + return new Vec3(launcher.getX() + .5, launcher.getY() + .5, launcher.getZ() + .5); + } + + @Redirect(method = "applyMotion", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(DDD)V")) + private void redirectSetDeltaMovement(Entity instance, double x, double y, double z) { + instance.setDeltaMovement(outMotion(instance, new Vec3(x, y, z))); + } + + @Unique + private Vec3 outMotion(Entity entity, Vec3 motion) { + Ship ship = VSGameUtilsKt.getShipManagingPos(entity.level, entity.getOnPos()); + if (ship != null) { + Vector3d tempVec = VectorConversionsMCKt.toJOML(motion); + ship.getTransform().getShipToWorld().transformDirection(tempVec); + motion = VectorConversionsMCKt.toMinecraft(tempVec); + } + return motion; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinRedstoneLinkNetworkHandler.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinRedstoneLinkNetworkHandler.java new file mode 100644 index 000000000..c1b6e3afb --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinRedstoneLinkNetworkHandler.java @@ -0,0 +1,51 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create; + +import com.simibubi.create.content.redstone.link.IRedstoneLinkable; +import com.simibubi.create.content.redstone.link.RedstoneLinkNetworkHandler; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(RedstoneLinkNetworkHandler.class) +public abstract class MixinRedstoneLinkNetworkHandler { + + @Unique + private static Level harvestedWorld; + + @Redirect( + method = "withinRange", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/core/BlockPos;closerThan(Lnet/minecraft/core/Vec3i;D)Z" + ) + ) + private static boolean redirectCloserThan(BlockPos instance, Vec3i vec3i, double v) { + Ship ship1 = VSGameUtilsKt.getShipManagingPos(harvestedWorld, instance); + Ship ship2 = VSGameUtilsKt.getShipManagingPos(harvestedWorld, new BlockPos(vec3i)); + Vec3 pos1 = Vec3.atLowerCornerOf(instance); + Vec3 pos2 = Vec3.atLowerCornerOf(vec3i); + if (ship1 != null) { + pos1 = VectorConversionsMCKt.toMinecraft(ship1.getShipToWorld().transformPosition(VectorConversionsMCKt.toJOML(pos1))); + } + if (ship2 != null) { + pos2 = VectorConversionsMCKt.toMinecraft(ship2.getShipToWorld().transformPosition(VectorConversionsMCKt.toJOML(pos2))); + } + return pos1.closerThan(pos2, v); + } + + @Inject(method = "updateNetworkOf", at = @At("HEAD")) + private void harvestLevel(LevelAccessor world, IRedstoneLinkable actor, CallbackInfo ci) { + harvestedWorld = (Level) world; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinSharedDepotBlockMethods.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinSharedDepotBlockMethods.java new file mode 100644 index 000000000..927e5241e --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinSharedDepotBlockMethods.java @@ -0,0 +1,28 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create; + +import com.simibubi.create.content.logistics.depot.SharedDepotBlockMethods; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(SharedDepotBlockMethods.class) +public abstract class MixinSharedDepotBlockMethods { + @Redirect(method = "onLanded", at = @At( + value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;blockPosition()Lnet/minecraft/core/BlockPos;" + )) + private static BlockPos redirectBlockPosition(Entity instance) { + BlockPos result = instance.blockPosition(); + Ship ship = VSGameUtilsKt.getShipObjectManagingPos(instance.level, instance.getOnPos()); + if (ship != null) { + Vector3d tempVec = new Vector3d(instance.position().x, instance.position().y, instance.position().z); + ship.getWorldToShip().transformPosition(tempVec, tempVec); + result = new BlockPos(Math.floor(tempVec.x), Math.floor(tempVec.y), Math.floor(tempVec.z)); + } + return result; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/OutlineParamsAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/OutlineParamsAccessor.java new file mode 100644 index 000000000..6c4fd3a9b --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/OutlineParamsAccessor.java @@ -0,0 +1,22 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.accessors; + +import com.simibubi.create.AllSpecialTextures; +import com.simibubi.create.foundation.outliner.Outline; +import java.util.Optional; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(Outline.OutlineParams.class) +public interface OutlineParamsAccessor { + @Accessor("alpha") + float getAlpha(); + + @Accessor("alpha") + void setAlpha(float alpha); + + @Accessor + boolean getDisableCull(); + + @Accessor + Optional<AllSpecialTextures> getFaceTexture(); +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinBlockBreakingMovementBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinBlockBreakingMovementBehaviour.java new file mode 100644 index 000000000..8d8897327 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinBlockBreakingMovementBehaviour.java @@ -0,0 +1,61 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.behaviour; + +import com.simibubi.create.content.contraptions.behaviour.MovementContext; +import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(BlockBreakingMovementBehaviour.class) +public class MixinBlockBreakingMovementBehaviour { + //Region start - fix equals -0 != 0 + private Vec3 flatten(Vec3 vec3) { + if (vec3.x == -0) { + vec3 = new Vec3(0, vec3.y, vec3.z); + } + if (vec3.y == -0) { + vec3 = new Vec3(vec3.x, 0, vec3.z); + } + if (vec3.z == -0) { + vec3 = new Vec3(vec3.x, vec3.y, 0); + } + return vec3; + } + + @Redirect(method = "tickBreaker", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;equals(Ljava/lang/Object;)Z")) + private boolean redirectEquals(Vec3 instance, final Object vec3) { + Vec3 other = (Vec3) vec3; + other = flatten(other); + instance = flatten(instance); + return instance.equals(other); + } + //Region end + //Region start - fix entity throwing not being aligned to ship + @Unique + private MovementContext movementContext; + + @Inject(method = "throwEntity", at = @At("HEAD")) + private void injectThrowEntity(final MovementContext context, final Entity entity, final CallbackInfo ci) { + movementContext = context; + } + + @Redirect(method = "throwEntity", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V")) + private void redirectSetDeltaMovement(final Entity instance, Vec3 motion) { + if (movementContext != null && VSGameUtilsKt.isBlockInShipyard(movementContext.world, movementContext.contraption.anchor)) { + Ship ship = VSGameUtilsKt.getShipManagingPos(movementContext.world, movementContext.contraption.anchor); + if (ship != null) + motion = VectorConversionsMCKt.toMinecraft(ship.getShipToWorld().transformDirection(VectorConversionsMCKt.toJOML(motion), new Vector3d())); + } + instance.setDeltaMovement(motion); + } + //Region end +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinFilteringBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinFilteringBehaviour.java new file mode 100644 index 000000000..ae9e47bd8 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinFilteringBehaviour.java @@ -0,0 +1,43 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.behaviour; + +import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringBehaviour; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(FilteringBehaviour.class) +public class MixinFilteringBehaviour { + @Redirect( + method = "testHit", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" + ) + ) + public Vec3 redirectSubtract(Vec3 instance, Vec3 vec) { + Level level = ((FilteringBehaviour) (Object) this).getWorld(); + + Vec3 pos1 = instance; + Vec3 pos2 = vec; + + if (level != null) { + Ship ship1 = VSGameUtilsKt.getShipManagingPos(level, pos1.x, pos1.y, pos1.z); + Ship ship2 = VSGameUtilsKt.getShipManagingPos(level, pos2.x, pos2.y, pos2.z); + if (ship1 != null && ship2 == null) { + pos2 = VectorConversionsMCKt.toMinecraft( + ship1.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos2)) + ); + } else if (ship1 == null && ship2 != null) { + pos1 = VectorConversionsMCKt.toMinecraft( + ship2.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos1)) + ); + } + } + return pos1.subtract(pos2); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinLinkBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinLinkBehaviour.java new file mode 100644 index 000000000..5abbba6d8 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinLinkBehaviour.java @@ -0,0 +1,43 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.behaviour; + +import com.simibubi.create.content.redstone.link.LinkBehaviour; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(LinkBehaviour.class) +public class MixinLinkBehaviour { + @Redirect( + method = "testHit", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" + ) + ) + public Vec3 redirectSubtract(Vec3 instance, Vec3 vec) { + Level level = ((LinkBehaviour) (Object) this).getWorld(); + + Vec3 pos1 = instance; + Vec3 pos2 = vec; + + if (level != null) { + Ship ship1 = VSGameUtilsKt.getShipManagingPos(level, pos1.x, pos1.y, pos1.z); + Ship ship2 = VSGameUtilsKt.getShipManagingPos(level, pos2.x, pos2.y, pos2.z); + if (ship1 != null && ship2 == null) { + pos2 = VectorConversionsMCKt.toMinecraft( + ship1.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos2)) + ); + } else if (ship1 == null && ship2 != null) { + pos1 = VectorConversionsMCKt.toMinecraft( + ship2.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos1)) + ); + } + } + return pos1.subtract(pos2); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinScrollValueBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinScrollValueBehaviour.java new file mode 100644 index 000000000..e0d31a48c --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinScrollValueBehaviour.java @@ -0,0 +1,45 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.behaviour; + +import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(targets = "com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour") +public class MixinScrollValueBehaviour { + + @Redirect( + method = "testHit", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" + ) + ) + public Vec3 redirectSubtract(Vec3 instance, Vec3 vec) { + Level level = ((ScrollValueBehaviour) (Object) this).getWorld(); + + Vec3 pos1 = instance; + Vec3 pos2 = vec; + + if (level != null) { + Ship ship1 = VSGameUtilsKt.getShipManagingPos(level, pos1.x, pos1.y, pos1.z); + Ship ship2 = VSGameUtilsKt.getShipManagingPos(level, pos2.x, pos2.y, pos2.z); + if (ship1 != null && ship2 == null) { + pos2 = VectorConversionsMCKt.toMinecraft( + ship1.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos2)) + ); + } else if (ship1 == null && ship2 != null) { + pos1 = VectorConversionsMCKt.toMinecraft( + ship2.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos1)) + ); + } + } + return pos1.subtract(pos2); + } +} + diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinSidedFilteringBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinSidedFilteringBehaviour.java new file mode 100644 index 000000000..a9f3fee09 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinSidedFilteringBehaviour.java @@ -0,0 +1,39 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.behaviour; + +import com.simibubi.create.foundation.blockEntity.behaviour.filtering.SidedFilteringBehaviour; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(SidedFilteringBehaviour.class) +public class MixinSidedFilteringBehaviour { + @Redirect( + method = "testHit", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" + ) + ) + public Vec3 redirectSubtract(Vec3 instance, Vec3 vec) { + Level level = ((SidedFilteringBehaviour) (Object) this).getWorld(); + + Vec3 pos1 = instance; + Vec3 pos2 = vec; + + if (level != null) { + Ship ship1 = VSGameUtilsKt.getShipManagingPos(level, pos1.x, pos1.y, pos1.z); + Ship ship2 = VSGameUtilsKt.getShipManagingPos(level, pos2.x, pos2.y, pos2.z); + if (ship1 != null && ship2 == null) { + pos2 = VectorConversionsMCKt.toMinecraft(ship1.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos2))); + } else if (ship1 == null && ship2 != null) { + pos1 = VectorConversionsMCKt.toMinecraft(ship2.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(pos1))); + } + } + return pos1.subtract(pos2); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinCrushingWheelBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinCrushingWheelBlock.java new file mode 100644 index 000000000..067725275 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinCrushingWheelBlock.java @@ -0,0 +1,81 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.block; + +import com.simibubi.create.content.kinetics.crusher.CrushingWheelBlock; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(CrushingWheelBlock.class) +public class MixinCrushingWheelBlock { + + @Unique + private BlockPos blockPosInside; + @Unique + private Level levelInside; + + @Inject(method = "entityInside", at = @At("HEAD")) + void startInside( + final BlockState state, final Level worldIn, final BlockPos pos, final Entity entityIn, + final CallbackInfo info) { + blockPosInside = pos; + levelInside = worldIn; + } + + @Unique + void transform(final Vector3d in) { + final Ship ship = VSGameUtilsKt.getShipManagingPos(levelInside, blockPosInside); + if (ship != null) { + ship.getWorldToShip().transformPosition(in); + } + } + + @Redirect( + method = "entityInside", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/Entity;getX()D" + ) + ) + double getXPos(final Entity entity) { + final Vector3d vector3d = new Vector3d(entity.getX(), entity.getY(), entity.getZ()); + transform(vector3d); + return vector3d.x; + } + + @Redirect( + method = "entityInside", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/Entity;getY()D" + ) + ) + double getYPos(final Entity entity) { + final Vector3d vector3d = new Vector3d(entity.getX(), entity.getY(), entity.getZ()); + transform(vector3d); + return vector3d.x; + } + + @Redirect( + method = "entityInside", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/Entity;getZ()D" + ) + ) + double getZPos(final Entity entity) { + final Vector3d vector3d = new Vector3d(entity.getX(), entity.getY(), entity.getZ()); + transform(vector3d); + return vector3d.x; + } + +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinEjectorBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinEjectorBlock.java new file mode 100644 index 000000000..4759a6b94 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinEjectorBlock.java @@ -0,0 +1,53 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.block; + +import com.simibubi.create.content.logistics.depot.EjectorBlock; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(EjectorBlock.class) +public abstract class MixinEjectorBlock { + @Redirect(method = "updateEntityAfterFallOn", at = @At( + value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;blockPosition()Lnet/minecraft/core/BlockPos;" + )) + private BlockPos redirectBlockPosition(Entity instance) { + return instance.getOnPos(); + } + + @Redirect(method = "updateEntityAfterFallOn", at = @At( + value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;" + )) + private Vec3 redirectEntityPosition(Entity instance) { + Vec3 result = instance.position(); + if (VSGameUtilsKt.getShipManagingPos(instance.level, instance.position()) == null) { + Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, instance.getOnPos()); + if (ship != null) { + Vector3d tempVec = VectorConversionsMCKt.toJOML(result); + ship.getWorldToShip().transformPosition(tempVec, tempVec); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + } + return result; + } + + @Redirect(method = "updateEntityAfterFallOn", at = @At( + value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setPos(DDD)V" + )) + private void redirectSetPos(Entity instance, double x, double y, double z) { + Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, instance.getOnPos()); + if (ship != null) { + Vector3d tempVec = new Vector3d(); + ship.getTransform().getShipToWorld().transformPosition(x, y, z, tempVec); + instance.setPos(tempVec.x, tempVec.y, tempVec.z); + } else { + instance.setPos(x, y, z); + } + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinRedstoneContactBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinRedstoneContactBlock.java new file mode 100644 index 000000000..78a0274bb --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinRedstoneContactBlock.java @@ -0,0 +1,132 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.block; + +import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; + +import com.mojang.datafixers.util.Pair; +import com.simibubi.create.AllBlocks; +import com.simibubi.create.content.redstone.contact.RedstoneContactBlock; +import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Random; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.LevelAccessor; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.block.state.properties.BooleanProperty; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import net.minecraft.world.ticks.TickPriority; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(RedstoneContactBlock.class) +public abstract class MixinRedstoneContactBlock extends WrenchableDirectionalBlock { + + private static Map<Pair<Level, BlockPos>, BlockPos> contactCache = new HashMap<>(); + + @Shadow + @Final + public static BooleanProperty POWERED; + @Unique + private static final double MAX_ALIGNMENT_ANGLE = -0.93972176; //Mth.cos(20*(Mth.DEG_TO_RAD)) + + public MixinRedstoneContactBlock(Properties properties) { + super(properties); + } + + @Inject(method = "onRemove", at = @At("HEAD")) + private void injectOnRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving, CallbackInfo ci) { + if (state.getBlock() == this && newState.isAir()) { + Pair<Level, BlockPos> key = Pair.of(worldIn, pos); + if (state.getValue(POWERED) && contactCache.containsKey(key)) { + worldIn.scheduleTick(contactCache.get(key), AllBlocks.REDSTONE_CONTACT.get(), 2, TickPriority.NORMAL); + contactCache.remove(key); + } + } + } + + @Inject(method = "tick", at = @At(value = "INVOKE_ASSIGN", shift = At.Shift.BY, by = 2, target = "Lcom/simibubi/create/content/redstone/contact/RedstoneContactBlock;hasValidContact(Lnet/minecraft/world/level/LevelAccessor;Lnet/minecraft/core/BlockPos;Lnet/minecraft/core/Direction;)Z"), locals = LocalCapture.CAPTURE_FAILHARD) + private void injectTick(BlockState state, ServerLevel worldIn, BlockPos pos, Random random, CallbackInfo ci, boolean hasValidContact) { + if (VSGameUtilsKt.isBlockInShipyard(worldIn, pos)) { + Pair<Level, BlockPos> key = Pair.of(worldIn, pos); + if (!hasValidContact && state.getValue(POWERED) && contactCache.containsKey(key)) { + worldIn.scheduleTick(contactCache.get(key), AllBlocks.REDSTONE_CONTACT.get(), 2, TickPriority.NORMAL); + contactCache.remove(key); + } + worldIn.scheduleTick(pos, AllBlocks.REDSTONE_CONTACT.get(), 2, TickPriority.NORMAL); + } + } + + @Unique + private static boolean hasContact(Level world, Ship ship, Vector3d searchPos, Direction direction, Ship shipItr) { + BlockState blockState = world.getBlockState(new BlockPos(VectorConversionsMCKt.toMinecraft(searchPos))); + if (AllBlocks.REDSTONE_CONTACT.has(blockState)) { + Vector3d worldDirection = toJOML(Vec3.atLowerCornerOf(direction.getNormal())); + Vector3d targetDirection = toJOML(Vec3.atLowerCornerOf(blockState.getValue(FACING).getNormal())); + if (ship != null) { + ship.getShipToWorld().transformDirection(worldDirection, worldDirection); + } + if (shipItr != null) { + shipItr.getShipToWorld().transformDirection(targetDirection, targetDirection); + } + double dotAngle = worldDirection.dot(targetDirection); + return dotAngle < MAX_ALIGNMENT_ANGLE; + } + return false; + } + + @Inject(method = "hasValidContact", at = @At("RETURN"), cancellable = true) + private static void injectHasValidContact(LevelAccessor world, BlockPos pos, Direction direction, CallbackInfoReturnable<Boolean> cir) { + boolean result = false; + Level worldLevel = (Level) world; + BlockState blockState = world.getBlockState(pos.relative(direction)); + if (AllBlocks.REDSTONE_CONTACT.has(blockState)) { + cir.setReturnValue(blockState.getValue(FACING) == direction.getOpposite()); + } else { + + AABB searchAABB = new AABB(pos.relative(direction)); + Vector3d searchPos = toJOML(Vec3.atCenterOf(pos.relative(direction))); + Ship ship = VSGameUtilsKt.getShipManagingPos(worldLevel, pos); + if (VSGameUtilsKt.isBlockInShipyard(worldLevel, pos) && ship != null) { + Vector3d tempVec = toJOML(Vec3.atCenterOf(pos.relative(direction))); + searchPos = ship.getShipToWorld().transformPosition(tempVec, new Vector3d()); + ship.getShipToWorld().transformPosition(tempVec, tempVec); + double bounds = 0.25; + searchAABB = new AABB(tempVec.x - bounds, tempVec.y - bounds, tempVec.z - bounds, + tempVec.x + bounds, tempVec.y + bounds, tempVec.z + bounds); + + result = hasContact(worldLevel, ship, searchPos, direction, null); + } + Iterator<Ship> ships = VSGameUtilsKt.getShipsIntersecting(worldLevel, searchAABB).iterator(); + if (ships.hasNext() && !result) { + do { + Ship shipItr = ships.next(); + if (shipItr == ship) continue; + Vector3d newSearchPos = shipItr.getWorldToShip().transformPosition(searchPos, new Vector3d()); + result = hasContact(worldLevel, ship, newSearchPos, direction, shipItr); + if (result) searchPos = newSearchPos; + } while (ships.hasNext() && !result); + } + if (result) { + contactCache.put(Pair.of(worldLevel, pos), new BlockPos(VectorConversionsMCKt.toMinecraft(searchPos))); + world.scheduleTick(new BlockPos(VectorConversionsMCKt.toMinecraft(searchPos)), AllBlocks.REDSTONE_CONTACT.get(), 2, TickPriority.NORMAL); + } + cir.setReturnValue(result); + } + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinStickerBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinStickerBlock.java new file mode 100644 index 000000000..b939eed99 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinStickerBlock.java @@ -0,0 +1,41 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.block; + +import com.simibubi.create.content.contraptions.chassis.StickerBlock; +import com.simibubi.create.content.contraptions.chassis.StickerBlockEntity; +import com.simibubi.create.foundation.block.IBE; +import com.simibubi.create.foundation.block.WrenchableDirectionalBlock; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.mod.mixinducks.mod_compat.create.IMixinStickerTileEntity; + +@Mixin(StickerBlock.class) +public abstract class MixinStickerBlock extends WrenchableDirectionalBlock implements IBE<StickerBlockEntity> { + + public MixinStickerBlock(Properties properties) { + super(properties); + } + + @Override + public void onRemove(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState newState, boolean isMoving) { + IBE.onRemove(state, world, pos, newState); + } + + @Inject(method = "neighborChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getValue(Lnet/minecraft/world/level/block/state/properties/Property;)Ljava/lang/Comparable;", ordinal = 0), cancellable = true) + private void injectNeighbourChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving, CallbackInfo ci) { + StickerBlockEntity ste = getBlockEntity(worldIn, pos); + if (ste != null && ((IMixinStickerTileEntity) ste).isAlreadyPowered(false)) { + if (!worldIn.hasNeighborSignal(pos)) { + ci.cancel(); + } else { + ((IMixinStickerTileEntity) ste).isAlreadyPowered(true); + } + } + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/IMixinMechanicalBearingTileEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/IMixinMechanicalBearingTileEntity.java new file mode 100644 index 000000000..a27061283 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/IMixinMechanicalBearingTileEntity.java @@ -0,0 +1,10 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.blockentity; + +import com.simibubi.create.content.contraptions.bearing.MechanicalBearingBlockEntity; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.gen.Accessor; + +@Mixin(MechanicalBearingBlockEntity.class) +public interface IMixinMechanicalBearingTileEntity { + @Accessor boolean isAssembleNextTick(); +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinCrushingWheelControllerTileEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinCrushingWheelControllerTileEntity.java new file mode 100644 index 000000000..a8c8f864d --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinCrushingWheelControllerTileEntity.java @@ -0,0 +1,114 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.blockentity; + +import com.simibubi.create.content.kinetics.crusher.CrushingWheelControllerBlock; +import com.simibubi.create.content.kinetics.crusher.CrushingWheelControllerBlockEntity; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.function.Predicate; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.joml.primitives.AABBd; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(CrushingWheelControllerBlockEntity.class) +public abstract class MixinCrushingWheelControllerTileEntity { + + @Shadow + public float crushingspeed; + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getEntities(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;)Ljava/util/List;")) + private List<Entity> redirectBounds(Level instance, Entity entity, AABB area, Predicate<Entity> predicate) { + if (instance != null) { + area = VSGameUtilsKt.transformAabbToWorld(instance, area); + return instance.getEntities(entity, area, predicate); + } + return new ArrayList<Entity>(); + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;intersects(Lnet/minecraft/world/phys/AABB;)Z")) + private boolean redirectIntersects(AABB instance, AABB other) { + Level level = ((CrushingWheelControllerBlockEntity) (Object) this).getLevel(); + if (level != null) { + Iterator<Ship> ships = VSGameUtilsKt.getShipsIntersecting(level, instance).iterator(); + if (ships.hasNext()) { + AABBd result = new AABBd(); + VectorConversionsMCKt.toJOML(instance).transform(ships.next().getTransform().getWorldToShip(), result); + instance = VectorConversionsMCKt.toMinecraft(result); + } + } + return instance.intersects(other); + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V")) + private void redirectSetDeltaMovement(Entity instance, Vec3 motion) { + + BlockPos worldPosition = ((CrushingWheelControllerBlockEntity) (Object) this).getBlockPos(); + Direction facing = ((CrushingWheelControllerBlockEntity) (Object) this) + .getBlockState().getValue(CrushingWheelControllerBlock.FACING); + Vec3 transformedPos = getTransformedPosition(instance); + double xMotion = ((worldPosition.getX() + .5) - transformedPos.x) / 2; + double zMotion = ((worldPosition.getZ() + .5) - transformedPos.z) / 2; + + if (instance.isShiftKeyDown()) + xMotion = zMotion = 0; + double movement = Math.max(-(this.crushingspeed * 4) / 4f, -.5f) * -facing.getAxisDirection().getStep(); + + Vec3 transformedDirection = directionShip2World(instance, + new Vec3( + facing.getAxis() == Direction.Axis.X ? movement : xMotion, + facing.getAxis() == Direction.Axis.Y ? movement : 0f, + facing.getAxis() == Direction.Axis.Z ? movement : zMotion + )); + + instance.setDeltaMovement(transformedDirection); + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getX()D")) + private double redirectEntityGetX(Entity instance) { + return getTransformedPosition(instance).x; + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getY()D")) + private double redirectEntityGetY(Entity instance) { + return getTransformedPosition(instance).y; + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getZ()D")) + private double redirectEntityGetZ(Entity instance) { + return getTransformedPosition(instance).z; + } + + private Vec3 getTransformedPosition(Entity instance) { + Vec3 result = instance.position(); + Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, ((CrushingWheelControllerBlockEntity) (Object) this).getBlockPos()); + if (ship != null) { + Vector3d tempVec = new Vector3d(); + ship.getTransform().getWorldToShip().transformPosition(result.x, result.y, result.z, tempVec); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + return result; + } + + private Vec3 directionShip2World(Entity instance, Vec3 direction) { + Vec3 result = direction; + Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, ((CrushingWheelControllerBlockEntity) (Object) this).getBlockPos()); + if (ship != null) { + Vector3d tempVec = new Vector3d(); + ship.getTransform().getShipToWorld().transformDirection(result.x, result.y, result.z, tempVec); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + return result; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEjectorTileEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEjectorTileEntity.java new file mode 100644 index 000000000..d1ff39aa5 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEjectorTileEntity.java @@ -0,0 +1,69 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.blockentity; + +import com.simibubi.create.content.logistics.depot.EjectorBlockEntity; +import java.util.List; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(EjectorBlockEntity.class) +public abstract class MixinEjectorTileEntity { + @ModifyVariable(method = "*", at = @At("STORE"), name = "ejectVec") + private Vec3 modEjectVec(Vec3 ejectVec) { + Vec3 result = ejectVec; + Level level = ((EjectorBlockEntity) (Object) this).getLevel(); + if (level != null) { + Ship ship = VSGameUtilsKt.getShipManagingPos(level, ((EjectorBlockEntity) (Object) this).getBlockPos()); + if (ship != null) { + Vector3d tempVec = new Vector3d(); + ship.getTransform().getShipToWorld().transformPosition(result.x, result.y, result.z, tempVec); + result = new Vec3(tempVec.x, tempVec.y, tempVec.z); + } + } + return result; + } + + @ModifyVariable(method = "*", at = @At("STORE"), name = "ejectMotionVec") + private Vec3 modEjectMotionVec(Vec3 ejectMotionVec) { + Vec3 result = ejectMotionVec; + Level level = ((EjectorBlockEntity) (Object) this).getLevel(); + if (level != null) { + Ship ship = VSGameUtilsKt.getShipManagingPos(level, ((EjectorBlockEntity) (Object) this).getBlockPos()); + if (ship != null) { + Vector3d tempVec = new Vector3d(); + ship.getTransform().getShipToWorld().transformDirection(result.x, result.y, result.z, tempVec); + result = new Vec3(tempVec.x, tempVec.y, tempVec.z); + } + } + return result; + } + + @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getEntitiesOfClass(Ljava/lang/Class;Lnet/minecraft/world/phys/AABB;)Ljava/util/List;")) + private List<Entity> redirectGetEntitiesOfClass(Level instance, Class<Entity> aClass, AABB aabb) { + return instance.getEntitiesOfClass(aClass, VSGameUtilsKt.transformAabbToWorld(instance, aabb)); + } + + @Redirect(method = "activateDeferred", at = @At( + value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setPos(DDD)V" + )) + private void redirectSetPos(Entity instance, double x, double y, double z) { + Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, ((EjectorBlockEntity) (Object) this).getBlockPos()); + if (ship != null) { + BlockPos temp = ((EjectorBlockEntity) (Object) this).getBlockPos(); + Vector3d tempVec = new Vector3d(temp.getX() + .5, temp.getY() + 1, temp.getZ() + .5); + ship.getTransform().getShipToWorld().transformPosition(tempVec, tempVec); + instance.setPos(tempVec.x, tempVec.y, tempVec.z); + } else { + instance.setPos(x, y, z); + } + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEncasedFanTileEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEncasedFanTileEntity.java new file mode 100644 index 000000000..e04dde8f3 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinEncasedFanTileEntity.java @@ -0,0 +1,35 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.blockentity; + +import com.simibubi.create.content.kinetics.base.KineticBlockEntity; +import com.simibubi.create.content.kinetics.fan.EncasedFanBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.entity.BlockEntityType; +import net.minecraft.world.level.block.state.BlockState; +import org.jetbrains.annotations.NotNull; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.mixinducks.mod_compat.create.IExtendedAirCurrentSource; + +@Mixin(EncasedFanBlockEntity.class) +public abstract class MixinEncasedFanTileEntity extends KineticBlockEntity implements IExtendedAirCurrentSource { + @Unique + private Ship ship = null; + + public MixinEncasedFanTileEntity(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) { + super(typeIn, pos, state); + } + + @Override + public void setLevel(@NotNull Level level) { + super.setLevel(level); + ship = VSGameUtilsKt.getShipManagingPos(level, getBlockPos()); + } + + @Override + public Ship getShip() { + return ship; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/cannons/MixinCannonMount.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/cannons/MixinCannonMount.java new file mode 100644 index 000000000..fec8a0b57 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/cannons/MixinCannonMount.java @@ -0,0 +1,151 @@ +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; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.LoadedServerShip; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import rbasamoyai.createbigcannons.cannon_control.ControlPitchContraption; +import rbasamoyai.createbigcannons.cannon_control.cannon_mount.CannonMountBlockEntity; + +@Mixin(CannonMountBlockEntity.class) +public abstract class MixinCannonMount extends KineticBlockEntity implements ControlPitchContraption.Block { + + private Integer cannonID = null; + private boolean alreadyAdded = false; + + Vector3d recoilVec = null; + double recoilForce = 0; + + public MixinCannonMount(BlockEntityType<?> typeIn, BlockPos pos, BlockState state) { + super(typeIn, pos, state); + } + + @Override + public void cacheRecoilVector(Vec3 vector, AbstractContraptionEntity cannon) { + recoilVec = VectorConversionsMCKt.toJOML(vector); + } + + @Unique + private void handleAssembly() { + LoadedServerShip ship = null; + if (!level.isClientSide) { + if (VSGameUtilsKt.getShipObjectManagingPos(level, getBlockPos()) != null) { + ship = VSGameUtilsKt.getShipObjectManagingPos((ServerLevel) level, getBlockPos()); + } + } + + if (ship != null) { + if (!alreadyAdded && cannonID == null) { + Vector3dc pos = VectorConversionsMCKt.toJOMLD(worldPosition); + //final CannonCreateData data = new CannonCreateData(pos); + //cannonID = CannonController.getOrCreate(ship).addCannon(data); + alreadyAdded = true; + } + } + } + + @Unique + private void handleDisassembly() { + LoadedServerShip ship = null; + if (!level.isClientSide) { + if (VSGameUtilsKt.getShipObjectManagingPos(level, getBlockPos()) != null) { + ship = VSGameUtilsKt.getShipObjectManagingPos((ServerLevel) level, getBlockPos()); + } + } + if (cannonID != null) { + //CannonController.getOrCreate(ship).removeCannon(cannonID); + cannonID = null; + alreadyAdded = false; + recoilVec = null; + } + + } + + @Unique + private void handleController() { + //do stuff here (I like to have the inject call to a separate function so the breakpoint will work properly for this function) + + LoadedServerShip ship = null; + if (!level.isClientSide) { + if (VSGameUtilsKt.getShipObjectManagingPos(level, getBlockPos()) != null) { + ship = VSGameUtilsKt.getShipObjectManagingPos((ServerLevel) level, getBlockPos()); + } + } + if (ship != null) { + if (alreadyAdded && cannonID != null) { + if (recoilVec != null) { + //final CannonUpdateData data = new CannonUpdateData(recoilVec); + //CannonController.getOrCreate(ship).updateCannon(cannonID, data); + } + } + if (this.isRemoved()) { + if (cannonID != null) { + //CannonController.getOrCreate(ship).removeCannon(cannonID); + cannonID = null; + alreadyAdded = false; + } + } + } + } + @Inject(method = "tick", at = @At("HEAD"), remap = false) + private void injectTick(CallbackInfo ci) { + handleController(); + } + + @Inject(method = "assemble", at = @At("RETURN"), remap = false) + private void injectAssemble(CallbackInfo ci) { + handleAssembly(); + } + + @Inject(method = "disassemble", at = @At("HEAD"), remap = false) + private void injectDisassemble(CallbackInfo ci) { + handleDisassembly(); + } + + @Unique + private CompoundTag writeToCompound(CompoundTag compound, boolean clientPacket){ + //write here + compound.putBoolean("alreadyAdded", alreadyAdded); + if (cannonID != null) { + compound.putInt("cannonID", cannonID); + } + return compound; + } + @Inject(method = "write", at = @At("HEAD"), cancellable = true, remap = false) + private void injectWrite(CompoundTag compound, boolean clientPacket, CallbackInfo ci) { + compound = writeToCompound(compound,clientPacket); + super.write(compound, clientPacket); + ci.cancel(); + } + + @Unique + private CompoundTag readFromCompound(CompoundTag compound, boolean clientPacket){ + //read (and remove before it passes up?) here + alreadyAdded = compound.getBoolean("alreadyAdded"); + if (compound.contains("cannonID")) { + cannonID = compound.getInt("cannonID"); + } + return compound; + } + @Inject(method = "read", at = @At("HEAD"), cancellable = true, remap = false) + private void injectRead(CompoundTag compound, boolean clientPacket, CallbackInfo ci) { + compound = readFromCompound(compound,clientPacket); + super.read(compound, clientPacket); + ci.cancel(); + } + +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinAABBOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinAABBOutline.java new file mode 100644 index 000000000..3e7c98b72 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinAABBOutline.java @@ -0,0 +1,76 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; +import com.simibubi.create.foundation.outliner.AABBOutline; +import com.simibubi.create.foundation.outliner.Outline; +import com.simibubi.create.foundation.render.RenderTypes; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; +import net.minecraft.client.Minecraft; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3dc; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.core.api.ships.properties.ShipTransform; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import org.valkyrienskies.mod.mixin.mod_compat.create.accessors.OutlineParamsAccessor; + +@Mixin(AABBOutline.class) +public abstract class MixinAABBOutline extends Outline { + @Shadow + protected abstract void renderBoxFaces(PoseStack ms, SuperRenderTypeBuffer buffer, boolean cull, Direction highlightedFace, Vector3f minPos, Vector3f maxPos, Vector4f color, int lightmap); + + @Shadow + protected abstract void renderBoxEdges(PoseStack ms, VertexConsumer consumer, Vector3f minPos, Vector3f maxPos, float lineWidth, Vector4f color, int lightmap, boolean disableNormals); + + @Inject(method = "renderBox", at = @At("HEAD"), cancellable = true) + private void preRenderBox(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, AABB box, Vector4f color, int lightmap, boolean disableLineNormals, CallbackInfo ci) { + final Level level = Minecraft.getInstance().level; + if (level != null) { + final Vector3dc average = VectorConversionsMCKt.toJOML(box.getCenter()); + final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, average); + if (ship != null) { + final ShipTransform renderTransform = ship.getRenderTransform(); + Vector3f minPos = new Vector3f(); + Vector3f maxPos = new Vector3f(); + + final Vector3dc cameraInShip = renderTransform.getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(camera)); + + boolean cameraInside = box.contains(VectorConversionsMCKt.toMinecraft(cameraInShip)); + boolean cull = !cameraInside && !((OutlineParamsAccessor) params).getDisableCull(); + float inflate = cameraInside ? -1 / 128f : 1 / 128f; + + final AABB boxRelShipCenter = box.move(-renderTransform.getPositionInShip().x(), -renderTransform.getPositionInShip().y(), -renderTransform.getPositionInShip().z()); + + minPos.set((float) boxRelShipCenter.minX - inflate, (float) boxRelShipCenter.minY - inflate, (float) boxRelShipCenter.minZ - inflate); + maxPos.set((float) boxRelShipCenter.maxX + inflate, (float) boxRelShipCenter.maxY + inflate, (float) boxRelShipCenter.maxZ + inflate); + + ms.pushPose(); + ms.translate(renderTransform.getPositionInWorld().x() - camera.x, renderTransform.getPositionInWorld().y() - camera.y, renderTransform.getPositionInWorld().z() - camera.z); + ms.scale((float) renderTransform.getShipToWorldScaling().x(), (float) renderTransform.getShipToWorldScaling().y(), (float) renderTransform.getShipToWorldScaling().z()); + ms.mulPose(VectorConversionsMCKt.toMinecraft(renderTransform.getShipToWorldRotation())); + renderBoxFaces(ms, buffer, cull, params.getHighlightedFace(), minPos, maxPos, color, lightmap); + + float lineWidth = params.getLineWidth(); + if (lineWidth == 0) + return; + + VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid()); + renderBoxEdges(ms, consumer, minPos, maxPos, lineWidth, color, lightmap, disableLineNormals); + + ms.popPose(); + ci.cancel(); + } + } + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinBlockClusterOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinBlockClusterOutline.java new file mode 100644 index 000000000..78b2c7014 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinBlockClusterOutline.java @@ -0,0 +1,152 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; +import com.simibubi.create.AllSpecialTextures; +import com.simibubi.create.foundation.outliner.BlockClusterOutline; +import com.simibubi.create.foundation.outliner.Outline; +import com.simibubi.create.foundation.render.RenderTypes; +import com.simibubi.create.foundation.render.SuperRenderTypeBuffer; +import java.util.Iterator; +import java.util.Optional; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.RenderType; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.core.api.ships.properties.ShipTransform; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import org.valkyrienskies.mod.mixin.mod_compat.create.accessors.OutlineParamsAccessor; +import org.valkyrienskies.mod.mixinducks.mod_compat.create.CWCluster; + +@Mixin(BlockClusterOutline.class) +public abstract class MixinBlockClusterOutline extends Outline { + @Unique + private CWCluster cw$cluster = null; + + @Shadow + @Final + protected Vector3f originTemp; + + @Shadow + protected abstract void bufferBlockFace(PoseStack.Pose pose, VertexConsumer consumer, BlockPos pos, Direction face, Vector4f color, int lightmap); + + @Inject(method = "<init>", at = @At("RETURN")) + private void postInit(final Iterable<BlockPos> positions, final CallbackInfo ci) { + final Iterator<BlockPos> iterator = positions.iterator(); + final BlockPos firstPos = iterator.hasNext() ? iterator.next() : null; + if (firstPos != null) { + final Level level = Minecraft.getInstance().level; + if (level != null && VSGameUtilsKt.getShipManagingPos(level, firstPos) != null) { + // Only generate cw$cluster if we're on a ship + cw$cluster = new CWCluster(); + positions.forEach(cw$cluster::include); + } + } + } + + @Inject(method = "renderFaces", at = @At("HEAD"), cancellable = true) + private void preRenderFaces(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt, Vector4f color, int lightmap, CallbackInfo ci) { + if (cw$cluster != null) { + final BlockPos anchorPos = cw$cluster.anchor; + if (anchorPos == null) { + return; + } + final Level level = Minecraft.getInstance().level; + final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, anchorPos); + if (ship != null) { + Optional<AllSpecialTextures> optionalFaceTexture = ((OutlineParamsAccessor) params).getFaceTexture(); + if (optionalFaceTexture.isEmpty()) + return; + + final ShipTransform renderTransform = ship.getRenderTransform(); + + ms.pushPose(); + ms.translate(renderTransform.getPositionInWorld().x() - camera.x, renderTransform.getPositionInWorld().y() - camera.y, renderTransform.getPositionInWorld().z() - camera.z); + ms.scale((float) renderTransform.getShipToWorldScaling().x(), (float) renderTransform.getShipToWorldScaling().y(), (float) renderTransform.getShipToWorldScaling().z()); + ms.mulPose(VectorConversionsMCKt.toMinecraft(renderTransform.getShipToWorldRotation())); + ms.translate( + cw$cluster.anchor.getX() - renderTransform.getPositionInShip().x(), + cw$cluster.anchor.getY() - renderTransform.getPositionInShip().y(), + cw$cluster.anchor.getZ() - renderTransform.getPositionInShip().z() + ); + + AllSpecialTextures faceTexture = optionalFaceTexture.get(); + PoseStack.Pose pose = ms.last(); + RenderType renderType = RenderTypes.getOutlineTranslucent(faceTexture.getLocation(), true); + VertexConsumer consumer = buffer.getLateBuffer(renderType); + + cw$cluster.visibleFaces.forEach((face, axisDirection) -> { + Direction direction = Direction.get(axisDirection, face.axis); + BlockPos pos = face.pos; + if (axisDirection == Direction.AxisDirection.POSITIVE) + pos = pos.relative(direction.getOpposite()); + + bufferBlockFace(pose, consumer, pos, direction, color, lightmap); + }); + + ms.popPose(); + ci.cancel(); + } + } + } + + @Inject(method = "renderEdges", at = @At("HEAD"), cancellable = true) + private void preRenderEdges(PoseStack ms, SuperRenderTypeBuffer buffer, Vec3 camera, float pt, Vector4f color, int lightmap, boolean disableNormals, CallbackInfo ci) { + if (cw$cluster != null) { + final BlockPos anchorPos = cw$cluster.anchor; + if (anchorPos == null) { + return; + } + final Level level = Minecraft.getInstance().level; + final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, anchorPos); + if (ship != null) { + float lineWidth = params.getLineWidth(); + if (lineWidth == 0) + return; + if (cw$cluster.isEmpty()) + return; + + final ShipTransform renderTransform = ship.getRenderTransform(); + + ms.pushPose(); + ms.translate(renderTransform.getPositionInWorld().x() - camera.x, renderTransform.getPositionInWorld().y() - camera.y, renderTransform.getPositionInWorld().z() - camera.z); + ms.scale((float) renderTransform.getShipToWorldScaling().x(), (float) renderTransform.getShipToWorldScaling().y(), (float) renderTransform.getShipToWorldScaling().z()); + ms.mulPose(VectorConversionsMCKt.toMinecraft(renderTransform.getShipToWorldRotation())); + ms.translate( + cw$cluster.anchor.getX() - renderTransform.getPositionInShip().x(), + cw$cluster.anchor.getY() - renderTransform.getPositionInShip().y(), + cw$cluster.anchor.getZ() - renderTransform.getPositionInShip().z() + ); + + PoseStack.Pose pose = ms.last(); + VertexConsumer consumer = buffer.getBuffer(RenderTypes.getOutlineSolid()); + + cw$cluster.visibleEdges.forEach(edge -> { + BlockPos pos = edge.pos; + Vector3f origin = originTemp; + origin.set(pos.getX(), pos.getY(), pos.getZ()); + Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, edge.axis); + bufferCuboidLine(pose, consumer, origin, direction, 1, lineWidth, color, lightmap, disableNormals); + }); + + ms.popPose(); + + ci.cancel(); + } + } + } +} + diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCarriageContraptionInstance.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCarriageContraptionInstance.java new file mode 100644 index 000000000..68db4f5c9 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCarriageContraptionInstance.java @@ -0,0 +1,66 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.jozufozu.flywheel.api.MaterialManager; +import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; +import com.jozufozu.flywheel.util.AnimationTickHolder; +import com.jozufozu.flywheel.util.transform.TransformStack; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Matrix4f; +import com.mojang.math.Vector3f; +import com.simibubi.create.content.trains.entity.CarriageContraptionEntity; +import com.simibubi.create.content.trains.entity.CarriageContraptionInstance; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.joml.Matrix4d; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.core.api.ships.properties.ShipTransform; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(CarriageContraptionInstance.class) +public abstract class MixinCarriageContraptionInstance extends EntityInstance { + + public MixinCarriageContraptionInstance(MaterialManager materialManager, Entity entity) { + super(materialManager, entity); + } + + @Redirect( + method = "beginFrame", at = @At(value = "INVOKE", + target = "Lcom/jozufozu/flywheel/util/transform/TransformStack;translate(Lcom/mojang/math/Vector3f;)Ljava/lang/Object;") + ) + private Object redirectTranslate(final TransformStack instance, final Vector3f vector3f) { + + final float partialTicks = AnimationTickHolder.getPartialTicks(); + final Level level = this.world; + final ClientShip ship = + (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(level, vector3f.x(), vector3f.y(), vector3f.z()); + + if (ship != null) { + final CarriageContraptionEntity carriageContraptionEntity = (CarriageContraptionEntity) this.entity; + final Vector3d origin = VectorConversionsMCKt.toJOMLD(this.materialManager.getOriginCoordinate()); + final Vec3 pos = carriageContraptionEntity.position(); + final Vector3d newPosition = + new Vector3d( + Mth.lerp(partialTicks, carriageContraptionEntity.xOld, pos.x), + Mth.lerp(partialTicks, carriageContraptionEntity.yOld, pos.y), + Mth.lerp(partialTicks, carriageContraptionEntity.zOld, pos.z) + ); + final ShipTransform transform = ship.getRenderTransform(); + Matrix4d renderMatrix = new Matrix4d() + .translate(origin.mul(-1)) + .mul(transform.getShipToWorld()) + .translate(newPosition); + Matrix4f mat4f = VectorConversionsMCKt.toMinecraft(renderMatrix); + ((PoseStack) instance).last().pose().multiply(mat4f); + } else { + instance.translate(vector3f); + } + return null; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItem.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItem.java new file mode 100644 index 000000000..644e81581 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItem.java @@ -0,0 +1,37 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import net.minecraft.client.Minecraft; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(targets = { + "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$SmallCogHelper", + "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$LargeCogHelper", + "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$DiagonalCogHelper", + "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$IntegratedLargeCogHelper", + "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$IntegratedSmallCogHelper" +}) +public class MixinCogwheelBlockItem { + @Redirect(method = "getOffset", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/BlockHitResult;getLocation()Lnet/minecraft/world/phys/Vec3;")) + private Vec3 redirectGetLocation(BlockHitResult instance) { + Vec3 result = instance.getLocation(); + Level world = Minecraft.getInstance().level; + if (world != null) { + Ship ship = VSGameUtilsKt.getShipManagingPos(world, instance.getBlockPos()); + if (ship != null && !VSGameUtilsKt.isBlockInShipyard(world, result.x, result.y, result.z)) { + Vector3d tempVec = VectorConversionsMCKt.toJOML(result); + ship.getWorldToShip().transformPosition(tempVec, tempVec); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + } + return result; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItemHitOnShaft.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItemHitOnShaft.java new file mode 100644 index 000000000..bb68b92d0 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinCogwheelBlockItemHitOnShaft.java @@ -0,0 +1,33 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import net.minecraft.client.Minecraft; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(targets = { + "com.simibubi.create.content.kinetics.simpleRelays.CogwheelBlockItem$DiagonalCogHelper" +}) +public class MixinCogwheelBlockItemHitOnShaft { + @Redirect(method = "hitOnShaft", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/BlockHitResult;getLocation()Lnet/minecraft/world/phys/Vec3;")) + private Vec3 redirectGetLocation(BlockHitResult instance) { + Vec3 result = instance.getLocation(); + Level world = Minecraft.getInstance().level; + if(world!=null) { + Ship ship = VSGameUtilsKt.getShipManagingPos(world, instance.getBlockPos()); + if (ship != null && !VSGameUtilsKt.isBlockInShipyard(world, result.x, result.y, result.z)) { + Vector3d tempVec = VectorConversionsMCKt.toJOML(result); + ship.getWorldToShip().transformPosition(tempVec, tempVec); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + } + return result; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionHandlerClient.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionHandlerClient.java new file mode 100644 index 000000000..68496373e --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionHandlerClient.java @@ -0,0 +1,58 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.simibubi.create.content.contraptions.ContraptionHandlerClient; +import com.simibubi.create.foundation.utility.Couple; +import java.util.Iterator; +import net.minecraft.client.Minecraft; +import net.minecraft.client.player.LocalPlayer; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.joml.Matrix4d; +import org.joml.Quaterniond; +import org.joml.Vector3d; +import org.joml.primitives.AABBic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(ContraptionHandlerClient.class) +public abstract class MixinContraptionHandlerClient { + + @Inject(method = "getRayInputs", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/Couple;create(Ljava/lang/Object;Ljava/lang/Object;)Lcom/simibubi/create/foundation/utility/Couple;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) + private static void redirectedOrigin(final LocalPlayer player, final CallbackInfoReturnable<Couple<Vec3>> cir, final Minecraft mc, Vec3 origin, final double reach, Vec3 target) { + + if (mc.hitResult != null) { + AABB searchAABB = new AABB(origin, target).inflate(0.25, 2, 0.25); + final Iterator<Ship> ships = VSGameUtilsKt.getShipsIntersecting(player.level, searchAABB).iterator(); + + if (ships.hasNext()) { + Ship ship = ships.next(); + + Matrix4d world2Ship = (Matrix4d) ship.getTransform().getWorldToShip(); + AABBic shAABBi = ship.getShipAABB(); + if (shAABBi == null) + return; + AABB shipAABB = new AABB(shAABBi.minX(), shAABBi.minY(), shAABBi.minZ(), shAABBi.maxX(), shAABBi.maxY(), shAABBi.maxZ()); + + + origin = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(origin))); + target = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(target))); + + Quaterniond tempQuat = new Quaterniond(); + if (player.getVehicle() != null && player.getVehicle().getBoundingBox().intersects(shipAABB.inflate(20))) { + ship.getTransform().getWorldToShip().getNormalizedRotation(tempQuat); + tempQuat.invert(); + Vector3d offset = VectorConversionsMCKt.toJOML(target.subtract(origin)); + tempQuat.transform(offset); + target = origin.add(VectorConversionsMCKt.toMinecraft(offset)); + } + } + } + cir.setReturnValue(Couple.create(origin, target)); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderDispatcher.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderDispatcher.java new file mode 100644 index 000000000..17ec80da9 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderDispatcher.java @@ -0,0 +1,26 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.jozufozu.flywheel.util.transform.TransformStack; +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.content.contraptions.render.ContraptionRenderDispatcher; +import net.minecraft.core.Vec3i; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.mod.common.VSClientGameUtils; + +@Mixin(ContraptionRenderDispatcher.class) +public abstract class MixinContraptionRenderDispatcher { + + @Redirect( + method = "renderActors", + at = @At( + value = "INVOKE", + target = "Lcom/jozufozu/flywheel/util/transform/TransformStack;translate(Lnet/minecraft/core/Vec3i;)Ljava/lang/Object;" + ) + ) + private static Object redirectTranslate(final TransformStack instance, final Vec3i vec3i) { + VSClientGameUtils.transformRenderIfInShipyard((PoseStack) instance, vec3i.getX(), vec3i.getY(), vec3i.getZ()); + return instance; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderInfo.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderInfo.java new file mode 100644 index 000000000..b24a697b0 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionRenderInfo.java @@ -0,0 +1,53 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.Contraption; +import com.simibubi.create.content.contraptions.render.ContraptionMatrices; +import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; +import com.simibubi.create.foundation.utility.AnimationTickHolder; +import net.minecraft.util.Mth; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.mod.common.VSClientGameUtils; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(ContraptionRenderInfo.class) +public class MixinContraptionRenderInfo { + + @Shadow + @Final + public Contraption contraption; + @Shadow + @Final + private ContraptionMatrices matrices; + + @Inject(method = "setupMatrices", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;pushPose()V"), cancellable = true) + private void injectAndDoTransformation(PoseStack viewProjection, double camX, double camY, double camZ, CallbackInfo ci) { + AbstractContraptionEntity entity = contraption.entity; + + if (VSGameUtilsKt.getShipManaging(entity) instanceof final ClientShip ship) { + viewProjection.pushPose(); + + double partialTick = AnimationTickHolder.getPartialTicks(); + VSClientGameUtils.transformRenderWithShip( + ship.getRenderTransform(), + viewProjection, + Mth.lerp(partialTick, entity.xOld, entity.getX()), + Mth.lerp(partialTick, entity.yOld, entity.getY()), + Mth.lerp(partialTick, entity.zOld, entity.getZ()), + camX, + camY, + camZ + ); + matrices.setup(viewProjection, entity); + viewProjection.popPose(); + ci.cancel(); + } + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinFilteringRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinFilteringRenderer.java new file mode 100644 index 000000000..352bcf2c2 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinFilteringRenderer.java @@ -0,0 +1,31 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.simibubi.create.foundation.blockEntity.behaviour.filtering.FilteringRenderer; +import net.minecraft.client.Minecraft; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(FilteringRenderer.class) +public class MixinFilteringRenderer { + + @Redirect( + method = "tick", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;") + ) + private static Vec3 redirectSubtract(Vec3 instance, Vec3 vec) { + Vec3 result = VSGameUtilsKt.toShipRenderCoordinates(Minecraft.getInstance().level, vec, instance); + return result.subtract(vec); + } + + @Redirect( + method = "renderOnBlockEntity", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D") + ) + private static double redirectDistanceToSqr(Vec3 instance, Vec3 vec) { + Vec3 result = VSGameUtilsKt.toShipRenderCoordinates(Minecraft.getInstance().level, vec, instance); + return result.distanceToSqr(vec); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinGhostBlockRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinGhostBlockRenderer.java new file mode 100644 index 000000000..cbf095eaa --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinGhostBlockRenderer.java @@ -0,0 +1,21 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.mojang.blaze3d.vertex.PoseStack; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.mod.common.VSClientGameUtils; + +@Mixin(targets = {"com.simibubi.create.foundation.utility.ghost.GhostBlockRenderer$DefaultGhostBlockRenderer", + "com.simibubi.create.foundation.utility.ghost.GhostBlockRenderer$TransparentGhostBlockRenderer"}) +public class MixinGhostBlockRenderer { + + @Redirect( + method = "render", + at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V", ordinal = 0) + ) + private void redirectTranslate( + final PoseStack instance, final double pose, final double d, final double e) { + VSClientGameUtils.transformRenderIfInShipyard(instance, pose, d, e); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinLinkRenderer.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinLinkRenderer.java new file mode 100644 index 000000000..8178ff275 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinLinkRenderer.java @@ -0,0 +1,21 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.simibubi.create.content.redstone.link.LinkRenderer; +import net.minecraft.client.Minecraft; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(LinkRenderer.class) +public class MixinLinkRenderer { + @Redirect( + method = "renderOnBlockEntity", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D") + ) + private static double redirectDistanceToSqr(Vec3 instance, Vec3 vec) { + Vec3 result = VSGameUtilsKt.toShipRenderCoordinates(Minecraft.getInstance().level, vec, instance); + return result.distanceToSqr(vec); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMinecartInstance.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMinecartInstance.java new file mode 100644 index 000000000..630dc7075 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMinecartInstance.java @@ -0,0 +1,59 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.jozufozu.flywheel.api.MaterialManager; +import com.jozufozu.flywheel.backend.instancing.entity.EntityInstance; +import com.jozufozu.flywheel.util.AnimationTickHolder; +import com.jozufozu.flywheel.util.transform.TransformStack; +import com.jozufozu.flywheel.vanilla.MinecartInstance; +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.math.Matrix4f; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.Vec3; +import org.joml.Matrix4d; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.core.api.ships.properties.ShipTransform; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(MinecartInstance.class) +public abstract class MixinMinecartInstance extends EntityInstance { + + + public MixinMinecartInstance(MaterialManager materialManager, Entity entity) { + super(materialManager, entity); + } + + @Redirect( + method = "beginFrame", at = @At(value = "INVOKE", + target = "Lcom/jozufozu/flywheel/util/transform/TransformStack;translate(DDD)Ljava/lang/Object;", ordinal = 0), + remap = false + ) + private Object redirectTranslate(TransformStack instance, double x, double y, double z) { + final float partialTicks = AnimationTickHolder.getPartialTicks(); + if (VSGameUtilsKt.getShipManaging(entity) instanceof ClientShip ship) { + final Vector3d origin = VectorConversionsMCKt.toJOMLD(materialManager.getOriginCoordinate()); + final Vec3 pos = entity.position(); + final Vector3d newPosition = + new Vector3d( + Mth.lerp(partialTicks, entity.xOld, pos.x), + Mth.lerp(partialTicks, entity.yOld, pos.y), + Mth.lerp(partialTicks, entity.zOld, pos.z) + ); + final ShipTransform transform = ship.getRenderTransform(); + Matrix4d renderMatrix = new Matrix4d() + .translate(origin.mul(-1)) + .mul(transform.getShipToWorld()) + .translate(newPosition); + Matrix4f mat4f = VectorConversionsMCKt.toMinecraft(renderMatrix); + ((PoseStack) instance).last().pose().multiply(mat4f); + } else { + instance.translate(x, y, z); + } + return null; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMultiplePlacementHelpers.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMultiplePlacementHelpers.java new file mode 100644 index 000000000..609047cc0 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinMultiplePlacementHelpers.java @@ -0,0 +1,48 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.simibubi.create.foundation.placement.PlacementOffset; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(targets = { + "com.simibubi.create.content.contraptions.bearing.SailBlock$PlacementHelper", + "com.simibubi.create.foundation.placement.PoleHelper", + "com.simibubi.create.content.decoration.girder.GirderPlacementHelper", + "com.simibubi.create.content.trains.display.FlapDisplayBlock$PlacementHelper" +}) +public class MixinMultiplePlacementHelpers { + + @Unique + private Level world; + + @Inject(method = "getOffset", at = @At("HEAD")) + private void harvestWorld(Player player, Level world, BlockState state, BlockPos pos, BlockHitResult ray, CallbackInfoReturnable<PlacementOffset> cir) { + this.world = world; + } + + @Redirect(method = "getOffset", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/BlockHitResult;getLocation()Lnet/minecraft/world/phys/Vec3;")) + private Vec3 redirectGetLocation(BlockHitResult instance) { + Vec3 result = instance.getLocation(); + Ship ship = VSGameUtilsKt.getShipManagingPos(world, instance.getBlockPos()); + if (ship != null && !VSGameUtilsKt.isBlockInShipyard(world,result.x,result.y,result.z)) { + Vector3d tempVec = VectorConversionsMCKt.toJOML(result); + ship.getWorldToShip().transformPosition(tempVec, tempVec); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + return result; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOrientedContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOrientedContraptionEntity.java new file mode 100644 index 000000000..8dae3ebf8 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOrientedContraptionEntity.java @@ -0,0 +1,66 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.jozufozu.flywheel.util.transform.TransformStack; +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.OrientedContraptionEntity; +import net.minecraft.client.Minecraft; +import net.minecraft.world.entity.Entity; +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.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.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(OrientedContraptionEntity.class) +public class MixinOrientedContraptionEntity { + + @Shadow + private Vec3 getCartOffset(float partialTicks, Entity ridingEntity) { + return Vec3.ZERO; + } + + @Redirect(method = "applyLocalTransforms", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/OrientedContraptionEntity;repositionOnCart(Lcom/mojang/blaze3d/vertex/PoseStack;FLnet/minecraft/world/entity/Entity;)V")) + private void redirectRepositionOnCart(OrientedContraptionEntity instance, PoseStack matrixStack, float partialTicks, Entity ridingEntity) { + + Vec3 cartPos = getCartOffset(partialTicks, ridingEntity); + if (cartPos != Vec3.ZERO) matrixStack.translate(cartPos.x, cartPos.y, cartPos.z); + + ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), ridingEntity.blockPosition()); + if (ship != null) { + Quaterniond quaternion = new Quaterniond(); + ship.getRenderTransform().getShipToWorld().getNormalizedRotation(quaternion); + TransformStack.cast(matrixStack).rotateCentered(VectorConversionsMCKt.toMinecraft(quaternion)); + } + } + + @Redirect(method = "repositionOnContraption", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V", ordinal = 0)) + private void redirectTranslate(final PoseStack instance, final double pose, final double d, final double e) { + instance.translate(pose, d, e); + + ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(Minecraft.getInstance().level, ((AbstractContraptionEntity) (Object) this).getVehicle().blockPosition()); + if (ship != null) { + Quaterniond quaternion = new Quaterniond(); + ship.getRenderTransform().getShipToWorld().getNormalizedRotation(quaternion); + TransformStack.cast(instance).rotateCentered(VectorConversionsMCKt.toMinecraft(quaternion)); + } + } + + @Redirect(method = "getContraptionOffset", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getPassengerPosition(Lnet/minecraft/world/entity/Entity;F)Lnet/minecraft/world/phys/Vec3;")) + private Vec3 redirectGetPassengerPosition(AbstractContraptionEntity instance, Entity passenger, float partialTicks) { + Vec3 result = instance.getPassengerPosition(passenger, partialTicks); + + ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), instance.position()); + if (ship != null) { + Vector3d dest = new Vector3d(); + ship.getRenderTransform().getShipToWorld().transformPosition(VectorConversionsMCKt.toJOML(result), dest); + result = VectorConversionsMCKt.toMinecraft(dest); + } + return result; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOutline.java new file mode 100644 index 000000000..7c2f112b2 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOutline.java @@ -0,0 +1,421 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.mojang.blaze3d.vertex.PoseStack; +import com.mojang.blaze3d.vertex.VertexConsumer; +import com.mojang.math.Vector3f; +import com.mojang.math.Vector4f; +import com.simibubi.create.foundation.outliner.Outline; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.texture.OverlayTexture; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.joml.Matrix4dc; +import org.joml.Vector3d; +import org.joml.Vector3dc; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.core.api.ships.properties.ShipTransform; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(Outline.class) +public abstract class MixinOutline { + @Shadow + public abstract void bufferCuboidLine(PoseStack poseStack, VertexConsumer consumer, Vec3 camera, com.mojang.math.Vector3d start, com.mojang.math.Vector3d end, float width, Vector4f color, int lightmap, boolean disableNormals); + + @Shadow + public abstract void bufferQuad(PoseStack.Pose pose, VertexConsumer consumer, Vector3f pos0, Vector3f pos1, Vector3f pos2, Vector3f pos3, Vector4f color, float minU, float minV, float maxU, float maxV, int lightmap, Vector3f normal); + + @Inject(method = "bufferCuboidLine(Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lnet/minecraft/world/phys/Vec3;Lcom/mojang/math/Vector3d;Lcom/mojang/math/Vector3d;FLcom/mojang/math/Vector4f;IZ)V", at = @At("HEAD"), cancellable = true) + private void preBufferCuboidLine0(PoseStack poseStack, VertexConsumer consumer, Vec3 camera, com.mojang.math.Vector3d start, com.mojang.math.Vector3d end, float width, Vector4f color, int lightmap, boolean disableNormals, CallbackInfo ci) { + final Level level = Minecraft.getInstance().level; + if (level != null) { + final Vector3dc average = new Vector3d((start.x + end.x) / 2.0, (start.y + end.y) / 2.0, (start.z + end.z) / 2.0); + final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, average); + if (ship != null) { + final ShipTransform transform = ship.getRenderTransform(); + final Vector3dc startTransformed = transform.getShipToWorld().transformPosition(new Vector3d(start.x, start.y, start.z)); + final Vector3dc endTransformed = transform.getShipToWorld().transformPosition(new Vector3d(end.x, end.y, end.z)); + float scaledWidth = (float) (width * transform.getShipToWorldScaling().x()); + bufferCuboidLine(poseStack, consumer, camera, new com.mojang.math.Vector3d(startTransformed.x(), startTransformed.y(), startTransformed.z()), new com.mojang.math.Vector3d(endTransformed.x(), endTransformed.y(), endTransformed.z()), scaledWidth, color, lightmap, disableNormals); + ci.cancel(); + } + } + } + + @Inject(method = "bufferCuboid", at = @At("HEAD"), cancellable = true) + private void preBufferCuboid(PoseStack.Pose pose, VertexConsumer consumer, Vector3f minPos, Vector3f maxPos, Vector4f color, int lightmap, boolean disableNormals, CallbackInfo ci) { + final Level level = Minecraft.getInstance().level; + if (level != null) { + final Vector3dc average = new Vector3d((minPos.x() + maxPos.x()) / 2.0, (minPos.y() + maxPos.y()) / 2.0, (minPos.z() + maxPos.z()) / 2.0); + final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, average); + if (ship != null) { + final ShipTransform transform = ship.getRenderTransform(); + + final Vector3d temp = new Vector3d(); + + float minX = minPos.x(); + float minY = minPos.y(); + float minZ = minPos.z(); + float maxX = maxPos.x(); + float maxY = maxPos.y(); + float maxZ = maxPos.z(); + + final Matrix4dc newPosMatrix = VectorConversionsMCKt.toJOML(pose.pose()).mul(transform.getShipToWorld()); + + temp.set(minX, minY, maxZ); + newPosMatrix.transformPosition(temp); + double x0 = temp.x(); + double y0 = temp.y(); + double z0 = temp.z(); + //System.out.println("temp is " + temp); + + temp.set(minX, minY, minZ); + newPosMatrix.transformPosition(temp); + double x1 = temp.x(); + double y1 = temp.y(); + double z1 = temp.z(); + + temp.set(maxX, minY, minZ); + newPosMatrix.transformPosition(temp); + double x2 = temp.x(); + double y2 = temp.y(); + double z2 = temp.z(); + + temp.set(maxX, minY, maxZ); + newPosMatrix.transformPosition(temp); + double x3 = temp.x(); + double y3 = temp.y(); + double z3 = temp.z(); + + temp.set(minX, maxY, minZ); + newPosMatrix.transformPosition(temp); + double x4 = temp.x(); + double y4 = temp.y(); + double z4 = temp.z(); + + temp.set(minX, maxY, maxZ); + newPosMatrix.transformPosition(temp); + double x5 = temp.x(); + double y5 = temp.y(); + double z5 = temp.z(); + + temp.set(maxX, maxY, maxZ); + newPosMatrix.transformPosition(temp); + double x6 = temp.x(); + double y6 = temp.y(); + double z6 = temp.z(); + + temp.set(maxX, maxY, minZ); + newPosMatrix.transformPosition(temp); + double x7 = temp.x(); + double y7 = temp.y(); + double z7 = temp.z(); + + float r = color.x(); + float g = color.y(); + float b = color.z(); + float a = color.w(); + + // down + + if (disableNormals) { + temp.set(0, 1, 0); + } else { + temp.set(0, -1, 0); + } + newPosMatrix.transformDirection(temp).normalize(); + float nx0 = (float) temp.x(); + float ny0 = (float) temp.y(); + float nz0 = (float) temp.z(); + + consumer.vertex(x0, y0, z0) + .color(r, g, b, a) + .uv(0, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx0, ny0, nz0) + .endVertex(); + + consumer.vertex(x1, y1, z1) + .color(r, g, b, a) + .uv(0, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx0, ny0, nz0) + .endVertex(); + + consumer.vertex(x2, y2, z2) + .color(r, g, b, a) + .uv(1, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx0, ny0, nz0) + .endVertex(); + + consumer.vertex(x3, y3, z3) + .color(r, g, b, a) + .uv(1, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx0, ny0, nz0) + .endVertex(); + + // up + + temp.set(0, 1, 0); + newPosMatrix.transformDirection(temp).normalize(); + float nx1 = (float) temp.x(); + float ny1 = (float) temp.y(); + float nz1 = (float) temp.z(); + + consumer.vertex(x4, y4, z4) + .color(r, g, b, a) + .uv(0, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx1, ny1, nz1) + .endVertex(); + + consumer.vertex(x5, y5, z5) + .color(r, g, b, a) + .uv(0, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx1, ny1, nz1) + .endVertex(); + + consumer.vertex(x6, y6, z6) + .color(r, g, b, a) + .uv(1, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx1, ny1, nz1) + .endVertex(); + + consumer.vertex(x7, y7, z7) + .color(r, g, b, a) + .uv(1, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx1, ny1, nz1) + .endVertex(); + + // north + + if (disableNormals) { + temp.set(0, 1, 0); + } else { + temp.set(0, 0, -1); + } + newPosMatrix.transformDirection(temp).normalize(); + float nx2 = (float) temp.x(); + float ny2 = (float) temp.y(); + float nz2 = (float) temp.z(); + + consumer.vertex(x7, y7, z7) + .color(r, g, b, a) + .uv(0, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx2, ny2, nz2) + .endVertex(); + + consumer.vertex(x2, y2, z2) + .color(r, g, b, a) + .uv(0, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx2, ny2, nz2) + .endVertex(); + + consumer.vertex(x1, y1, z1) + .color(r, g, b, a) + .uv(1, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx2, ny2, nz2) + .endVertex(); + + consumer.vertex(x4, y4, z4) + .color(r, g, b, a) + .uv(1, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx2, ny2, nz2) + .endVertex(); + + // south + + if (disableNormals) { + temp.set(0, 1, 0); + } else { + temp.set(0, 0, 1); + } + newPosMatrix.transformDirection(temp).normalize(); + float nx3 = (float) temp.x(); + float ny3 = (float) temp.y(); + float nz3 = (float) temp.z(); + + consumer.vertex(x5, y5, z5) + .color(r, g, b, a) + .uv(0, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx3, ny3, nz3) + .endVertex(); + + consumer.vertex(x0, y0, z0) + .color(r, g, b, a) + .uv(0, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx3, ny3, nz3) + .endVertex(); + + consumer.vertex(x3, y3, z3) + .color(r, g, b, a) + .uv(1, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx3, ny3, nz3) + .endVertex(); + + consumer.vertex(x6, y6, z6) + .color(r, g, b, a) + .uv(1, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx3, ny3, nz3) + .endVertex(); + + // west + + if (disableNormals) { + temp.set(0, 1, 0); + } else { + temp.set(-1, 0, 0); + } + newPosMatrix.transformDirection(temp).normalize(); + float nx4 = (float) temp.x(); + float ny4 = (float) temp.y(); + float nz4 = (float) temp.z(); + + consumer.vertex(x4, y4, z4) + .color(r, g, b, a) + .uv(0, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx4, ny4, nz4) + .endVertex(); + + consumer.vertex(x1, y1, z1) + .color(r, g, b, a) + .uv(0, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx4, ny4, nz4) + .endVertex(); + + consumer.vertex(x0, y0, z0) + .color(r, g, b, a) + .uv(1, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx4, ny4, nz4) + .endVertex(); + + consumer.vertex(x5, y5, z5) + .color(r, g, b, a) + .uv(1, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx4, ny4, nz4) + .endVertex(); + + // east + + if (disableNormals) { + temp.set(0, 1, 0); + } else { + temp.set(1, 0, 0); + } + newPosMatrix.transformDirection(temp).normalize(); + float nx5 = (float) temp.x(); + float ny5 = (float) temp.y(); + float nz5 = (float) temp.z(); + + consumer.vertex(x6, y6, z6) + .color(r, g, b, a) + .uv(0, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx5, ny5, nz5) + .endVertex(); + + consumer.vertex(x3, y3, z3) + .color(r, g, b, a) + .uv(0, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx5, ny5, nz5) + .endVertex(); + + consumer.vertex(x2, y2, z2) + .color(r, g, b, a) + .uv(1, 1) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx5, ny5, nz5) + .endVertex(); + + consumer.vertex(x7, y7, z7) + .color(r, g, b, a) + .uv(1, 0) + .overlayCoords(OverlayTexture.NO_OVERLAY) + .uv2(lightmap) + .normal(nx5, ny5, nz5) + .endVertex(); + + ci.cancel(); + } + } + } + + @Inject(method = "bufferQuad(Lcom/mojang/blaze3d/vertex/PoseStack$Pose;Lcom/mojang/blaze3d/vertex/VertexConsumer;Lcom/mojang/math/Vector3f;Lcom/mojang/math/Vector3f;Lcom/mojang/math/Vector3f;Lcom/mojang/math/Vector3f;Lcom/mojang/math/Vector4f;FFFFILcom/mojang/math/Vector3f;)V", at = @At("HEAD"), cancellable = true) + private void preBufferQuad(PoseStack.Pose pose, VertexConsumer consumer, Vector3f pos0, Vector3f pos1, Vector3f pos2, Vector3f pos3, Vector4f color, float minU, float minV, float maxU, float maxV, int lightmap, Vector3f normal, CallbackInfo ci) { + final Level level = Minecraft.getInstance().level; + if (level != null) { + final Vector3dc average = new Vector3d((pos0.x() + pos1.x() + pos2.x() + pos3.x()) / 4.0, (pos0.y() + pos1.y() + pos2.y() + pos3.y()) / 4.0, (pos0.z() + pos1.z() + pos2.z() + pos3.z()) / 4.0); + final ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(level, average); + if (ship != null) { + final ShipTransform transform = ship.getRenderTransform(); + final Vector3dc pos0Transformed = transform.getShipToWorld().transformPosition(new Vector3d(pos0.x(), pos0.y(), pos0.z())); + final Vector3dc pos1Transformed = transform.getShipToWorld().transformPosition(new Vector3d(pos1.x(), pos1.y(), pos1.z())); + final Vector3dc pos2Transformed = transform.getShipToWorld().transformPosition(new Vector3d(pos2.x(), pos2.y(), pos2.z())); + final Vector3dc pos3Transformed = transform.getShipToWorld().transformPosition(new Vector3d(pos3.x(), pos3.y(), pos3.z())); + final Vector3dc normalTransformed = transform.getShipToWorld().transformDirection(new Vector3d(normal.x(), normal.y(), normal.z())); + bufferQuad( + pose, + consumer, + new Vector3f((float) pos0Transformed.x(), (float) pos0Transformed.y(), (float) pos0Transformed.z()), + new Vector3f((float) pos1Transformed.x(), (float) pos1Transformed.y(), (float) pos1Transformed.z()), + new Vector3f((float) pos2Transformed.x(), (float) pos2Transformed.y(), (float) pos2Transformed.z()), + new Vector3f((float) pos3Transformed.x(), (float) pos3Transformed.y(), (float) pos3Transformed.z()), + color, + minU, + minV, + maxU, + maxV, + lightmap, + new Vector3f((float) normalTransformed.x(), (float) normalTransformed.y(), (float) normalTransformed.z()) + ); + ci.cancel(); + } + } + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinPlacementHelpers.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinPlacementHelpers.java new file mode 100644 index 000000000..093fe2061 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinPlacementHelpers.java @@ -0,0 +1,30 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.simibubi.create.foundation.placement.PlacementHelpers; +import com.simibubi.create.foundation.utility.VecHelper; +import net.minecraft.client.Minecraft; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(PlacementHelpers.class) +public class MixinPlacementHelpers { + @Redirect(method = "drawDirectionIndicator", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/VecHelper;getCenterOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 redirectGetCenterOf(Vec3i pos) { + Vec3 result = VecHelper.getCenterOf(pos); + Level world = Minecraft.getInstance().level; + if (world != null && VSGameUtilsKt.isBlockInShipyard(world, pos.getX(),pos.getY(),pos.getZ()) && VSGameUtilsKt.getShipManagingPos(world, pos.getX(),pos.getY(),pos.getZ()) instanceof ClientShip ship) { + Vector3d tempVec = new Vector3d(pos.getX() + .5, pos.getY() + .5, pos.getZ() + .5); + ship.getShipToWorld().transformPosition(tempVec, tempVec); + result = VectorConversionsMCKt.toMinecraft(tempVec); + } + return result; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSoundScapes.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSoundScapes.java new file mode 100644 index 000000000..b0aa8caad --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinSoundScapes.java @@ -0,0 +1,43 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.simibubi.create.foundation.sound.SoundScapes; +import net.minecraft.client.Minecraft; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(SoundScapes.class) +public abstract class MixinSoundScapes { + + @Redirect(method = "outOfRange", at = @At(value = "INVOKE", target = "Lnet/minecraft/core/BlockPos;closerThan(Lnet/minecraft/core/Vec3i;D)Z")) + private static boolean redirectCloserThan(BlockPos instance, Vec3i vec3i, double v) { + Vec3 newVec3 = new Vec3(vec3i.getX(), vec3i.getY(), vec3i.getZ()); + Level world = Minecraft.getInstance().player.level; + final Ship ship = VSGameUtilsKt.getShipManagingPos(world, newVec3); + if (ship != null) { + newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, newVec3); + } + return new Vec3(instance.getX(), instance.getY(), instance.getZ()).closerThan(newVec3, v); + } + + @ModifyVariable(method = "play", at = @At("HEAD"), index = 1, argsOnly = true) + private static BlockPos modBlockPos(BlockPos value) { + BlockPos result = value; + Level world = Minecraft.getInstance().player.level; + final Ship ship = VSGameUtilsKt.getShipManagingPos(world, value); + if (ship != null) { + Vector3d tempVec = new Vector3d(); + ship.getTransform().getShipToWorld().transformPosition(value.getX(), value.getY(), value.getZ(), tempVec); + result = new BlockPos(tempVec.x, tempVec.y, tempVec.z); + } + return result; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTileEntityRenderHelper.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTileEntityRenderHelper.java new file mode 100644 index 000000000..5b15a5eef --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTileEntityRenderHelper.java @@ -0,0 +1,25 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.jozufozu.flywheel.util.transform.TransformStack; +import com.mojang.blaze3d.vertex.PoseStack; +import com.simibubi.create.foundation.render.BlockEntityRenderHelper; +import net.minecraft.core.Vec3i; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.mod.common.VSClientGameUtils; + +@Mixin(BlockEntityRenderHelper.class) +public abstract class MixinTileEntityRenderHelper { + @Redirect( + method = "renderBlockEntities(Lnet/minecraft/world/level/Level;Lcom/jozufozu/flywheel/core/virtual/VirtualRenderWorld;Ljava/lang/Iterable;Lcom/mojang/blaze3d/vertex/PoseStack;Lcom/mojang/math/Matrix4f;Lnet/minecraft/client/renderer/MultiBufferSource;F)V", + at = @At( + value = "INVOKE", + target = "Lcom/jozufozu/flywheel/util/transform/TransformStack;translate(Lnet/minecraft/core/Vec3i;)Ljava/lang/Object;" + ) + ) + private static Object redirectTranslate(final TransformStack instance, final Vec3i vec3i) { + VSClientGameUtils.transformRenderIfInShipyard((PoseStack) instance, vec3i.getX(), vec3i.getY(), vec3i.getZ()); + return instance; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java new file mode 100644 index 000000000..69d74d550 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrackBlockOutline.java @@ -0,0 +1,84 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.simibubi.create.content.trains.track.TrackBlockOutline; +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.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.mod.common.VSGameUtilsKt; + +@Mixin(TrackBlockOutline.class) +public class MixinTrackBlockOutline { + @Unique + private static boolean isShip = false; + @Unique + private static BlockPos shipBlockPos; + + @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.hitResult.getType() == Type.BLOCK) { + shipBlockPos = ((BlockHitResult) mc.hitResult).getBlockPos(); + + final List<Vector3d> + ships = VSGameUtilsKt.transformToNearbyShipsAndWorld(mc.level, shipBlockPos.getX(), shipBlockPos.getY(), + shipBlockPos.getZ(), 10); + isShip = !ships.isEmpty(); + } + } + + @Redirect( + method = "pickCurves()V", + 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<Vector3d> + 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); + } 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;" + ) + ) + private static Vec3 redirectedTarget(final Player playerIn, final double range, final Vec3 origin) { + if (isShip) { + return new Vec3(shipBlockPos.getX(), shipBlockPos.getY(), shipBlockPos.getZ()); + } else { + return RaycastHelper.getTraceTarget(playerIn, range, origin); + } + } +} 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 new file mode 100644 index 000000000..c59d5bf4f --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinTrainRelocator.java @@ -0,0 +1,27 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.simibubi.create.content.trains.entity.TrainRelocator; +import net.minecraft.client.Minecraft; +import net.minecraft.core.Position; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(TrainRelocator.class) +public abstract class MixinTrainRelocator { + + @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;closerThan(Lnet/minecraft/core/Position;D)Z")) + private static boolean redirectCloserThan(final Vec3 instance, final Position arg, final double d) { + Vec3 newVec3 = (Vec3) arg; + Level world = Minecraft.getInstance().player.level; + final Ship ship = VSGameUtilsKt.getShipManagingPos(world, arg); + if (ship != null) { + newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, (Vec3) arg); + } + return instance.closerThan(newVec3, d); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinAbstractContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinAbstractContraptionEntity.java new file mode 100644 index 000000000..7c23b115e --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinAbstractContraptionEntity.java @@ -0,0 +1,259 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.entity; + +import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; +import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toMinecraft; + +import com.simibubi.create.CreateClient; +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.plough.PloughMovementBehaviour; +import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; +import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; +import com.simibubi.create.content.contraptions.behaviour.MovementContext; +import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour; +import com.simibubi.create.content.kinetics.deployer.DeployerFakePlayer; +import com.simibubi.create.content.kinetics.deployer.DeployerMovementBehaviour; +import com.simibubi.create.foundation.utility.VecHelper; +import java.util.Iterator; +import net.minecraft.core.BlockPos; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.vehicle.AbstractMinecart; +import net.minecraft.world.item.BlockItem; +import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.CocoaBlock; +import net.minecraft.world.level.block.CropBlock; +import net.minecraft.world.level.block.DirectionalBlock; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.apache.commons.lang3.tuple.MutablePair; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.NotNull; +import org.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.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.CompatUtil; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.mixin.mod_compat.create.IMixinDeployerHandler; +import org.valkyrienskies.mod.mixin.mod_compat.create.IMixinDeployerMovementBehaviour; +import org.valkyrienskies.mod.mixinducks.mod_compat.create.MixinAbstractContraptionEntityDuck; + +@Mixin(AbstractContraptionEntity.class) +public abstract class MixinAbstractContraptionEntity extends Entity implements MixinAbstractContraptionEntityDuck { + + public MixinAbstractContraptionEntity(EntityType<?> entityType, Level level) { + super(entityType, level); + } + + @Unique + private static final Logger LOGGER = LogManager.getLogger("Clockwork.MixinAbstractContraptionEntity"); + + @Shadow(remap = false) + protected Contraption contraption; + + @Shadow + public abstract Vec3 getPassengerPosition(Entity passenger, float partialTicks); + + @Shadow + public abstract Vec3 applyRotation(Vec3 localPos, float partialTicks); + + @Shadow + public abstract Vec3 getAnchorVec(); + + @Shadow + public abstract Vec3 getPrevAnchorVec(); + + //Region start - fix being sent to the ̶s̶h̶a̶d̶o̶w̶r̶e̶a̶l̶m̶ shipyard on ship contraption disassembly + @Redirect(method = "moveCollidedEntitiesOnDisassembly", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setPos(DDD)V")) + private void redirectSetPos(Entity instance, double x, double y, double z) { + Vec3 result = CompatUtil.INSTANCE.toSameSpaceAs(instance.getCommandSenderWorld(), x, y, z, instance.position()); + if (instance.position().distanceTo(result) < 20) { + instance.setPos(result.x, result.y, result.z); + } else LOGGER.warn("Warning distance too high ignoring setPos request"); + } + + @Redirect(method = "moveCollidedEntitiesOnDisassembly", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;teleportTo(DDD)V")) + private void redirectTeleportTo(Entity instance, double x, double y, double z) { + Vec3 result = CompatUtil.INSTANCE.toSameSpaceAs(instance.getCommandSenderWorld(), x, y, z, instance.position()); + if (instance.position().distanceTo(result) < 20) { + if (VSGameUtilsKt.isBlockInShipyard(instance.getCommandSenderWorld(), result.x, result.y, result.z) && instance instanceof AbstractMinecart) { + result.add(0, 0.5, 0); + } + instance.teleportTo(result.x, result.y, result.z); + } else { + LOGGER.warn("Warning distance too high ignoring teleportTo request"); + } + } + + //Region end + //Region start - fix entity rider position on ship contraptions + @Override + public void positionRider(@NotNull Entity passenger) { + 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); + riderPos.add(0, SeatEntity.getCustomEntitySeatOffset(passenger) - 1 / 8f, 0); + if (ship != null) { + riderPos = toMinecraft(ship.getShipToWorld().transformPosition(toJOML(riderPos))); + } + } + passenger.setPos(riderPos); + } + + @Inject(method = "toGlobalVector(Lnet/minecraft/world/phys/Vec3;FZ)Lnet/minecraft/world/phys/Vec3;", + at = @At("HEAD"), cancellable = true) + private void redirectToGlobalVector(Vec3 localVec, final float partialTicks, final boolean prevAnchor, final CallbackInfoReturnable<Vec3> cir) { + if (partialTicks != 1 && !prevAnchor) { + final Vec3 anchor = getAnchorVec(); + final Vec3 oldAnchor = getPrevAnchorVec(); + final Vec3 lerpedAnchor = + new Vec3( + Mth.lerp(partialTicks, oldAnchor.x, anchor.x), + Mth.lerp(partialTicks, oldAnchor.y, anchor.y), + Mth.lerp(partialTicks, oldAnchor.z, anchor.z) + ); + final Vec3 rotationOffset = VecHelper.getCenterOf(BlockPos.ZERO); + localVec = localVec.subtract(rotationOffset); + localVec = applyRotation(localVec, partialTicks); + localVec = localVec.add(rotationOffset) + .add(lerpedAnchor); + cir.setReturnValue(localVec); + } + } + + //Region end + //Region start - Ship contraption actors affecting world + @Shadow + public abstract Vec3 toGlobalVector(Vec3 localVec, float partialTicks); + + @Shadow + public abstract Vec3 getPrevPositionVec(); + + @Shadow + protected abstract StructureTransform makeStructureTransform(); + + @Unique + private static Boolean isValidBlock(Level world, BlockPos colliderPos, MovementBehaviour movementBehaviour, MovementContext context) { + BlockState worldBlockState = world.getBlockState(colliderPos); + if (worldBlockState.getBlock() instanceof CocoaBlock) + return false; + if (movementBehaviour != null) { + if (movementBehaviour instanceof DeployerMovementBehaviour && context.temporaryData instanceof DeployerFakePlayer player) { + ((IMixinDeployerMovementBehaviour) movementBehaviour).invokeTryGrabbingItem(context); + if ((player.getMainHandItem().getItem() instanceof BlockItem blockItem) && (blockItem.getBlock() instanceof CropBlock)) { + return IMixinDeployerHandler.invokeShouldActivate(player.getMainHandItem(), context.world, colliderPos, null); + } else + return false; + } + if (movementBehaviour instanceof PloughMovementBehaviour behaviour) { + return worldBlockState.isAir() || behaviour.canBreak(world, colliderPos, worldBlockState); + } + if (movementBehaviour instanceof HarvesterMovementBehaviour harvesterMovementBehaviour) { + return harvesterMovementBehaviour.isValidCrop(world, colliderPos, worldBlockState) + || harvesterMovementBehaviour.isValidOther(world, colliderPos, worldBlockState); + } + if (movementBehaviour instanceof BlockBreakingMovementBehaviour behaviour) { + return behaviour.canBreak(world, colliderPos, worldBlockState); + } + } + return !worldBlockState.isAir(); + } + + @Unique + private boolean shouldMod(MovementBehaviour moveBehaviour) { + return ((moveBehaviour instanceof BlockBreakingMovementBehaviour) || (moveBehaviour instanceof HarvesterMovementBehaviour) || (moveBehaviour instanceof DeployerMovementBehaviour)); + } + + @Unique + private StructureTemplate.StructureBlockInfo structureBlockInfo; + + @Inject(method = "tickActors", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/AllMovementBehaviours;getBehaviour(Lnet/minecraft/world/level/block/state/BlockState;)Lcom/simibubi/create/content/contraptions/behaviour/MovementBehaviour;"), locals = LocalCapture.CAPTURE_FAILHARD) + private void injectTickActors(CallbackInfo ci, boolean stalledPreviously, Iterator<MutablePair<StructureTemplate.StructureBlockInfo, MovementContext>> var2, MutablePair<StructureTemplate.StructureBlockInfo, MovementContext> pair, MovementContext context, StructureTemplate.StructureBlockInfo blockInfo) { + structureBlockInfo = blockInfo; + } + + @Unique + private BlockPos getTargetPos(MovementBehaviour instance, MovementContext context, BlockPos pos, StructureTemplate.StructureBlockInfo blockInfo) { + if (shouldMod(instance) && context.world.getBlockState(pos).isAir() && VSGameUtilsKt.isBlockInShipyard(context.world, pos)) { + Ship ship = VSGameUtilsKt.getShipManagingPos(context.world, pos); + if (ship != null) { + Vector3d searchPos = toJOML(toGlobalVector(VecHelper.getCenterOf(blockInfo.pos) + .add(instance.getActiveAreaOffset(context)), 1)); + Vector3d searchPos2 = new Vector3d(searchPos); + + Vec3 transformedSearchPos = toMinecraft(ship.getShipToWorld().transformPosition(searchPos)); + if (blockInfo.state.hasProperty(DirectionalBlock.FACING)) { + searchPos2.add(toJOML( + Vec3.atLowerCornerOf(blockInfo.state.getValue(DirectionalBlock.FACING).getNormal()) + )); + } else { + searchPos2.add(0, 0, 1); + } + Vec3 transformedSearchPos2 = toMinecraft(ship.getShipToWorld().transformPosition(searchPos2)); + BlockPos blockPos = new BlockPos(transformedSearchPos); + boolean check = isValidBlock(context.world, blockPos, instance, context); + if (level.isClientSide) { + //Debug helper for future mixin work + //boolean debugView = Minecraft.getInstance().options.renderDebug; + if (false) { + int ttl = 100; + CreateClient.OUTLINER.showLine("actorPosDebugLine-" + context.localPos + "-" + context.contraption.anchor, transformedSearchPos, transformedSearchPos2) + .colored(0x0070ff) + .lineWidth(2 / 32f); + CreateClient.OUTLINER.showAABB("actorPosDebug-" + context.localPos + "-" + context.contraption.anchor, new AABB(blockPos.getX(), blockPos.getY(), blockPos.getZ(), blockPos.getX() + 1, blockPos.getY() + 1, blockPos.getZ() + 1), ttl) + .colored(check ? 0xff7000 : 0x70ff00) + .lineWidth(2 / 16f); + } + } + if (check) + pos = blockPos; + } + } + return pos; + } + + @Redirect(method = "tickActors", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/behaviour/MovementBehaviour;visitNewPosition(Lcom/simibubi/create/content/contraptions/behaviour/MovementContext;Lnet/minecraft/core/BlockPos;)V")) + private void redirectVisitNewPosition(MovementBehaviour instance, MovementContext context, BlockPos pos) { + instance.visitNewPosition(context, getTargetPos(instance, context, pos, structureBlockInfo)); + } + + //Region end + //Region start - Contraption Entity Collision + @Inject(method = "getContactPointMotion", at = @At("HEAD")) + private void modGetContactPointMotion(Vec3 globalContactPoint, CallbackInfoReturnable<Vec3> cir) { + if (VSGameUtilsKt.isBlockInShipyard(level, getAnchorVec().x, getAnchorVec().y, getAnchorVec().z) != VSGameUtilsKt.isBlockInShipyard(level, getPrevAnchorVec().x, getPrevAnchorVec().y, getPrevAnchorVec().z)) { + Ship ship = VSGameUtilsKt.getShipManagingPos(level, getAnchorVec()); + if (ship != null) { + Vec3 result = toMinecraft(ship.getWorldToShip().transformPosition(toJOML(getPrevPositionVec()))); + xo = result.x; + yo = result.y; + zo = result.z; + } + } + } + //Region end + + @Override + public StructureTransform getStructureTransform() { + return makeStructureTransform(); + } +} 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 new file mode 100644 index 000000000..a0a18c037 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinCarriageContraptionEntity.java @@ -0,0 +1,50 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.entity; + +import com.simibubi.create.content.trains.entity.CarriageContraptionEntity; +import java.util.Collection; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Position; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(CarriageContraptionEntity.class) +public abstract class MixinCarriageContraptionEntity { + @Unique + private Level world; + + @Inject( + method = "control", + at = @At("HEAD"), locals = LocalCapture.CAPTURE_FAILHARD + ) + private void injectCaptureLevel( + final BlockPos controlsLocalPos, final Collection<Integer> heldControls, final Player player, + final CallbackInfoReturnable<Boolean> cir) { + this.world = player.level; + } + + @Redirect( + method = "control", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;closerThan(Lnet/minecraft/core/Position;D)Z" + ) + ) + private boolean redirectCloserThan(final Vec3 instance, final Position arg, final double d) { + Vec3 newVec3 = instance; + if (VSGameUtilsKt.isBlockInShipyard(this.world, new BlockPos(instance.x, instance.y, instance.z))) { + final Ship ship = VSGameUtilsKt.getShipManagingPos(this.world, instance); + newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, instance); + } + return newVec3.closerThan(arg, d); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinControlledContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinControlledContraptionEntity.java new file mode 100644 index 000000000..c8edbc7cc --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinControlledContraptionEntity.java @@ -0,0 +1,49 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.entity; + +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.ControlledContraptionEntity; +import com.simibubi.create.content.contraptions.IControlContraption; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.mod.mixinducks.mod_compat.create.IMixinControlledContraptionEntity; + +@Mixin(ControlledContraptionEntity.class) +public abstract class MixinControlledContraptionEntity extends AbstractContraptionEntity implements + IMixinControlledContraptionEntity { + @Shadow protected abstract IControlContraption getController(); + + public MixinControlledContraptionEntity(EntityType<?> entityTypeIn, Level worldIn) { + super(entityTypeIn, worldIn); + } + + //Region start - fix equals -0 != 0 + private Vec3 flatten(Vec3 vec3) { + if (vec3.x == -0) + vec3 = new Vec3(0, vec3.y, vec3.z); + if (vec3.y == -0) + vec3 = new Vec3(vec3.x, 0, vec3.z); + if (vec3.z == -0) + vec3 = new Vec3(vec3.x, vec3.y, 0); + return vec3; + } + + @Redirect(method = "shouldActorTrigger", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;equals(Ljava/lang/Object;)Z")) + private boolean redirectEquals(Vec3 instance, Object vec3) { + Vec3 other = (Vec3) vec3; + other = flatten(other); + instance = flatten(instance); + return instance.equals(other); + } + + //Region end + + @Override + public IControlContraption grabController(){ + return getController(); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinSeatEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinSeatEntity.java new file mode 100644 index 000000000..ca277740c --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinSeatEntity.java @@ -0,0 +1,44 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.entity; + +import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.jetbrains.annotations.NotNull; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(SeatEntity.class) +public abstract class MixinSeatEntity extends Entity { + + @Shadow + public static double getCustomEntitySeatOffset(Entity entity) { + return 0; + } + + public MixinSeatEntity(EntityType<?> entityType, Level level) { + super(entityType, level); + } + + @Override + public void positionRider(@NotNull Entity passenger) { + 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) { + Vector3d tempVec = VectorConversionsMCKt.toJOML(riderPos); + ship.getShipToWorld().transformPosition(tempVec, tempVec); + riderPos = VectorConversionsMCKt.toMinecraft(tempVec); + } + passenger.setPos(riderPos); + } +} 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 new file mode 100644 index 000000000..fcebd0771 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinControlsInputPacket.java @@ -0,0 +1,47 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.packets; + +import com.simibubi.create.content.contraptions.actors.trainControls.ControlsInputPacket; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Position; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(ControlsInputPacket.class) +public abstract class MixinControlsInputPacket { + @Unique + private Level level; + + @Redirect( + method = "lambda$handle$0", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/phys/Vec3;closerThan(Lnet/minecraft/core/Position;D)Z" + ) + ) + private boolean redirectCloserThan(final Vec3 instance, final Position arg, final double d) { + Vec3 newVec3 = instance; + if (VSGameUtilsKt.isBlockInShipyard(this.level, new BlockPos(instance.x, instance.y, instance.z))) { + final Ship ship = VSGameUtilsKt.getShipManagingPos(this.level, instance); + newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, instance); + } + return newVec3.closerThan(arg, d); + } + + @Redirect( + method = "lambda$handle$0", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/server/level/ServerPlayer;getCommandSenderWorld()Lnet/minecraft/world/level/Level;" + ) + ) + private Level stealLevel(ServerPlayer player) { + return (level = player.getCommandSenderWorld()); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinCurvedTrackDestroyPacket.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinCurvedTrackDestroyPacket.java new file mode 100644 index 000000000..24763945c --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinCurvedTrackDestroyPacket.java @@ -0,0 +1,49 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.packets; + +import com.simibubi.create.content.trains.track.CurvedTrackDestroyPacket; +import com.simibubi.create.content.trains.track.TrackBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.level.Level; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(CurvedTrackDestroyPacket.class) +public abstract class MixinCurvedTrackDestroyPacket { + @Unique + private Level world; + + @Redirect( + method = "applySettings(Lnet/minecraft/server/level/ServerPlayer;Lcom/simibubi/create/content/trains/track/TrackBlockEntity;)V", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/core/BlockPos;closerThan(Lnet/minecraft/core/Vec3i;D)Z" + ) + ) + private boolean redirectCloserThan(final BlockPos instance, final Vec3i vec3i, final double v) { + BlockPos blockPos = instance; + if (VSGameUtilsKt.isBlockInShipyard(this.world, instance)) { + final Ship ship = VSGameUtilsKt.getShipManagingPos(this.world, instance); + final Vector3d tempVec = VSGameUtilsKt.toWorldCoordinates(ship, instance); + blockPos = new BlockPos(tempVec.x, tempVec.y, tempVec.z); + } + return blockPos.closerThan(vec3i, v); + } + + @Inject( + method = "applySettings(Lnet/minecraft/server/level/ServerPlayer;Lcom/simibubi/create/content/trains/track/TrackBlockEntity;)V", + at = @At("HEAD"), locals = LocalCapture.CAPTURE_FAILHARD + ) + private void injectCaptureLevel(final ServerPlayer player, final TrackBlockEntity te, final CallbackInfo ci) { + this.world = player.level; + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinSuperGlueRemovalPacket.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinSuperGlueRemovalPacket.java new file mode 100644 index 000000000..3b034986d --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinSuperGlueRemovalPacket.java @@ -0,0 +1,28 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.packets; + +import com.simibubi.create.content.contraptions.glue.SuperGlueRemovalPacket; +import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerPlayer; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(SuperGlueRemovalPacket.class) +public abstract class MixinSuperGlueRemovalPacket { + @Redirect(method = "lambda$handle$0", at = @At(value = "INVOKE", target = "Lnet/minecraft/server/level/ServerPlayer;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D")) + private double redirectPlayerDistanceToSqr(final ServerPlayer instance, final Vec3 vec3) { + Vec3 newVec3 = vec3; + if (VSGameUtilsKt.isBlockInShipyard(instance.level, new BlockPos(vec3.x, vec3.y, vec3.z))) { + final Ship ship = VSGameUtilsKt.getShipManagingPos(instance.level, vec3); + if (ship != null) { + newVec3 = VectorConversionsMCKt.toMinecraft(ship.getShipToWorld().transformPosition(new Vector3d(vec3.x, vec3.y, vec3.z))); + } + } + return instance.distanceToSqr(newVec3); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTileEntityConfigurationPacket.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTileEntityConfigurationPacket.java new file mode 100644 index 000000000..d1eea4999 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTileEntityConfigurationPacket.java @@ -0,0 +1,48 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.packets; + +import com.simibubi.create.foundation.networking.BlockEntityConfigurationPacket; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.world.level.Level; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(BlockEntityConfigurationPacket.class) +public abstract class MixinTileEntityConfigurationPacket { + @Unique + private Level _clockworkLevel; + + @Redirect( + method = "lambda$handle$0", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/core/BlockPos;closerThan(Lnet/minecraft/core/Vec3i;D)Z" + ) + ) + private boolean redirectCloserThan(final BlockPos instance, final Vec3i vec3i, final double v) { + BlockPos blockPos = instance; + if (VSGameUtilsKt.isBlockInShipyard(this._clockworkLevel, instance)) { + final Ship ship = VSGameUtilsKt.getShipManagingPos(this._clockworkLevel, instance); + final Vector3d tempVec = VSGameUtilsKt.toWorldCoordinates(ship, instance); + blockPos = new BlockPos(tempVec.x, tempVec.y, tempVec.z); + } + return blockPos.closerThan(vec3i, v); + } + + @Redirect( + method = "lambda$handle$0", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/level/Level;isLoaded(Lnet/minecraft/core/BlockPos;)Z" + ) + ) + private boolean injectCaptureLevel(final Level instance, final BlockPos pos) { + this._clockworkLevel = instance; + return instance.isLoaded(pos); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTrainRelocationPacket.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTrainRelocationPacket.java new file mode 100644 index 000000000..c46630797 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/packets/MixinTrainRelocationPacket.java @@ -0,0 +1,34 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.packets; + +import com.simibubi.create.content.trains.entity.TrainRelocationPacket; +import net.minecraft.core.Position; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(TrainRelocationPacket.class) +public abstract class MixinTrainRelocationPacket { + @Unique + private Level level; + + @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;closerThan(Lnet/minecraft/core/Position;D)Z")) + private boolean redirectCloserThan(final Vec3 instance, final Position arg, final double d) { + Vec3 newVec3 = (Vec3) arg; + final Ship ship = VSGameUtilsKt.getShipManagingPos(this.level, arg); + if (ship != null) { + newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, (Vec3) arg); + } + return instance.closerThan(newVec3, d); + } + + @Redirect(method = "*", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;getEntity(I)Lnet/minecraft/world/entity/Entity;")) + private Entity stealLevel(Level instance, int i) { + return (level = instance).getEntity(i); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/pr/MixinSeatBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/pr/MixinSeatBlock.java new file mode 100644 index 000000000..d80d0baad --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/pr/MixinSeatBlock.java @@ -0,0 +1,30 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.pr; + +import com.simibubi.create.content.contraptions.actors.seat.SeatBlock; +import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; + +@Mixin(SeatBlock.class) +public class MixinSeatBlock { + + /** + * @author ewoudje + * @reason Floating point additions help + */ + @Overwrite(remap = false) + public static void sitDown(Level world, BlockPos pos, Entity entity) { + if (world.isClientSide) + return; + SeatEntity seat = new SeatEntity(world, pos); + seat.setPos(pos.getX() + .5, pos.getY(), pos.getZ() + .5); + world.addFreshEntity(seat); + entity.startRiding(seat, true); + if (entity instanceof TamableAnimal ta) + ta.setInSittingPose(true); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWCluster.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWCluster.java new file mode 100644 index 000000000..4aada2a8b --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWCluster.java @@ -0,0 +1,73 @@ +package org.valkyrienskies.mod.mixinducks.mod_compat.create; + +import com.simibubi.create.foundation.utility.Iterate; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; + +/** + * This class only exists because Creates Cluster class is private, and I can't get an access widener to work on it >.< + */ +public class CWCluster { + public BlockPos anchor; + public final Map<CWMergeEntry, Direction.AxisDirection> visibleFaces; + public final Set<CWMergeEntry> visibleEdges; + + public CWCluster() { + visibleEdges = new HashSet<>(); + visibleFaces = new HashMap<>(); + } + + public boolean isEmpty() { + return anchor == null; + } + + public void include(BlockPos pos) { + if (anchor == null) + anchor = pos; + + pos = pos.subtract(anchor); + + // 6 FACES + for (Direction.Axis axis : Iterate.axes) { + Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, axis); + for (int offset : Iterate.zeroAndOne) { + CWMergeEntry entry = new CWMergeEntry(axis, pos.relative(direction, offset)); + if (visibleFaces.remove(entry) == null) + visibleFaces.put(entry, offset == 0 ? Direction.AxisDirection.NEGATIVE : Direction.AxisDirection.POSITIVE); + } + } + + // 12 EDGES + for (Direction.Axis axis : Iterate.axes) { + for (Direction.Axis axis2 : Iterate.axes) { + if (axis == axis2) + continue; + for (Direction.Axis axis3 : Iterate.axes) { + if (axis == axis3) + continue; + if (axis2 == axis3) + continue; + + Direction direction = Direction.get(Direction.AxisDirection.POSITIVE, axis2); + Direction direction2 = Direction.get(Direction.AxisDirection.POSITIVE, axis3); + + for (int offset : Iterate.zeroAndOne) { + BlockPos entryPos = pos.relative(direction, offset); + for (int offset2 : Iterate.zeroAndOne) { + entryPos = entryPos.relative(direction2, offset2); + CWMergeEntry entry = new CWMergeEntry(axis, entryPos); + if (!visibleEdges.remove(entry)) + visibleEdges.add(entry); + } + } + } + + break; + } + } + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWMergeEntry.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWMergeEntry.java new file mode 100644 index 000000000..7029d1172 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/CWMergeEntry.java @@ -0,0 +1,32 @@ +package org.valkyrienskies.mod.mixinducks.mod_compat.create; + +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; + +/** + * This class only exists because Creates MergeEntry class is private, and I can't get an access widener to work on it >.< + */ +public class CWMergeEntry { + public final Direction.Axis axis; + public final BlockPos pos; + + public CWMergeEntry(Direction.Axis axis, BlockPos pos) { + this.axis = axis; + this.pos = pos; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (!(o instanceof CWMergeEntry other)) + return false; + + return this.axis == other.axis && this.pos.equals(other.pos); + } + + @Override + public int hashCode() { + return this.pos.hashCode() * 31 + axis.ordinal(); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IExtendedAirCurrentSource.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IExtendedAirCurrentSource.java new file mode 100644 index 000000000..0b7f04184 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IExtendedAirCurrentSource.java @@ -0,0 +1,10 @@ +package org.valkyrienskies.mod.mixinducks.mod_compat.create; + +import com.simibubi.create.content.kinetics.fan.IAirCurrentSource; +import org.valkyrienskies.core.api.ships.Ship; + +public interface IExtendedAirCurrentSource extends IAirCurrentSource { + + Ship getShip(); + +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinControlledContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinControlledContraptionEntity.java new file mode 100644 index 000000000..9c8214d43 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinControlledContraptionEntity.java @@ -0,0 +1,7 @@ +package org.valkyrienskies.mod.mixinducks.mod_compat.create; + +import com.simibubi.create.content.contraptions.IControlContraption; + +public interface IMixinControlledContraptionEntity { + IControlContraption grabController(); +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinStickerTileEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinStickerTileEntity.java new file mode 100644 index 000000000..ca09a4ed9 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/IMixinStickerTileEntity.java @@ -0,0 +1,6 @@ +package org.valkyrienskies.mod.mixinducks.mod_compat.create; + +public interface IMixinStickerTileEntity { + + boolean isAlreadyPowered(boolean reset); +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuck.java new file mode 100644 index 000000000..7d6d1da29 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuck.java @@ -0,0 +1,8 @@ +package org.valkyrienskies.mod.mixinducks.mod_compat.create; + + +import com.simibubi.create.content.contraptions.StructureTransform; + +public interface MixinAbstractContraptionEntityDuck { + StructureTransform getStructureTransform(); +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/CompatUtil.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/CompatUtil.kt new file mode 100644 index 000000000..56dace1d3 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/CompatUtil.kt @@ -0,0 +1,41 @@ +package org.valkyrienskies.mod.common + +import net.minecraft.world.level.Level +import net.minecraft.world.phys.Vec3 +import org.joml.Vector3d +import org.valkyrienskies.core.api.ships.Ship +import org.valkyrienskies.mod.common.util.toJOML +import org.valkyrienskies.mod.common.util.toMinecraft + +object CompatUtil { + fun toSameSpaceAs(level: Level, position: Vector3d, target: Vector3d): Vector3d { + var ship: Ship? + if (level.isBlockInShipyard(position.x, position.y, position.z) && !level.isBlockInShipyard( + target.x, + target.y, + target.z + ) + ) { + ship = level.getShipManagingPos(position) + ship!!.shipToWorld.transformPosition(position) + } + if (!level.isBlockInShipyard(position.x, position.y, position.z) && level.isBlockInShipyard( + target.x, + target.y, + target.z + ) + ) { + ship = level.getShipManagingPos(target) + ship!!.worldToShip.transformPosition(position) + } + return position + } + + fun toSameSpaceAs(level: Level, position: Vec3, target: Vec3): Vec3 { + return toSameSpaceAs(level, position.toJOML(), target.toJOML()).toMinecraft() + } + + fun toSameSpaceAs(level: Level, px: Double, py: Double, pz: Double, target: Vec3): Vec3 { + return toSameSpaceAs(level, Vector3d(px, py, pz), target.toJOML()).toMinecraft() + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 2b9bfd0d0..570ee847f 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -51,6 +51,40 @@ "feature.water_in_ships_entity.MixinEntity", "feature.world_border.MixinLevel", "feature.world_border.MixinWorldBorder", + "mod_compat.create.accessors.OutlineParamsAccessor", + "mod_compat.create.IMixinDeployerHandler", + "mod_compat.create.IMixinDeployerMovementBehaviour", + "mod_compat.create.MixinAirCurrent", + "mod_compat.create.MixinAirFlowParticle", + "mod_compat.create.MixinBeltMovementHandler", + "mod_compat.create.MixinContraption", + "mod_compat.create.MixinContraptionCollider", + "mod_compat.create.MixinEntityLauncher", + "mod_compat.create.MixinRedstoneLinkNetworkHandler", + "mod_compat.create.MixinSharedDepotBlockMethods", + "mod_compat.create.behaviour.MixinBlockBreakingMovementBehaviour", + "mod_compat.create.behaviour.MixinFilteringBehaviour", + "mod_compat.create.behaviour.MixinLinkBehaviour", + "mod_compat.create.behaviour.MixinScrollValueBehaviour", + "mod_compat.create.behaviour.MixinSidedFilteringBehaviour", + "mod_compat.create.block.MixinCrushingWheelBlock", + "mod_compat.create.block.MixinEjectorBlock", + "mod_compat.create.block.MixinRedstoneContactBlock", + "mod_compat.create.block.MixinStickerBlock", + "mod_compat.create.blockentity.IMixinMechanicalBearingTileEntity", + "mod_compat.create.blockentity.MixinCrushingWheelControllerTileEntity", + "mod_compat.create.blockentity.MixinEjectorTileEntity", + "mod_compat.create.blockentity.MixinEncasedFanTileEntity", + "mod_compat.create.entity.MixinAbstractContraptionEntity", + "mod_compat.create.entity.MixinCarriageContraptionEntity", + "mod_compat.create.entity.MixinControlledContraptionEntity", + "mod_compat.create.entity.MixinSeatEntity", + "mod_compat.create.packets.MixinControlsInputPacket", + "mod_compat.create.packets.MixinCurvedTrackDestroyPacket", + "mod_compat.create.packets.MixinSuperGlueRemovalPacket", + "mod_compat.create.packets.MixinTileEntityConfigurationPacket", + "mod_compat.create.packets.MixinTrainRelocationPacket", + "mod_compat.create.pr.MixinSeatBlock", "mod_compat.create_big_cannons.MixinPitchOrientedContraptionEntity", "mod_compat.ftb_chunks.MixinClaimedChunkManager", "mod_compat.sodium.MixinChunkTracker", diff --git a/gradle.properties b/gradle.properties index 552d2dd3b..36d3a9f2e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,11 +5,12 @@ archives_base_name=valkyrienskies-118 mod_version=2.1.1-beta.3 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 -fabric_loader_version=0.14.10 -fabric_api_version=0.59.0+1.18.2 +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 vs_core_version=1.1.0+00bb578f02 # Prevent kotlin from autoincluding stdlib as a dependency, which breaks # gradle's composite builds (includeBuild) for some reason. We'll add it manually From cb158e815ddf187d3819ccb947bff9e60fe75b5a Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 16 Oct 2023 08:17:28 -0600 Subject: [PATCH 278/437] Added fabric create mixins --- .../valkyrienskies-common.mixins.json | 20 ++++++ .../MixinBlockBreakingKineticTileEntity.java | 66 ++++++++++++++++++ .../mixin/compat/create/MixinBlocks.java | 64 +++++++++++++++++ .../MixinControlledContraptionEntity.java | 40 +++++++++++ .../client/MixinContraptionRenderInfo.java | 26 +++++++ .../MixinCullingBlockEntityIterator.java | 26 +++++++ .../create/client/MixinFlwContraption.java | 61 +++++++++++++++++ .../client/MixinScrollValueBehaviour.java | 21 ++++++ .../MixinSuperGlueSelectionHandler.java | 68 +++++++++++++++++++ .../compat/create/client/MixinValueBox.java | 25 +++++++ .../valkyrienskies-fabric.mixins.json | 12 +++- 11 files changed, 428 insertions(+), 1 deletion(-) create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlockBreakingKineticTileEntity.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlocks.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinControlledContraptionEntity.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionRenderInfo.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinCullingBlockEntityIterator.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinFlwContraption.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinScrollValueBehaviour.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 570ee847f..2873ddbc3 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -143,6 +143,26 @@ "feature.transform_particles.MixinLevelRenderer", "feature.transform_particles.MixinParticle", "feature.vs2_alpha_hud.MixinGui", + "mod_compat.create.client.MixinAABBOutline", + "mod_compat.create.client.MixinBlockClusterOutline", + "mod_compat.create.client.MixinCarriageContraptionInstance", + "mod_compat.create.client.MixinCogwheelBlockItem", + "mod_compat.create.client.MixinCogwheelBlockItemHitOnShaft", + "mod_compat.create.client.MixinContraptionHandlerClient", + "mod_compat.create.client.MixinContraptionRenderDispatcher", + "mod_compat.create.client.MixinContraptionRenderInfo", + "mod_compat.create.client.MixinFilteringRenderer", + "mod_compat.create.client.MixinGhostBlockRenderer", + "mod_compat.create.client.MixinLinkRenderer", + "mod_compat.create.client.MixinMinecartInstance", + "mod_compat.create.client.MixinMultiplePlacementHelpers", + "mod_compat.create.client.MixinOrientedContraptionEntity", + "mod_compat.create.client.MixinOutline", + "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.flywheel.InstancingEngineAccessor", "mod_compat.flywheel.MixinBlockEntityInstanceManager", "mod_compat.flywheel.MixinInstanceManager", diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlockBreakingKineticTileEntity.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlockBreakingKineticTileEntity.java new file mode 100644 index 000000000..ef2cb5122 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlockBreakingKineticTileEntity.java @@ -0,0 +1,66 @@ +package org.valkyrienskies.mod.fabric.mixin.compat.create; + +import com.simibubi.create.content.kinetics.base.BlockBreakingKineticBlockEntity; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ClipContext; +import net.minecraft.world.phys.BlockHitResult; +import net.minecraft.world.phys.HitResult; +import net.minecraft.world.phys.Vec3; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(BlockBreakingKineticBlockEntity.class) +public abstract class MixinBlockBreakingKineticTileEntity { + + @Shadow + protected abstract BlockPos getBreakingPos(); + + @Redirect( + method = "tick", + at = @At( + value = "INVOKE", + target = "Lcom/simibubi/create/content/kinetics/base/BlockBreakingKineticBlockEntity;getBreakingPos()Lnet/minecraft/core/BlockPos;" + ) + ) + private BlockPos getBreakingBlockPos(final BlockBreakingKineticBlockEntity self) { + final BlockPos orig = this.getBreakingPos(); + final Vec3 origin; + final Vec3 target; + final Ship ship = VSGameUtilsKt.getShipManagingPos(self.getLevel(), self.getBlockPos()); + + if (ship != null) { + origin = VectorConversionsMCKt.toMinecraft( + ship.getShipToWorld() + .transformPosition(VectorConversionsMCKt.toJOMLD(self.getBlockPos()).add(0.5, 0.5, 0.5)) + ); + target = VectorConversionsMCKt.toMinecraft( + ship.getShipToWorld().transformPosition(VectorConversionsMCKt.toJOMLD(orig).add(0.5, 0.5, 0.5)) + ); + } else { + origin = Vec3.atCenterOf(self.getBlockPos()); + target = Vec3.atCenterOf(orig); + } + + final Vec3 diff = target.subtract(origin); + final BlockHitResult result = self.getLevel().clip(new ClipContext( + origin.add(diff.scale(0.4)), + target.add(diff.scale(0.2)), + ClipContext.Block.COLLIDER, + ClipContext.Fluid.NONE, + null + )); + + if (result.getType() == HitResult.Type.MISS) { + return orig; + } + + return result.getBlockPos(); + } + +} + diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlocks.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlocks.java new file mode 100644 index 000000000..ac355ef2f --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinBlocks.java @@ -0,0 +1,64 @@ +package org.valkyrienskies.mod.fabric.mixin.compat.create; + +import com.simibubi.create.content.kinetics.millstone.MillstoneBlock; +import com.simibubi.create.content.logistics.chute.AbstractChuteBlock; +import com.simibubi.create.content.processing.basin.BasinBlock; +import java.util.Iterator; +import net.minecraft.core.BlockPos; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(value = { + MillstoneBlock.class, + BasinBlock.class, + AbstractChuteBlock.class +}) +public class MixinBlocks { + + @Redirect( + method = "updateEntityAfterFallOn", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/Entity;blockPosition()Lnet/minecraft/core/BlockPos;" + ), + require = 0 + ) + protected BlockPos redirectBlockPosition(final Entity entity) { + final Iterator<Ship> ships = + VSGameUtilsKt.getShipsIntersecting(entity.level, entity.getBoundingBox()).iterator(); + if (ships.hasNext()) { + final Vector3d pos = ships.next().getWorldToShip() + .transformPosition(VectorConversionsMCKt.toJOML(entity.position())); + return new BlockPos(Math.floor(pos.x), Math.floor(pos.y), Math.floor(pos.z)); + } else { + return entity.blockPosition(); + } + } + + @Redirect( + method = "updateEntityAfterFallOn", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/Entity;position()Lnet/minecraft/world/phys/Vec3;" + ), + require = 0 + ) + Vec3 redirectPosition(final Entity entity) { + final Iterator<Ship> ships = + VSGameUtilsKt.getShipsIntersecting(entity.level, entity.getBoundingBox()).iterator(); + if (ships.hasNext()) { + return VectorConversionsMCKt.toMinecraft(ships.next().getWorldToShip() + .transformPosition(VectorConversionsMCKt.toJOML(entity.position()))); + } else { + return entity.position(); + } + } + +} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinControlledContraptionEntity.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinControlledContraptionEntity.java new file mode 100644 index 000000000..7d2e49ff9 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinControlledContraptionEntity.java @@ -0,0 +1,40 @@ +package org.valkyrienskies.mod.fabric.mixin.compat.create; + +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.ControlledContraptionEntity; +import com.simibubi.create.content.contraptions.bearing.BearingContraption; +import com.simibubi.create.content.contraptions.behaviour.MovementContext; +import net.minecraft.core.Direction; +import net.minecraft.core.Vec3i; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.joml.Math; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(ControlledContraptionEntity.class) +public abstract class MixinControlledContraptionEntity extends AbstractContraptionEntity { + public MixinControlledContraptionEntity(EntityType<?> entityTypeIn, Level worldIn) { + super(entityTypeIn, worldIn); + } + + //Region start - fix actors in the center of a bearing contraption not triggering correctly (vanilla create bug) + @Shadow + protected float angleDelta; + + @Redirect(method = "shouldActorTrigger", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lcom/simibubi/create/content/contraptions/behaviour/MovementContext;motion:Lnet/minecraft/world/phys/Vec3;")) + private void redirectPutMotion(MovementContext instance, Vec3 value) { + BearingContraption bc = (BearingContraption) contraption; + Direction facing = bc.getFacing(); + Vec3i dir = facing.getNormal(); + + double scalar = Math.abs(angleDelta / 360.0) * Math.signum(dir.getX() + dir.getY() + dir.getZ()); + + instance.motion = new Vec3(Math.abs(dir.getX()), Math.abs(dir.getY()), Math.abs(dir.getZ())).scale(scalar); + } + //Region end +} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionRenderInfo.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionRenderInfo.java new file mode 100644 index 000000000..be7946f45 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionRenderInfo.java @@ -0,0 +1,26 @@ +package org.valkyrienskies.mod.fabric.mixin.compat.create.client; + +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; +import net.minecraft.client.multiplayer.ClientLevel; +import net.minecraft.world.phys.AABB; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(ContraptionRenderInfo.class) +public class MixinContraptionRenderInfo { + + @Redirect( + at = @At( + value = "INVOKE", + target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBoxForCulling()Lnet/minecraft/world/phys/AABB;" + ), + method = "beginFrame" + ) + private AABB redirectGetAABBForCulling(final AbstractContraptionEntity receiver) { + return VSGameUtilsKt.transformRenderAABBToWorld(((ClientLevel) receiver.level), receiver.position(), + receiver.getBoundingBoxForCulling()); + } +} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinCullingBlockEntityIterator.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinCullingBlockEntityIterator.java new file mode 100644 index 000000000..60e8b7ecc --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinCullingBlockEntityIterator.java @@ -0,0 +1,26 @@ +package org.valkyrienskies.mod.fabric.mixin.compat.create.client; + +import io.github.fabricators_of_create.porting_lib.block.CullingBlockEntityIterator; +import net.minecraft.client.Minecraft; +import net.minecraft.client.renderer.culling.Frustum; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.AABB; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(CullingBlockEntityIterator.class) +public abstract class MixinCullingBlockEntityIterator { + @Redirect(method = "nextCulled", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/renderer/culling/Frustum;isVisible(Lnet/minecraft/world/phys/AABB;)Z") + ) + private boolean inject(final Frustum instance, final AABB arg) { + AABB newAABB = arg; + final Level level = Minecraft.getInstance().level; + if (level != null) { + newAABB = VSGameUtilsKt.transformAabbToWorld(level, arg); + } + return instance.isVisible(newAABB); + } +} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinFlwContraption.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinFlwContraption.java new file mode 100644 index 000000000..dadc3e560 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinFlwContraption.java @@ -0,0 +1,61 @@ +package org.valkyrienskies.mod.fabric.mixin.compat.create.client; + +import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; +import com.mojang.math.Matrix4f; +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.Contraption; +import com.simibubi.create.content.contraptions.render.ContraptionRenderInfo; +import com.simibubi.create.content.contraptions.render.FlwContraption; +import net.minecraft.util.Mth; +import net.minecraft.world.phys.AABB; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.mod.common.VSClientGameUtils; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Mixin(FlwContraption.class) +public class MixinFlwContraption extends ContraptionRenderInfo { + + public MixinFlwContraption( + final Contraption contraption, + final VirtualRenderWorld renderWorld) { + super(contraption, renderWorld); + } + + @Inject(at = @At("HEAD"), method = "setupModelViewPartial", cancellable = true, remap = false) + private static void beforeSetupModelViewPartial(final Matrix4f matrix, final Matrix4f modelMatrix, + final AbstractContraptionEntity entity, final double camX, final double camY, final double camZ, final float pt, + final CallbackInfo ci) { + + if (VSGameUtilsKt.getShipManaging(entity) instanceof final ClientShip ship) { + VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), + matrix, + Mth.lerp(pt, entity.xOld, entity.getX()), + Mth.lerp(pt, entity.yOld, entity.getY()), + Mth.lerp(pt, entity.zOld, entity.getZ()), + camX, + camY, + camZ + ); + + matrix.multiply(modelMatrix); + ci.cancel(); + } + } + + @Redirect( + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/phys/AABB;move(DDD)Lnet/minecraft/world/phys/AABB;" + ), + method = "beginFrame" + ) + private AABB transformLightboxToWorld(final AABB aabb, final double negCamX, final double negCamY, + final double negCamZ) { + return VSGameUtilsKt.transformAabbToWorld(this.contraption.entity.level, aabb).move(negCamX, negCamY, negCamZ); + } +} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinScrollValueBehaviour.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinScrollValueBehaviour.java new file mode 100644 index 000000000..8a9d7a12a --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinScrollValueBehaviour.java @@ -0,0 +1,21 @@ +package org.valkyrienskies.mod.fabric.mixin.compat.create.client; + +import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(ScrollValueBehaviour.class) +public class MixinScrollValueBehaviour { + +// @Redirect( +// at = @At( +// value = "INVOKE", +// target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" +// ), +// method = "testHit" +// ) +// private Vec3 transformHitToShip(final Vec3 hitPos, final Vec3 blockPos) { +// final Vec3 inShipHit = VSGameUtilsKt.toShipRenderCoordinates(Minecraft.getInstance().level, blockPos, hitPos); +// return inShipHit.subtract(blockPos); +// } + +} 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 new file mode 100644 index 000000000..3bfbff08f --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java @@ -0,0 +1,68 @@ +package org.valkyrienskies.mod.fabric.mixin.compat.create.client; + +import com.jamieswhiteshirt.reachentityattributes.ReachEntityAttributes; +import com.simibubi.create.content.contraptions.glue.SuperGlueSelectionHandler; +import com.simibubi.create.foundation.utility.RaycastHelper; +import java.util.Iterator; +import net.minecraft.client.Minecraft; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.joml.Matrix4d; +import org.joml.Quaterniond; +import org.joml.Vector3d; +import org.joml.primitives.AABBic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(SuperGlueSelectionHandler.class) +public abstract class MixinSuperGlueSelectionHandler { + @Unique + private Vec3 newTarget; + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/RaycastHelper;getTraceOrigin(Lnet/minecraft/world/entity/player/Player;)Lnet/minecraft/world/phys/Vec3;")) + private Vec3 redirectGetTraceOrigin(Player playerIn) { + Minecraft mc = Minecraft.getInstance(); + double range = ReachEntityAttributes.getReachDistance(playerIn, playerIn.isCreative() ? 5.0 : 4.5); // PlatformUtils.getReachDistance(playerIn) + 1; + Vec3 origin = RaycastHelper.getTraceOrigin(playerIn); + Vec3 target = RaycastHelper.getTraceTarget(playerIn, range, origin); + + + AABB searchAABB = new AABB(origin, target).inflate(0.25, 2, 0.25); + final Iterator<Ship> ships = VSGameUtilsKt.getShipsIntersecting(playerIn.level, searchAABB).iterator(); + + if (ships.hasNext()) { + Ship ship = ships.next(); + + Matrix4d world2Ship = (Matrix4d) ship.getTransform().getWorldToShip(); + AABBic shAABBi = ship.getShipAABB(); + AABB shipAABB = new AABB(shAABBi.minX(), shAABBi.minY(), shAABBi.minZ(), shAABBi.maxX(), shAABBi.maxY(), shAABBi.maxZ()); + + + origin = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(origin))); + target = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(target))); + + Quaterniond tempQuat = new Quaterniond(); + if (playerIn.getVehicle() != null && playerIn.getVehicle().getBoundingBox().intersects(shipAABB.inflate(20))) { + ship.getTransform().getWorldToShip().getNormalizedRotation(tempQuat); + tempQuat.invert(); + Vector3d offset = VectorConversionsMCKt.toJOML(target.subtract(origin)); + tempQuat.transform(offset); + target = origin.add(VectorConversionsMCKt.toMinecraft(offset)); + } + } + + newTarget = target; + return origin; + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/RaycastHelper;getTraceTarget(Lnet/minecraft/world/entity/player/Player;DLnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;")) + private Vec3 redirectGetTraceTarget(final Player playerIn, final double range, final Vec3 origin) { + return newTarget; + } +} diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java new file mode 100644 index 000000000..b946ce720 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinValueBox.java @@ -0,0 +1,25 @@ +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 dc75436f1..e84ccbce9 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -10,11 +10,21 @@ "compat.cc_restitched.MixinWirelessNetwork", "compat.create.Matrix3dAccessor", "compat.create.MixinAbstractContraptionEntity", + "compat.create.MixinBlockBreakingKineticTileEntity", + "compat.create.MixinBlocks", + "compat.create.MixinControlledContraptionEntity", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", "world.level.block.FireMixin" ], - "client": [], + "client": [ + "compat.create.client.MixinContraptionRenderInfo", + "compat.create.client.MixinCullingBlockEntityIterator", + "compat.create.client.MixinFlwContraption", + "compat.create.client.MixinScrollValueBehaviour", + "compat.create.client.MixinSuperGlueSelectionHandler", + "compat.create.client.MixinValueBox" + ], "injectors": { "defaultRequire": 1 }, From 63468f6bc8170f92b35b033021c386bb52239ccd Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 16 Oct 2023 08:27:52 -0600 Subject: [PATCH 279/437] Fixed forge not launching --- .../behaviour/MixinScrollValueBehaviour.java | 2 +- .../client/MixinScrollValueBehaviour.java | 21 ---------------- .../valkyrienskies-fabric.mixins.json | 1 - .../client/MixinScrollValueBehaviour.java | 25 ------------------- .../valkyrienskies-forge.mixins.json | 1 - 5 files changed, 1 insertion(+), 49 deletions(-) delete mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinScrollValueBehaviour.java delete mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinScrollValueBehaviour.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinScrollValueBehaviour.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinScrollValueBehaviour.java index e0d31a48c..fc052d56d 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinScrollValueBehaviour.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/behaviour/MixinScrollValueBehaviour.java @@ -10,7 +10,7 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -@Mixin(targets = "com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour") +@Mixin(ScrollValueBehaviour.class) public class MixinScrollValueBehaviour { @Redirect( diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinScrollValueBehaviour.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinScrollValueBehaviour.java deleted file mode 100644 index 8a9d7a12a..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinScrollValueBehaviour.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create.client; - -import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(ScrollValueBehaviour.class) -public class MixinScrollValueBehaviour { - -// @Redirect( -// at = @At( -// value = "INVOKE", -// target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" -// ), -// method = "testHit" -// ) -// private Vec3 transformHitToShip(final Vec3 hitPos, final Vec3 blockPos) { -// final Vec3 inShipHit = VSGameUtilsKt.toShipRenderCoordinates(Minecraft.getInstance().level, blockPos, hitPos); -// return inShipHit.subtract(blockPos); -// } - -} diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index e84ccbce9..f9fd54a75 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -21,7 +21,6 @@ "compat.create.client.MixinContraptionRenderInfo", "compat.create.client.MixinCullingBlockEntityIterator", "compat.create.client.MixinFlwContraption", - "compat.create.client.MixinScrollValueBehaviour", "compat.create.client.MixinSuperGlueSelectionHandler", "compat.create.client.MixinValueBox" ], 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 deleted file mode 100644 index dd4cc0125..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinScrollValueBehaviour.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create.client; - -import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; -import net.minecraft.client.Minecraft; -import net.minecraft.world.phys.Vec3; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; -import org.valkyrienskies.mod.common.VSGameUtilsKt; - -@Mixin(ScrollValueBehaviour.class) -public class MixinScrollValueBehaviour { - - @Redirect( - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/phys/Vec3;subtract(Lnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;" - ), - method = "testHit" - ) - private Vec3 transformHitToShip(final Vec3 hitPos, final Vec3 blockPos) { - final Vec3 inShipHit = VSGameUtilsKt.toShipRenderCoordinates(Minecraft.getInstance().level, blockPos, hitPos); - return inShipHit.subtract(blockPos); - } -} diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 96701e995..3ad4b2842 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -22,7 +22,6 @@ "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", From e00ea733a3e1c292d615bfe7ecfc46579de9d4a7 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Mon, 16 Oct 2023 08:34:03 -0600 Subject: [PATCH 280/437] Added forge create mixins --- .../MixinControlledContraptionEntity.java | 41 +++++++++++ .../MixinSuperGlueSelectionHandler.java | 68 +++++++++++++++++++ .../valkyrienskies-forge.mixins.json | 2 + 3 files changed, 111 insertions(+) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinControlledContraptionEntity.java create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinControlledContraptionEntity.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinControlledContraptionEntity.java new file mode 100644 index 000000000..9bfa2693e --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinControlledContraptionEntity.java @@ -0,0 +1,41 @@ +package org.valkyrienskies.mod.forge.mixin.compat.create; + +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.ControlledContraptionEntity; +import com.simibubi.create.content.contraptions.bearing.BearingContraption; +import com.simibubi.create.content.contraptions.behaviour.MovementContext; +import net.minecraft.core.Direction; +import net.minecraft.core.Vec3i; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.joml.Math; +import org.objectweb.asm.Opcodes; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(ControlledContraptionEntity.class) +public abstract class MixinControlledContraptionEntity extends AbstractContraptionEntity { + public MixinControlledContraptionEntity(EntityType<?> entityTypeIn, Level worldIn) { + super(entityTypeIn, worldIn); + } + + //Region start - fix actors in the center of a bearing contraption not triggering correctly (vanilla create bug) + @Shadow + protected float angleDelta; + + @Redirect(method = "shouldActorTrigger", at = @At(value = "FIELD", opcode = Opcodes.PUTFIELD, target = "Lcom/simibubi/create/content/contraptions/behaviour/MovementContext;motion:Lnet/minecraft/world/phys/Vec3;"), + remap = false) + private void redirectPutMotion(MovementContext instance, Vec3 value) { + BearingContraption bc = (BearingContraption) contraption; + Direction facing = bc.getFacing(); + Vec3i dir = facing.getNormal(); + + double scalar = Math.abs(angleDelta / 360.0) * Math.signum(dir.getX() + dir.getY() + dir.getZ()); + + instance.motion = new Vec3(Math.abs(dir.getX()), Math.abs(dir.getY()), Math.abs(dir.getZ())).scale(scalar); + } + //Region end +} diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java new file mode 100644 index 000000000..f8e013bb0 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinSuperGlueSelectionHandler.java @@ -0,0 +1,68 @@ +package org.valkyrienskies.mod.forge.mixin.compat.create.client; + +import com.simibubi.create.content.contraptions.glue.SuperGlueSelectionHandler; +import com.simibubi.create.foundation.utility.RaycastHelper; +import java.util.Iterator; +import net.minecraft.client.Minecraft; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import net.minecraftforge.common.ForgeMod; +import org.joml.Matrix4d; +import org.joml.Quaterniond; +import org.joml.Vector3d; +import org.joml.primitives.AABBic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Unique; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(SuperGlueSelectionHandler.class) +public abstract class MixinSuperGlueSelectionHandler { + @Unique + private Vec3 newTarget; + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/RaycastHelper;getTraceOrigin(Lnet/minecraft/world/entity/player/Player;)Lnet/minecraft/world/phys/Vec3;"), remap = false) + private Vec3 redirectGetTraceOrigin(Player playerIn) { + Minecraft mc = Minecraft.getInstance(); + double range = playerIn.getAttribute(ForgeMod.REACH_DISTANCE.get()).getValue() + 1; + Vec3 origin = RaycastHelper.getTraceOrigin(playerIn); + Vec3 target = RaycastHelper.getTraceTarget(playerIn, range, origin); + + + AABB searchAABB = new AABB(origin, target).inflate(0.25, 2, 0.25); + final Iterator<Ship> ships = VSGameUtilsKt.getShipsIntersecting(playerIn.level, searchAABB).iterator(); + + if (ships.hasNext()) { + Ship ship = ships.next(); + + Matrix4d world2Ship = (Matrix4d) ship.getTransform().getWorldToShip(); + AABBic shAABBi = ship.getShipAABB(); + AABB shipAABB = new AABB(shAABBi.minX(), shAABBi.minY(), shAABBi.minZ(), shAABBi.maxX(), shAABBi.maxY(), shAABBi.maxZ()); + + + origin = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(origin))); + target = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(target))); + + Quaterniond tempQuat = new Quaterniond(); + if (playerIn.getVehicle() != null && playerIn.getVehicle().getBoundingBox().intersects(shipAABB.inflate(20))) { + ship.getTransform().getWorldToShip().getNormalizedRotation(tempQuat); + tempQuat.invert(); + Vector3d offset = VectorConversionsMCKt.toJOML(target.subtract(origin)); + tempQuat.transform(offset); + target = origin.add(VectorConversionsMCKt.toMinecraft(offset)); + } + } + + newTarget = target; + return origin; + } + + @Redirect(method = "tick", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/RaycastHelper;getTraceTarget(Lnet/minecraft/world/entity/player/Player;DLnet/minecraft/world/phys/Vec3;)Lnet/minecraft/world/phys/Vec3;"), remap = false) + private Vec3 redirectGetTraceTarget(final Player playerIn, final double range, final Vec3 origin) { + return newTarget; + } +} diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 3ad4b2842..6e3bd7e50 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -12,6 +12,7 @@ "compat.create.MixinAbstractContraptionEntity", "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", + "compat.create.MixinControlledContraptionEntity", "compat.immersivengineering.MixinBlockEntityInventory", "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", @@ -22,6 +23,7 @@ "client.render.MixinLevelRenderer", "compat.create.client.MixinContraptionRenderInfo", "compat.create.client.MixinFlwContraption", + "compat.create.client.MixinSuperGlueSelectionHandler", "compat.create.client.MixinValueBox", "compat.sodium.MixinRenderSectionManager", "compat.tis3d.MixinCasingTileEntityRender", From 4986c942e619fb2c0c958dbaf769a0739c81f8d5 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 17 Oct 2023 07:07:57 -0600 Subject: [PATCH 281/437] Fixed static ships acting sus --- forge/build.gradle | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index dbe555bbe..72e471c48 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -104,7 +104,7 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+ae61d8d103") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+b1feca895c") { transitive = false } diff --git a/gradle.properties b/gradle.properties index 36d3a9f2e..bdb97e562 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+00bb578f02 +vs_core_version=1.1.0+d51f73d426 # 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 854f492b08e969285493c5f08dd0e009619afad6 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Tue, 17 Oct 2023 08:19:17 -0600 Subject: [PATCH 282/437] =?UTF-8?q?Fixed=20static=20ships=20acting=20sus?= =?UTF-8?q?=20(again=20=F0=9F=98=B3)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- forge/build.gradle | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index 72e471c48..6927771ed 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -104,7 +104,7 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+b1feca895c") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+10c94b01e2") { transitive = false } diff --git a/gradle.properties b/gradle.properties index bdb97e562..206c8a765 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+d51f73d426 +vs_core_version=1.1.0+3ecfd56292 # 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 4c612b209b702b2ad6d37048faa2011cb9420be8 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Wed, 18 Oct 2023 01:06:03 +0200 Subject: [PATCH 283/437] Extra info for a log, and limited the zip bombing --- .../mod/mixin/client/MixinMinecraft.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) 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 a61a30f5d..ae6ed83a6 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 @@ -38,6 +38,8 @@ public abstract class MixinMinecraft @Unique private static final Logger log = LogManager.getLogger("VS2 MixinMinecraft"); + @Unique + private static long lastLog = System.currentTimeMillis(); @Shadow private boolean pause; @@ -86,9 +88,15 @@ public ClientShipWorldCore getShipObjectWorld() { final ClientShipWorldCore shipObjectWorldCopy = shipObjectWorld; if (shipObjectWorldCopy == null) { - log.warn("Requested getShipObjectWorld() when shipObjectWorld was null!"); + if (lastLog + 5000 < System.currentTimeMillis()) { + lastLog = System.currentTimeMillis(); + log.warn("Requested getShipObjectWorld() but failed returning dummy world", + new IllegalStateException("shipObjectWorld is null")); + } + return ValkyrienSkiesMod.getVsCore().getDummyShipWorldClient(); } + return shipObjectWorldCopy; } From f8638b1ba14d4ee9b4b3cc70b666d1ce9e150b8d Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 18 Oct 2023 22:54:05 -0600 Subject: [PATCH 284/437] Replaced MixinCarriageContraptionEntity @Redirect with @WrapOperation --- .../entity/MixinCarriageContraptionEntity.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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 a0a18c037..c2031e472 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 @@ -1,5 +1,7 @@ package org.valkyrienskies.mod.mixin.mod_compat.create.entity; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.simibubi.create.content.trains.entity.CarriageContraptionEntity; import java.util.Collection; import net.minecraft.core.BlockPos; @@ -11,7 +13,6 @@ import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import org.valkyrienskies.core.api.ships.Ship; @@ -20,7 +21,7 @@ @Mixin(CarriageContraptionEntity.class) public abstract class MixinCarriageContraptionEntity { @Unique - private Level world; + private Level vs$world; @Inject( method = "control", @@ -29,22 +30,22 @@ public abstract class MixinCarriageContraptionEntity { private void injectCaptureLevel( final BlockPos controlsLocalPos, final Collection<Integer> heldControls, final Player player, final CallbackInfoReturnable<Boolean> cir) { - this.world = player.level; + this.vs$world = player.level; } - @Redirect( + @WrapOperation( method = "control", at = @At( value = "INVOKE", target = "Lnet/minecraft/world/phys/Vec3;closerThan(Lnet/minecraft/core/Position;D)Z" ) ) - private boolean redirectCloserThan(final Vec3 instance, final Position arg, final double d) { + private boolean wrapCloserThan(final Vec3 instance, final Position arg, final double d, final Operation<Boolean> closerThan) { Vec3 newVec3 = instance; - if (VSGameUtilsKt.isBlockInShipyard(this.world, new BlockPos(instance.x, instance.y, instance.z))) { - final Ship ship = VSGameUtilsKt.getShipManagingPos(this.world, instance); + if (VSGameUtilsKt.isBlockInShipyard(this.vs$world, new BlockPos(instance.x, instance.y, instance.z))) { + final Ship ship = VSGameUtilsKt.getShipManagingPos(this.vs$world, instance); newVec3 = VSGameUtilsKt.toWorldCoordinates(ship, instance); } - return newVec3.closerThan(arg, d); + return closerThan.call(newVec3, arg, d); } } From c82b8363f39cda709e7a6d5c93d680299f5fa3da Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 19 Oct 2023 02:30:51 -0600 Subject: [PATCH 285/437] Updated vs-core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 206c8a765..6e13d1617 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+3ecfd56292 +vs_core_version=1.1.0+9542346681 # 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 1b862df86ad50d01d30612655858d828266673a1 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 19 Oct 2023 04:34:57 -0600 Subject: [PATCH 286/437] Fixed crash when moving train from ship to world --- .../mixin/compat/create/MixinAbstractContraptionEntity.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 9a000267a..4bbd5036d 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 @@ -43,7 +43,10 @@ private void postTick(final CallbackInfo ci) { if (wingGroupId != -1 && level instanceof final ServerLevel serverLevel) { final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(serverLevel, VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); - ship.getAttachment(WingManager.class).setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); + if (ship != null) { + // This can happen if a player moves a train contraption from ship to world using a wrench + ship.getAttachment(WingManager.class).setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); + } } } From 8578aacdc09b29d5ad59185294660f556e0d86bc Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 19 Oct 2023 04:50:03 -0600 Subject: [PATCH 287/437] Fixed ship contraption raytracing when multiple ships near player --- .../client/MixinContraptionHandlerClient.java | 69 ++++++++----------- .../client/MixinElevatorControlsHandler.java | 29 ++++++++ .../valkyrienskies-common.mixins.json | 3 +- 3 files changed, 58 insertions(+), 43 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinElevatorControlsHandler.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionHandlerClient.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionHandlerClient.java index 68496373e..92c16cb45 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionHandlerClient.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionHandlerClient.java @@ -1,58 +1,43 @@ package org.valkyrienskies.mod.mixin.mod_compat.create.client; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.ContraptionHandlerClient; -import com.simibubi.create.foundation.utility.Couple; -import java.util.Iterator; import net.minecraft.client.Minecraft; -import net.minecraft.client.player.LocalPlayer; import net.minecraft.world.phys.AABB; import net.minecraft.world.phys.Vec3; -import org.joml.Matrix4d; -import org.joml.Quaterniond; -import org.joml.Vector3d; -import org.joml.primitives.AABBic; +import org.joml.primitives.AABBdc; 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.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; -import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.core.api.ships.ClientShip; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @Mixin(ContraptionHandlerClient.class) -public abstract class MixinContraptionHandlerClient { - - @Inject(method = "getRayInputs", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/Couple;create(Ljava/lang/Object;Ljava/lang/Object;)Lcom/simibubi/create/foundation/utility/Couple;"), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true) - private static void redirectedOrigin(final LocalPlayer player, final CallbackInfoReturnable<Couple<Vec3>> cir, final Minecraft mc, Vec3 origin, final double reach, Vec3 target) { - - if (mc.hitResult != null) { - AABB searchAABB = new AABB(origin, target).inflate(0.25, 2, 0.25); - final Iterator<Ship> ships = VSGameUtilsKt.getShipsIntersecting(player.level, searchAABB).iterator(); - - if (ships.hasNext()) { - Ship ship = ships.next(); - - Matrix4d world2Ship = (Matrix4d) ship.getTransform().getWorldToShip(); - AABBic shAABBi = ship.getShipAABB(); - if (shAABBi == null) - return; - AABB shipAABB = new AABB(shAABBi.minX(), shAABBi.minY(), shAABBi.minZ(), shAABBi.maxX(), shAABBi.maxY(), shAABBi.maxZ()); - - - origin = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(origin))); - target = VectorConversionsMCKt.toMinecraft(world2Ship.transformPosition(VectorConversionsMCKt.toJOML(target))); +public class MixinContraptionHandlerClient { + // Fixes raytracing contraptions on ships + @WrapOperation(method = "rayTraceContraption", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;toLocalVector(Lnet/minecraft/world/phys/Vec3;F)Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 wrapRayTraceContraptionToLocalVector( + final AbstractContraptionEntity instance, final Vec3 localVec, final float partialTicks, final Operation<Vec3> toLocalVector + ) { + final ClientShip clientShip = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance.getAnchorVec().x, instance.getAnchorVec().y, instance.getAnchorVec().z); + if (clientShip != null) { + final Vec3 newLocalVec = VectorConversionsMCKt.toMinecraft(clientShip.getRenderTransform().getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(localVec))); + return toLocalVector.call(instance, newLocalVec, partialTicks); + } + return toLocalVector.call(instance, localVec, partialTicks); + } - Quaterniond tempQuat = new Quaterniond(); - if (player.getVehicle() != null && player.getVehicle().getBoundingBox().intersects(shipAABB.inflate(20))) { - ship.getTransform().getWorldToShip().getNormalizedRotation(tempQuat); - tempQuat.invert(); - Vector3d offset = VectorConversionsMCKt.toJOML(target.subtract(origin)); - tempQuat.transform(offset); - target = origin.add(VectorConversionsMCKt.toMinecraft(offset)); - } - } + // Fixes raytracing contraptions on ships + @WrapOperation(method = "rightClickingOnContraptionsGetsHandledLocally", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) + private static AABB wrapRightClickingOnContraptionsGetsHandledLocallyGetBoundingBox(final AbstractContraptionEntity instance, final Operation<AABB> getBoundingBox) { + final ClientShip clientShip = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance.getAnchorVec().x, instance.getAnchorVec().y, instance.getAnchorVec().z); + if (clientShip != null) { + final AABB original = getBoundingBox.call(instance); + final AABBdc modified = VectorConversionsMCKt.toJOML(original).transform(clientShip.getRenderTransform().getShipToWorld()); + return VectorConversionsMCKt.toMinecraft(modified); } - cir.setReturnValue(Couple.create(origin, target)); + return getBoundingBox.call(instance); } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinElevatorControlsHandler.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinElevatorControlsHandler.java new file mode 100644 index 000000000..0d200f69b --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinElevatorControlsHandler.java @@ -0,0 +1,29 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.client; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.elevator.ElevatorControlsHandler; +import net.minecraft.client.Minecraft; +import net.minecraft.world.phys.AABB; +import org.joml.primitives.AABBdc; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(ElevatorControlsHandler.class) +public class MixinElevatorControlsHandler { + // Fixes raytracing contraptions on ships + @WrapOperation(method = "onScroll", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) + private static AABB onScrollGetBoundingBox(final AbstractContraptionEntity instance, final Operation<AABB> getBoundingBox) { + final ClientShip clientShip = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance.getAnchorVec().x, instance.getAnchorVec().y, instance.getAnchorVec().z); + if (clientShip != null) { + final AABB original = getBoundingBox.call(instance); + final AABBdc modified = VectorConversionsMCKt.toJOML(original).transform(clientShip.getRenderTransform().getShipToWorld()); + return VectorConversionsMCKt.toMinecraft(modified); + } + return getBoundingBox.call(instance); + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 2873ddbc3..71d3397a0 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -51,7 +51,6 @@ "feature.water_in_ships_entity.MixinEntity", "feature.world_border.MixinLevel", "feature.world_border.MixinWorldBorder", - "mod_compat.create.accessors.OutlineParamsAccessor", "mod_compat.create.IMixinDeployerHandler", "mod_compat.create.IMixinDeployerMovementBehaviour", "mod_compat.create.MixinAirCurrent", @@ -62,6 +61,7 @@ "mod_compat.create.MixinEntityLauncher", "mod_compat.create.MixinRedstoneLinkNetworkHandler", "mod_compat.create.MixinSharedDepotBlockMethods", + "mod_compat.create.accessors.OutlineParamsAccessor", "mod_compat.create.behaviour.MixinBlockBreakingMovementBehaviour", "mod_compat.create.behaviour.MixinFilteringBehaviour", "mod_compat.create.behaviour.MixinLinkBehaviour", @@ -151,6 +151,7 @@ "mod_compat.create.client.MixinContraptionHandlerClient", "mod_compat.create.client.MixinContraptionRenderDispatcher", "mod_compat.create.client.MixinContraptionRenderInfo", + "mod_compat.create.client.MixinElevatorControlsHandler", "mod_compat.create.client.MixinFilteringRenderer", "mod_compat.create.client.MixinGhostBlockRenderer", "mod_compat.create.client.MixinLinkRenderer", From a3c2f4ea2ba5aa472db7d3baed4af5ff503609ef Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Fri, 20 Oct 2023 02:22:13 -0600 Subject: [PATCH 288/437] Updated vs-core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 6e13d1617..c103bd78d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+9542346681 +vs_core_version=1.1.0+9ee5a1c6f8 # 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 df32e768f0083ddce690e11afe9cb9f147094b94 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Fri, 20 Oct 2023 23:52:32 -0600 Subject: [PATCH 289/437] Fixed game freezing because of too-large entity AABBs --- .../feature/get_entities/MixinLevel.java | 10 ++-- .../world/level/MixinBlockCollisions.java | 53 +++++++++++++++++++ .../common/util/EntityShipCollisionUtils.kt | 5 ++ .../org/valkyrienskies/mod/util/BugFixUtil.kt | 9 ++++ .../valkyrienskies-common.mixins.json | 1 + 5 files changed, 71 insertions(+), 7 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinBlockCollisions.java create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/util/BugFixUtil.kt diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/get_entities/MixinLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/get_entities/MixinLevel.java index 863abae56..a459b8699 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/get_entities/MixinLevel.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/get_entities/MixinLevel.java @@ -19,6 +19,7 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.valkyrienskies.core.util.RateLimiter; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.util.BugFixUtil; @Mixin(Level.class) public class MixinLevel { @@ -28,11 +29,6 @@ public class MixinLevel { @Unique private static final RateLimiter LIMITER = new RateLimiter(Duration.ofSeconds(5)); - @Unique - private static boolean isCollisionBoxToBig(final AABB aabb) { - return aabb.getXsize() > 1000 || aabb.getYsize() > 1000 || aabb.getZsize() > 1000; - } - @ModifyVariable( method = "getEntities(Lnet/minecraft/world/entity/Entity;Lnet/minecraft/world/phys/AABB;Ljava/util/function/Predicate;)Ljava/util/List;", at = @At("HEAD"), @@ -59,7 +55,7 @@ private AABB moveAABB2(final AABB aabb) { private <T extends Entity> void check1(final EntityTypeTest<Entity, T> entityTypeTest, final AABB area, final Predicate<? super T> predicate, final CallbackInfoReturnable<List<T>> cir) { - if (isCollisionBoxToBig(area)) { + if (BugFixUtil.INSTANCE.isCollisionBoxToBig(area)) { LIMITER.maybeRun(() -> LOGGER.error(new Exception( "Collision box is too big! " + area + " returning empty list! this might break things"))); @@ -76,7 +72,7 @@ private <T extends Entity> void check1(final EntityTypeTest<Entity, T> entityTyp private <T extends Entity> void check2(@Nullable final Entity entity, final AABB area, final Predicate<? super Entity> predicate, final CallbackInfoReturnable<List<Entity>> cir) { - if (isCollisionBoxToBig(area)) { + if (BugFixUtil.INSTANCE.isCollisionBoxToBig(area)) { LIMITER.maybeRun(() -> LOGGER.error(new Exception( "Collision box is too big! " + area + " returning empty list! this might break things"))); 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 new file mode 100644 index 000000000..28a9f4b31 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/world/level/MixinBlockCollisions.java @@ -0,0 +1,53 @@ +package org.valkyrienskies.mod.mixin.world.level; + +import net.minecraft.core.Cursor3D; +import net.minecraft.util.Mth; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.level.BlockCollisions; +import net.minecraft.world.level.CollisionGetter; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.shapes.Shapes; +import net.minecraft.world.phys.shapes.VoxelShape; +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.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.valkyrienskies.mod.util.BugFixUtil; + +/** + * Fix game freezing when a too-large AABB is used in a BlockCollisions object + */ +@Mixin(BlockCollisions.class) +public class MixinBlockCollisions { + @Shadow + @Final + @Mutable + private AABB box; + @Shadow + @Final + @Mutable + private Cursor3D cursor; + @Shadow + @Final + @Mutable + private VoxelShape entityShape; + + @Inject(method = "<init>(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) { + 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); + this.box = newBox; + final int i = Mth.floor(newBox.minX - 1.0E-7) - 1; + final int j = Mth.floor(newBox.maxX + 1.0E-7) + 1; + final int k = Mth.floor(newBox.minY - 1.0E-7) - 1; + final int l = Mth.floor(newBox.maxY + 1.0E-7) + 1; + final int m = Mth.floor(newBox.minZ - 1.0E-7) - 1; + final int n = Mth.floor(newBox.maxZ + 1.0E-7) + 1; + this.cursor = new Cursor3D(i, k, m, j, l, n); + } + } +} 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 eb5172f0a..89b3128f8 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 @@ -18,6 +18,7 @@ import org.valkyrienskies.core.util.extend import org.valkyrienskies.mod.common.getShipsIntersecting import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.vsCore +import org.valkyrienskies.mod.util.BugFixUtil import kotlin.math.max object EntityShipCollisionUtils { @@ -116,6 +117,10 @@ object EntityShipCollisionUtils { shipTransform.worldToShip ) val entityBoundingBoxInShipCoordinates: AABBdc = entityPolyInShipCoordinates.getEnclosingAABB(AABBd()) + if (BugFixUtil.isCollisionBoxToBig(entityBoundingBoxInShipCoordinates.toMinecraft())) { + // Box too large, skip it + continue + } val shipBlockCollisionStream = world.getBlockCollisions(entity, entityBoundingBoxInShipCoordinates.toMinecraft()) shipBlockCollisionStream.forEach { voxelShape: VoxelShape -> diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/util/BugFixUtil.kt b/common/src/main/kotlin/org/valkyrienskies/mod/util/BugFixUtil.kt new file mode 100644 index 000000000..58e39edc2 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/util/BugFixUtil.kt @@ -0,0 +1,9 @@ +package org.valkyrienskies.mod.util + +import net.minecraft.world.phys.AABB + +object BugFixUtil { + fun isCollisionBoxToBig(aabb: AABB): Boolean { + return aabb.xsize > 1000 || aabb.ysize > 1000 || aabb.zsize > 1000 + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 71d3397a0..7a900ea56 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -103,6 +103,7 @@ "world.chunk.MixinLevelChunk", "world.entity.MixinPlayer", "world.entity.projectile.ProjectileUtilMixin", + "world.level.MixinBlockCollisions", "world.level.MixinLevel", "world.level.chunk.MixinChunkGenerator", "world.level.levelgen.MixinFlatLevelSource", From 6aba87af769bd862865ef593eab9870f9882b6bf Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 21 Oct 2023 23:12:58 -0600 Subject: [PATCH 290/437] Added setting to disable teleporting ships when touching portals --- .../mod/mixin/server/MixinMinecraftServer.java | 5 +++++ .../org/valkyrienskies/mod/common/util/ShipSettings.kt | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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 e69c7bd36..fce1429bb 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 @@ -57,6 +57,7 @@ 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; @@ -242,6 +243,10 @@ private void handleShipPortals() { // Teleport ships that touch portals final ArrayList<LoadedServerShip> loadedShipsCopy = new ArrayList<>(shipWorld.getLoadedShips()); for (final LoadedServerShip shipObject : loadedShipsCopy) { + if (!ShipSettingsKt.getSettings(shipObject).getChangeDimensionOnTouchPortals()) { + // Only send ships through portals if it's enabled in settings + continue; + } final ServerLevel level = dimensionToLevelMap.get(shipObject.getChunkClaimDimension()); final Vector3dc shipPos = shipObject.getTransform().getPositionInWorld(); final double bbRadius = 0.5; diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt index c5eb9a222..be9f2f8c7 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/ShipSettings.kt @@ -12,7 +12,12 @@ data class ShipSettings( * Should the ship chunks try to generate? If true it will generate chunks in the shipyard. * You normally don't want this EVER */ - var shouldGenerateChunks: Boolean = false + var shouldGenerateChunks: Boolean = false, + + /** + * If true this ship will change dimensions when it touches a portal + */ + var changeDimensionOnTouchPortals: Boolean = true ) val ServerShip.settings: ShipSettings From 0ba628d7f58b1596e77a42c3c3726b732b8001bd Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 22 Oct 2023 00:08:53 -0600 Subject: [PATCH 291/437] Fixed bug when teleporting ships across dimensions --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index c103bd78d..9a2fb38b8 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+9ee5a1c6f8 +vs_core_version=1.1.0+2b49aeb3fe # 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 799c85df351d340ca8c605aae8149722720a87ef Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 22 Oct 2023 00:18:23 -0600 Subject: [PATCH 292/437] Empty commit to retry actions From ce9d3612fd67c01465a58ad36b873d20237afdc9 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 22 Oct 2023 04:02:16 -0600 Subject: [PATCH 293/437] Fixed players getting stuck colliding with ships in other dimensions --- .../kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 8c76a1ad3..762d61df2 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -169,7 +169,7 @@ private fun getShipObjectManagingPosImpl(world: Level?, chunkX: Int, chunkZ: Int * Get all ships intersecting an AABB in world-space, then call [cb] with the AABB itself, * followed by the AABB in the ship-space of the intersecting ships. */ -fun Level?.transformFromWorldToNearbyShipsAndWorld(aabb: AABB, cb: Consumer<AABB>) { +fun Level.transformFromWorldToNearbyShipsAndWorld(aabb: AABB, cb: Consumer<AABB>) { cb.accept(aabb) val tmpAABB = AABBd() getShipsIntersecting(aabb).forEach { ship -> @@ -395,8 +395,8 @@ fun Level?.getWorldCoordinates(blockPos: BlockPos, pos: Vector3d): Vector3d { return this.getShipObjectManagingPos(blockPos)?.transform?.shipToWorld?.transformPosition(pos) ?: pos } -fun Level?.getShipsIntersecting(aabb: AABB): Iterable<Ship> = allShips.getIntersecting(aabb.toJOML()) -fun Level?.getShipsIntersecting(aabb: AABBdc): Iterable<Ship> = allShips.getShipDataIntersecting(aabb) +fun Level.getShipsIntersecting(aabb: AABB): Iterable<Ship> = getShipsIntersecting(aabb.toJOML()) +fun Level.getShipsIntersecting(aabb: AABBdc): Iterable<Ship> = allShips.getIntersecting(aabb).filter { it.chunkClaimDimension == dimensionId } fun Level?.transformAabbToWorld(aabb: AABB): AABB = transformAabbToWorld(aabb.toJOML()).toMinecraft() fun Level?.transformAabbToWorld(aabb: AABBd) = this?.transformAabbToWorld(aabb, aabb) ?: aabb From d11ad1a0754ace18edab23c2c37f775ae536ecd0 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 22 Oct 2023 04:23:48 -0600 Subject: [PATCH 294/437] Make Level.transformAabbToWorld only transform if the ship dimension is the same as the level --- .../main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 762d61df2..3e8530969 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -405,7 +405,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) { + if (ship1 == ship2 && ship1 != null && ship1.chunkClaimDimension == dimensionId) { return aabb.transform(ship1.shipToWorld, dest) } From 1413de5f5c3bf5b3b81871f779fc1db595f64500 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 22 Oct 2023 06:15:33 -0600 Subject: [PATCH 295/437] Made getShipObjectManagingPos() only return the ship if it's in the same dimension as the level invoking it --- .../kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 3e8530969..8a51aa7e5 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -289,7 +289,12 @@ fun ServerLevel?.getShipObjectManagingPos(pos: Vector3dc) = private fun getShipManagingPosImpl(world: Level?, x: Int, z: Int): Ship? { return if (world != null && world.isChunkInShipyard(x, z)) { - world.shipObjectWorld.allShips.getByChunkPos(x, z, world.dimensionId) + val ship = world.shipObjectWorld.allShips.getByChunkPos(x, z, world.dimensionId) + if (ship != null && ship.chunkClaimDimension == world.dimensionId) { + ship + } else { + null + } } else { null } From 8dedf680a5a11d40ef49fc5a7f3885cc0d869e3a Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sun, 22 Oct 2023 19:04:35 -0600 Subject: [PATCH 296/437] Fixed create compat on forge --- .../valkyrienskies-common.mixins.json | 1 - .../client/MixinContraptionHandlerClient.java | 43 +++++++++++++++++++ .../valkyrienskies-fabric.mixins.json | 1 + .../client/MixinContraptionHandlerClient.java | 4 +- .../valkyrienskies-forge.mixins.json | 1 + 5 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionHandlerClient.java rename {common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat => forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat}/create/client/MixinContraptionHandlerClient.java (97%) diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 7a900ea56..bfb2a99b6 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -149,7 +149,6 @@ "mod_compat.create.client.MixinCarriageContraptionInstance", "mod_compat.create.client.MixinCogwheelBlockItem", "mod_compat.create.client.MixinCogwheelBlockItemHitOnShaft", - "mod_compat.create.client.MixinContraptionHandlerClient", "mod_compat.create.client.MixinContraptionRenderDispatcher", "mod_compat.create.client.MixinContraptionRenderInfo", "mod_compat.create.client.MixinElevatorControlsHandler", diff --git a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionHandlerClient.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionHandlerClient.java new file mode 100644 index 000000000..ec38248d9 --- /dev/null +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client/MixinContraptionHandlerClient.java @@ -0,0 +1,43 @@ +package org.valkyrienskies.mod.fabric.mixin.compat.create.client; + +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import com.simibubi.create.content.contraptions.AbstractContraptionEntity; +import com.simibubi.create.content.contraptions.ContraptionHandlerClient; +import net.minecraft.client.Minecraft; +import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.joml.primitives.AABBdc; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.valkyrienskies.core.api.ships.ClientShip; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(ContraptionHandlerClient.class) +public class MixinContraptionHandlerClient { + // Fixes raytracing contraptions on ships + @WrapOperation(method = "rayTraceContraption", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;toLocalVector(Lnet/minecraft/world/phys/Vec3;F)Lnet/minecraft/world/phys/Vec3;")) + private static Vec3 wrapRayTraceContraptionToLocalVector( + final AbstractContraptionEntity instance, final Vec3 localVec, final float partialTicks, final Operation<Vec3> toLocalVector + ) { + final ClientShip clientShip = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance.getAnchorVec().x, instance.getAnchorVec().y, instance.getAnchorVec().z); + if (clientShip != null) { + final Vec3 newLocalVec = VectorConversionsMCKt.toMinecraft(clientShip.getRenderTransform().getWorldToShip().transformPosition(VectorConversionsMCKt.toJOML(localVec))); + return toLocalVector.call(instance, newLocalVec, partialTicks); + } + return toLocalVector.call(instance, localVec, partialTicks); + } + + // Fixes raytracing contraptions on ships + @WrapOperation(method = "rightClickingOnContraptionsGetsHandledLocally", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getBoundingBox()Lnet/minecraft/world/phys/AABB;")) + private static AABB wrapRightClickingOnContraptionsGetsHandledLocallyGetBoundingBox(final AbstractContraptionEntity instance, final Operation<AABB> getBoundingBox) { + final ClientShip clientShip = VSGameUtilsKt.getShipObjectManagingPos(Minecraft.getInstance().level, instance.getAnchorVec().x, instance.getAnchorVec().y, instance.getAnchorVec().z); + if (clientShip != null) { + final AABB original = getBoundingBox.call(instance); + final AABBdc modified = VectorConversionsMCKt.toJOML(original).transform(clientShip.getRenderTransform().getShipToWorld()); + return VectorConversionsMCKt.toMinecraft(modified); + } + return getBoundingBox.call(instance); + } +} diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index f9fd54a75..29543038e 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -18,6 +18,7 @@ "world.level.block.FireMixin" ], "client": [ + "compat.create.client.MixinContraptionHandlerClient", "compat.create.client.MixinContraptionRenderInfo", "compat.create.client.MixinCullingBlockEntityIterator", "compat.create.client.MixinFlwContraption", diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionHandlerClient.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinContraptionHandlerClient.java similarity index 97% rename from common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionHandlerClient.java rename to forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinContraptionHandlerClient.java index 92c16cb45..7d2797ece 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinContraptionHandlerClient.java +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinContraptionHandlerClient.java @@ -1,4 +1,4 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; +package org.valkyrienskies.mod.forge.mixin.compat.create.client; import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; @@ -17,7 +17,7 @@ @Mixin(ContraptionHandlerClient.class) public class MixinContraptionHandlerClient { // Fixes raytracing contraptions on ships - @WrapOperation(method = "rayTraceContraption", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;toLocalVector(Lnet/minecraft/world/phys/Vec3;F)Lnet/minecraft/world/phys/Vec3;")) + @WrapOperation(method = "rayTraceContraption", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;toLocalVector(Lnet/minecraft/world/phys/Vec3;F)Lnet/minecraft/world/phys/Vec3;"), remap = false) private static Vec3 wrapRayTraceContraptionToLocalVector( final AbstractContraptionEntity instance, final Vec3 localVec, final float partialTicks, final Operation<Vec3> toLocalVector ) { diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 6e3bd7e50..8a0e6a367 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -21,6 +21,7 @@ ], "client": [ "client.render.MixinLevelRenderer", + "compat.create.client.MixinContraptionHandlerClient", "compat.create.client.MixinContraptionRenderInfo", "compat.create.client.MixinFlwContraption", "compat.create.client.MixinSuperGlueSelectionHandler", From 2a688603e9c2f00ec9b48a6e4a54a79ee71bb61d Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 25 Oct 2023 01:34:50 -0600 Subject: [PATCH 297/437] Updated vs-core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 9a2fb38b8..9a8fdb02a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+2b49aeb3fe +vs_core_version=1.1.0+05bdb9b8af # 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 52b910bb6edfc6756ee390bbebf8325f99e23f44 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Wed, 25 Oct 2023 18:37:55 -0600 Subject: [PATCH 298/437] Revert "Don't create render chunks for air sections" This reverts commit babd2876bd736efd060eaa4f8a7c48f219b1edb4. --- .../vanilla_renderer/MixinLevelRendererVanilla.java | 8 -------- .../mod_compat/vanilla_renderer/MixinViewAreaVanilla.java | 3 --- 2 files changed, 11 deletions(-) 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 20b33b254..6c9cf355c 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 @@ -27,8 +27,6 @@ import net.minecraft.core.BlockPos; import net.minecraft.core.Vec3i; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.chunk.ChunkAccess; -import net.minecraft.world.level.chunk.LevelChunkSection; import org.jetbrains.annotations.Nullable; import org.joml.Vector3dc; import org.spongepowered.asm.mixin.Final; @@ -124,13 +122,7 @@ private void addShipVisibleChunks( } shipObject.getActiveChunksSet().forEach((x, z) -> { - final ChunkAccess chunk = level.getChunk(x, z); for (int y = level.getMinSection(); y < level.getMaxSection(); y++) { - final LevelChunkSection levelChunkSection = chunk.getSection(y - level.getMinSection()); - if (levelChunkSection.hasOnlyAir()) { - // Skip air sections - continue; - } tempPos.set(x << 4, y << 4, z << 4); final ChunkRenderDispatcher.RenderChunk renderChunk = chunkStorageAccessor.callGetRenderChunkAt(tempPos); 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 104e4db9f..0d18a2c02 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 @@ -14,7 +14,6 @@ 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; @@ -36,11 +35,9 @@ public class MixinViewAreaVanilla implements IVSViewAreaMethods { protected int chunkGridSizeY; // Maps chunk position to an array of BuiltChunk, indexed by the y value. - @Unique private final Long2ObjectMap<ChunkRenderDispatcher.RenderChunk[]> vs$shipRenderChunks = new Long2ObjectOpenHashMap<>(); // This creates render chunks - @Unique private ChunkRenderDispatcher vs$chunkBuilder; /** From 3df498e9b1638c66278c429a4e1825fc9176cd7b Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 28 Oct 2023 03:29:48 -0600 Subject: [PATCH 299/437] Use contraption anchor pos for wings --- .../mixin/compat/create/MixinAbstractContraptionEntity.java | 2 +- .../mixin/compat/create/MixinAbstractContraptionEntity.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 0b3f26275..c27d62b53 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 @@ -58,7 +58,7 @@ public Matrix4dc computeContraptionWingTransform() { final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); final Matrix3d rotationMatrix = CreateConversionsKt.toJOML(thisAsAbstractContraptionEntity.getRotationState().asMatrix()); - final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position()); + final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.getAnchorVec()); return new Matrix4d(rotationMatrix).setTranslation(pos); } } 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 4bbd5036d..32714a60d 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 @@ -56,7 +56,7 @@ public Matrix4dc computeContraptionWingTransform() { final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); final Matrix3d rotationMatrix = CreateConversionsKt.toJOML(thisAsAbstractContraptionEntity.getRotationState().asMatrix()); - final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position()); + final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.getAnchorVec()); return new Matrix4d(rotationMatrix).setTranslation(pos); } } From 4e46321386638b20588279e8faecf0d222bf7d70 Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Sat, 28 Oct 2023 03:52:17 -0600 Subject: [PATCH 300/437] Added 100 tick delay when unloading chunks --- .../mixin/server/world/MixinServerLevel.java | 52 ++++++++++++------- 1 file changed, 32 insertions(+), 20 deletions(-) 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 01f1cfd30..b3e4c96e9 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 @@ -4,6 +4,7 @@ import com.llamalad7.mixinextras.injector.wrapoperation.Operation; import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; +import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -22,7 +23,6 @@ import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ServerChunkCache; import net.minecraft.server.level.ServerLevel; -import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.level.progress.ChunkProgressListener; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.block.state.BlockState; @@ -59,22 +59,25 @@ @Mixin(ServerLevel.class) public abstract class MixinServerLevel implements IShipObjectWorldServerProvider, VSServerLevel { - @Shadow @Final private ServerChunkCache chunkSource; - @Shadow - @Final - List<ServerPlayer> players; - @Shadow @NotNull public abstract MinecraftServer getServer(); // Map from ChunkPos to the list of voxel chunks that chunk owns @Unique - private final Map<ChunkPos, List<Vector3ic>> knownChunks = new HashMap<>(); + private final Map<ChunkPos, List<Vector3ic>> vs$knownChunks = new HashMap<>(); + + // Maps chunk pos to number of ticks we have considered unloading the chunk + @Unique + private final Long2LongOpenHashMap vs$chunksToUnload = new Long2LongOpenHashMap(); + + // How many ticks we wait before unloading a chunk + @Unique + private static final long VS$CHUNK_UNLOAD_THRESHOLD = 100; @Nullable @Override @@ -127,8 +130,10 @@ private boolean includeShipsInParticleDistanceCheck( } @Unique - private void loadChunk(@NotNull final ChunkAccess worldChunk, final List<TerrainUpdate> voxelShapeUpdates) { - if (!knownChunks.containsKey(worldChunk.getPos())) { + private void vs$loadChunk(@NotNull final ChunkAccess worldChunk, final List<TerrainUpdate> voxelShapeUpdates) { + // Remove the chunk pos from vs$chunksToUnload if its present + vs$chunksToUnload.remove(worldChunk.getPos().toLong()); + if (!vs$knownChunks.containsKey(worldChunk.getPos())) { final List<Vector3ic> voxelChunkPositions = new ArrayList<>(); final int chunkX = worldChunk.getPos().x; @@ -184,7 +189,7 @@ private void loadChunk(@NotNull final ChunkAccess worldChunk, final List<Terrain voxelShapeUpdates.add(emptyVoxelShapeUpdate); } } - knownChunks.put(worldChunk.getPos(), voxelChunkPositions); + vs$knownChunks.put(worldChunk.getPos(), voxelChunkPositions); } } @@ -207,22 +212,29 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf if (worldChunkOptional.isPresent() && distanceManagerAccessor.getTickets().containsKey(chunkHolder.getPos().toLong())) { // Only load chunks that have a ticket final LevelChunk worldChunk = worldChunkOptional.get(); - loadChunk(worldChunk, voxelShapeUpdates); + vs$loadChunk(worldChunk, voxelShapeUpdates); } } - final Iterator<Entry<ChunkPos, List<Vector3ic>>> knownChunkPosIterator = knownChunks.entrySet().iterator(); + final Iterator<Entry<ChunkPos, List<Vector3ic>>> knownChunkPosIterator = vs$knownChunks.entrySet().iterator(); while (knownChunkPosIterator.hasNext()) { final Entry<ChunkPos, List<Vector3ic>> knownChunkPosEntry = knownChunkPosIterator.next(); + final long chunkPos = knownChunkPosEntry.getKey().toLong(); // Unload chunks if they don't have tickets or if they're not in the visible chunks - if ((!distanceManagerAccessor.getTickets().containsKey(knownChunkPosEntry.getKey().toLong()) || chunkMapAccessor.callGetVisibleChunkIfPresent(knownChunkPosEntry.getKey().toLong()) == null)) { - // Delete this chunk - for (final Vector3ic unloadedChunk : knownChunkPosEntry.getValue()) { - final TerrainUpdate deleteVoxelShapeUpdate = - getVsCore().newDeleteTerrainUpdate(unloadedChunk.x(), unloadedChunk.y(), unloadedChunk.z()); - voxelShapeUpdates.add(deleteVoxelShapeUpdate); + if ((!distanceManagerAccessor.getTickets().containsKey(chunkPos) || chunkMapAccessor.callGetVisibleChunkIfPresent(chunkPos) == null)) { + final long ticksWaitingToUnload = vs$chunksToUnload.getOrDefault(chunkPos, 0L); + if (ticksWaitingToUnload > VS$CHUNK_UNLOAD_THRESHOLD) { + // Unload this chunk + for (final Vector3ic unloadedChunk : knownChunkPosEntry.getValue()) { + final TerrainUpdate deleteVoxelShapeUpdate = + getVsCore().newDeleteTerrainUpdate(unloadedChunk.x(), unloadedChunk.y(), unloadedChunk.z()); + voxelShapeUpdates.add(deleteVoxelShapeUpdate); + } + knownChunkPosIterator.remove(); + vs$chunksToUnload.remove(chunkPos); + } else { + vs$chunksToUnload.put(chunkPos, ticksWaitingToUnload + 1); } - knownChunkPosIterator.remove(); } } @@ -236,6 +248,6 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf @Override public void removeChunk(final int chunkX, final int chunkZ) { final ChunkPos chunkPos = new ChunkPos(chunkX, chunkZ); - knownChunks.remove(chunkPos); + vs$knownChunks.remove(chunkPos); } } From 301addc7eb2e1e6a51b7db540d6bc8fc46c961ce Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 2 Nov 2023 01:52:44 -0600 Subject: [PATCH 301/437] Unified common mixin code --- .../create/accessors}/Matrix3dAccessor.java | 2 +- .../MixinAbstractContraptionEntity.java | 49 +++++++++++++- .../mod/compat}/CreateConversions.kt | 4 +- .../valkyrienskies-common.mixins.json | 1 + .../mixin/compat/create/Matrix3dAccessor.java | 37 ----------- .../MixinAbstractContraptionEntity.java | 64 ------------------- .../mod/fabric/common/CreateConversions.kt | 13 ---- .../valkyrienskies-fabric.mixins.json | 2 - .../MixinAbstractContraptionEntity.java | 62 ------------------ .../valkyrienskies-forge.mixins.json | 2 - 10 files changed, 52 insertions(+), 184 deletions(-) rename {forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create => common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors}/Matrix3dAccessor.java (90%) rename {forge/src/main/kotlin/org/valkyrienskies/mod/forge/common => common/src/main/kotlin/org/valkyrienskies/mod/compat}/CreateConversions.kt (73%) delete mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/Matrix3dAccessor.java delete mode 100644 fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinAbstractContraptionEntity.java delete mode 100644 fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/CreateConversions.kt delete mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinAbstractContraptionEntity.java diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/Matrix3dAccessor.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/Matrix3dAccessor.java similarity index 90% rename from forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/Matrix3dAccessor.java rename to common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/Matrix3dAccessor.java index 442fa71a3..cb571c775 100644 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/Matrix3dAccessor.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/accessors/Matrix3dAccessor.java @@ -1,4 +1,4 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create; +package org.valkyrienskies.mod.mixin.mod_compat.create.accessors; import com.simibubi.create.foundation.collision.Matrix3d; import org.spongepowered.asm.mixin.Mixin; 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 7c23b115e..aee924b13 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 @@ -19,6 +19,7 @@ import com.simibubi.create.foundation.utility.VecHelper; import java.util.Iterator; import net.minecraft.core.BlockPos; +import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; @@ -36,6 +37,9 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.jetbrains.annotations.NotNull; +import org.joml.Matrix3d; +import org.joml.Matrix4d; +import org.joml.Matrix4dc; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -46,15 +50,21 @@ 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.ContraptionWingProvider; +import org.valkyrienskies.core.api.ships.LoadedServerShip; import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.core.api.ships.WingManager; import org.valkyrienskies.mod.common.CompatUtil; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import org.valkyrienskies.mod.compat.CreateConversionsKt; import org.valkyrienskies.mod.mixin.mod_compat.create.IMixinDeployerHandler; import org.valkyrienskies.mod.mixin.mod_compat.create.IMixinDeployerMovementBehaviour; import org.valkyrienskies.mod.mixinducks.mod_compat.create.MixinAbstractContraptionEntityDuck; @Mixin(AbstractContraptionEntity.class) -public abstract class MixinAbstractContraptionEntity extends Entity implements MixinAbstractContraptionEntityDuck { +public abstract class MixinAbstractContraptionEntity extends Entity implements MixinAbstractContraptionEntityDuck, + ContraptionWingProvider { public MixinAbstractContraptionEntity(EntityType<?> entityType, Level level) { super(entityType, level); @@ -63,6 +73,9 @@ public MixinAbstractContraptionEntity(EntityType<?> entityType, Level level) { @Unique private static final Logger LOGGER = LogManager.getLogger("Clockwork.MixinAbstractContraptionEntity"); + @Unique + private int wingGroupId = -1; + @Shadow(remap = false) protected Contraption contraption; @@ -256,4 +269,38 @@ private void modGetContactPointMotion(Vec3 globalContactPoint, CallbackInfoRetur public StructureTransform getStructureTransform() { return makeStructureTransform(); } + + @Override + public int getWingGroupId() { + return wingGroupId; + } + + @Override + public void setWingGroupId(final int wingGroupId) { + this.wingGroupId = wingGroupId; + } + + @Inject(method = "tick", at = @At("HEAD")) + private void postTick(final CallbackInfo ci) { + final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); + final Level level = thisAsAbstractContraptionEntity.level; + if (wingGroupId != -1 && level instanceof final ServerLevel serverLevel) { + final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(serverLevel, + VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); + if (ship != null) { + // This can happen if a player moves a train contraption from ship to world using a wrench + ship.getAttachment(WingManager.class).setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); + } + } + } + + @NotNull + @Override + public Matrix4dc computeContraptionWingTransform() { + final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); + final Matrix3d rotationMatrix = + CreateConversionsKt.toJOML(thisAsAbstractContraptionEntity.getRotationState().asMatrix()); + final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.getAnchorVec()); + return new Matrix4d(rotationMatrix).setTranslation(pos); + } } diff --git a/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/CreateConversions.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateConversions.kt similarity index 73% rename from forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/CreateConversions.kt rename to common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateConversions.kt index 68f3319a4..93b73338c 100644 --- a/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/CreateConversions.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/compat/CreateConversions.kt @@ -1,7 +1,7 @@ -package org.valkyrienskies.mod.forge.common +package org.valkyrienskies.mod.compat import org.joml.Matrix3d -import org.valkyrienskies.mod.forge.mixin.compat.create.Matrix3dAccessor +import org.valkyrienskies.mod.mixin.mod_compat.create.accessors.Matrix3dAccessor fun com.simibubi.create.foundation.collision.Matrix3d.toJOML(): Matrix3d { val accessor = this as Matrix3dAccessor diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index bfb2a99b6..84033b658 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -61,6 +61,7 @@ "mod_compat.create.MixinEntityLauncher", "mod_compat.create.MixinRedstoneLinkNetworkHandler", "mod_compat.create.MixinSharedDepotBlockMethods", + "mod_compat.create.accessors.Matrix3dAccessor", "mod_compat.create.accessors.OutlineParamsAccessor", "mod_compat.create.behaviour.MixinBlockBreakingMovementBehaviour", "mod_compat.create.behaviour.MixinFilteringBehaviour", 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 deleted file mode 100644 index 8a6192c90..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/Matrix3dAccessor.java +++ /dev/null @@ -1,37 +0,0 @@ -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; -import org.spongepowered.asm.mixin.gen.Accessor; - -@Pseudo -@Mixin(Matrix3d.class) -public interface Matrix3dAccessor { - @Accessor("m00") - double getM00(); - - @Accessor("m01") - double getM01(); - - @Accessor("m02") - double getM02(); - - @Accessor("m10") - double getM10(); - - @Accessor("m11") - double getM11(); - - @Accessor("m12") - double getM12(); - - @Accessor("m20") - double getM20(); - - @Accessor("m21") - double getM21(); - - @Accessor("m22") - double getM22(); -} diff --git a/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 deleted file mode 100644 index c27d62b53..000000000 --- a/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinAbstractContraptionEntity.java +++ /dev/null @@ -1,64 +0,0 @@ -package org.valkyrienskies.mod.fabric.mixin.compat.create; - -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; -import org.joml.Matrix3d; -import org.joml.Matrix4d; -import org.joml.Matrix4dc; -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.CallbackInfo; -import org.valkyrienskies.core.api.ships.ContraptionWingProvider; -import org.valkyrienskies.core.api.ships.LoadedServerShip; -import org.valkyrienskies.core.api.ships.WingManager; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import org.valkyrienskies.mod.fabric.common.CreateConversionsKt; - -@Pseudo -@Mixin(AbstractContraptionEntity.class) -public abstract class MixinAbstractContraptionEntity implements ContraptionWingProvider { - - @Unique - private int wingGroupId = -1; - - @Override - public int getWingGroupId() { - return wingGroupId; - } - - @Override - public void setWingGroupId(final int wingGroupId) { - this.wingGroupId = wingGroupId; - } - - @Inject(method = "tick", at = @At("HEAD")) - private void postTick(final CallbackInfo ci) { - final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); - final Level level = thisAsAbstractContraptionEntity.level; - if (wingGroupId != -1 && level instanceof final ServerLevel serverLevel) { - final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(serverLevel, - VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); - if (ship != null) { - ship.getAttachment(WingManager.class) - .setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); - } - } - } - - @NotNull - @Override - public Matrix4dc computeContraptionWingTransform() { - final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); - final Matrix3d rotationMatrix = - CreateConversionsKt.toJOML(thisAsAbstractContraptionEntity.getRotationState().asMatrix()); - final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.getAnchorVec()); - return new Matrix4d(rotationMatrix).setTranslation(pos); - } -} 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 deleted file mode 100644 index 1f65afc9a..000000000 --- a/fabric/src/main/kotlin/org/valkyrienskies/mod/fabric/common/CreateConversions.kt +++ /dev/null @@ -1,13 +0,0 @@ -package org.valkyrienskies.mod.fabric.common - -import org.joml.Matrix3d -import org.valkyrienskies.mod.fabric.mixin.compat.create.Matrix3dAccessor - -fun com.simibubi.create.foundation.collision.Matrix3d.toJOML(): Matrix3d { - val accessor = this as Matrix3dAccessor - return Matrix3d( - accessor.m00, accessor.m01, accessor.m02, - accessor.m10, accessor.m11, accessor.m12, - accessor.m20, accessor.m21, accessor.m22 - ) -} diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 29543038e..59ece5b8c 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -8,8 +8,6 @@ "compat.cc_restitched.MixinTurtleBrain", "compat.cc_restitched.MixinTurtleMoveCommand", "compat.cc_restitched.MixinWirelessNetwork", - "compat.create.Matrix3dAccessor", - "compat.create.MixinAbstractContraptionEntity", "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", "compat.create.MixinControlledContraptionEntity", 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 deleted file mode 100644 index 32714a60d..000000000 --- a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinAbstractContraptionEntity.java +++ /dev/null @@ -1,62 +0,0 @@ -package org.valkyrienskies.mod.forge.mixin.compat.create; - -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import net.minecraft.server.level.ServerLevel; -import net.minecraft.world.level.Level; -import org.jetbrains.annotations.NotNull; -import org.joml.Matrix3d; -import org.joml.Matrix4d; -import org.joml.Matrix4dc; -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.callback.CallbackInfo; -import org.valkyrienskies.core.api.ships.ContraptionWingProvider; -import org.valkyrienskies.core.api.ships.LoadedServerShip; -import org.valkyrienskies.core.api.ships.WingManager; -import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -import org.valkyrienskies.mod.forge.common.CreateConversionsKt; - -@Mixin(AbstractContraptionEntity.class) -public abstract class MixinAbstractContraptionEntity implements ContraptionWingProvider { - - @Unique - private int wingGroupId = -1; - - @Override - public int getWingGroupId() { - return wingGroupId; - } - - @Override - public void setWingGroupId(final int wingGroupId) { - this.wingGroupId = wingGroupId; - } - - @Inject(method = "tick", at = @At("HEAD")) - private void postTick(final CallbackInfo ci) { - final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); - final Level level = thisAsAbstractContraptionEntity.level; - if (wingGroupId != -1 && level instanceof final ServerLevel serverLevel) { - final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(serverLevel, - VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); - if (ship != null) { - // This can happen if a player moves a train contraption from ship to world using a wrench - ship.getAttachment(WingManager.class).setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); - } - } - } - - @NotNull - @Override - public Matrix4dc computeContraptionWingTransform() { - final AbstractContraptionEntity thisAsAbstractContraptionEntity = AbstractContraptionEntity.class.cast(this); - final Matrix3d rotationMatrix = - CreateConversionsKt.toJOML(thisAsAbstractContraptionEntity.getRotationState().asMatrix()); - final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.getAnchorVec()); - return new Matrix4d(rotationMatrix).setTranslation(pos); - } -} diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 8a0e6a367..448f11e1c 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -8,8 +8,6 @@ "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.create.MixinControlledContraptionEntity", From b3b36822569bdf4d7d45f16e8c3059f578bbe48f Mon Sep 17 00:00:00 2001 From: StewStrong <stew.strong.420@gmail.com> Date: Thu, 2 Nov 2023 03:53:31 -0600 Subject: [PATCH 302/437] Improved drill contraptions on ships --- .../MixinAbstractContraptionEntity.java | 197 ++++++++++-------- .../MixinAbstractContraptionEntityDuck.java | 5 +- 2 files changed, 106 insertions(+), 96 deletions(-) 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 aee924b13..ea077730b 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 @@ -3,35 +3,26 @@ import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toMinecraft; -import com.simibubi.create.CreateClient; +import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.content.contraptions.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.Contraption; import com.simibubi.create.content.contraptions.OrientedContraptionEntity; -import com.simibubi.create.content.contraptions.StructureTransform; import com.simibubi.create.content.contraptions.actors.harvester.HarvesterMovementBehaviour; -import com.simibubi.create.content.contraptions.actors.plough.PloughMovementBehaviour; import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour; -import com.simibubi.create.content.kinetics.deployer.DeployerFakePlayer; import com.simibubi.create.content.kinetics.deployer.DeployerMovementBehaviour; import com.simibubi.create.foundation.utility.VecHelper; -import java.util.Iterator; import net.minecraft.core.BlockPos; +import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.Mth; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.vehicle.AbstractMinecart; -import net.minecraft.world.item.BlockItem; import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.CocoaBlock; -import net.minecraft.world.level.block.CropBlock; -import net.minecraft.world.level.block.DirectionalBlock; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; -import net.minecraft.world.phys.AABB; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate.StructureBlockInfo; import net.minecraft.world.phys.Vec3; import org.apache.commons.lang3.tuple.MutablePair; import org.apache.logging.log4j.LogManager; @@ -41,6 +32,8 @@ import org.joml.Matrix4d; import org.joml.Matrix4dc; import org.joml.Vector3d; +import org.joml.Vector3dc; +import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; @@ -49,7 +42,6 @@ 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.ContraptionWingProvider; import org.valkyrienskies.core.api.ships.LoadedServerShip; import org.valkyrienskies.core.api.ships.Ship; @@ -58,8 +50,6 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.compat.CreateConversionsKt; -import org.valkyrienskies.mod.mixin.mod_compat.create.IMixinDeployerHandler; -import org.valkyrienskies.mod.mixin.mod_compat.create.IMixinDeployerMovementBehaviour; import org.valkyrienskies.mod.mixinducks.mod_compat.create.MixinAbstractContraptionEntityDuck; @Mixin(AbstractContraptionEntity.class) @@ -161,92 +151,120 @@ private void redirectToGlobalVector(Vec3 localVec, final float partialTicks, fin @Shadow public abstract Vec3 getPrevPositionVec(); - @Shadow - protected abstract StructureTransform makeStructureTransform(); + @Unique + private boolean vs$shouldMod(final MovementBehaviour moveBehaviour) { + return ((moveBehaviour instanceof BlockBreakingMovementBehaviour) || (moveBehaviour instanceof HarvesterMovementBehaviour) || (moveBehaviour instanceof DeployerMovementBehaviour)); + } @Unique - private static Boolean isValidBlock(Level world, BlockPos colliderPos, MovementBehaviour movementBehaviour, MovementContext context) { - BlockState worldBlockState = world.getBlockState(colliderPos); - if (worldBlockState.getBlock() instanceof CocoaBlock) - return false; - if (movementBehaviour != null) { - if (movementBehaviour instanceof DeployerMovementBehaviour && context.temporaryData instanceof DeployerFakePlayer player) { - ((IMixinDeployerMovementBehaviour) movementBehaviour).invokeTryGrabbingItem(context); - if ((player.getMainHandItem().getItem() instanceof BlockItem blockItem) && (blockItem.getBlock() instanceof CropBlock)) { - return IMixinDeployerHandler.invokeShouldActivate(player.getMainHandItem(), context.world, colliderPos, null); - } else - return false; - } - if (movementBehaviour instanceof PloughMovementBehaviour behaviour) { - return worldBlockState.isAir() || behaviour.canBreak(world, colliderPos, worldBlockState); - } - if (movementBehaviour instanceof HarvesterMovementBehaviour harvesterMovementBehaviour) { - return harvesterMovementBehaviour.isValidCrop(world, colliderPos, worldBlockState) - || harvesterMovementBehaviour.isValidOther(world, colliderPos, worldBlockState); - } - if (movementBehaviour instanceof BlockBreakingMovementBehaviour behaviour) { - return behaviour.canBreak(world, colliderPos, worldBlockState); + private BlockPos vs$getTargetPos(final MovementBehaviour instance, final MovementContext context, final BlockPos pos, final Vec3 actorPosition) { + if (vs$shouldMod(instance) && context.world.getBlockState(pos).isAir() && VSGameUtilsKt.isBlockInShipyard(context.world, pos)) { + final Ship ship = VSGameUtilsKt.getShipManagingPos(context.world, pos); + if (ship != null) { + final Vector3dc actorPosInWorld = ship.getTransform().getShipToWorld().transformPosition(toJOML(actorPosition)); + return new BlockPos(actorPosInWorld.x(), actorPosInWorld.y(), actorPosInWorld.z()); } } - return !worldBlockState.isAir(); + return pos; } @Unique - private boolean shouldMod(MovementBehaviour moveBehaviour) { - return ((moveBehaviour instanceof BlockBreakingMovementBehaviour) || (moveBehaviour instanceof HarvesterMovementBehaviour) || (moveBehaviour instanceof DeployerMovementBehaviour)); - } + private boolean vs$forceStall = false; - @Unique - private StructureTemplate.StructureBlockInfo structureBlockInfo; + @Shadow + private boolean skipActorStop; - @Inject(method = "tickActors", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/AllMovementBehaviours;getBehaviour(Lnet/minecraft/world/level/block/state/BlockState;)Lcom/simibubi/create/content/contraptions/behaviour/MovementBehaviour;"), locals = LocalCapture.CAPTURE_FAILHARD) - private void injectTickActors(CallbackInfo ci, boolean stalledPreviously, Iterator<MutablePair<StructureTemplate.StructureBlockInfo, MovementContext>> var2, MutablePair<StructureTemplate.StructureBlockInfo, MovementContext> pair, MovementContext context, StructureTemplate.StructureBlockInfo blockInfo) { - structureBlockInfo = blockInfo; - } + @Shadow + @Final + private static EntityDataAccessor<Boolean> STALLED; - @Unique - private BlockPos getTargetPos(MovementBehaviour instance, MovementContext context, BlockPos pos, StructureTemplate.StructureBlockInfo blockInfo) { - if (shouldMod(instance) && context.world.getBlockState(pos).isAir() && VSGameUtilsKt.isBlockInShipyard(context.world, pos)) { - Ship ship = VSGameUtilsKt.getShipManagingPos(context.world, pos); - if (ship != null) { - Vector3d searchPos = toJOML(toGlobalVector(VecHelper.getCenterOf(blockInfo.pos) - .add(instance.getActiveAreaOffset(context)), 1)); - Vector3d searchPos2 = new Vector3d(searchPos); - - Vec3 transformedSearchPos = toMinecraft(ship.getShipToWorld().transformPosition(searchPos)); - if (blockInfo.state.hasProperty(DirectionalBlock.FACING)) { - searchPos2.add(toJOML( - Vec3.atLowerCornerOf(blockInfo.state.getValue(DirectionalBlock.FACING).getNormal()) - )); - } else { - searchPos2.add(0, 0, 1); - } - Vec3 transformedSearchPos2 = toMinecraft(ship.getShipToWorld().transformPosition(searchPos2)); - BlockPos blockPos = new BlockPos(transformedSearchPos); - boolean check = isValidBlock(context.world, blockPos, instance, context); - if (level.isClientSide) { - //Debug helper for future mixin work - //boolean debugView = Minecraft.getInstance().options.renderDebug; - if (false) { - int ttl = 100; - CreateClient.OUTLINER.showLine("actorPosDebugLine-" + context.localPos + "-" + context.contraption.anchor, transformedSearchPos, transformedSearchPos2) - .colored(0x0070ff) - .lineWidth(2 / 32f); - CreateClient.OUTLINER.showAABB("actorPosDebug-" + context.localPos + "-" + context.contraption.anchor, new AABB(blockPos.getX(), blockPos.getY(), blockPos.getZ(), blockPos.getX() + 1, blockPos.getY() + 1, blockPos.getZ() + 1), ttl) - .colored(check ? 0xff7000 : 0x70ff00) - .lineWidth(2 / 16f); - } - } - if (check) - pos = blockPos; + @Shadow + public abstract boolean isStalled(); + + @Shadow + protected abstract boolean shouldActorTrigger(MovementContext context, StructureBlockInfo blockInfo, MovementBehaviour actor, Vec3 actorPosition, BlockPos gridPosition); + + @Shadow + protected abstract boolean isActorActive(MovementContext context, MovementBehaviour actor); + + @Shadow + protected abstract void onContraptionStalled(); + + @Inject(method = "tickActors", at = @At("HEAD"), cancellable = true, remap = false) + private void preTickActors(final CallbackInfo ci) { + ci.cancel(); + + final boolean stalledPreviously = contraption.stalled; + + if (!level.isClientSide) + contraption.stalled = vs$forceStall; + + skipActorStop = true; + for (final MutablePair<StructureBlockInfo, MovementContext> pair : contraption.getActors()) { + final MovementContext context = pair.right; + final StructureBlockInfo blockInfo = pair.left; + final MovementBehaviour actor = AllMovementBehaviours.getBehaviour(blockInfo.state); + + if (actor == null) + continue; + + final Vec3 oldMotion = context.motion; + final Vec3 actorPosition = toGlobalVector(VecHelper.getCenterOf(blockInfo.pos) + .add(actor.getActiveAreaOffset(context)), 1); + final BlockPos gridPosition = vs$getTargetPos(actor, context, new BlockPos(actorPosition), actorPosition); // new BlockPos(actorPosition); + final boolean newPosVisited = + !context.stall && shouldActorTrigger(context, blockInfo, actor, actorPosition, gridPosition); + + context.rotation = v -> applyRotation(v, 1); + context.position = actorPosition; + if (!isActorActive(context, actor) && !actor.mustTickWhileDisabled()) + continue; + if (newPosVisited && !context.stall) { + actor.visitNewPosition(context, gridPosition); + if (!isAlive()) + break; + context.firstMovement = false; + } + if (!oldMotion.equals(context.motion)) { + actor.onSpeedChanged(context, oldMotion, context.motion); + if (!isAlive()) + break; } + actor.tick(context); + if (!isAlive()) + break; + contraption.stalled |= context.stall; } - return pos; + if (!isAlive()) { + contraption.stop(level); + return; + } + skipActorStop = false; + + for (final Entity entity : getPassengers()) { + if (!(entity instanceof final OrientedContraptionEntity orientedCE)) + continue; + if (contraption.getBearingPosOf(entity.getUUID()) == null) + continue; + if (orientedCE.getContraption() != null && orientedCE.getContraption().stalled) { + contraption.stalled = true; + break; + } + } + + if (!level.isClientSide) { + if (!stalledPreviously && contraption.stalled) + onContraptionStalled(); + entityData.set(STALLED, contraption.stalled); + return; + } + + contraption.stalled = isStalled(); } - @Redirect(method = "tickActors", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/behaviour/MovementBehaviour;visitNewPosition(Lcom/simibubi/create/content/contraptions/behaviour/MovementContext;Lnet/minecraft/core/BlockPos;)V")) - private void redirectVisitNewPosition(MovementBehaviour instance, MovementContext context, BlockPos pos) { - instance.visitNewPosition(context, getTargetPos(instance, context, pos, structureBlockInfo)); + @Override + public void vs$setForceStall(final boolean forceStall) { + this.vs$forceStall = forceStall; } //Region end @@ -265,11 +283,6 @@ private void modGetContactPointMotion(Vec3 globalContactPoint, CallbackInfoRetur } //Region end - @Override - public StructureTransform getStructureTransform() { - return makeStructureTransform(); - } - @Override public int getWingGroupId() { return wingGroupId; 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 7d6d1da29..2bd8894bf 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,8 +1,5 @@ package org.valkyrienskies.mod.mixinducks.mod_compat.create; - -import com.simibubi.create.content.contraptions.StructureTransform; - public interface MixinAbstractContraptionEntityDuck { - StructureTransform getStructureTransform(); + void vs$setForceStall(boolean forceStall); } From 9528e931374a88f6f6a88091c853e92152117a23 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 5 Nov 2023 18:10:52 -0700 Subject: [PATCH 303/437] Fixed flywheel block entities still rendering after ship is deleted --- .../mod/compat/FlywheelEvents.java | 35 +++++++++++++++++++ .../MixinBlockEntityInstanceManager.java | 20 +++++++---- .../flywheel/MixinInstanceWorld.java | 25 ++++++++----- .../flywheel/MixinInstancingEngine.java | 12 ++----- .../MixinBlockEntityInstanceManagerDuck.java | 3 +- .../mixinducks/MixinInstancingEngineDuck.java | 2 +- gradle.properties | 2 +- 7 files changed, 71 insertions(+), 28 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java diff --git a/common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java b/common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java new file mode 100644 index 000000000..8e5076018 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/compat/FlywheelEvents.java @@ -0,0 +1,35 @@ +package org.valkyrienskies.mod.compat; + +import com.jozufozu.flywheel.backend.instancing.InstanceWorld; +import java.util.Collections; +import java.util.Set; +import java.util.WeakHashMap; +import org.valkyrienskies.core.impl.hooks.VSEvents.ShipUnloadEventClient; +import org.valkyrienskies.mod.mixinducks.MixinBlockEntityInstanceManagerDuck; + +public class FlywheelEvents { + static { + registerEvents(); + } + + private static final Set<InstanceWorld> weakLoadedInstanceWorlds = + Collections.newSetFromMap( + new WeakHashMap<>() + ); + + private static synchronized void registerEvents() { + ShipUnloadEventClient.Companion.on(event -> { + for (final InstanceWorld instanceWorld : weakLoadedInstanceWorlds) { + ((MixinBlockEntityInstanceManagerDuck) instanceWorld.getBlockEntityInstanceManager()).vs$removeShipManager(event.getShip()); + } + }); + } + + public static void onInstanceWorldLoad(final InstanceWorld instanceWorld) { + weakLoadedInstanceWorlds.add(instanceWorld); + } + + public static void onInstanceWorldUnload(final InstanceWorld instanceWorld) { + weakLoadedInstanceWorlds.remove(instanceWorld); + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinBlockEntityInstanceManager.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinBlockEntityInstanceManager.java index 8254b7be2..7424739e8 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 @@ -33,12 +33,8 @@ public abstract class MixinBlockEntityInstanceManager extends InstanceManager<BlockEntity> implements MixinBlockEntityInstanceManagerDuck { - public WeakHashMap<ClientShip, MaterialManager> getShipMaterialManagers() { - return shipMaterialManagers; - } - @Unique - private final WeakHashMap<ClientShip, MaterialManager> shipMaterialManagers = + private final WeakHashMap<ClientShip, MaterialManager> vs$shipMaterialManagers = new WeakHashMap<>(); public MixinBlockEntityInstanceManager(final MaterialManager materialManager) { @@ -57,7 +53,7 @@ void preCreateRaw(final BlockEntity blockEntity, final CallbackInfoReturnable<In level, blockEntity.getBlockPos()); if (ship != null) { final MaterialManager manager = - shipMaterialManagers.computeIfAbsent(ship, k -> createMaterialManager()); + vs$shipMaterialManagers.computeIfAbsent(ship, k -> vs$createMaterialManager()); final Vector3i c = ship.getChunkClaim().getCenterBlockCoordinates(VSGameUtilsKt.getYRange(nullableLevel), new Vector3i()); ((InstancingEngineAccessor) manager).setOriginCoordinate(new BlockPos(c.x, c.y, c.z)); @@ -67,8 +63,18 @@ void preCreateRaw(final BlockEntity blockEntity, final CallbackInfoReturnable<In } } + @Override + public WeakHashMap<ClientShip, MaterialManager> vs$getShipMaterialManagers() { + return vs$shipMaterialManagers; + } + + @Override + public void vs$removeShipManager(final ClientShip clientShip) { + vs$shipMaterialManagers.remove(clientShip); + } + @Unique - private MaterialManager createMaterialManager() { + private MaterialManager vs$createMaterialManager() { if (Backend.getBackendType() == BackendType.INSTANCING) { return InstancingEngine.builder(Contexts.WORLD).build(); } else if (Backend.getBackendType() == BackendType.BATCHING) { 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..a66ba50c8 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 @@ -23,6 +23,7 @@ import org.valkyrienskies.core.api.ships.ClientShip; import org.valkyrienskies.mod.common.VSClientGameUtils; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; +import org.valkyrienskies.mod.compat.FlywheelEvents; import org.valkyrienskies.mod.mixinducks.MixinBlockEntityInstanceManagerDuck; import org.valkyrienskies.mod.mixinducks.MixinInstancingEngineDuck; @@ -49,17 +50,15 @@ void renderShipTiles(final RenderLayerEvent event, final CallbackInfo ci) { //not sure if restoreState stuff should be here or in the ((MixinInstancingEngineDuck) manager).render() method final GlStateTracker.State restoreState = GlStateTracker.getRestoreState(); final var shipManagers = - ((MixinBlockEntityInstanceManagerDuck) blockEntityInstanceManager).getShipMaterialManagers(); + ((MixinBlockEntityInstanceManagerDuck) blockEntityInstanceManager).vs$getShipMaterialManagers(); - shipManagers.forEach((ship, manager) -> { - render(ship, manager, event); - }); + shipManagers.forEach((ship, manager) -> vs$render(ship, manager, event)); restoreState.restore(); } @Unique - void render(final ClientShip ship, final MaterialManager manager, final RenderLayerEvent event) { - if (manager instanceof InstancingEngine<?> engine) { + private void vs$render(final ClientShip ship, final MaterialManager manager, final RenderLayerEvent event) { + if (manager instanceof final InstancingEngine<?> engine) { final Vector3d origin = VectorConversionsMCKt.toJOMLD(engine.getOriginCoordinate()); final Matrix4d viewProjection = VectorConversionsMCKt.toJOML(event.viewProjection); @@ -76,14 +75,14 @@ void render(final ClientShip ship, final MaterialManager manager, final RenderLa final Matrix4f fnlProj = VectorConversionsMCKt.toMinecraft(finalProjection); - ((MixinInstancingEngineDuck) engine).render( + ((MixinInstancingEngineDuck) engine).vs$render( fnlProj, camInShipLocal.x, camInShipLocal.y, camInShipLocal.z, event.layer ); - } else if (manager instanceof BatchingEngine engine) { + } else if (manager instanceof final BatchingEngine engine) { event.stack.pushPose(); VSClientGameUtils.multiplyWithShipToWorld(event.stack, ship); engine.render(taskEngine, event); @@ -92,4 +91,14 @@ void render(final ClientShip ship, final MaterialManager manager, final RenderLa throw new IllegalArgumentException("unrecognized engine"); } } + + @Inject(method = "<init>", at = @At("RETURN")) + private void postInit(final CallbackInfo ci) { + FlywheelEvents.onInstanceWorldLoad(InstanceWorld.class.cast(this)); + } + + @Inject(method = "delete", at = @At("RETURN")) + private void postDelete(final CallbackInfo ci) { + FlywheelEvents.onInstanceWorldUnload(InstanceWorld.class.cast(this)); + } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstancingEngine.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/flywheel/MixinInstancingEngine.java index 213ba443a..cb843a8fd 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 @@ -6,29 +6,21 @@ 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.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Pseudo; import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.Unique; import org.valkyrienskies.mod.mixinducks.MixinInstancingEngineDuck; @Pseudo @Mixin(value = InstancingEngine.class, remap = false) public abstract class MixinInstancingEngine<P extends WorldProgram> implements MixinInstancingEngineDuck { - @Unique - private static final Logger LOGGER = LogManager.getLogger("VS2 flywheel.client.MixinInstancingEngine"); - @Shadow protected abstract Stream<InstancedMaterialGroup<P>> getGroupsToRender(@Nullable RenderLayer layer); @Override - public void render(final Matrix4f viewProjection, final double camX, final double camY, final double camZ, + public void vs$render(final Matrix4f viewProjection, final double camX, final double camY, final double camZ, final RenderLayer layer) { - this.getGroupsToRender(layer).forEach(g -> { - g.render(viewProjection, camX, camY, camZ, layer); - }); + this.getGroupsToRender(layer).forEach(g -> g.render(viewProjection, camX, camY, camZ, layer)); } } 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..00be12a98 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinBlockEntityInstanceManagerDuck.java @@ -6,6 +6,7 @@ public interface MixinBlockEntityInstanceManagerDuck { - WeakHashMap<ClientShip, MaterialManager> getShipMaterialManagers(); + WeakHashMap<ClientShip, MaterialManager> vs$getShipMaterialManagers(); + void vs$removeShipManager(ClientShip clientShip); } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java index 2b9eeba86..ff8cb7cf7 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/MixinInstancingEngineDuck.java @@ -4,5 +4,5 @@ import com.mojang.math.Matrix4f; public interface MixinInstancingEngineDuck { - void render(Matrix4f viewProjection, double camX, double camY, double camZ, RenderLayer layer); + void vs$render(Matrix4f viewProjection, double camX, double camY, double camZ, RenderLayer layer); } diff --git a/gradle.properties b/gradle.properties index 9a8fdb02a..71717e789 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+05bdb9b8af +vs_core_version=1.1.0+4708cc0c0e # 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 959c03917b72eb8207ad5ab27aed392564d31e87 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Mon, 6 Nov 2023 02:43:00 -0700 Subject: [PATCH 304/437] Print reason when Krunch fails to load --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 71717e789..729994223 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+4708cc0c0e +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 kotlin.stdlib.default.dependency=false From b1010254afb4b572e9308a75dea6d27b44ad7665 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Mon, 6 Nov 2023 06:16:16 -0700 Subject: [PATCH 305/437] Fix entities in ships not rendering when Sodium is installed --- .../mod_compat/sodium/MixinSodiumWorldRenderer.java | 11 +++++++++++ 1 file changed, 11 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 a70ed2137..fd894a38a 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 @@ -18,7 +18,9 @@ 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.Redirect; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.valkyrienskies.core.api.ships.ClientShip; import org.valkyrienskies.mod.common.VSGameUtilsKt; @@ -48,4 +50,13 @@ private void renderShipChunkBlockEntity(final BlockEntityRenderDispatcher instan instance.render(blockEntity, tickDelta, matrixStack, buffer); } + /** + * 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<Boolean> cir) { + if (VSGameUtilsKt.isChunkInShipyard(world, x, z)) { + cir.setReturnValue(true); + } + } } From e90b7104c220136084a2e7dc82ec6e948934de98 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Tue, 7 Nov 2023 05:20:55 -0700 Subject: [PATCH 306/437] Only load Sodium mixins on client side --- .../src/main/resources/valkyrienskies-common.mixins.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 84033b658..7f72f3301 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -88,10 +88,6 @@ "mod_compat.create.pr.MixinSeatBlock", "mod_compat.create_big_cannons.MixinPitchOrientedContraptionEntity", "mod_compat.ftb_chunks.MixinClaimedChunkManager", - "mod_compat.sodium.MixinChunkTracker", - "mod_compat.sodium.MixinRegionChunkRenderer", - "mod_compat.sodium.MixinRenderSectionManager", - "mod_compat.sodium.MixinSodiumWorldRenderer", "server.MixinMinecraftServer", "server.MixinPlayerList", "server.command.MixinCommands", @@ -173,6 +169,10 @@ "mod_compat.optifine.MixinViewAreaOptifine", "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.sound_physics_remastered.MixinSoundPhysics", "mod_compat.vanilla_renderer.MixinLevelRendererVanilla", "mod_compat.vanilla_renderer.MixinViewAreaVanilla", From 1993e1741922678e9e0c4cdfcd3cbe479adbedad Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Wed, 8 Nov 2023 18:58:57 -0700 Subject: [PATCH 307/437] Added compat with ReachEntityAttributes to fix chests on ships closing immediately after being opened --- .../MixinReachEntityAttributes.java | 41 +++++++++++++++++++ .../valkyrienskies-common.mixins.json | 1 + 2 files changed, 42 insertions(+) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/reachentityattributes/MixinReachEntityAttributes.java diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/reachentityattributes/MixinReachEntityAttributes.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/reachentityattributes/MixinReachEntityAttributes.java new file mode 100644 index 000000000..d6f48d905 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/reachentityattributes/MixinReachEntityAttributes.java @@ -0,0 +1,41 @@ +package org.valkyrienskies.mod.mixin.mod_compat.reachentityattributes; + +import com.jamieswhiteshirt.reachentityattributes.ReachEntityAttributes; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Predicate; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import org.valkyrienskies.mod.common.VSGameUtilsKt; + +@Pseudo +@Mixin(ReachEntityAttributes.class) +public class MixinReachEntityAttributes { + @Shadow + public static double getReachDistance(final LivingEntity entity, final double baseReachDistance) { + return 0.0; + } + + /** + * @author Triode + * @reason Fix getting players within reach of ship blocks + */ + @Overwrite + public static List<Player> getPlayersWithinReach(final Predicate<Player> viewerPredicate, final Level world, final int x, final int y, final int z, final double baseReachDistance) { + final List<Player> playersWithinReach = new ArrayList<>(0); + for (final Player player : world.players()) { + if (viewerPredicate.test(player)) { + final var reach = getReachDistance(player, baseReachDistance); + if (VSGameUtilsKt.squaredDistanceBetweenInclShips(world, x + 0.5, y + 0.5, z + 0.5, player.getX(), player.getEyeY(), player.getZ()) <= (reach * reach)) { + playersWithinReach.add(player); + } + } + } + return playersWithinReach; + } +} diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 7f72f3301..b24ddc4e8 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -88,6 +88,7 @@ "mod_compat.create.pr.MixinSeatBlock", "mod_compat.create_big_cannons.MixinPitchOrientedContraptionEntity", "mod_compat.ftb_chunks.MixinClaimedChunkManager", + "mod_compat.reachentityattributes.MixinReachEntityAttributes", "server.MixinMinecraftServer", "server.MixinPlayerList", "server.command.MixinCommands", From c8f16ebd98939e5eb57b0b4636c22fa9878a95fa Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sat, 11 Nov 2023 21:06:46 -0700 Subject: [PATCH 308/437] Make VSPhysicsEntity.physicsEntityData and VSPhysicsEntity.physicsEntityServer protected --- .../org/valkyrienskies/mod/common/entity/VSPhysicsEntity.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 41f31eff6..2b561f8e2 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 @@ -37,10 +37,10 @@ import org.valkyrienskies.mod.mixin.accessors.entity.EntityAccessor open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity(type, level) { // Physics data, persistent - private var physicsEntityData: PhysicsEntityData? = null + protected var physicsEntityData: PhysicsEntityData? = null // The physics entity, transient, only exists server side after this entity has been added to a world - private var physicsEntityServer: PhysicsEntityServer? = null + protected var physicsEntityServer: PhysicsEntityServer? = null private var lerpPos: Vector3dc? = null private var lerpSteps = 0 From 7155e68379f42bf80ade663edfe5d6e04dbe20bb Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sat, 11 Nov 2023 21:12:46 -0700 Subject: [PATCH 309/437] Fixed compile error --- .../org/valkyrienskies/mod/common/entity/VSPhysicsEntity.kt | 2 ++ 1 file changed, 2 insertions(+) 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 2b561f8e2..b636d67ff 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 @@ -38,9 +38,11 @@ import org.valkyrienskies.mod.mixin.accessors.entity.EntityAccessor open class VSPhysicsEntity(type: EntityType<VSPhysicsEntity>, level: Level) : Entity(type, level) { // Physics data, persistent protected var physicsEntityData: PhysicsEntityData? = null + private set // The physics entity, transient, only exists server side after this entity has been added to a world protected var physicsEntityServer: PhysicsEntityServer? = null + private set private var lerpPos: Vector3dc? = null private var lerpSteps = 0 From edc97125e2f0b44e528f886ad56de8c28a66f935 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sat, 11 Nov 2023 23:31:32 -0700 Subject: [PATCH 310/437] Fixed chests rendering double with sodium --- .../client/world/MixinClientChunkCache.java | 42 +++++++------------ .../MixinBlockEntityInstanceManager.java | 6 ++- .../optifine_vanilla/MixinLevelRenderer.java | 2 +- .../client/world/ClientChunkCacheDuck.java | 2 +- 4 files changed, 23 insertions(+), 29 deletions(-) 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..0f4fb6db1 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 @@ -5,18 +5,16 @@ import java.util.function.Consumer; import net.minecraft.client.multiplayer.ClientChunkCache; import net.minecraft.client.multiplayer.ClientLevel; -import net.minecraft.core.SectionPos; import net.minecraft.nbt.CompoundTag; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.network.protocol.game.ClientboundLevelChunkPacketData.BlockEntityTagOutput; import net.minecraft.world.level.ChunkPos; import net.minecraft.world.level.chunk.ChunkStatus; import net.minecraft.world.level.chunk.LevelChunk; -import net.minecraft.world.level.chunk.LevelChunkSection; -import net.minecraft.world.level.lighting.LevelLightEngine; 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; @@ -43,11 +41,12 @@ public abstract class MixinClientChunkCache implements ClientChunkCacheDuck { @Final ClientLevel level; - public LongObjectMap<LevelChunk> vs_getShipChunks() { - return shipChunks; + public LongObjectMap<LevelChunk> vs$getShipChunks() { + return vs$shipChunks; } - private final LongObjectMap<LevelChunk> shipChunks = new LongObjectHashMap<>(); + @Unique + private final LongObjectMap<LevelChunk> vs$shipChunks = new LongObjectHashMap<>(); @Inject(method = "replaceWithPacketData", at = @At("HEAD"), cancellable = true) private void preLoadChunkFromPacket(final int x, final int z, @@ -60,25 +59,19 @@ private void preLoadChunkFromPacket(final int x, final int z, if (VSGameUtilsKt.isChunkInShipyard(level, x, z)) { final long chunkPosLong = ChunkPos.asLong(x, z); - final LevelChunk worldChunk = new LevelChunk(this.level, new ChunkPos(x, z)); - worldChunk.replaceWithPacketData(buf, tag, consumer); - shipChunks.put(chunkPosLong, worldChunk); - - final LevelChunkSection[] chunkSections = worldChunk.getSections(); - final LevelLightEngine lightingProvider = this.getLightEngine(); - lightingProvider.enableLightSources(new ChunkPos(x, z), true); - - for (int j = 0; j < chunkSections.length; ++j) { - final LevelChunkSection chunkSection = chunkSections[j]; - lightingProvider - .updateSectionStatus(SectionPos.of(x, level.getSectionYFromSectionIndex(j), z), - chunkSection.hasOnlyAir()); + final LevelChunk oldChunk = vs$shipChunks.get(chunkPosLong); + final LevelChunk worldChunk; + if (oldChunk != null) { + worldChunk = oldChunk; + oldChunk.replaceWithPacketData(buf, tag, consumer); + } else { + worldChunk = new LevelChunk(this.level, new ChunkPos(x, z)); + worldChunk.replaceWithPacketData(buf, tag, consumer); + vs$shipChunks.put(chunkPosLong, worldChunk); } this.level.onChunkLoaded(new ChunkPos(x, z)); - SodiumCompat.onChunkAdded(x, z); - cir.setReturnValue(worldChunk); } } @@ -86,7 +79,7 @@ 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) { - shipChunks.remove(ChunkPos.asLong(chunkX, chunkZ)); + vs$shipChunks.remove(ChunkPos.asLong(chunkX, chunkZ)); if (ValkyrienCommonMixinConfigPlugin.getVSRenderer() != VSRenderer.SODIUM) { ((IVSViewAreaMethods) ((LevelRendererAccessor) ((ClientLevelAccessor) level).getLevelRenderer()).getViewArea()) .unloadChunk(chunkX, chunkZ); @@ -100,12 +93,9 @@ public void preUnload(final int chunkX, final int chunkZ, final CallbackInfo ci) at = @At("HEAD"), cancellable = true) public void preGetChunk(final int chunkX, final int chunkZ, final ChunkStatus chunkStatus, final boolean bl, final CallbackInfoReturnable<LevelChunk> cir) { - final LevelChunk shipChunk = shipChunks.get(ChunkPos.asLong(chunkX, chunkZ)); + final LevelChunk shipChunk = vs$shipChunks.get(ChunkPos.asLong(chunkX, chunkZ)); if (shipChunk != null) { cir.setReturnValue(shipChunk); } } - - @Shadow - public abstract LevelLightEngine getLightEngine(); } 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 7424739e8..86ad788fa 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 @@ -5,6 +5,7 @@ import com.jozufozu.flywheel.backend.Backend; import com.jozufozu.flywheel.backend.instancing.InstanceManager; import com.jozufozu.flywheel.backend.instancing.InstancedRenderRegistry; +import com.jozufozu.flywheel.backend.instancing.RenderDispatcher; import com.jozufozu.flywheel.backend.instancing.batching.BatchingEngine; import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstanceManager; import com.jozufozu.flywheel.backend.instancing.instancing.InstancingEngine; @@ -70,7 +71,10 @@ void preCreateRaw(final BlockEntity blockEntity, final CallbackInfoReturnable<In @Override public void vs$removeShipManager(final ClientShip clientShip) { - vs$shipMaterialManagers.remove(clientShip); + final MaterialManager removed = vs$shipMaterialManagers.remove(clientShip); + if (removed instanceof final RenderDispatcher removedRenderer) { + removedRenderer.delete(); + } } @Unique 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..56dd49216 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,7 @@ public abstract class MixinLevelRenderer { ) ) private void afterRefresh(final CallbackInfo ci) { - ((ClientChunkCacheDuck) this.level.getChunkSource()).vs_getShipChunks().forEach((pos, chunk) -> { + ((ClientChunkCacheDuck) this.level.getChunkSource()).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/mixinducks/client/world/ClientChunkCacheDuck.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/client/world/ClientChunkCacheDuck.java index 74136c9b6..89169d9a4 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/client/world/ClientChunkCacheDuck.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/client/world/ClientChunkCacheDuck.java @@ -4,5 +4,5 @@ import net.minecraft.world.level.chunk.LevelChunk; public interface ClientChunkCacheDuck { - LongObjectMap<LevelChunk> vs_getShipChunks(); + LongObjectMap<LevelChunk> vs$getShipChunks(); } From b794c55467f69c816b1eba8089f27abf1f46a7b9 Mon Sep 17 00:00:00 2001 From: mrsterner <simon@sterner.dev> Date: Thu, 16 Nov 2023 01:34:06 +0100 Subject: [PATCH 311/437] 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<InteractionResult> 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 = "<init>" ) 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<Level> resourceKey, + final Holder<DimensionType> holder, + final Supplier<ProfilerFiller> 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<Level, BlockPos> 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 = "<init>" ) - 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<Integer> getChessboardDistance) { + private int skipDistanceCheck(final ChunkPos instance, final ChunkPos chunkPos, final Operation<Integer> 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 = "<init>", 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<Level> levelId, final LevelStem levelStem, + final ChunkProgressListener chunkProgressListener, final boolean bl, + final long l, final List<CustomSpawner> 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<ConfiguredStructureFeature<?, ?>> holderSet, BlockPos blockPos, int i, boolean bl, final CallbackInfoReturnable<Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>>> cir) { + @Inject(method = "findNearestMapStructure", at = @At("HEAD"), cancellable = true) + private void preFindNearestMapFeature(ServerLevel serverLevel, HolderSet<Structure> holderSet, BlockPos blockPos, int i, boolean bl, CallbackInfoReturnable<Pair<BlockPos, Holder<Structure>>> 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<StructureSet> resourceKey, long l, int chunkX, int chunkZ, int k, final CallbackInfoReturnable<Boolean> cir) { + @Inject(method = "hasStructureChunkInRange", at = @At("HEAD"), cancellable = true) + private void preHasFeatureChunkInRange(Holder<StructureSet> holder, RandomState randomState, long l, int chunkX, int chunkZ, int k, CallbackInfoReturnable<Boolean> 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<CompletableFuture<ChunkAccess>> cir) { + private void preFillFromNoise(Executor executor, Blender blender, RandomState randomState, StructureManager structureManager, ChunkAccess chunkAccess, CallbackInfoReturnable<CompletableFuture<ChunkAccess>> 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<NoiseGeneratorSettings> 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<NoiseColumn> cir) { + private void preGetBaseColumn(int i, int j, LevelHeightAccessor levelHeightAccessor, RandomState randomState, CallbackInfoReturnable<NoiseColumn> 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<CompletableFuture<ChunkAccess>> cir) { + private void preFillFromNoise(Executor executor, Blender blender, RandomState randomState, StructureManager structureManager, ChunkAccess chunkAccess, CallbackInfoReturnable<CompletableFuture<ChunkAccess>> 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<RelativeVector3> { @@ -164,7 +165,7 @@ class RelativeVector3Argument : ArgumentType<RelativeVector3> { 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<String> = 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<ServerShip> 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<VSCommandSource>).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<VSCommandSource>).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<VSCommandSource>).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<VSCommandSource>).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<ServerShip> 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<ServerShip> 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<VSCommandSource>).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<VSCommandSource>).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 <simon@sterner.dev> Date: Thu, 16 Nov 2023 02:36:40 +0100 Subject: [PATCH 312/437] 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 <A extends ArgumentType<?>, T extends ArgumentTypeInfo.Template<A>> ArgumentTypeInfo<A, T> register( + Registry<ArgumentTypeInfo<?, ?>> arg, String string, Class<? extends A> class_, ArgumentTypeInfo<A, T> arg2) { + throw new IllegalStateException(); + } + + @Inject(method = "bootstrap", at = @At("TAIL")) + private static void postBootstrap(final Registry<ArgumentTypeInfo<?, ?>> registry, + final CallbackInfoReturnable<ArgumentTypeInfo<?, ?>> 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 <T extends ArgumentType<?>> void register(final String id, final Class<T> argClass, final ArgumentSerializer<T> 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<String> = EXAMPLES - - object Serializer : ArgumentSerializer<ShipArgument> { - 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<ShipArgument, ShipArgumentInfoTemplate> { + 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<ShipArgument> { + override fun instantiate(commandBuildContext: CommandBuildContext): ShipArgument { + return if (selectorOnly) { + ShipArgument.selectorOnly() + } else { + Companion.ships() + } + } + + override fun type(): ArgumentTypeInfo<ShipArgument, *> { + 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<VSCommandSource>(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<ServerShip> 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<ServerShip> val position = Vec3Argument.getVec3(it as CommandContext<CommandSourceStack>, "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<VSCommandSource>).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<CommandSourceStack> @@ -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<VSCommandSource>).source.shipWorld as ServerShipWorld - val newScale = DoubleArgumentType.getDouble(it, "newScale") - val r = ShipArgument.getShips(it, "ships").toList() as List<ServerShip> - 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<CommandSourceStack>, "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<VSCommandSource>).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<VSCommandSource>).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<Component> { 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<String> set, final Set<String> set1) { - - } - - @Override - public List<String> 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<String> set, final Set<String> set1) { - - } - - @Override - public List<String> 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 <simon@sterner.dev> Date: Thu, 16 Nov 2023 03:03:07 +0100 Subject: [PATCH 313/437] 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<Void> 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<Void> 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<Block> private val TEST_HINGE_REGISTRY: RegistryObject<Block> private val TEST_FLAP_REGISTRY: RegistryObject<Block> @@ -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 <simon@sterner.dev> Date: Thu, 16 Nov 2023 12:20:09 +0100 Subject: [PATCH 314/437] 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 <simon@sterner.dev> Date: Thu, 16 Nov 2023 13:51:21 +0100 Subject: [PATCH 315/437] 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 <simon@sterner.dev> Date: Thu, 16 Nov 2023 14:19:05 +0100 Subject: [PATCH 316/437] 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<Double> 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 <simon@sterner.dev> Date: Thu, 16 Nov 2023 14:35:35 +0100 Subject: [PATCH 317/437] 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 47d4fcc862bb66772ef25372ccf53dcfc494049c Mon Sep 17 00:00:00 2001 From: mrsterner <simon@sterner.dev> Date: Thu, 16 Nov 2023 23:41:49 +0100 Subject: [PATCH 318/437] 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 b3b37eef6f44bd89b28526add1486201c75ea149 Mon Sep 17 00:00:00 2001 From: some-du6e <103129948+some-du6e@users.noreply.github.com> Date: Thu, 16 Nov 2023 17:16:32 -0600 Subject: [PATCH 319/437] Change Deprecated Libraries This commit changes "fabric" to "fabric-api" since "fabric" is deprecated. --- fabric/src/main/resources/fabric.mod.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 186e340e3..a55d4d5b4 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -31,7 +31,7 @@ "depends": { "fabricloader": ">=0.14.6", "minecraft": ">=1.18.2", - "fabric": "*" + "fabric-api": "*" }, "breaks": { } From 21ee5648c0b16600d1bfba26168d5578340340fd Mon Sep 17 00:00:00 2001 From: mrsterner <simon@sterner.dev> Date: Fri, 17 Nov 2023 11:16:23 +0100 Subject: [PATCH 320/437] 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 8171a8aa275ac6e20a64778dc43e114c912328c1 Mon Sep 17 00:00:00 2001 From: mrsterner <simon@sterner.dev> Date: Fri, 17 Nov 2023 15:04:32 +0100 Subject: [PATCH 321/437] 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 6f85423bfe85f04aece35b9f82d0f6d5d0e013e7 Mon Sep 17 00:00:00 2001 From: mrsterner <simon@sterner.dev> Date: Fri, 17 Nov 2023 20:32:17 +0100 Subject: [PATCH 322/437] 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 <simon@sterner.dev> Date: Fri, 17 Nov 2023 20:32:46 +0100 Subject: [PATCH 323/437] 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 b742eebf3d4559fdd44e7b88b5b0b53d2fab0f4e Mon Sep 17 00:00:00 2001 From: TechTastic <74630543+TechTastic@users.noreply.github.com> Date: Fri, 17 Nov 2023 23:29:55 -0600 Subject: [PATCH 324/437] Added dependency for Modular Routers Mixin'd into ContainerModularRouter to fix distance check --- forge/build.gradle | 3 ++ .../MixinContainerModularRouter.java | 35 +++++++++++++++++++ .../valkyrienskies-forge.mixins.json | 1 + 3 files changed, 39 insertions(+) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/modular_routers/MixinContainerModularRouter.java diff --git a/forge/build.gradle b/forge/build.gradle index 6927771ed..d56e4a985 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -78,6 +78,9 @@ dependencies { //modImplementation("curse.maven:tis3d-238603:3738437") //modImplementation("curse.maven:markdownmanual-502485:3738124") + // Modular Routers + modCompileOnly("curse.maven:mr-250294:3776175") + // Add Kotlin for Forge (3.12.0) forgeRuntimeLibrary('curse.maven:kotlinforforge-351264:4513187') diff --git a/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/modular_routers/MixinContainerModularRouter.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/modular_routers/MixinContainerModularRouter.java new file mode 100644 index 000000000..2d911dfaa --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/modular_routers/MixinContainerModularRouter.java @@ -0,0 +1,35 @@ +package org.valkyrienskies.mod.forge.mixin.compat.modular_routers; + +import me.desht.modularrouters.block.tile.ModularRouterBlockEntity; +import me.desht.modularrouters.container.ContainerModularRouter; +import net.minecraft.world.level.Level; +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.Pseudo; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Pseudo +@Mixin(ContainerModularRouter.class) +public class MixinContainerModularRouter { + @Shadow + @Final + private ModularRouterBlockEntity router; + + @Redirect(method = "stillValid", at = @At(target = "Lnet/minecraft/world/phys/Vec3;distanceToSqr(Lnet/minecraft/world/phys/Vec3;)D", value = "INVOKE")) + public double ValkyrienSkies$distanceCheck(final Vec3 instance, final Vec3 vec3) { + final Level level = router.getLevel(); + final Ship ship = VSGameUtilsKt.getShipManagingPos(level, instance); + if (ship == null) + return instance.distanceToSqr(vec3); + + final Vector3d newInstance = ship.getTransform().getShipToWorld().transformPosition(VectorConversionsMCKt.toJOML(instance)); + return VectorConversionsMCKt.toMinecraft(newInstance).distanceToSqr(vec3); + } +} diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 448f11e1c..3379b2775 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -14,6 +14,7 @@ "compat.immersivengineering.MixinBlockEntityInventory", "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", + "compat.modular_routers.MixinContainerModularRouter", "feature.forge_interact.MixinIForgePlayer", "world.level.block.FireMixin" ], From efbac0cc084f8c8267f8327a54581bc76728e2e2 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 19 Nov 2023 07:44:05 -0700 Subject: [PATCH 325/437] Fixed entities not sitting in seats on ships --- .../mod_compat/create/pr/MixinSeatBlock.java | 68 +++++++++++++++++-- 1 file changed, 64 insertions(+), 4 deletions(-) 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 d80d0baad..73563a7c8 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 @@ -4,27 +4,87 @@ import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.TamableAnimal; +import net.minecraft.world.entity.player.Player; +import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; +import net.minecraft.world.level.block.Block; +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.Overwrite; +import org.spongepowered.asm.mixin.Shadow; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider; @Mixin(SeatBlock.class) -public class MixinSeatBlock { +public abstract class MixinSeatBlock extends Block { + public MixinSeatBlock(final Properties properties) { + super(properties); + } /** * @author ewoudje * @reason Floating point additions help */ @Overwrite(remap = false) - public static void sitDown(Level world, BlockPos pos, Entity entity) { + public static void sitDown(final Level world, final BlockPos pos, final Entity entity) { if (world.isClientSide) return; - SeatEntity seat = new SeatEntity(world, pos); + final SeatEntity seat = new SeatEntity(world, pos); seat.setPos(pos.getX() + .5, pos.getY(), pos.getZ() + .5); world.addFreshEntity(seat); entity.startRiding(seat, true); - if (entity instanceof TamableAnimal ta) + if (entity instanceof final TamableAnimal ta) ta.setInSittingPose(true); } + + @Shadow + public static boolean canBePickedUp(final Entity passenger) { + throw new IllegalStateException(); + } + + @Shadow + public static boolean isSeatOccupied(final Level world, final BlockPos pos) { + throw new IllegalStateException(); + } + + /** + * @author Triode + * @reason Fix entities not sitting in seats on ships + */ + @Overwrite + public void updateEntityAfterFallOn(final @NotNull BlockGetter reader, final Entity entity) { + BlockPos pos = entity.blockPosition(); + final Long shipStandingOnId = ((IEntityDraggingInformationProvider) entity).getDraggingInformation().getLastShipStoodOn(); + if (shipStandingOnId != null) { + final Ship ship = VSGameUtilsKt.getShipObjectWorld(entity.level).getLoadedShips().getById(shipStandingOnId); + if (ship != null) { + final Vector3dc posInShip = ship.getTransform().getWorldToShip().transformPosition(entity.getX(), entity.getY(), entity.getZ(), new Vector3d()); + pos = new BlockPos(posInShip.x(), posInShip.y(), posInShip.z()); + } + } + if (entity instanceof Player || !(entity instanceof LivingEntity) || !canBePickedUp(entity) || isSeatOccupied(entity.level, pos)) { + if (entity.isSuppressingBounce()) { + super.updateEntityAfterFallOn(reader, entity); + return; + } + + final Vec3 vec3 = entity.getDeltaMovement(); + if (vec3.y < 0.0D) { + final double d0 = entity instanceof LivingEntity ? 1.0D : 0.8D; + entity.setDeltaMovement(vec3.x, -vec3.y * (double) 0.66F * d0, vec3.z); + } + + return; + } + if (reader.getBlockState(pos).getBlock() != this) { + return; + } + sitDown(entity.level, pos, entity); + } } From 62d1c0e974fdf54f8eeacee87c60ab370bc4daab Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 19 Nov 2023 21:32:57 -0700 Subject: [PATCH 326/437] Fixed dismounting destroyed seats teleporting entities into the sky --- .../MixinLivingEntity.java | 54 +++++++++++++ .../create/entity/MixinSeatEntity.java | 33 ++++++-- .../mod_compat/create/pr/MixinSeatBlock.java | 76 ++++++++----------- .../valkyrienskies-common.mixins.json | 1 + 4 files changed, 112 insertions(+), 52 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/feature/dismount_dead_entities/MixinLivingEntity.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 new file mode 100644 index 000000000..015a452d1 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/dismount_dead_entities/MixinLivingEntity.java @@ -0,0 +1,54 @@ +package org.valkyrienskies.mod.mixin.feature.dismount_dead_entities; + +import net.minecraft.tags.BlockTags; +import net.minecraft.world.entity.Entity; +import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; +import net.minecraft.world.level.Level; +import net.minecraft.world.phys.Vec3; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +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.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(LivingEntity.class) +public abstract class MixinLivingEntity extends Entity { + @Unique + private static final Logger VS$LOGGER = LogManager.getLogger(); + + public MixinLivingEntity(final EntityType<?> entityType, final Level level) { + super(entityType, level); + } + + /** + * Fix dismounting dead chairs on ships teleporting entities into the sky + */ + @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 (ship != null) { + final Vector3dc transformedPos = ship.getTransform().getShipToWorld().transformPosition(VectorConversionsMCKt.toJOML(entity.position())); + final double d = Math.max(this.getY(), transformedPos.y()); + final Vec3 vec3 = new Vec3(this.getX(), d, this.getZ()); + this.dismountTo(vec3.x, vec3.y, vec3.z); + ci.cancel(); + } + } else { + // We're in the shipyard but no ship? + VS$LOGGER.debug("Modifying strange dismount"); + final Vec3 vec3 = new Vec3(this.getX(), this.getY(), this.getZ()); + this.dismountTo(vec3.x, vec3.y, vec3.z); + ci.cancel(); + } + } + } +} 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..a6ea56ed9 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 @@ -3,11 +3,13 @@ import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.EntityType; +import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; import org.joml.Vector3d; import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.Shadow; import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; @@ -17,28 +19,45 @@ public abstract class MixinSeatEntity extends Entity { @Shadow - public static double getCustomEntitySeatOffset(Entity entity) { + public static double getCustomEntitySeatOffset(final Entity entity) { return 0; } - public MixinSeatEntity(EntityType<?> entityType, Level level) { + public MixinSeatEntity(final EntityType<?> entityType, final Level level) { super(entityType, level); } - @Override - public void positionRider(@NotNull Entity passenger) { + /** + * @author Triode + * @reason Fix rider position + */ + @Overwrite + public void positionRider(@NotNull final Entity passenger, final Entity.MoveFunction moveFunction) { if (!this.hasPassenger(passenger)) return; - double d0 = this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(); + final 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); + final 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); + final Vector3d tempVec = VectorConversionsMCKt.toJOML(riderPos); ship.getShipToWorld().transformPosition(tempVec, tempVec); riderPos = VectorConversionsMCKt.toMinecraft(tempVec); } passenger.setPos(riderPos); } + + /** + * @author Triode + * @reason Fix dismount position when ship or seat is destroyed + */ + @Overwrite + public @NotNull Vec3 getDismountLocationForPassenger(final @NotNull LivingEntity livingEntity) { + if (VSGameUtilsKt.isBlockInShipyard(level, position()) && VSGameUtilsKt.getShipManagingPos(level, position()) == null) { + // Don't teleport to the ship if we can't find the ship + return livingEntity.position(); + } + return super.getDismountLocationForPassenger(livingEntity).add(0, 0.5f, 0); + } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/pr/MixinSeatBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/pr/MixinSeatBlock.java index 73563a7c8..fbc276a73 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 @@ -1,24 +1,22 @@ package org.valkyrienskies.mod.mixin.mod_compat.create.pr; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.simibubi.create.content.contraptions.actors.seat.SeatBlock; import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.TamableAnimal; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.BlockGetter; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; -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.Overwrite; -import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.EntityDraggingInformation; import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider; @Mixin(SeatBlock.class) @@ -33,58 +31,46 @@ public MixinSeatBlock(final Properties properties) { */ @Overwrite(remap = false) public static void sitDown(final Level world, final BlockPos pos, final Entity entity) { - if (world.isClientSide) + if (world.isClientSide) { return; + } final SeatEntity seat = new SeatEntity(world, pos); seat.setPos(pos.getX() + .5, pos.getY(), pos.getZ() + .5); world.addFreshEntity(seat); entity.startRiding(seat, true); - if (entity instanceof final TamableAnimal ta) + if (entity instanceof final TamableAnimal ta) { ta.setInSittingPose(true); - } - - @Shadow - public static boolean canBePickedUp(final Entity passenger) { - throw new IllegalStateException(); - } - - @Shadow - public static boolean isSeatOccupied(final Level world, final BlockPos pos) { - throw new IllegalStateException(); + } } /** * @author Triode * @reason Fix entities not sitting in seats on ships */ - @Overwrite - public void updateEntityAfterFallOn(final @NotNull BlockGetter reader, final Entity entity) { - BlockPos pos = entity.blockPosition(); - final Long shipStandingOnId = ((IEntityDraggingInformationProvider) entity).getDraggingInformation().getLastShipStoodOn(); - if (shipStandingOnId != null) { - final Ship ship = VSGameUtilsKt.getShipObjectWorld(entity.level).getLoadedShips().getById(shipStandingOnId); - if (ship != null) { - final Vector3dc posInShip = ship.getTransform().getWorldToShip().transformPosition(entity.getX(), entity.getY(), entity.getZ(), new Vector3d()); - pos = new BlockPos(posInShip.x(), posInShip.y(), posInShip.z()); - } - } - if (entity instanceof Player || !(entity instanceof LivingEntity) || !canBePickedUp(entity) || isSeatOccupied(entity.level, pos)) { - if (entity.isSuppressingBounce()) { - super.updateEntityAfterFallOn(reader, entity); - return; - } - - final Vec3 vec3 = entity.getDeltaMovement(); - if (vec3.y < 0.0D) { - final double d0 = entity instanceof LivingEntity ? 1.0D : 0.8D; - entity.setDeltaMovement(vec3.x, -vec3.y * (double) 0.66F * d0, vec3.z); + @WrapOperation( + method = "updateEntityAfterFallOn", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/Entity;blockPosition()Lnet/minecraft/core/BlockPos;" + ), + remap = false + ) + private BlockPos wrapBlockPosInUpdateEntityAfterFallOn( + final Entity entity, + final Operation<BlockPos> getBlockPosition + ) { + final EntityDraggingInformation draggingInformation = ((IEntityDraggingInformationProvider) entity).getDraggingInformation(); + if (draggingInformation.isEntityBeingDraggedByAShip()) { + final Long shipStandingOnId = draggingInformation.getLastShipStoodOn(); + if (shipStandingOnId != null) { + final Ship ship = VSGameUtilsKt.getShipObjectWorld(entity.level).getLoadedShips().getById(shipStandingOnId); + if (ship != null) { + final Vector3dc posInShip = ship.getTransform().getWorldToShip() + .transformPosition(entity.getX(), entity.getY(), entity.getZ(), new Vector3d()); + return new BlockPos(posInShip.x(), posInShip.y(), posInShip.z()); + } } - - return; - } - if (reader.getBlockState(pos).getBlock() != this) { - return; } - sitDown(entity.level, pos, entity); + return getBlockPosition.call(entity); } } diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index b24ddc4e8..8091744c0 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -27,6 +27,7 @@ "feature.commands.MixinCommandSourceStack", "feature.conduit_fix.ConduitMixin", "feature.container_distance_check.MixinRandomizableContainerBlockEntity", + "feature.dismount_dead_entities.MixinLivingEntity", "feature.dispensers.MixinDefaultDispenseItemBehavior", "feature.distance_replace.MixinEntity", "feature.entity_collision.MixinEntity", From 57ff5e9c2adbf6e671c91ad9fe193084876256a8 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Mon, 20 Nov 2023 01:51:08 -0700 Subject: [PATCH 327/437] Fixed forge server not launching --- .../create/entity/MixinSeatEntity.java | 31 ------------------- 1 file changed, 31 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 a6ea56ed9..a299409d7 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 @@ -7,47 +7,16 @@ import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import org.jetbrains.annotations.NotNull; -import org.joml.Vector3d; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; -import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @Mixin(SeatEntity.class) public abstract class MixinSeatEntity extends Entity { - - @Shadow - public static double getCustomEntitySeatOffset(final Entity entity) { - return 0; - } - public MixinSeatEntity(final EntityType<?> entityType, final Level level) { super(entityType, level); } - /** - * @author Triode - * @reason Fix rider position - */ - @Overwrite - public void positionRider(@NotNull final Entity passenger, final Entity.MoveFunction moveFunction) { - if (!this.hasPassenger(passenger)) - return; - - final double d0 = this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(); - Vec3 riderPos = new Vec3(this.getX(), d0 + getCustomEntitySeatOffset(passenger), this.getZ()); - - final 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) { - final Vector3d tempVec = VectorConversionsMCKt.toJOML(riderPos); - ship.getShipToWorld().transformPosition(tempVec, tempVec); - riderPos = VectorConversionsMCKt.toMinecraft(tempVec); - } - passenger.setPos(riderPos); - } - /** * @author Triode * @reason Fix dismount position when ship or seat is destroyed From 183167fcf30a6e5a644f45fa55424d05f09afd74 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Mon, 20 Nov 2023 03:41:43 -0700 Subject: [PATCH 328/437] Replaced an @Overwrite with @WrapOperation --- .../mod_compat/create/pr/MixinSeatBlock.java | 20 ++++--------------- 1 file changed, 4 insertions(+), 16 deletions(-) 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 fbc276a73..5da93a395 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 @@ -6,13 +6,11 @@ import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; import net.minecraft.core.BlockPos; import net.minecraft.world.entity.Entity; -import net.minecraft.world.entity.TamableAnimal; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import org.joml.Vector3d; import org.joml.Vector3dc; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; import org.spongepowered.asm.mixin.injection.At; import org.valkyrienskies.core.api.ships.Ship; import org.valkyrienskies.mod.common.VSGameUtilsKt; @@ -26,21 +24,11 @@ public MixinSeatBlock(final Properties properties) { } /** - * @author ewoudje - * @reason Floating point additions help + * Use doubles instead of floats when invoking setPos() */ - @Overwrite(remap = false) - public static void sitDown(final Level world, final BlockPos pos, final Entity entity) { - if (world.isClientSide) { - return; - } - final SeatEntity seat = new SeatEntity(world, pos); - seat.setPos(pos.getX() + .5, pos.getY(), pos.getZ() + .5); - world.addFreshEntity(seat); - entity.startRiding(seat, true); - if (entity instanceof final TamableAnimal ta) { - ta.setInSittingPose(true); - } + @WrapOperation(method = "sitDown", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/actors/seat/SeatEntity;setPos(DDD)V")) + private static void wrapSitDownSetPos(final SeatEntity seatEntity, final double origX, final double origY, final double origZ, final Operation<Void> setPosOperation, final Level world, final BlockPos pos, final Entity entity) { + setPosOperation.call(seatEntity, pos.getX() + .5, (double) pos.getY(), pos.getZ() + .5); } /** From 90e23ed86f11283185d8cc3f89c1822e5a926159 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Mon, 20 Nov 2023 23:58:21 -0700 Subject: [PATCH 329/437] Don't drag entities that are mounted to an entity --- .../client/renderer/MixinGameRenderer.java | 60 +++++++++---------- .../mod/common/util/EntityDragger.kt | 3 +- .../common/util/EntityDraggingInformation.kt | 3 +- 3 files changed, 33 insertions(+), 33 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..8bfef4dfd 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 @@ -144,41 +144,39 @@ private void preRender(final float tickDelta, final long startTime, final boolea continue; } - if (entityShouldBeHere == null) { - final EntityDraggingInformation entityDraggingInformation = - ((IEntityDraggingInformationProvider) entity).getDraggingInformation(); - final Long lastShipStoodOn = entityDraggingInformation.getLastShipStoodOn(); - // Then try getting [entityShouldBeHere] from [entityDraggingInformation] - if (lastShipStoodOn != null && entityDraggingInformation.isEntityBeingDraggedByAShip()) { - final ClientShip shipObject = - VSGameUtilsKt.getShipObjectWorld(clientWorld).getLoadedShips().getById(lastShipStoodOn); - if (shipObject != null) { - entityDraggingInformation.setCachedLastPosition( - new Vector3d(entity.xo, entity.yo, entity.zo)); - entityDraggingInformation.setRestoreCachedLastPosition(true); + final EntityDraggingInformation entityDraggingInformation = + ((IEntityDraggingInformationProvider) entity).getDraggingInformation(); + final Long lastShipStoodOn = entityDraggingInformation.getLastShipStoodOn(); + // Then try getting [entityShouldBeHere] from [entityDraggingInformation] + if (lastShipStoodOn != null && entityDraggingInformation.isEntityBeingDraggedByAShip()) { + final ClientShip shipObject = + VSGameUtilsKt.getShipObjectWorld(clientWorld).getLoadedShips().getById(lastShipStoodOn); + if (shipObject != null) { + entityDraggingInformation.setCachedLastPosition( + new Vector3d(entity.xo, entity.yo, entity.zo)); + entityDraggingInformation.setRestoreCachedLastPosition(true); - // The velocity added to the entity by ship dragging - final Vector3dc entityAddedVelocity = entityDraggingInformation.getAddedMovementLastTick(); + // The velocity added to the entity by ship dragging + final Vector3dc entityAddedVelocity = entityDraggingInformation.getAddedMovementLastTick(); - // The velocity of the entity before we added ship dragging - final double entityMovementX = entity.getX() - entityAddedVelocity.x() - entity.xo; - final double entityMovementY = entity.getY() - entityAddedVelocity.y() - entity.yo; - final double entityMovementZ = entity.getZ() - entityAddedVelocity.z() - entity.zo; + // The velocity of the entity before we added ship dragging + final double entityMovementX = entity.getX() - entityAddedVelocity.x() - entity.xo; + final double entityMovementY = entity.getY() - entityAddedVelocity.y() - entity.yo; + final double entityMovementZ = entity.getZ() - entityAddedVelocity.z() - entity.zo; - // Without ship dragging, the entity would've been here - final Vector3dc entityShouldBeHerePreTransform = new Vector3d( - entity.xo + entityMovementX * tickDelta, - entity.yo + entityMovementY * tickDelta, - entity.zo + entityMovementZ * tickDelta - ); + // Without ship dragging, the entity would've been here + final Vector3dc entityShouldBeHerePreTransform = new Vector3d( + entity.xo + entityMovementX * tickDelta, + entity.yo + entityMovementY * tickDelta, + entity.zo + entityMovementZ * tickDelta + ); - // Move [entityShouldBeHerePreTransform] with the ship, using the prev transform and the - // current render transform - entityShouldBeHere = shipObject.getRenderTransform().getShipToWorldMatrix() - .transformPosition( - shipObject.getPrevTickShipTransform().getWorldToShipMatrix() - .transformPosition(entityShouldBeHerePreTransform, new Vector3d())); - } + // Move [entityShouldBeHerePreTransform] with the ship, using the prev transform and the + // current render transform + entityShouldBeHere = shipObject.getRenderTransform().getShipToWorldMatrix() + .transformPosition( + shipObject.getPrevTickShipTransform().getWorldToShipMatrix() + .transformPosition(entityShouldBeHerePreTransform, new Vector3d())); } } 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..425ef4c48 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 @@ -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.allShips.getById(shipDraggingEntity) if (shipData != null) { dragTheEntity = true @@ -114,6 +114,7 @@ object EntityDragger { } } entityDraggingInformation.ticksSinceStoodOnShip++ + entityDraggingInformation.mountedToEntity = entity.vehicle != null } } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt index e0b140942..690263a87 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt @@ -16,13 +16,14 @@ class EntityDraggingInformation { field = value } var ticksSinceStoodOnShip: Int = 0 + var mountedToEntity: Boolean = false // Used by the client rendering code only var cachedLastPosition: Vector3dc? = null var restoreCachedLastPosition = false fun isEntityBeingDraggedByAShip(): Boolean { - return (lastShipStoodOn != null) && (ticksSinceStoodOnShip < 10) + return (lastShipStoodOn != null) && (ticksSinceStoodOnShip < 10) && !mountedToEntity } } From aa02ad9de4fe6d8919943229d85fbe23d322e286 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Tue, 21 Nov 2023 04:58:15 -0700 Subject: [PATCH 330/437] Fixed Sodium rendering deleted ships --- .../sodium/MixinSodiumWorldRenderer.java | 25 +++++++++++++++++++ 1 file changed, 25 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 fd894a38a..1ed8a2766 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 @@ -6,7 +6,9 @@ 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 net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.client.renderer.MultiBufferSource; import net.minecraft.client.renderer.RenderBuffers; @@ -17,9 +19,11 @@ 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.VSGameUtilsKt; @@ -30,6 +34,27 @@ public class MixinSodiumWorldRenderer { @Shadow private ClientLevel world; + @Shadow + private RenderSectionManager renderSectionManager; + + @Unique + private boolean vs$prevFrameHadShips = false; + + /** + * @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; + } + @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, From a9b1a7c3dbca3c2255f1a330bc24d6ab8e2a121b Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Tue, 21 Nov 2023 05:32:56 -0700 Subject: [PATCH 331/437] Added necessary remap --- .../mod/mixin/mod_compat/create/pr/MixinSeatBlock.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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..19d90ac43 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 @@ -40,8 +40,7 @@ private static void wrapSitDownSetPos(final SeatEntity seatEntity, final double at = @At( value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;blockPosition()Lnet/minecraft/core/BlockPos;" - ), - remap = false + ) ) private BlockPos wrapBlockPosInUpdateEntityAfterFallOn( final Entity entity, From 30f689dcc1c21e99e199d81bc284f26578d01da9 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Tue, 21 Nov 2023 05:50:41 -0700 Subject: [PATCH 332/437] Updated vs-core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 729994223..9dabb0c0e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+f2a6aaad81 +vs_core_version=1.1.0+c957c12bf9 # 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 b25fa9806dc286c45048251994b14a8d3e8a3ac5 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Fri, 24 Nov 2023 23:08:44 -0700 Subject: [PATCH 333/437] Updated the thing --- .../mixin/feature/sound/client/MixinSoundEngine.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSoundEngine.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSoundEngine.java index 47fad3930..7c5923fe4 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSoundEngine.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSoundEngine.java @@ -19,6 +19,8 @@ import org.valkyrienskies.core.api.ships.ClientShip; import org.valkyrienskies.mod.client.audio.VelocityTickableSoundInstance; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.EntityDraggingInformation; +import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider; import org.valkyrienskies.mod.mixinducks.com.mojang.blaze3d.audio.HasOpenALVelocity; @Mixin(SoundEngine.class) @@ -31,6 +33,7 @@ public abstract class MixinSoundEngine { protected abstract float calculatePitch(SoundInstance sound); // Applies the velocity provided by a VelocityTickableSoundInstance + @SuppressWarnings("unused") @WrapOperation( at = @At( value = "INVOKE", @@ -39,7 +42,7 @@ public abstract class MixinSoundEngine { ), method = "tickNonPaused" ) - private Object redirectGet(final Map instance, final Object obj, final Operation<Object> get) { + private Object redirectGet(final Map<?, ?> instance, final Object obj, final Operation<Object> get) { if (obj instanceof final VelocityTickableSoundInstance soundInstance) { final ChannelAccess.ChannelHandle handle = (ChannelAccess.ChannelHandle) instance.get(soundInstance); final float f = calculateVolume(soundInstance); @@ -59,6 +62,7 @@ private Object redirectGet(final Map instance, final Object obj, final Operation return get.call(instance, obj); } + @SuppressWarnings("unused") @WrapOperation( at = @At( value = "INVOKE", @@ -76,6 +80,12 @@ private void injectListenerVelocity(final Listener listener, final Vec3 position final ClientShip mounted = VSGameUtilsKt.getShipObjectEntityMountedTo(level, player); if (mounted != null) { ((HasOpenALVelocity) listener).setVelocity(mounted.getVelocity()); + } else { + final EntityDraggingInformation dragInfo = ((IEntityDraggingInformationProvider) player).getDraggingInformation(); + if (dragInfo.isEntityBeingDraggedByAShip()) { + final Vector3dc playerVel = dragInfo.getAddedMovementLastTick(); + ((HasOpenALVelocity) listener).setVelocity(playerVel); + } } } From e1d14c6343fe7a5e5041d8a8ab36be896aebac41 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 26 Nov 2023 00:46:56 -0700 Subject: [PATCH 334/437] Fixed stabilized contraptions acting weird on ships --- .../client/renderer/MixinGameRenderer.java | 20 ++++-- .../mod/mixin/entity/MixinEntity.java | 5 ++ .../MixinOrientedContraptionEntity.java | 66 ------------------- .../MixinAbstractContraptionEntity.java | 8 ++- .../common/util/EntityDraggingInformation.kt | 2 + .../valkyrienskies-common.mixins.json | 1 - 6 files changed, 29 insertions(+), 73 deletions(-) delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOrientedContraptionEntity.java 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 8bfef4dfd..22578544f 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 @@ -25,6 +25,7 @@ import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.valkyrienskies.core.api.ships.ClientShip; import org.valkyrienskies.core.apigame.world.ClientShipWorldCore; @@ -92,17 +93,23 @@ public HitResult modifyCrosshairTargetBlocks(final Entity receiver, final double return pick.call(receiver, maxDistance, tickDelta, includeFluids); } - @WrapOperation( + @Redirect( 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, final Operation<Vec3> distanceToSqr) { - return VSGameUtilsKt.squaredDistanceBetweenInclShips(this.minecraft.level, - vec.x, vec.y, vec.z, - instance.x, instance.y, instance.z); + public double correctDistanceChecks(final Vec3 instance, final Vec3 vec) { + return VSGameUtilsKt.squaredDistanceBetweenInclShips( + this.minecraft.level, + vec.x, + vec.y, + vec.z, + instance.x, + instance.y, + instance.z + ); } @Inject(method = "render", at = @At("HEAD")) @@ -120,6 +127,9 @@ private void preRender(final float tickDelta, final long startTime, final boolea // Also update entity last tick positions, so that they interpolate correctly for (final Entity entity : clientWorld.entitiesForRendering()) { + if (!((IEntityDraggingInformationProvider) entity).vs$shouldDrag()) { + continue; + } // The position we want to render [entity] at for this frame // This is set when an entity is mounted to a ship, or an entity is being dragged by a ship Vector3dc entityShouldBeHere = null; 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..6a30ff909 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 @@ -199,4 +199,9 @@ private void preCalculateViewVector(final float xRot, final float yRot, final Ca public EntityDraggingInformation getDraggingInformation() { return draggingInformation; } + + @Override + public boolean vs$shouldDrag() { + return true; + } } 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 deleted file mode 100644 index 8dae3ebf8..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinOrientedContraptionEntity.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.client; - -import com.jozufozu.flywheel.util.transform.TransformStack; -import com.mojang.blaze3d.vertex.PoseStack; -import com.simibubi.create.content.contraptions.AbstractContraptionEntity; -import com.simibubi.create.content.contraptions.OrientedContraptionEntity; -import net.minecraft.client.Minecraft; -import net.minecraft.world.entity.Entity; -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.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.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; - -@Mixin(OrientedContraptionEntity.class) -public class MixinOrientedContraptionEntity { - - @Shadow - private Vec3 getCartOffset(float partialTicks, Entity ridingEntity) { - return Vec3.ZERO; - } - - @Redirect(method = "applyLocalTransforms", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/OrientedContraptionEntity;repositionOnCart(Lcom/mojang/blaze3d/vertex/PoseStack;FLnet/minecraft/world/entity/Entity;)V")) - private void redirectRepositionOnCart(OrientedContraptionEntity instance, PoseStack matrixStack, float partialTicks, Entity ridingEntity) { - - Vec3 cartPos = getCartOffset(partialTicks, ridingEntity); - if (cartPos != Vec3.ZERO) matrixStack.translate(cartPos.x, cartPos.y, cartPos.z); - - ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), ridingEntity.blockPosition()); - if (ship != null) { - Quaterniond quaternion = new Quaterniond(); - ship.getRenderTransform().getShipToWorld().getNormalizedRotation(quaternion); - TransformStack.cast(matrixStack).rotateCentered(VectorConversionsMCKt.toMinecraft(quaternion)); - } - } - - @Redirect(method = "repositionOnContraption", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/vertex/PoseStack;translate(DDD)V", ordinal = 0)) - private void redirectTranslate(final PoseStack instance, final double pose, final double d, final double e) { - instance.translate(pose, d, e); - - ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(Minecraft.getInstance().level, ((AbstractContraptionEntity) (Object) this).getVehicle().blockPosition()); - if (ship != null) { - Quaterniond quaternion = new Quaterniond(); - ship.getRenderTransform().getShipToWorld().getNormalizedRotation(quaternion); - TransformStack.cast(instance).rotateCentered(VectorConversionsMCKt.toMinecraft(quaternion)); - } - } - - @Redirect(method = "getContraptionOffset", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/AbstractContraptionEntity;getPassengerPosition(Lnet/minecraft/world/entity/Entity;F)Lnet/minecraft/world/phys/Vec3;")) - private Vec3 redirectGetPassengerPosition(AbstractContraptionEntity instance, Entity passenger, float partialTicks) { - Vec3 result = instance.getPassengerPosition(passenger, partialTicks); - - ClientShip ship = (ClientShip) VSGameUtilsKt.getShipManagingPos(instance.getCommandSenderWorld(), instance.position()); - if (ship != null) { - Vector3d dest = new Vector3d(); - ship.getRenderTransform().getShipToWorld().transformPosition(VectorConversionsMCKt.toJOML(result), dest); - result = VectorConversionsMCKt.toMinecraft(dest); - } - return result; - } -} 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..f8511fd70 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 @@ -48,13 +48,14 @@ import org.valkyrienskies.core.api.ships.WingManager; import org.valkyrienskies.mod.common.CompatUtil; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; import org.valkyrienskies.mod.compat.CreateConversionsKt; import org.valkyrienskies.mod.mixinducks.mod_compat.create.MixinAbstractContraptionEntityDuck; @Mixin(AbstractContraptionEntity.class) public abstract class MixinAbstractContraptionEntity extends Entity implements MixinAbstractContraptionEntityDuck, - ContraptionWingProvider { + ContraptionWingProvider, IEntityDraggingInformationProvider { public MixinAbstractContraptionEntity(EntityType<?> entityType, Level level) { super(entityType, level); @@ -316,4 +317,9 @@ public Matrix4dc computeContraptionWingTransform() { final Vector3d pos = VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.getAnchorVec()); return new Matrix4d(rotationMatrix).setTranslation(pos); } + + @Override + public boolean vs$shouldDrag() { + return false; + } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt index 690263a87..7b48e76bd 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt @@ -29,4 +29,6 @@ class EntityDraggingInformation { interface IEntityDraggingInformationProvider { val draggingInformation: EntityDraggingInformation + + fun `vs$shouldDrag`(): Boolean } diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 8091744c0..6b270cb06 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -156,7 +156,6 @@ "mod_compat.create.client.MixinLinkRenderer", "mod_compat.create.client.MixinMinecartInstance", "mod_compat.create.client.MixinMultiplePlacementHelpers", - "mod_compat.create.client.MixinOrientedContraptionEntity", "mod_compat.create.client.MixinOutline", "mod_compat.create.client.MixinPlacementHelpers", "mod_compat.create.client.MixinSoundScapes", From e59ff2aa46df6a9c598fae707ddb086d956e2512 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 26 Nov 2023 21:16:31 -0700 Subject: [PATCH 335/437] Fixed order of rotations in VS teleport command --- .../valkyrienskies/mod/common/command/RelativeVector3.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3.kt index f54cdb6d5..b935c2c63 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/command/RelativeVector3.kt @@ -6,10 +6,10 @@ import java.lang.Math.toRadians data class RelativeVector3(val x: RelativeValue, val y: RelativeValue, val z: RelativeValue) { fun toEulerRotation(sourcePitchDegrees: Double, sourceYawDegrees: Double, sourceRollDegrees: Double): Quaterniond = - Quaterniond().rotateXYZ( - toRadians(x.getRelativeValue(sourcePitchDegrees)), - toRadians(y.getRelativeValue(sourceYawDegrees)), + Quaterniond().rotateZYX( toRadians(z.getRelativeValue(sourceRollDegrees)), + toRadians(y.getRelativeValue(sourceYawDegrees)), + toRadians(x.getRelativeValue(sourcePitchDegrees)), ) fun toEulerRotationFromMCEntity(mcEntityPitch: Double, mcEntityYaw: Double) = From 6248cbdfd3a48cc3d454326215835ca4ea41c1fb Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Wed, 29 Nov 2023 19:38:18 +0100 Subject: [PATCH 336/437] TFC mixin compat --- .../level/chunk/MixinChunkGenerator.java | 3 + .../compat/tfc/MixinTFCChunkGenerator.java | 102 ++++++++++++++++++ .../valkyrienskies-forge.mixins.json | 1 + 3 files changed, 106 insertions(+) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfc/MixinTFCChunkGenerator.java 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..e65b21ae2 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 @@ -24,6 +24,9 @@ @Mixin(ChunkGenerator.class) public class MixinChunkGenerator { + // TODO its pretty standard to extend this class, if they do super.whatever, these mixins will not work correctly + // tfc in forge part of the mod has a bandaid solution, if this is fixed please remove that + @Inject(method = "findNearestMapFeature", at = @At("HEAD"), cancellable = true) private void preFindNearestMapFeature(ServerLevel serverLevel, HolderSet<ConfiguredStructureFeature<?, ?>> holderSet, BlockPos blockPos, int i, boolean bl, final CallbackInfoReturnable<Pair<BlockPos, Holder<ConfiguredStructureFeature<?, ?>>>> cir) { if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(blockPos.getX() >> 4, blockPos.getZ() >> 4)) { 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 new file mode 100644 index 000000000..dd27c58ee --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/tfc/MixinTFCChunkGenerator.java @@ -0,0 +1,102 @@ +package org.valkyrienskies.mod.forge.mixin.compat.tfc; + +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Executor; +import net.minecraft.core.RegistryAccess; +import net.minecraft.server.level.WorldGenRegion; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.LevelHeightAccessor; +import net.minecraft.world.level.NoiseColumn; +import net.minecraft.world.level.StructureFeatureManager; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.biome.BiomeManager; +import net.minecraft.world.level.block.state.BlockState; +import net.minecraft.world.level.chunk.ChunkAccess; +import net.minecraft.world.level.levelgen.GenerationStep; +import net.minecraft.world.level.levelgen.blending.Blender; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.valkyrienskies.mod.common.VS2ChunkAllocator; + +@Pseudo +@Mixin(targets = "net.dries007.tfc.world.TFCChunkGenerator") +public class MixinTFCChunkGenerator { + + @Inject(method = "m_183372_", at = @At("HEAD"), cancellable = true) + private void preApplyBiomeDecoration( + final WorldGenLevel worldGenLevel, final ChunkAccess chunkAccess, + final StructureFeatureManager structureFeatureManager, final CallbackInfo callbackInfo + ) { + final ChunkPos chunkPos = chunkAccess.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + callbackInfo.cancel(); + } + } + + @Inject(method = "m_62199_", at = @At("HEAD"), cancellable = true) + private void preCreateStructures( + final RegistryAccess registryAccess, + final StructureFeatureManager structureFeatureManager, final ChunkAccess chunkAccess, + final StructureManager structureManager, final long l, final CallbackInfo callbackInfo + ) { + final ChunkPos chunkPos = chunkAccess.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + callbackInfo.cancel(); + } + } + + @Inject(method = "m_62177_", at = @At("HEAD"), cancellable = true) + private void preCreateReferences( + final WorldGenLevel worldGenLevel, final StructureFeatureManager structureFeatureManager, + final ChunkAccess chunkAccess, final CallbackInfo callbackInfo + ) { + final ChunkPos chunkPos = chunkAccess.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + callbackInfo.cancel(); + } + } + + @Inject(method = "m_141914_", at = @At("HEAD"), cancellable = true) + private void preGetBaseColumn(int i, int j, LevelHeightAccessor levelHeightAccessor, CallbackInfoReturnable<NoiseColumn> cir) { + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(i, j)) { + cir.setReturnValue(new NoiseColumn(0, new BlockState[0])); + } + } + + @Inject(method = "m_183621_", at = @At("HEAD"), cancellable = true) + private void preBuildSurface(WorldGenRegion worldGenRegion, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess, CallbackInfo ci) { + final ChunkPos chunkPos = chunkAccess.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + ci.cancel(); + } + } + + @Inject(method = "m_183516_", at = @At("HEAD"), cancellable = true) + private void preApplyCarvers(WorldGenRegion worldGenRegion, long l, BiomeManager biomeManager, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess, GenerationStep.Carving carving, CallbackInfo ci) { + final ChunkPos chunkPos = chunkAccess.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + ci.cancel(); + } + } + + @Inject(method = "m_183489_", at = @At("HEAD"), cancellable = true) + private void preFillFromNoise(Executor executor, Blender blender, StructureFeatureManager structureFeatureManager, ChunkAccess chunkAccess, CallbackInfoReturnable<CompletableFuture<ChunkAccess>> cir) { + final ChunkPos chunkPos = chunkAccess.getPos(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + cir.setReturnValue(CompletableFuture.completedFuture(chunkAccess)); + } + } + + @Inject(method = "m_6929_", at = @At("HEAD"), cancellable = true) + private void preSpawnOriginalMobs(WorldGenRegion worldGenRegion, CallbackInfo ci) { + final ChunkPos chunkPos = worldGenRegion.getCenter(); + if (VS2ChunkAllocator.INSTANCE.isChunkInShipyardCompanion(chunkPos.x, chunkPos.z)) { + ci.cancel(); + } + } +} diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 3379b2775..c678251a6 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -12,6 +12,7 @@ "compat.create.MixinBlocks", "compat.create.MixinControlledContraptionEntity", "compat.immersivengineering.MixinBlockEntityInventory", + "compat.tfc.MixinTFCChunkGenerator", "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", "compat.modular_routers.MixinContainerModularRouter", 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 337/437] 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<Void> 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 19a64eae2d504a5d90bc024d30a41b2f2492c74f Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sat, 2 Dec 2023 01:55:49 -0700 Subject: [PATCH 338/437] Updated vs-core --- forge/build.gradle | 4 ++-- gradle.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index d56e4a985..11e0a1807 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -107,11 +107,11 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+10c94b01e2") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+ac2c4627d7") { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+94304c13aa") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+ef379c4c1c") { transitive = false } diff --git a/gradle.properties b/gradle.properties index 9dabb0c0e..efcd30394 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+c957c12bf9 +vs_core_version=1.1.0+3ca0e01760 # 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 d20ba10b654d184316ec65b11fbff0cb4b8735bd Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sat, 2 Dec 2023 03:28:12 -0700 Subject: [PATCH 339/437] Updated vs-core (again :sob:) --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index efcd30394..a45897e04 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+3ca0e01760 +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 17f0d50ae6ff691ccae288cc1e5813d63f94bfe7 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 3 Dec 2023 01:10:43 -0700 Subject: [PATCH 340/437] Fixed compat with create 0.5.1.f --- .../mod_compat/create/MixinAirCurrent.java | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java index 52f9d86f8..f3583f559 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java @@ -94,7 +94,8 @@ private static void clipFlowLimit(Level level, BlockPos start, float max, Direct } } - @Redirect(method = "tickAffectedEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;intersects(Lnet/minecraft/world/phys/AABB;)Z")) + // Require 0 because this mixin doesn't work in create 0.5.1f + @Redirect(method = "tickAffectedEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;intersects(Lnet/minecraft/world/phys/AABB;)Z"), require = 0) private boolean redirectIntersects(AABB instance, AABB other) { Ship ship = getShip(); if (ship != null) { @@ -104,13 +105,15 @@ private boolean redirectIntersects(AABB instance, AABB other) { } else return instance.intersects(other); } + // Require 0 because this mixin doesn't work in create 0.5.1f @Inject( - method = "tickAffectedEntities", - at = @At( - value = "INVOKE", - target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;" - ), - locals = LocalCapture.CAPTURE_FAILHARD + method = "tickAffectedEntities", + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;" + ), + locals = LocalCapture.CAPTURE_FAILHARD, + require = 0 ) private void harvester(Level world, Direction facing, CallbackInfo ci, Iterator<Entity> iterator, Entity entity, Vec3 center, Vec3i flow, float sneakModifier, float speed, double entityDistance, float acceleration) { Ship ship = getShip(); @@ -122,8 +125,9 @@ private void harvester(Level world, Direction facing, CallbackInfo ci, Iterator< this.acceleration = acceleration; } + // Require 0 because this mixin doesn't work in create 0.5.1f @Redirect(method = "tickAffectedEntities", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V") + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;setDeltaMovement(Lnet/minecraft/world/phys/Vec3;)V"), require = 0 ) private void redirectSetDeltaMovement(Entity instance, Vec3 motion) { Ship ship = getShip(); @@ -138,7 +142,8 @@ private void redirectSetDeltaMovement(Entity instance, Vec3 motion) { } } - @Redirect(method = "tickAffectedEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/VecHelper;getCenterOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;"), allow = 1) + // Require 0 because this mixin doesn't work in create 0.5.1f + @Redirect(method = "tickAffectedEntities", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/VecHelper;getCenterOf(Lnet/minecraft/core/Vec3i;)Lnet/minecraft/world/phys/Vec3;"), allow = 1, require = 0) private Vec3 redirectGetCenterOf(Vec3i pos) { Ship ship = getShip(); Vec3 result = VecHelper.getCenterOf(pos); From 5d5cec54787e4b9a3388dbc7c04ec83ac8201d75 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 3 Dec 2023 05:45:52 -0700 Subject: [PATCH 341/437] Fixed compat with create 0.5.1.f (again) --- .../mod/mixin/mod_compat/create/MixinAirCurrent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java index f3583f559..70c1592e9 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/MixinAirCurrent.java @@ -112,7 +112,7 @@ private boolean redirectIntersects(AABB instance, AABB other) { value = "INVOKE", target = "Lnet/minecraft/world/entity/Entity;getDeltaMovement()Lnet/minecraft/world/phys/Vec3;" ), - locals = LocalCapture.CAPTURE_FAILHARD, + locals = LocalCapture.CAPTURE_FAILSOFT, require = 0 ) private void harvester(Level world, Direction facing, CallbackInfo ci, Iterator<Entity> iterator, Entity entity, Vec3 center, Vec3i flow, float sneakModifier, float speed, double entityDistance, float acceleration) { From 0dc9c2d69a1b8215e59fcefe9dc181110a091282 Mon Sep 17 00:00:00 2001 From: ThePlasticPotato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 3 Dec 2023 13:26:06 -0500 Subject: [PATCH 342/437] initial commit From ceac1732b2f1b2f75b7e3bef7c6e126c2e41a238 Mon Sep 17 00:00:00 2001 From: ThePlasticPotato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 3 Dec 2023 20:43:46 -0500 Subject: [PATCH 343/437] pain? --- .../mixin/server/world/MixinServerLevel.java | 20 +++ .../mod/common/assembly/SubShipAssembly.kt | 140 ++++++++++++++++++ .../mod/common/hooks/VSGameEvents.kt | 10 ++ 3 files changed, 170 insertions(+) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SubShipAssembly.kt 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..4f31bb66e 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 @@ -7,6 +7,7 @@ import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; import java.util.ArrayList; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -47,10 +48,13 @@ import org.valkyrienskies.core.api.ships.LoadedServerShip; import org.valkyrienskies.core.api.ships.Wing; import org.valkyrienskies.core.api.ships.WingManager; +import org.valkyrienskies.core.api.ships.datastructures.ShipConnDataAttachment; import org.valkyrienskies.core.apigame.world.ServerShipWorldCore; import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate; +import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet; import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.assembly.SubShipAssemblyKt; import org.valkyrienskies.mod.common.block.WingBlock; import org.valkyrienskies.mod.common.util.VSServerLevel; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @@ -243,6 +247,22 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf VSGameUtilsKt.getDimensionId(self), voxelShapeUpdates ); + + // Process pending ship breakages + for (final LoadedServerShip loadedShip : shipObjectWorld.getLoadedShips()) { + if (loadedShip.getAttachment(ShipConnDataAttachment.class) instanceof ShipConnDataAttachment) { + ShipConnDataAttachment connData = loadedShip.getAttachment(ShipConnDataAttachment.class); + assert connData != null; + HashSet<Object> shipBreakages = (HashSet<Object>) connData.getBreakages(); + for (Object breakage : shipBreakages) { + if (breakage instanceof DenseBlockPosSet breaking) { + SubShipAssemblyKt.splitShip(VectorConversionsMCKt.toBlockPos(breaking.stream().iterator().next()), breaking, self, loadedShip); + } + } + connData.getBreakages().clear(); + + } + } } @Override diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SubShipAssembly.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SubShipAssembly.kt new file mode 100644 index 000000000..ff859a5c1 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SubShipAssembly.kt @@ -0,0 +1,140 @@ +package org.valkyrienskies.mod.common.assembly + +import net.minecraft.core.BlockPos +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.level.ChunkPos +import org.joml.Vector3d +import org.joml.Vector3dc +import org.valkyrienskies.core.api.ships.ServerShip +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.core.util.x +import org.valkyrienskies.mod.common.dimensionId +import org.valkyrienskies.mod.common.executeIf +import org.valkyrienskies.mod.common.hooks.VSGameEvents +import org.valkyrienskies.mod.common.isTickingChunk +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.settings +import org.valkyrienskies.mod.common.util.toJOML +import org.valkyrienskies.mod.common.util.toJOMLD +import org.valkyrienskies.mod.util.relocateBlock +import org.valkyrienskies.mod.util.updateBlock + +fun splitShip(centerBlock: BlockPos, blocks: DenseBlockPosSet, level: ServerLevel, originalShip: ServerShip): 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<ChunkPos, Pair<ChunkPos, ChunkPos>>() + 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 shipChunkXUpdated = ship.chunkClaim.xMiddle + val shipChunkZUpdated = ship.chunkClaim.zMiddle + + val centerPosCentered = centerBlock.toJOMLD().add(0.5, 0.5, 0.5) + + val centerInShipUpdated: Vector3dc = Vector3d( + ((shipChunkXUpdated shl 4) + (centerBlock.x and 15).toDouble()), + centerBlock.y.toDouble(), + (shipChunkZUpdated shl 4) + (centerBlock.z and 15).toDouble() + ) + + val scaling = ship.transform.shipToWorldScaling + val offset: Vector3dc = + ship.inertiaData.centerOfMassInShip.sub(centerInShipUpdated, Vector3d()) + + val posInWorld = originalShip.transform.shipToWorld.transformPosition(centerPosCentered.add(offset, Vector3d()), Vector3d()) + val rotInWorld = originalShip.transform.shipToWorldRotation + val velVec = Vector3d(originalShip.velocity) + val omegaVec = Vector3d(originalShip.omega) + + val newShipTransform = ShipTransformImpl(posInWorld, ship.inertiaData.centerOfMassInShip, rotInWorld, scaling) + + ship.transform = newShipTransform + ship.physicsData.linearVelocity = velVec + ship.physicsData.angularVelocity = omegaVec + + val event = VSGameEvents.ShipSplitEvent(originalShip.id, ship.id, blocks) + VSGameEvents.shipSplit.emit(event) + + return ship +} 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..ae181f6dd 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.api.ships.properties.ShipId import org.valkyrienskies.core.impl.util.events.EventEmitterImpl +import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet object VSGameEvents { @@ -18,6 +20,8 @@ object VSGameEvents { val postRenderShip = EventEmitterImpl<ShipRenderEvent>() val shipsStartRendering = EventEmitterImpl<ShipStartRenderEvent>() + val shipSplit = EventEmitterImpl<ShipSplitEvent>() + data class ShipStartRenderEvent( val renderer: LevelRenderer, val renderType: RenderType, @@ -35,5 +39,11 @@ object VSGameEvents { val ship: ClientShip, val chunks: ObjectList<RenderChunkInfo> ) + + data class ShipSplitEvent( + val ship: ShipId, + val newShip: ShipId, + val blocks: DenseBlockPosSet + ) } From f25af18d0aebb8e28df69206a37525c8f82299fb Mon Sep 17 00:00:00 2001 From: ThePlasticPotato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Tue, 5 Dec 2023 13:48:37 -0500 Subject: [PATCH 344/437] Literally the only mixin needed --- .../mod/mixin/server/world/MixinServerLevel.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 4f31bb66e..024c651f4 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 @@ -51,7 +51,7 @@ import org.valkyrienskies.core.api.ships.datastructures.ShipConnDataAttachment; import org.valkyrienskies.core.apigame.world.ServerShipWorldCore; import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate; -import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet; +import org.valkyrienskies.core.util.datastructures.Breakage; import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.assembly.SubShipAssemblyKt; @@ -255,11 +255,12 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf assert connData != null; HashSet<Object> shipBreakages = (HashSet<Object>) connData.getBreakages(); for (Object breakage : shipBreakages) { - if (breakage instanceof DenseBlockPosSet breaking) { - SubShipAssemblyKt.splitShip(VectorConversionsMCKt.toBlockPos(breaking.stream().iterator().next()), breaking, self, loadedShip); + if (breakage instanceof Breakage breaking) { + SubShipAssemblyKt.splitShip(VectorConversionsMCKt.toBlockPos(breaking.component1()), breaking.component2(), self, loadedShip); + connData.getBreakages().remove(breakage); } } - connData.getBreakages().clear(); + } } From 847537425c655a0b615051f5da7d79a907dd6754 Mon Sep 17 00:00:00 2001 From: Weromano <84074856+Weromano@users.noreply.github.com> Date: Sat, 9 Dec 2023 12:05:21 +0100 Subject: [PATCH 345/437] Update masonry.json (#646) forgot to define masses for cut sandstone and cut red sandstone --- .../resources/data/valkyrienskies/vs_mass/masonry.json | 10 ++++++++++ 1 file changed, 10 insertions(+) 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 bd5e2a265..a2a151ed6 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/masonry.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/masonry.json @@ -4,6 +4,16 @@ "mass": 1300.0, "friction": 0.6 }, + { + "block": "minecraft:cut_red_sandstone", + "mass": 2300.0, + "friction": 0.6 + }, + { + "block": "minecraft:cut_sandstone", + "mass": 2300.0, + "friction": 0.6 + }, { "block": "minecraft:smooth_stone_slab", "mass": 1300.0, From 27bc0196bbe3c0ee54007e1315209c948866c219 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sat, 16 Dec 2023 09:34:16 -0700 Subject: [PATCH 346/437] Made ships drag jumping entities for 1 second instead of 0.5 seconds --- .../mod/common/util/EntityDraggingInformation.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt index 7b48e76bd..353310f39 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/EntityDraggingInformation.kt @@ -23,7 +23,12 @@ class EntityDraggingInformation { var restoreCachedLastPosition = false fun isEntityBeingDraggedByAShip(): Boolean { - return (lastShipStoodOn != null) && (ticksSinceStoodOnShip < 10) && !mountedToEntity + return (lastShipStoodOn != null) && (ticksSinceStoodOnShip < TICKS_TO_DRAG_ENTITIES) && !mountedToEntity + } + + companion object { + // Max number of ticks we will drag an entity after the entity has jumped off the ship + private const val TICKS_TO_DRAG_ENTITIES = 20 } } From 88d583220f32f1675a0baa3918702e2667ea7846 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 17 Dec 2023 22:18:41 -0700 Subject: [PATCH 347/437] Fixing the processUnloads() crash --- .../MixinPersistentEntitySectionManager.java | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) 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 index fbbaf3831..e330afdf9 100644 --- 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 @@ -1,17 +1,24 @@ 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 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 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.Redirect; import org.valkyrienskies.mod.mixinducks.world.OfLevel; @Mixin(PersistentEntitySectionManager.class) -public class MixinPersistentEntitySectionManager implements OfLevel { +public abstract class MixinPersistentEntitySectionManager implements OfLevel { @Shadow @Final EntitySectionStorage<Entity> sectionStorage; @@ -29,4 +36,40 @@ public void setLevel(final Level level) { this.level = level; ((OfLevel) this.sectionStorage).setLevel(level); } + + @Shadow + @Final + private LongSet chunksToUnload; + + @Shadow + @Final + private Long2ObjectMap<Visibility> 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 + */ + @Redirect( + method = "processUnloads", + at = @At( + value = "INVOKE", + target = "Lit/unimi/dsi/fastutil/longs/LongSet;removeIf(Ljava/util/function/LongPredicate;)Z" + ) + ) + private boolean replaceProcessUnloads(final LongSet instance, final LongPredicate longPredicate) { + 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); + return !toRemove.isEmpty(); + } } From 3cd460526546d1ae07533b3ad0ff3b2407c82214 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 17 Dec 2023 23:41:23 -0700 Subject: [PATCH 348/437] Fixing the processUnloads() crash (pt 2) --- .../MixinPersistentEntitySectionManager.java | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) 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 index e330afdf9..4d6aa8996 100644 --- 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 @@ -3,7 +3,6 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; -import java.util.function.LongPredicate; import net.minecraft.world.entity.Entity; import net.minecraft.world.level.Level; import net.minecraft.world.level.entity.EntitySectionStorage; @@ -14,7 +13,8 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.valkyrienskies.mod.mixinducks.world.OfLevel; @Mixin(PersistentEntitySectionManager.class) @@ -53,14 +53,10 @@ private boolean processChunkUnload(final long l) { /** * This fixes this function randomly crashing. I'm not sure why but the removeIf() function is buggy */ - @Redirect( - method = "processUnloads", - at = @At( - value = "INVOKE", - target = "Lit/unimi/dsi/fastutil/longs/LongSet;removeIf(Ljava/util/function/LongPredicate;)Z" - ) + @Inject( + method = "processUnloads", at = @At(value = "HEAD"), cancellable = true ) - private boolean replaceProcessUnloads(final LongSet instance, final LongPredicate longPredicate) { + private void replaceProcessUnloads(final CallbackInfo ci) { final LongSet toRemove = new LongOpenHashSet(); for (final long key : this.chunksToUnload) { if (this.chunkVisibility.get(key) != Visibility.HIDDEN) { @@ -70,6 +66,6 @@ private boolean replaceProcessUnloads(final LongSet instance, final LongPredicat } } chunksToUnload.removeAll(toRemove); - return !toRemove.isEmpty(); + ci.cancel(); } } From e1ec1529f625c2374a0d72479503c111316978eb Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Mon, 18 Dec 2023 05:08:21 -0700 Subject: [PATCH 349/437] Updated vs-core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index a45897e04..bfc4bec7b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+d0aa57abb9 +vs_core_version=1.1.0+ec4fe54cd6 # 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 4bc1b4a6753f8a974ddfa1292b8ac0675f032eba Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Mon, 18 Dec 2023 09:55:49 -0700 Subject: [PATCH 350/437] Added kinematic property to ships --- forge/build.gradle | 4 ++-- gradle.properties | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/forge/build.gradle b/forge/build.gradle index 11e0a1807..1f360349c 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -107,11 +107,11 @@ dependencies { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+ac2c4627d7") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api_krunch:1.0.0+7db6a103f1") { transitive = false } - forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+ef379c4c1c") { + forgeRuntimeLibrary shadowCommon("org.valkyrienskies:physics_api:1.0.0+0ba0cc41e1") { transitive = false } diff --git a/gradle.properties b/gradle.properties index bfc4bec7b..f03017752 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+ec4fe54cd6 +vs_core_version=1.1.0+c37d346883 # 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 23f71c6a3fbe9e29e1734962ec384eeb92eed9d0 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Thu, 21 Dec 2023 06:09:23 -0700 Subject: [PATCH 351/437] Fixed stickers being broken --- .../create/block/MixinStickerBlock.java | 33 +++++++++++++++---- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinStickerBlock.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinStickerBlock.java index b939eed99..ab6a7a908 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinStickerBlock.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/block/MixinStickerBlock.java @@ -18,23 +18,42 @@ @Mixin(StickerBlock.class) public abstract class MixinStickerBlock extends WrenchableDirectionalBlock implements IBE<StickerBlockEntity> { - public MixinStickerBlock(Properties properties) { + public MixinStickerBlock(final Properties properties) { super(properties); } @Override - public void onRemove(@NotNull BlockState state, @NotNull Level world, @NotNull BlockPos pos, @NotNull BlockState newState, boolean isMoving) { + public void onRemove( + @NotNull final BlockState state, + @NotNull final Level world, + @NotNull final BlockPos pos, + @NotNull final BlockState newState, + final boolean isMoving + ) { IBE.onRemove(state, world, pos, newState); } - @Inject(method = "neighborChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getValue(Lnet/minecraft/world/level/block/state/properties/Property;)Ljava/lang/Comparable;", ordinal = 0), cancellable = true) - private void injectNeighbourChanged(BlockState state, Level worldIn, BlockPos pos, Block blockIn, BlockPos fromPos, boolean isMoving, CallbackInfo ci) { - StickerBlockEntity ste = getBlockEntity(worldIn, pos); - if (ste != null && ((IMixinStickerTileEntity) ste).isAlreadyPowered(false)) { + @Inject( + method = "neighborChanged", + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/state/BlockState;getValue(Lnet/minecraft/world/level/block/state/properties/Property;)Ljava/lang/Comparable;", ordinal = 0), + cancellable = true + ) + private void injectNeighbourChanged( + final BlockState state, + final Level worldIn, + final BlockPos pos, + final Block blockIn, + final BlockPos fromPos, + final boolean isMoving, + final CallbackInfo ci + ) { + final StickerBlockEntity ste = getBlockEntity(worldIn, pos); + // By checking `instanceof IMixinStickerTileEntity` we only run this code if Clockwork is installed + if (ste instanceof final IMixinStickerTileEntity iMixinStickerTileEntity && iMixinStickerTileEntity.isAlreadyPowered(false)) { if (!worldIn.hasNeighborSignal(pos)) { ci.cancel(); } else { - ((IMixinStickerTileEntity) ste).isAlreadyPowered(true); + iMixinStickerTileEntity.isAlreadyPowered(true); } } } From 3396e16659e98ad723a883ff91daa5704c194d08 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Thu, 21 Dec 2023 19:43:53 -0700 Subject: [PATCH 352/437] Fix replaceProcessUnloads I think? --- .../MixinPersistentEntitySectionManager.java | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) 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 index 4d6aa8996..0f7068745 100644 --- 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 @@ -57,15 +57,20 @@ private boolean processChunkUnload(final long l) { method = "processUnloads", at = @At(value = "HEAD"), cancellable = true ) private void replaceProcessUnloads(final CallbackInfo ci) { - 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); + // 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(); } - chunksToUnload.removeAll(toRemove); ci.cancel(); } } From 89fa9804a3ed9b6c4b6a6298177423bf39f8b224 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Fri, 22 Dec 2023 04:32:40 -0700 Subject: [PATCH 353/437] Increment version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index f03017752..6f48be23d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.1-beta.3 +mod_version=2.1.1-beta.4 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.11 From 4a0b4b3cf60a05694a611b42b0534bb81db743f6 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sat, 23 Dec 2023 06:26:21 -0700 Subject: [PATCH 354/437] 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 <stewstronger@gmail.com> Date: Sat, 23 Dec 2023 08:05:06 -0700 Subject: [PATCH 355/437] 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 ca668561f53f1d6b75de7ca193f6db3e2ce6b776 Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Sun, 24 Dec 2023 09:41:10 -0800 Subject: [PATCH 356/437] Feature/refactor ship mounting (#660) * Initial work refactoring ship mounting * Make ShipMountedToData.shipMountedTo non-nullable * Renamed ship mounted to functions * Added ShipMountedToDataProvider * Only drag entities that aren't mounted to vehicles --- .../client/renderer/MixinGameRenderer.java | 30 ++++++++++--------- .../mod/mixin/entity/MixinEntity.java | 22 ++++---------- .../sound/client/MixinSoundEngine.java | 2 +- .../MixinLevelRendererVanilla.java | 2 +- .../valkyrienskies/mod/common/VSGameUtils.kt | 29 ++++++++++-------- .../mod/common/entity/ShipMountedToData.kt | 9 ++++++ .../entity/ShipMountedToDataProvider.kt | 7 +++++ .../mod/common/util/EntityDragger.kt | 15 ++++------ .../mod/common/util/MinecraftPlayer.kt | 16 +++------- .../forge/common/ValkyrienSkiesModForge.kt | 2 +- 10 files changed, 67 insertions(+), 67 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToData.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToDataProvider.kt 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 22578544f..8b9c6fe44 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 @@ -31,6 +31,7 @@ import org.valkyrienskies.core.apigame.world.ClientShipWorldCore; import org.valkyrienskies.mod.client.IVSCamera; import org.valkyrienskies.mod.common.IShipObjectWorldClientProvider; +import org.valkyrienskies.mod.common.entity.ShipMountedToData; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.EntityDraggingInformation; import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider; @@ -134,14 +135,13 @@ private void preRender(final float tickDelta, final long startTime, final boolea // This is set when an entity is mounted to a ship, or an entity is being dragged by a ship Vector3dc entityShouldBeHere = null; - // First, try getting [entityShouldBeHere] from [shipMountedTo] - final ClientShip shipMountedTo = - VSGameUtilsKt.getShipObjectEntityMountedTo(clientWorld, entity); + // First, try getting the ship the entity is mounted to, if one exists + final ShipMountedToData shipMountedToData = VSGameUtilsKt.getShipMountedToData(entity, tickDelta); - if (shipMountedTo != null) { + if (shipMountedToData != null) { + final ClientShip shipMountedTo = (ClientShip) shipMountedToData.getShipMountedTo(); // If the entity is mounted to a ship then update their position - final Vector3dc passengerPos = - VSGameUtilsKt.getPassengerPos(entity.getVehicle(), entity.getMyRidingOffset(), tickDelta); + final Vector3dc passengerPos = shipMountedToData.getMountPosInShip(); entityShouldBeHere = shipMountedTo.getRenderTransform().getShipToWorld() .transformPosition(passengerPos, new Vector3d()); entity.setPos(entityShouldBeHere.x(), entityShouldBeHere.y(), entityShouldBeHere.z()); @@ -248,12 +248,13 @@ private void setupCameraWithMountedShip(final LevelRenderer instance, final Pose prepareCullFrustum.call(instance, matrixStack, vec3, matrix4f); return; } - final ClientShip playerShipMountedTo = - VSGameUtilsKt.getShipObjectEntityMountedTo(clientLevel, player); - if (playerShipMountedTo == null) { + + final ShipMountedToData shipMountedToData = VSGameUtilsKt.getShipMountedToData(player, partialTicks); + if (shipMountedToData == null) { prepareCullFrustum.call(instance, matrixStack, vec3, matrix4f); return; } + final Entity playerVehicle = player.getVehicle(); if (playerVehicle == null) { prepareCullFrustum.call(instance, matrixStack, vec3, matrix4f); @@ -261,8 +262,6 @@ private void setupCameraWithMountedShip(final LevelRenderer instance, final Pose } // Update [matrixStack] to mount the camera to the ship - final Vector3dc inShipPos = - VSGameUtilsKt.getPassengerPos(playerVehicle, player.getMyRidingOffset(), partialTicks); final Camera camera = this.mainCamera; if (camera == null) { @@ -270,19 +269,22 @@ private void setupCameraWithMountedShip(final LevelRenderer instance, final Pose return; } + final ClientShip clientShip = (ClientShip) shipMountedToData.getShipMountedTo(); + ((IVSCamera) camera).setupWithShipMounted( this.minecraft.level, this.minecraft.getCameraEntity() == null ? this.minecraft.player : this.minecraft.getCameraEntity(), !this.minecraft.options.getCameraType().isFirstPerson(), this.minecraft.options.getCameraType().isMirrored(), partialTicks, - playerShipMountedTo, - inShipPos + clientShip, + shipMountedToData.getMountPosInShip() ); // Apply the ship render transform to [matrixStack] final Quaternion invShipRenderRotation = VectorConversionsMCKt.toMinecraft( - playerShipMountedTo.getRenderTransform().getShipToWorldRotation().conjugate(new Quaterniond())); + clientShip.getRenderTransform().getShipToWorldRotation().conjugate(new Quaterniond()) + ); matrixStack.mulPose(invShipRenderRotation); // We also need to recompute [inverseViewRotationMatrix] after updating [matrixStack] 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 6a30ff909..94b1c5eb3 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 @@ -16,7 +16,6 @@ import net.minecraft.world.phys.BlockHitResult; 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.joml.primitives.AABBd; @@ -33,6 +32,7 @@ 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; import org.valkyrienskies.mod.common.util.IEntityDraggingInformationProvider; @@ -105,11 +105,11 @@ private void originalCheckInside(final AABBd aABB) { */ @Inject(method = "getEyePosition(F)Lnet/minecraft/world/phys/Vec3;", at = @At("HEAD"), cancellable = true) private void preGetEyePosition(final float partialTicks, final CallbackInfoReturnable<Vec3> cir) { - final LoadedShip shipMountedTo = - VSGameUtilsKt.getShipObjectEntityMountedTo(level, Entity.class.cast(this)); - if (shipMountedTo == null) { + final ShipMountedToData shipMountedToData = VSGameUtilsKt.getShipMountedToData(Entity.class.cast(this), partialTicks); + if (shipMountedToData == null) { return; } + final LoadedShip shipMountedTo = shipMountedToData.getShipMountedTo(); final ShipTransform shipTransform; if (shipMountedTo instanceof ShipObjectClient) { @@ -118,8 +118,7 @@ private void preGetEyePosition(final float partialTicks, final CallbackInfoRetur shipTransform = shipMountedTo.getShipTransform(); } final Vector3dc basePos = shipTransform.getShipToWorldMatrix() - .transformPosition(VSGameUtilsKt.getPassengerPos(this.vehicle, getMyRidingOffset(), partialTicks), - new Vector3d()); + .transformPosition(shipMountedToData.getMountPosInShip(), new Vector3d()); final Vector3dc eyeRelativePos = shipTransform.getShipCoordinatesToWorldCoordinatesRotation().transform( new Vector3d(0.0, getEyeHeight(), 0.0) ); @@ -127,15 +126,12 @@ private void preGetEyePosition(final float partialTicks, final CallbackInfoRetur cir.setReturnValue(newEyePos); } - @Shadow - private Vec3 position; - /** * @reason Needed for players to pick blocks correctly when mounted to a ship */ @Inject(method = "calculateViewVector", at = @At("HEAD"), cancellable = true) private void preCalculateViewVector(final float xRot, final float yRot, final CallbackInfoReturnable<Vec3> cir) { - final LoadedShip shipMountedTo = VSGameUtilsKt.getShipObjectEntityMountedTo(level, Entity.class.cast(this)); + final LoadedShip shipMountedTo = VSGameUtilsKt.getShipMountedTo(Entity.class.cast(this)); if (shipMountedTo == null) { return; } @@ -180,9 +176,6 @@ private void preCalculateViewVector(final float xRot, final float yRot, final Ca @Shadow public abstract double getX(); - @Shadow - private @Nullable Entity vehicle; - @Shadow public abstract float getEyeHeight(); @@ -191,9 +184,6 @@ private void preCalculateViewVector(final float xRot, final float yRot, final Ca @Shadow public abstract EntityType<?> getType(); - @Shadow - public abstract double getMyRidingOffset(); - @Override @NotNull public EntityDraggingInformation getDraggingInformation() { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSoundEngine.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSoundEngine.java index 7c5923fe4..b0a30a022 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSoundEngine.java +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/sound/client/MixinSoundEngine.java @@ -77,7 +77,7 @@ private void injectListenerVelocity(final Listener listener, final Vec3 position ((HasOpenALVelocity) listener).setVelocity(new Vector3d()); if (level != null && player != null) { - final ClientShip mounted = VSGameUtilsKt.getShipObjectEntityMountedTo(level, player); + final ClientShip mounted = (ClientShip) VSGameUtilsKt.getShipMountedTo(player); if (mounted != null) { ((HasOpenALVelocity) listener).setVelocity(mounted.getVelocity()); } else { 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..abc72d5f5 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 @@ -96,7 +96,7 @@ private boolean needsFrustumUpdate(final boolean needsFrustumUpdate) { // force frustum update if default behaviour says to OR if the player is mounted to a ship return needsFrustumUpdate || - (player != null && VSGameUtilsKt.getShipObjectEntityMountedTo(level, player) != null); + (player != null && VSGameUtilsKt.getShipMountedTo(player) != null); } /** 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..f7b0e59ec 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -36,6 +36,8 @@ 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 +import org.valkyrienskies.mod.common.entity.ShipMountedToData +import org.valkyrienskies.mod.common.entity.ShipMountedToDataProvider import org.valkyrienskies.mod.common.util.DimensionIdProvider import org.valkyrienskies.mod.common.util.MinecraftPlayer import org.valkyrienskies.mod.common.util.set @@ -242,11 +244,6 @@ fun Level?.getShipObjectManagingPos(posX: Double, posY: Double, posZ: Double) = fun Level?.getShipObjectManagingPos(chunkPos: ChunkPos) = getShipObjectManagingPos(chunkPos.x, chunkPos.z) -fun Level.getShipObjectEntityMountedTo(entity: Entity): LoadedShip? { - val vehicle = entity.vehicle ?: return null - return getShipObjectManagingPos(vehicle.position().toJOML()) -} - // ClientLevel fun ClientLevel?.getShipObjectManagingPos(chunkX: Int, chunkZ: Int) = getShipObjectManagingPosImpl(this, chunkX, chunkZ) as ClientShip? @@ -266,11 +263,6 @@ fun ClientLevel?.getShipObjectManagingPos(pos: Position) = fun ClientLevel?.getShipObjectManagingPos(chunkPos: ChunkPos) = getShipObjectManagingPos(chunkPos.x, chunkPos.z) -fun ClientLevel?.getShipObjectEntityMountedTo(entity: Entity): ClientShip? { - val vehicle = entity.vehicle ?: return null - return getShipObjectManagingPos(vehicle.position().toJOML()) -} - // ServerWorld fun ServerLevel?.getShipObjectManagingPos(chunkX: Int, chunkZ: Int) = getShipObjectManagingPosImpl(this, chunkX, chunkZ) as ShipObjectServer? @@ -417,7 +409,18 @@ fun Level.transformAabbToWorld(aabb: AABBdc, dest: AABBd): AABBd { return dest.set(aabb) } -fun Entity.getPassengerPos(myRidingOffset: Double, partialTicks: Float): Vector3dc { - return this.getPosition(partialTicks) - .add(0.0, this.passengersRidingOffset + myRidingOffset, 0.0).toJOML() +fun getShipMountedToData(passenger: Entity, partialTicks: Float? = null): ShipMountedToData? { + val vehicle = passenger.vehicle ?: return null + if (vehicle is ShipMountedToDataProvider) { + return vehicle.provideShipMountedToData(passenger) + } + val shipObjectEntityMountedTo = passenger.level.getShipObjectManagingPos(vehicle.position().toJOML()) ?: return null + val mountedPosInShip: Vector3dc = vehicle.getPosition(partialTicks ?: 0.0f) + .add(0.0, vehicle.passengersRidingOffset + passenger.myRidingOffset, 0.0).toJOML() + + return ShipMountedToData(shipObjectEntityMountedTo, mountedPosInShip) +} + +fun getShipMountedTo(entity: Entity): LoadedShip? { + return getShipMountedToData(entity)?.shipMountedTo } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToData.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToData.kt new file mode 100644 index 000000000..1cdd1996c --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToData.kt @@ -0,0 +1,9 @@ +package org.valkyrienskies.mod.common.entity + +import org.joml.Vector3dc +import org.valkyrienskies.core.api.ships.LoadedShip + +data class ShipMountedToData( + val shipMountedTo: LoadedShip, + val mountPosInShip: Vector3dc, +) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToDataProvider.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToDataProvider.kt new file mode 100644 index 000000000..4ea6fbb41 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToDataProvider.kt @@ -0,0 +1,7 @@ +package org.valkyrienskies.mod.common.entity + +import net.minecraft.world.entity.Entity + +interface ShipMountedToDataProvider { + fun provideShipMountedToData(passenger: Entity): ShipMountedToData? +} 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 425ef4c48..2c6e4bf5f 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 @@ -4,7 +4,6 @@ import net.minecraft.server.level.ServerPlayer import net.minecraft.world.entity.Entity import org.joml.Vector3d import org.joml.Vector3dc -import org.valkyrienskies.mod.common.getShipObjectEntityMountedTo import org.valkyrienskies.mod.common.shipObjectWorld import kotlin.math.asin import kotlin.math.atan2 @@ -13,17 +12,13 @@ import kotlin.math.sin object EntityDragger { // How much we decay the addedMovement each tick after player hasn't collided with a ship for at least 10 ticks. - private const val addedMovementDecay = 0.9 + private const val ADDED_MOVEMENT_DECAY = 0.9 /** * Drag these entities with the ship they're standing on. */ fun dragEntitiesWithShips(entities: Iterable<Entity>) { entities.forEach { entity -> - val shipMountedTo = entity.level.getShipObjectEntityMountedTo(entity) - // Don't drag entities that are already mounted to a ship - if (shipMountedTo != null) return@forEach - val entityDraggingInformation = (entity as IEntityDraggingInformationProvider).draggingInformation var dragTheEntity = false @@ -31,7 +26,9 @@ object EntityDragger { var addedYRot = 0.0 val shipDraggingEntity = entityDraggingInformation.lastShipStoodOn - if (shipDraggingEntity != null) { + + // Only drag entities that aren't mounted to vehicles + if (shipDraggingEntity != null && entity.vehicle == null) { if (entityDraggingInformation.isEntityBeingDraggedByAShip()) { // Compute how much we should drag the entity val shipData = entity.level.shipObjectWorld.allShips.getById(shipDraggingEntity) @@ -87,8 +84,8 @@ object EntityDragger { } else { dragTheEntity = true addedMovement = entityDraggingInformation.addedMovementLastTick - .mul(addedMovementDecay, Vector3d()) - addedYRot = entityDraggingInformation.addedYawRotLastTick * addedMovementDecay + .mul(ADDED_MOVEMENT_DECAY, Vector3d()) + addedYRot = entityDraggingInformation.addedYawRotLastTick * ADDED_MOVEMENT_DECAY } } 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..603227d92 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 @@ -2,14 +2,11 @@ package org.valkyrienskies.mod.common.util import net.minecraft.world.entity.player.Player import org.joml.Vector3d -import org.joml.Vector3dc -import org.valkyrienskies.core.api.ships.properties.ShipId import org.valkyrienskies.core.apigame.world.IPlayer import org.valkyrienskies.core.apigame.world.PlayerState import org.valkyrienskies.core.apigame.world.properties.DimensionId import org.valkyrienskies.mod.common.dimensionId -import org.valkyrienskies.mod.common.getPassengerPos -import org.valkyrienskies.mod.common.getShipObjectEntityMountedTo +import org.valkyrienskies.mod.common.getShipMountedToData import org.valkyrienskies.mod.common.vsCore import java.lang.ref.WeakReference import java.util.UUID @@ -40,18 +37,13 @@ class MinecraftPlayer(playerObject: Player) : IPlayer { } override fun getPlayerState(): PlayerState { - var mountedShip: ShipId? = null - var mountedPos: Vector3dc? = null - player.level.getShipObjectEntityMountedTo(player)?.let { - mountedShip = it.id - mountedPos = player.vehicle!!.getPassengerPos(player.myRidingOffset, 0.0f) - } + val mountedShipAndPos = getShipMountedToData(player) return PlayerState( Vector3d(player.x, player.y, player.z), Vector3d(Vector3d(player.x - player.xo, player.y - player.yo, player.z - player.zo)), dimension, - mountedShip, - mountedPos, + mountedShipAndPos?.shipMountedTo?.id, + mountedShipAndPos?.mountPosInShip, ) } 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..9591baa35 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 @@ -76,7 +76,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) From cbbadd397b0d0fdf330d8b02b65756a5193bdd71 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 24 Dec 2023 11:50:10 -0700 Subject: [PATCH 357/437] Added partialTicks to ShipMountedToDataProvider.provideShipMountedToData() --- .../main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 2 +- .../mod/common/entity/ShipMountedToDataProvider.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 f7b0e59ec..9368ad3fd 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -412,7 +412,7 @@ fun Level.transformAabbToWorld(aabb: AABBdc, dest: AABBd): AABBd { fun getShipMountedToData(passenger: Entity, partialTicks: Float? = null): ShipMountedToData? { val vehicle = passenger.vehicle ?: return null if (vehicle is ShipMountedToDataProvider) { - return vehicle.provideShipMountedToData(passenger) + return vehicle.provideShipMountedToData(passenger, partialTicks) } val shipObjectEntityMountedTo = passenger.level.getShipObjectManagingPos(vehicle.position().toJOML()) ?: return null val mountedPosInShip: Vector3dc = vehicle.getPosition(partialTicks ?: 0.0f) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToDataProvider.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToDataProvider.kt index 4ea6fbb41..852499f0b 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToDataProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/entity/ShipMountedToDataProvider.kt @@ -3,5 +3,5 @@ package org.valkyrienskies.mod.common.entity import net.minecraft.world.entity.Entity interface ShipMountedToDataProvider { - fun provideShipMountedToData(passenger: Entity): ShipMountedToData? + fun provideShipMountedToData(passenger: Entity, partialTicks: Float?): ShipMountedToData? } From fbad5cbf7076af6b94b2d78247bd0c49bb069e82 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 24 Dec 2023 14:12:24 -0700 Subject: [PATCH 358/437] Make it possible to disable Contraption positionRider changes --- .../MixinAbstractContraptionEntity.java | 30 +++++++++++-------- ...xinAbstractContraptionEntityDuckFlags.java | 5 ++++ 2 files changed, 22 insertions(+), 13 deletions(-) create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuckFlags.java 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 f8511fd70..0bc6f8637 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 @@ -2,6 +2,7 @@ import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toMinecraft; +import static org.valkyrienskies.mod.mixinducks.mod_compat.create.MixinAbstractContraptionEntityDuckFlags.ENABLE_DEFAULT_VS_CONTRAPTION_FIX; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.content.contraptions.AbstractContraptionEntity; @@ -106,21 +107,24 @@ 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) { - 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); - riderPos.add(0, SeatEntity.getCustomEntitySeatOffset(passenger) - 1 / 8f, 0); - if (ship != null) { - riderPos = toMinecraft(ship.getShipToWorld().transformPosition(toJOML(riderPos))); + @Inject(method = "positionRider", at = @At("HEAD"), cancellable = true) + public void prePositionRider(final Entity passenger, final MoveFunction callback, final CallbackInfo ci) { + if (ENABLE_DEFAULT_VS_CONTRAPTION_FIX) { + ci.cancel(); + if (!hasPassenger(passenger)) + return; + Vec3 riderPos = getPassengerPosition(passenger, 1); + if (riderPos == null) + return; + if (!(passenger instanceof OrientedContraptionEntity)) { + final 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))); + } } + passenger.setPos(riderPos); } - passenger.setPos(riderPos); } @Inject(method = "toGlobalVector(Lnet/minecraft/world/phys/Vec3;FZ)Lnet/minecraft/world/phys/Vec3;", diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuckFlags.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuckFlags.java new file mode 100644 index 000000000..42d2c05be --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuckFlags.java @@ -0,0 +1,5 @@ +package org.valkyrienskies.mod.mixinducks.mod_compat.create; + +public class MixinAbstractContraptionEntityDuckFlags { + public static boolean ENABLE_DEFAULT_VS_CONTRAPTION_FIX = true; +} From d9d9a3e3ddabb6c90390ef0feaf97a5615554115 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 24 Dec 2023 14:43:34 -0700 Subject: [PATCH 359/437] Removed positionRider code from MixinAbstractContraptionEntity --- .../MixinAbstractContraptionEntity.java | 24 ------------------- ...xinAbstractContraptionEntityDuckFlags.java | 5 ---- 2 files changed, 29 deletions(-) delete mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuckFlags.java 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 0bc6f8637..3bb776a09 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 @@ -2,14 +2,12 @@ import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toJOML; import static org.valkyrienskies.mod.common.util.VectorConversionsMCKt.toMinecraft; -import static org.valkyrienskies.mod.mixinducks.mod_compat.create.MixinAbstractContraptionEntityDuckFlags.ENABLE_DEFAULT_VS_CONTRAPTION_FIX; import com.simibubi.create.AllMovementBehaviours; import com.simibubi.create.content.contraptions.AbstractContraptionEntity; import com.simibubi.create.content.contraptions.Contraption; import com.simibubi.create.content.contraptions.OrientedContraptionEntity; import com.simibubi.create.content.contraptions.actors.harvester.HarvesterMovementBehaviour; -import com.simibubi.create.content.contraptions.actors.seat.SeatEntity; import com.simibubi.create.content.contraptions.behaviour.MovementBehaviour; import com.simibubi.create.content.contraptions.behaviour.MovementContext; import com.simibubi.create.content.kinetics.base.BlockBreakingMovementBehaviour; @@ -105,28 +103,6 @@ private void redirectTeleportTo(Entity instance, double x, double y, double z) { } } - //Region end - //Region start - fix entity rider position on ship contraptions - @Inject(method = "positionRider", at = @At("HEAD"), cancellable = true) - public void prePositionRider(final Entity passenger, final MoveFunction callback, final CallbackInfo ci) { - if (ENABLE_DEFAULT_VS_CONTRAPTION_FIX) { - ci.cancel(); - if (!hasPassenger(passenger)) - return; - Vec3 riderPos = getPassengerPosition(passenger, 1); - if (riderPos == null) - return; - if (!(passenger instanceof OrientedContraptionEntity)) { - final 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))); - } - } - passenger.setPos(riderPos); - } - } - @Inject(method = "toGlobalVector(Lnet/minecraft/world/phys/Vec3;FZ)Lnet/minecraft/world/phys/Vec3;", at = @At("HEAD"), cancellable = true) private void redirectToGlobalVector(Vec3 localVec, final float partialTicks, final boolean prevAnchor, final CallbackInfoReturnable<Vec3> cir) { diff --git a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuckFlags.java b/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuckFlags.java deleted file mode 100644 index 42d2c05be..000000000 --- a/common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/create/MixinAbstractContraptionEntityDuckFlags.java +++ /dev/null @@ -1,5 +0,0 @@ -package org.valkyrienskies.mod.mixinducks.mod_compat.create; - -public class MixinAbstractContraptionEntityDuckFlags { - public static boolean ENABLE_DEFAULT_VS_CONTRAPTION_FIX = true; -} From b9cf9beec9c96269521e68905b65e24d4d6f5e6d Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 24 Dec 2023 15:52:05 -0700 Subject: [PATCH 360/437] Use ShipMountedToData when rendering entities --- .../MixinEntityRenderDispatcher.java | 65 +++++++++++++------ 1 file changed, 46 insertions(+), 19 deletions(-) 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..73c857a0b 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 @@ -8,6 +8,9 @@ import net.minecraft.client.renderer.entity.EntityRenderer; import net.minecraft.world.entity.Entity; import net.minecraft.world.phys.AABB; +import net.minecraft.world.phys.Vec3; +import org.joml.Vector3d; +import org.joml.Vector3dc; import org.joml.primitives.AABBd; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; @@ -15,7 +18,9 @@ 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.properties.ShipTransform; import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.entity.ShipMountedToData; import org.valkyrienskies.mod.common.entity.handling.VSEntityManager; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @@ -32,27 +37,49 @@ <T extends Entity> void render( final T entity, final double x, final double y, final double z, final float rotationYaw, final float partialTicks, final PoseStack matrixStack, final MultiBufferSource buffer, final int packedLight, final CallbackInfo ci, - final EntityRenderer<T> entityRenderer) { + final EntityRenderer<T> entityRenderer + ) { + final ShipMountedToData shipMountedToData = VSGameUtilsKt.getShipMountedToData(entity, partialTicks); - final ClientShip ship = - (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level, entity.blockPosition()); - if (ship != null) { - // Remove the earlier applied translation - matrixStack.popPose(); - matrixStack.pushPose(); + if (shipMountedToData != null) { + final ShipTransform renderTransform = ((ClientShip) shipMountedToData.getShipMountedTo()).getRenderTransform(); - VSEntityManager.INSTANCE.getHandler(entity) - .applyRenderTransform(ship, entity, entityRenderer, x, y, z, - rotationYaw, partialTicks, matrixStack, - buffer, packedLight); - } else if (entity.isPassenger()) { - final ClientShip vehicleShip = - (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level, - entity.getVehicle().blockPosition()); - // If the entity is a passenger and that vehicle is in ship space - if (vehicleShip != null) { - VSEntityManager.INSTANCE.getHandler(entity.getVehicle()) - .applyRenderOnMountedEntity(vehicleShip, entity.getVehicle(), entity, partialTicks, matrixStack); + final Vec3 entityPosition = entity.getPosition(partialTicks); + final Vector3dc transformed = renderTransform.getShipToWorld().transformPosition(shipMountedToData.getMountPosInShip(), new Vector3d()); + + final double camX = x - entityPosition.x; + final double camY = y - entityPosition.y; + final double camZ = z - entityPosition.z; + + final Vec3 offset = entityRenderer.getRenderOffset(entity, partialTicks); + final Vector3dc scale = renderTransform.getShipToWorldScaling(); + + matrixStack.translate(transformed.x() + camX, transformed.y() + camY, transformed.z() + camZ); + matrixStack.mulPose(VectorConversionsMCKt.toMinecraft(renderTransform.getShipToWorldRotation())); + matrixStack.scale((float) scale.x(), (float) scale.y(), (float) scale.z()); + matrixStack.translate(offset.x, offset.y, offset.z); + } else { + final ClientShip ship = + (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level, entity.blockPosition()); + if (ship != null) { + // Remove the earlier applied translation + matrixStack.popPose(); + matrixStack.pushPose(); + + VSEntityManager.INSTANCE.getHandler(entity) + .applyRenderTransform(ship, entity, entityRenderer, x, y, z, + rotationYaw, partialTicks, matrixStack, + buffer, packedLight); + } else if (entity.isPassenger()) { + final ClientShip vehicleShip = + (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level, + entity.getVehicle().blockPosition()); + // If the entity is a passenger and that vehicle is in ship space + if (vehicleShip != null) { + VSEntityManager.INSTANCE.getHandler(entity.getVehicle()) + .applyRenderOnMountedEntity(vehicleShip, entity.getVehicle(), entity, partialTicks, + matrixStack); + } } } } From ee9a5f30fe068ce87eadffbd640448d4a3abcece Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 24 Dec 2023 16:05:45 -0700 Subject: [PATCH 361/437] Added code I forgot --- .../shipyard_entities/MixinEntityRenderDispatcher.java | 4 ++++ 1 file changed, 4 insertions(+) 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 73c857a0b..95a93dc7a 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 @@ -42,6 +42,10 @@ <T extends Entity> void render( final ShipMountedToData shipMountedToData = VSGameUtilsKt.getShipMountedToData(entity, partialTicks); if (shipMountedToData != null) { + // Remove the earlier applied translation + matrixStack.popPose(); + matrixStack.pushPose(); + final ShipTransform renderTransform = ((ClientShip) shipMountedToData.getShipMountedTo()).getRenderTransform(); final Vec3 entityPosition = entity.getPosition(partialTicks); From c877334879d0a424bbd8097f342dae8c2507e822 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 24 Dec 2023 16:20:54 -0700 Subject: [PATCH 362/437] Increment version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 6f48be23d..8e6bc5338 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.1-beta.4 +mod_version=2.1.1-beta.5 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.11 From b10a02f5db542c9e78e8cf7de0ef963dc047be63 Mon Sep 17 00:00:00 2001 From: MrSterner <32911664+mrsterner@users.noreply.github.com> Date: Tue, 26 Dec 2023 15:49:52 +0100 Subject: [PATCH 363/437] fixed create valuebox rendering, on 1.18 (#662) --- .../create/client/MixinValueBox.java | 39 +++++++++++++++++++ .../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, 46 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..9a1f3f327 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/MixinValueBox.java @@ -0,0 +1,39 @@ +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<Void> 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 6b270cb06..b5c68eae8 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -77,6 +77,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 59ece5b8c..2cbfecb71 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -20,8 +20,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 c678251a6..4423ab23b 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -25,7 +25,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 2e0c5438328c380829817e3a26a8184eb3473eef Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Wed, 27 Dec 2023 15:55:33 -0700 Subject: [PATCH 364/437] Fixed enabling collision between ships not working --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8e6bc5338..4d2d3c1de 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+c37d346883 +vs_core_version=1.1.0+b19b27c4a4 # 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 72fac3232e20f1179b53d586f7825ab77f233ff4 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Thu, 28 Dec 2023 10:13:44 -0700 Subject: [PATCH 365/437] Catch setWingGroupTransform() throwing an exception --- .../create/entity/MixinAbstractContraptionEntity.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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 3bb776a09..da842738a 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 @@ -282,8 +282,14 @@ private void postTick(final CallbackInfo ci) { final LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(serverLevel, VectorConversionsMCKt.toJOML(thisAsAbstractContraptionEntity.position())); if (ship != null) { - // This can happen if a player moves a train contraption from ship to world using a wrench - ship.getAttachment(WingManager.class).setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); + try { + // This can happen if a player moves a train contraption from ship to world using a wrench + ship.getAttachment(WingManager.class) + .setWingGroupTransform(wingGroupId, computeContraptionWingTransform()); + } catch (final Exception e) { + // I'm not sure why, but this fails sometimes. For now just catch the error and print it + e.printStackTrace(); + } } } } From b1ee932637e3e0b533613a07591d383568211c51 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Fri, 29 Dec 2023 06:51:07 -0700 Subject: [PATCH 366/437] Increment version --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 4d2d3c1de..d5b9cee07 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx4G -XX:MaxMetaspaceSize=1G minecraft_version=1.18.2 enabled_platforms=quilt,fabric,forge archives_base_name=valkyrienskies-118 -mod_version=2.1.1-beta.5 +mod_version=2.1.1-beta.6 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.11 From fc8f75bb281e426e84dc35b0ff190835195a8aa9 Mon Sep 17 00:00:00 2001 From: ThePlasticPotato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Fri, 29 Dec 2023 18:29:10 -0500 Subject: [PATCH 367/437] DONE. --- .../mod/mixin/server/world/MixinServerLevel.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 024c651f4..c98ced9b7 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 @@ -254,14 +254,15 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf ShipConnDataAttachment connData = loadedShip.getAttachment(ShipConnDataAttachment.class); assert connData != null; HashSet<Object> shipBreakages = (HashSet<Object>) connData.getBreakages(); - for (Object breakage : shipBreakages) { + Iterator<Object> breakageIterator = shipBreakages.iterator(); + + while (breakageIterator.hasNext()) { + Object breakage = breakageIterator.next(); if (breakage instanceof Breakage breaking) { SubShipAssemblyKt.splitShip(VectorConversionsMCKt.toBlockPos(breaking.component1()), breaking.component2(), self, loadedShip); - connData.getBreakages().remove(breakage); + breakageIterator.remove(); } } - - } } } From a2caf4de40486f56f019c8f72eaee974393192e0 Mon Sep 17 00:00:00 2001 From: MrSterner <32911664+mrsterner@users.noreply.github.com> Date: Sat, 30 Dec 2023 16:31:02 +0100 Subject: [PATCH 368/437] loot container dupe fix on ship assembly (#667) * fixed create valuebox rendering, on 1.18 * loot container dupe fix * loot container dupe fix --- .../kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt | 8 ++++++++ 1 file changed, 8 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..068c55533 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/util/RelocationUtil.kt @@ -2,10 +2,13 @@ package org.valkyrienskies.mod.util import net.minecraft.core.BlockPos import net.minecraft.world.Clearable +import net.minecraft.world.Container 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.ChestBlockEntity +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 +43,11 @@ fun relocateBlock( it.clearContent() } + // so loot containers dont drop its content + if (it is RandomizableContainerBlockEntity) { + it.setLootTable(null, 0) + } + tag } 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 369/437] 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 eace2ef186ffb042710ee63d66ad41c9369ee9c4 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sat, 30 Dec 2023 12:20:01 -0700 Subject: [PATCH 370/437] 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 e2c87d4a47df629580eb0f236004722ee0becc7b Mon Sep 17 00:00:00 2001 From: illuc <70791404+illucc@users.noreply.github.com> Date: Sun, 31 Dec 2023 14:50:03 +0200 Subject: [PATCH 371/437] Mekanism radiation compat (#671) * Mekanism radiation compat * teeny tiny fixes --- forge/build.gradle | 3 ++ .../mekanism/MixinRadiationManager.java | 31 +++++++++++++++++++ .../valkyrienskies-forge.mixins.json | 1 + 3 files changed, 35 insertions(+) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mekanism/MixinRadiationManager.java diff --git a/forge/build.gradle b/forge/build.gradle index 1f360349c..21f7d0fe4 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -81,6 +81,9 @@ dependencies { // Modular Routers modCompileOnly("curse.maven:mr-250294:3776175") + // Mekanism + modCompileOnly ("curse.maven:mekanism-268560:3875976") + // Add Kotlin for Forge (3.12.0) forgeRuntimeLibrary('curse.maven:kotlinforforge-351264:4513187') 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<Level> 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/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 4423ab23b..66795029a 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", "compat.modular_routers.MixinContainerModularRouter", + "compat.mekanism.MixinRadiationManager", "feature.forge_interact.MixinIForgePlayer", "world.level.block.FireMixin" ], From 3c80849edf4b830b245592671654bacefb343c99 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 31 Dec 2023 06:06:25 -0700 Subject: [PATCH 372/437] 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 88089315dd9be41486ed82264abfb73d675507bd Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Tue, 2 Jan 2024 06:52:50 -0700 Subject: [PATCH 373/437] Added block masses for steel armor blocks mod --- .../vs_mass/steelarmorblocks.json | 1486 +++++++++++++++++ 1 file changed, 1486 insertions(+) create mode 100644 common/src/main/resources/data/valkyrienskies/vs_mass/steelarmorblocks.json 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..943ca271b --- /dev/null +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/steelarmorblocks.json @@ -0,0 +1,1486 @@ +[ + { + "block": "s_a_b:doublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:steelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:hardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:lightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:steelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:lightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:steelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:lightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:steelarmorstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelwl", + "mass": 11760.0 + }, + { + "block": "s_a_b:armorwl", + "mass": 43120.0 + }, + { + "block": "s_a_b:sandbag", + "mass": 6240.0 + }, + { + "block": "s_a_b:blacksteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:redsteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:greensteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:bluesteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:cyansteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:brownsteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:graysteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:whitesteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:lightgraysteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:lightbluesteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:magentasteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:yellowsteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:pinksteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:purplesteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:orangesteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:limesteelblock", + "mass": 11760.0 + }, + { + "block": "s_a_b:blackhardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:redhardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:greenhardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:bluehardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:cyanhardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:brownhardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:grayhardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:lightgrayhardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:lightbluehardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:magentahardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:yellowhardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:pinkhardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:purplehardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:orangehardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:limehardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:whitehardsteelblock", + "mass": 43120.0 + }, + { + "block": "s_a_b:blacklightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:redlightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:greenlightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:bluelightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:cyanlightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:brownlightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:graylightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightgraylightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightbluelightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:magentalightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:yellowlightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:pinklightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:purplelightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:orangelightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:limelightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:whitelightsteelblock", + "mass": 3920.0 + }, + { + "block": "s_a_b:blackdoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:reddoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:greendoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:bluedoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:cyandoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:browndoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:graydoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:lightgraydoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:lightbluedoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:magentadoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:yellowdoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:pinkdoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:purpledoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:orangedoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:limedoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:whitedoublesteelblock", + "mass": 27440.0 + }, + { + "block": "s_a_b:blacklightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:redlightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:greenlightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:bluelightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:cyanlightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:brownlightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:graylightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightgraylightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightbluelightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:magentalightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:yellowlightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:pinklightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:purplelightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:orangelightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:limelightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:whitelightsteelvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:blacksteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:redsteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:greensteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:bluesteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:cyansteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:brownsteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:graysteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:lightgraysteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:lightbluesteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:magentasteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:yellowsteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:pinksteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:purplesteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:orangesteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:limesteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:whitesteelvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:blacklightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:redlightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:greenlightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:bluelightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:cyanlightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:brownlightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:graylightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightgraylightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightbluelightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:magentalightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:yellowlightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:pinklightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:purplelightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:orangelightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:limelightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:whitelightsteelslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:blacksteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:redsteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:greensteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:bluesteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:cyansteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:brownsteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:graysteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:lightgraysteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:lightbluesteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:magentasteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:yellowsteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:pinksteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:purplesteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:orangesteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:limesteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:whitesteelslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:blacklightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:redlightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:greenlightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:bluelightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:cyanlightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:brownlightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:graylightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:lightgraylightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:lightbluelightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:magentalightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:yellowlightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:pinklightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:purplelightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:orangelightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:limelightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:whitelightsteelstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:blacksteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:redsteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:greensteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:bluesteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:cyansteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:brownsteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:graysteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:lightgraysteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:lightbluesteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:magentasteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:yellowsteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:pinksteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:purplesteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:orangesteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:limesteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:whitesteelstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelblockcolored_29", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelblockcolored_31", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelblockcolored_32", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelblockcolored_33", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelblockcoloredparade", + "mass": 11760.0 + }, + { + "block": "s_a_b:doublesteelblockcolored_29", + "mass": 27440.0 + }, + { + "block": "s_a_b:doublesteelblockcolored_31", + "mass": 27440.0 + }, + { + "block": "s_a_b:doublesteelblockcolored_32", + "mass": 27440.0 + }, + { + "block": "s_a_b:doublesteelblockcolored_33", + "mass": 27440.0 + }, + { + "block": "s_a_b:doublesteelblockcoloredparade", + "mass": 27440.0 + }, + { + "block": "s_a_b:lightsteelblockcolored_29", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelblockcolored_31", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelblockcolored_32", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelblockcolored_33", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelblockcoloredparade", + "mass": 3920.0 + }, + { + "block": "s_a_b:hardsteelblockcolored_29", + "mass": 43120.0 + }, + { + "block": "s_a_b:hardsteelblockcolored_31", + "mass": 43120.0 + }, + { + "block": "s_a_b:hardsteelblockcolored_32", + "mass": 43120.0 + }, + { + "block": "s_a_b:hardsteelblockcolored_33", + "mass": 43120.0 + }, + { + "block": "s_a_b:hardsteelblockcoloredparade", + "mass": 43120.0 + }, + { + "block": "s_a_b:steelvslabcolored_29", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelvslabcolored_31", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelvslabcolored_32", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelvslabcolored_33", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelvslabcoloredparade", + "mass": 5880.0 + }, + { + "block": "s_a_b:lightsteelvslabcolored_29", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelvslabcolored_31", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelvslabcolored_32", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelvslabcolored_33", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelvslabcoloredparade", + "mass": 1960.0 + }, + { + "block": "s_a_b:steelslabcolored_29", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelslabcolored_31", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelslabcolored_32", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelslabcolored_33", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelslabcoloredparade", + "mass": 5880.0 + }, + { + "block": "s_a_b:lightsteelslabcolored_29", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelslabcolored_31", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelslabcolored_32", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelslabcolored_33", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelslabcoloredparade", + "mass": 1960.0 + }, + { + "block": "s_a_b:steelstairscolored_29", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelstairscolored_31", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelstairscolored_32", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelstairscolored_33", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelstairscoloredparade", + "mass": 8820.0 + }, + { + "block": "s_a_b:lightsteelstairscolored_29", + "mass": 2940.0 + }, + { + "block": "s_a_b:lghtsteelstairscolored_31", + "mass": 2940.0 + }, + { + "block": "s_a_b:lghtsteelstairscolored_32", + "mass": 2940.0 + }, + { + "block": "s_a_b:lghtsteelstairscolored_33", + "mass": 2940.0 + }, + { + "block": "s_a_b:lghtsteelstairscoloredparade", + "mass": 32340.0 + }, + { + "block": "s_a_b:doublesteelblockshipbottom", + "mass": 27440.0 + }, + { + "block": "s_a_b:steelblockshipbottom", + "mass": 11760.0 + }, + { + "block": "s_a_b:hardsteelblockshipbottom", + "mass": 43120.0 + }, + { + "block": "s_a_b:lightsteelblockshipbottom", + "mass": 3920.0 + }, + { + "block": "s_a_b:doublesteelblock_4bo", + "mass": 27440.0 + }, + { + "block": "s_a_b:steelblock_4bo", + "mass": 11760.0 + }, + { + "block": "s_a_b:hardsteelblock_4bo", + "mass": 43120.0 + }, + { + "block": "s_a_b:lightsteelblock_4bo", + "mass": 3920.0 + }, + { + "block": "s_a_b:doublesteelblockgelb", + "mass": 27440.0 + }, + { + "block": "s_a_b:steelblockgelb", + "mass": 11760.0 + }, + { + "block": "s_a_b:hardsteelblockgelb", + "mass": 43120.0 + }, + { + "block": "s_a_b:lightsteelblockgelb", + "mass": 3920.0 + }, + { + "block": "s_a_b:doublesteelblockpanzergrau", + "mass": 27440.0 + }, + { + "block": "s_a_b:steelblockpanzergrau", + "mass": 11760.0 + }, + { + "block": "s_a_b:hardsteelblockpanzergrau", + "mass": 43120.0 + }, + { + "block": "s_a_b:lightsteelblockpanzergrau", + "mass": 3920.0 + }, + { + "block": "s_a_b:doublesteelblockrotbraun", + "mass": 27440.0 + }, + { + "block": "s_a_b:steelblockrotbraun", + "mass": 11760.0 + }, + { + "block": "s_a_b:hardsteelblockrotbraun", + "mass": 43120.0 + }, + { + "block": "s_a_b:lightsteelblockrotbraun", + "mass": 3920.0 + }, + { + "block": "s_a_b:steelslabshipbottom", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelvslabshipbottom", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelstairsshipbottom", + "mass": 8820.0 + }, + { + "block": "s_a_b:lightsteelslabshipbottom", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelvslabshipbottom", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelstairsshipbottom", + "mass": 2940.0 + }, + { + "block": "s_a_b:steelslab_4bo", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelvslab_4bo", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelstairs_4bo", + "mass": 8820.0 + }, + { + "block": "s_a_b:lightsteelslab_4bo", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelvslab_4bo", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelstairs_4bo", + "mass": 2940.0 + }, + { + "block": "s_a_b:steelslabgelb", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelvslabgelb", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelstairsgelb", + "mass": 8820.0 + }, + { + "block": "s_a_b:lightsteelslabgelb", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelvslabgelb", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelstairsgelb", + "mass": 2940.0 + }, + { + "block": "s_a_b:steelslabpanzergrau", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelvslabpanzergrau", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelstairspanzergrau", + "mass": 8820.0 + }, + { + "block": "s_a_b:lightsteelslabpanzergrau", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelvslabpanzergrau", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelstairspanzergrau", + "mass": 2940.0 + }, + { + "block": "s_a_b:steelslabrotbraun", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelvslabrotbraun", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelstairsrotbraun", + "mass": 8820.0 + }, + { + "block": "s_a_b:lightsteelslabrotbraun", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelvslabrotbraun", + "mass": 1960.0 + }, + { + "block": "s_a_b:lightsteelstairsrotbraun", + "mass": 2940.0 + }, + { + "block": "s_a_b:steelwl_29", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelwl_31", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelwl_32", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelwl_33", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelwlblack", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelwlgray", + "mass": 11760.0 + }, + { + "block": "s_a_b:lightwl_29", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightwl_31", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightwl_32", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightwl_33", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightwlblack", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightwlgray", + "mass": 3920.0 + }, + { + "block": "s_a_b:armorwl_29", + "mass": 43120.0 + }, + { + "block": "s_a_b:armorwl_31", + "mass": 43120.0 + }, + { + "block": "s_a_b:armorwl_32", + "mass": 43120.0 + }, + { + "block": "s_a_b:armorwl_33", + "mass": 43120.0 + }, + { + "block": "s_a_b:armorwlblack", + "mass": 43120.0 + }, + { + "block": "s_a_b:armorwlgray", + "mass": 43120.0 + }, + { + "block": "s_a_b:lightsteelblockcamoplains", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelcamoforest", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelcamosnow", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelcamodesert", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelcamomesa", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelcamoswamp", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelcamojungle", + "mass": 3920.0 + }, + { + "block": "s_a_b:lightsteelcamotaiga", + "mass": 3920.0 + }, + { + "block": "s_a_b:steelblockcamoplains", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelblockcamoforest", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelblockcamosnow", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelblockcamodesert", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelblockcamomesa", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelblockcamoswamp", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelblockcamojungle", + "mass": 11760.0 + }, + { + "block": "s_a_b:steelblockcamotaiga", + "mass": 11760.0 + }, + { + "block": "s_a_b:doublesteelblockcamoplains", + "mass": 27440.0 + }, + { + "block": "s_a_b:doublesteelblockcamoforest", + "mass": 27440.0 + }, + { + "block": "s_a_b:doublesteelblockcamosnow", + "mass": 27440.0 + }, + { + "block": "s_a_b:doublesteelblockcamodesert", + "mass": 27440.0 + }, + { + "block": "s_a_b:doublesteelblockcamomesa", + "mass": 27440.0 + }, + { + "block": "s_a_b:doublesteelblockcamoswamp", + "mass": 27440.0 + }, + { + "block": "s_a_b:doublesteelblockcamojungle", + "mass": 27440.0 + }, + { + "block": "s_a_b:doublesteelblockcamotaiga", + "mass": 27440.0 + }, + { + "block": "s_a_b:hardsteelblockcamoplains", + "mass": 43120.0 + }, + { + "block": "s_a_b:hardsteelblockcamoforest", + "mass": 43120.0 + }, + { + "block": "s_a_b:hardsteelblockcamosnow", + "mass": 43120.0 + }, + { + "block": "s_a_b:hardsteelblockcamodesert", + "mass": 43120.0 + }, + { + "block": "s_a_b:hardsteelblockcamomesa", + "mass": 43120.0 + }, + { + "block": "s_a_b:hardsteelblockcamoswamp", + "mass": 43120.0 + }, + { + "block": "s_a_b:hardsteelblockcamojungle", + "mass": 43120.0 + }, + { + "block": "s_a_b:hardsteelblockcamotaiga", + "mass": 43120.0 + }, + { + "block": "s_a_b:iightsteelcamoplainsslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamoplainsvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamoplainsstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:iightsteelcamoforestslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamoforestvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamoforeststairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:iightsteelcamosnowslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamosnowvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamosnowstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:iightsteelcamodesertslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamodesertvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamodesertstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:iightsteelcamomesaslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamomesavslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamomesastairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:iightsteelcamoswampslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamoswampvslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamoswampstairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:iightsteelcamojungleslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamojunglevslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamojunglestairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:iightsteelcamotaigaslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamotaigavslab", + "mass": 1960.0 + }, + { + "block": "s_a_b:iightsteelcamotaigastairs", + "mass": 2940.0 + }, + { + "block": "s_a_b:steelcamoplainsslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamoplainsvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamoplainsstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelcamoforestslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamoforestvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamoforeststairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelcamosnowslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamosnowvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamosnowstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelcamodesertslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamodesertvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamodesertstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelcamomesaslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamomesavslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamomesastairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelcamoswampslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamoswampvslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamoswampstairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelcamojungleslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamojunglevslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamojunglestairs", + "mass": 8820.0 + }, + { + "block": "s_a_b:steelcamotaigaslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamotaigavslab", + "mass": 5880.0 + }, + { + "block": "s_a_b:steelcamotaigastairs", + "mass": 8820.0 + } +] From 5eef9017066f5fcec002aa61e2ea8cf14ef90982 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Fri, 5 Jan 2024 17:57:12 -0500 Subject: [PATCH 374/437] 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 8f8ecebe5d9701fa619cdde2cafae52ce7970474 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Fri, 5 Jan 2024 17:57:12 -0500 Subject: [PATCH 375/437] 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 8a4ee715ddcbab4c6aa0e34106030eafd378bebb Mon Sep 17 00:00:00 2001 From: ThePlasticPotato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Fri, 19 Jan 2024 10:39:50 -0500 Subject: [PATCH 376/437] Update VS-Core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index a45897e04..5871a68da 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+d0aa57abb9 +vs_core_version=1.1.0+ea661be66d # 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 535ef4f370851840b819323d026734c526e5c90b Mon Sep 17 00:00:00 2001 From: ThePlasticPotato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sat, 20 Jan 2024 11:52:47 -0500 Subject: [PATCH 377/437] fixed chutes on ships --- .../accessors/ChuteBlockEntityAccessor.java | 16 +++++ .../blockentity/MixinChuteBlockEntity.java | 61 +++++++++++++++++++ .../valkyrienskies-common.mixins.json | 2 + 3 files changed, 79 insertions(+) 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/blockentity/MixinChuteBlockEntity.java 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/blockentity/MixinChuteBlockEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinChuteBlockEntity.java new file mode 100644 index 000000000..10ed17e72 --- /dev/null +++ b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinChuteBlockEntity.java @@ -0,0 +1,61 @@ +package org.valkyrienskies.mod.mixin.mod_compat.create.blockentity; + +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.spongepowered.asm.mixin.injection.callback.LocalCapture; +import org.valkyrienskies.core.api.ships.ServerShip; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.mixin.mod_compat.create.accessors.ChuteBlockEntityAccessor; + +@Mixin(ChuteBlockEntity.class) +public class MixinChuteBlockEntity { + @Inject(method = "findEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;<init>(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;)V", shift = Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, remap = false) + private void preFindEntities(float itemSpeed, CallbackInfo ci, Vec3 center) { + if (((ChuteBlockEntity) (Object) this).getLevel() != null) { + + final ChuteBlockEntity be = (ChuteBlockEntity) (Object) this; + final ChuteBlockEntityAccessor bea = (ChuteBlockEntityAccessor) be; + Level level = ((ChuteBlockEntity) (Object) this).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/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 6b270cb06..ad3590d7e 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -62,6 +62,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", @@ -74,6 +75,7 @@ "mod_compat.create.block.MixinRedstoneContactBlock", "mod_compat.create.block.MixinStickerBlock", "mod_compat.create.blockentity.IMixinMechanicalBearingTileEntity", + "mod_compat.create.blockentity.MixinChuteBlockEntity", "mod_compat.create.blockentity.MixinCrushingWheelControllerTileEntity", "mod_compat.create.blockentity.MixinEjectorTileEntity", "mod_compat.create.blockentity.MixinEncasedFanTileEntity", From 79af6335292e869ef2c8890e627ec1d1b1aed855 Mon Sep 17 00:00:00 2001 From: ThePlasticPotato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sat, 20 Jan 2024 19:28:54 -0500 Subject: [PATCH 378/437] update vscore also kjill mef --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 95399fe74..aac4b337a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+ea661be66d +vs_core_version=1.1.0+277442cf47 # 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 138e7bbe7b11cb6de21e64287495281750136557 Mon Sep 17 00:00:00 2001 From: ThePlasticPotato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 21 Jan 2024 17:49:14 -0500 Subject: [PATCH 379/437] Update VSCore --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index aac4b337a..c32cb2d02 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+277442cf47 +vs_core_version=1.1.0+7dbd2ee63a # 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 1409e2d788cdc52de80dcfe1fc51e0ae7756c029 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Tue, 23 Jan 2024 17:57:26 +0100 Subject: [PATCH 380/437] No collision, does expand AABB otherwise we can't find blocks wich are marked as AIR. --- .../valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt | 2 +- gradle.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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..34fff90ba 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt @@ -31,6 +31,6 @@ object DefaultBlockStateInfoProvider : BlockStateInfoProvider { 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 + return if (blockMaterial.isSolid) vsCore.blockTypes.solid else vsCore.blockTypes.noCollision } } diff --git a/gradle.properties b/gradle.properties index c32cb2d02..445da381d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ 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 -vs_core_version=1.1.0+7dbd2ee63a +vs_core_version=1.1.0+e26d9059c0 # 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 5944d564cd786b54bfc68c2d79638e5903e81ad9 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Mon, 29 Jan 2024 12:41:29 -0500 Subject: [PATCH 381/437] Move ValueBox mixin to client (#681) 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 44005a881..96fb725bb 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -79,7 +79,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", @@ -165,6 +164,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 0b8f5b6277bd413d65906ed2fcc9338f84eaa4e2 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Mon, 29 Jan 2024 12:41:39 -0500 Subject: [PATCH 382/437] 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 80d2d9370000ce7491d9568f71343b28f603fcf3 Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins <31552479+FluffyJenkins@users.noreply.github.com> Date: Mon, 29 Jan 2024 17:55:48 +0000 Subject: [PATCH 383/437] Create Compat(1.18.x): Fixed track outlines and picking (#692) * 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<Vector3d> - 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<Vector3d> - 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<Boolean> 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 96fb725bb..815fcbf1e 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -164,6 +164,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 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 384/437] 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<Vector3d> - 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<Vector3d> - 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<Boolean> 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 d3a84b57a837b7367d44f394222dad1b2a2263ed Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Mon, 29 Jan 2024 19:17:38 +0100 Subject: [PATCH 385/437] 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 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 386/437] 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 42ce6f544ea8452a45063503d27ac0410e39701d Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Mon, 29 Jan 2024 23:15:06 +0100 Subject: [PATCH 387/437] Priorities in datapacks --- .../mod/common/config/VSMassDataLoader.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) 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..ccadba0f1 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,7 +17,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 @@ -26,6 +25,7 @@ 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 @@ -160,7 +160,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,6 +173,13 @@ object MassDatapackResolver : BlockStateInfoProvider { } } + fun decideDefaultPriority(resourceLocation: ResourceLocation) = when { + resourceLocation.namespace.equals(ValkyrienSkiesMod.MOD_ID) -> 1000 + resourceLocation.namespace.equals("custom") -> 50 + else -> 100 + } + + private fun generateStairCollisionShapes(stairShapes: Array<VoxelShape>): Map<VoxelShape, Lod1SolidCollisionShape> { val testPoints = listOf( CollisionPoint(Vector3f(.25f, .25f, .25f), .25f), From 5e053f1d934a5bc664dd22ef2838723a3066467b Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Tue, 30 Jan 2024 16:26:13 +0100 Subject: [PATCH 388/437] If an error happens on place, untransform --- .../MixinBlockItem.java | 44 ++++++------------- 1 file changed, 14 insertions(+), 30 deletions(-) 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..4a0b2e0d1 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,34 @@ 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<InteractionResult> 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<InteractionResult> cir) { - if (context.getPlayer() == null) { - return; + private BlockState transformPlayerWhenPlacing(BlockItem _instance, BlockPlaceContext _ctx, Operation<BlockState> 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 + ); } } From 8efd751c2d990382a702040bc71b0fb99d5ed7a1 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Mon, 5 Feb 2024 14:15:15 +0100 Subject: [PATCH 389/437] Fixed placing error, cleaned a bit of code --- .../MixinBlockItem.java | 7 ++-- .../valkyrienskies/mod/common/PlayerUtil.kt | 33 ++++++++----------- 2 files changed, 19 insertions(+), 21 deletions(-) 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 4a0b2e0d1..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 @@ -19,7 +19,10 @@ public abstract class MixinBlockItem { ), method = "place" ) - private BlockState transformPlayerWhenPlacing(BlockItem _instance, BlockPlaceContext _ctx, Operation<BlockState> original, final BlockPlaceContext ctx) { + private BlockState transformPlayerWhenPlacing( + final BlockItem _instance, final BlockPlaceContext _ctx, + final Operation<BlockState> original, final BlockPlaceContext ctx + ) { if (ctx == null || ctx.getPlayer() == null) { return null; } @@ -28,7 +31,7 @@ private BlockState transformPlayerWhenPlacing(BlockItem _instance, BlockPlaceCon ctx.getPlayer(), ctx.getLevel(), ctx.getClickedPos(), - original::call + () -> original.call(this, ctx) ); } } 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 From 6754162905b531087855c6f65df5ecccde1e0284 Mon Sep 17 00:00:00 2001 From: Fluffy Jenkins <31552479+FluffyJenkins@users.noreply.github.com> Date: Sun, 18 Feb 2024 15:10:33 +0000 Subject: [PATCH 390/437] Create Compat(1.18.x): Removed old file causing crashes/renamed function (#737) * Remove old file that somehow got missed... * renamed function --- .../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 815fcbf1e..328fe8370 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -162,7 +162,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 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 391/437] 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 1705b550dda6112aa22742b31f6fab623f7dcc87 Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Sat, 24 Feb 2024 17:12:04 +0100 Subject: [PATCH 392/437] Bluemap Compat (#703) --- common/build.gradle | 3 + .../bluemap/HiresTileModelAccessor.java | 15 +++ .../mixin/mod_compat/bluemap/MixinBmMap.java | 47 ++++++++ .../bluemap/MixinHiresModelManager.java | 100 ++++++++++++++++++ .../mixin/mod_compat/bluemap/MixinWorld.java | 36 +++++++ .../mixin/server/MinecraftServerAccessor.java | 13 +++ .../mod_compat/bluemap/WorldDuck.java | 10 ++ .../valkyrienskies-common.mixins.json | 5 + 8 files changed, 229 insertions(+) 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/server/MinecraftServerAccessor.java create mode 100644 common/src/main/java/org/valkyrienskies/mod/mixinducks/mod_compat/bluemap/WorldDuck.java diff --git a/common/build.gradle b/common/build.gradle index 349552ef0..4b0d5a6b3 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("io.github.fabricators_of_create:Porting-Lib:${port_lib_version}+${minecraft_version}") modCompileOnly("com.rbasamoyai:createbigcannons-fabric-${minecraft_version}:${createbigcannons_version}") + + //Bluemap fabric 1.18 + modCompileOnly("curse.maven:bluemap-406463:4950063") } architectury { 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<Object> 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/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/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/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 328fe8370..569f9e31a 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -52,6 +52,10 @@ "feature.water_in_ships_entity.MixinEntity", "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", @@ -92,6 +96,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", From a585dff452b52cd32181b732bfc7f8f6af4594eb Mon Sep 17 00:00:00 2001 From: ewoudje <7384674+ewoudje@users.noreply.github.com> Date: Mon, 11 Mar 2024 18:41:40 +0100 Subject: [PATCH 393/437] Added id to @v --- .../mod/common/command/ShipArgumentParser.kt | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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..6483c2d44 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) } From 1d478eb17fa6d11984fbf581382300b7e37ca9d6 Mon Sep 17 00:00:00 2001 From: ThePlasticPotato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Mon, 25 Mar 2024 12:17:39 -0400 Subject: [PATCH 394/437] The Great Weightloss of 2024 --- .../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 | 742 +++++++++--------- .../data/valkyrienskies/vs_mass/wood.json | 122 +-- 12 files changed, 984 insertions(+), 984 deletions(-) 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 index 943ca271b..d1b599284 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/steelarmorblocks.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/steelarmorblocks.json @@ -1,1486 +1,1486 @@ [ { "block": "s_a_b:doublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:steelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:hardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:lightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:steelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:lightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:steelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:lightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:steelarmorstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelwl", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:armorwl", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:sandbag", - "mass": 6240.0 + "mass": 624.0 }, { "block": "s_a_b:blacksteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:redsteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:greensteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:bluesteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:cyansteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:brownsteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:graysteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:whitesteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:lightgraysteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:lightbluesteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:magentasteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:yellowsteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:pinksteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:purplesteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:orangesteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:limesteelblock", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:blackhardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:redhardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:greenhardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:bluehardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:cyanhardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:brownhardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:grayhardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:lightgrayhardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:lightbluehardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:magentahardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:yellowhardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:pinkhardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:purplehardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:orangehardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:limehardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:whitehardsteelblock", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:blacklightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:redlightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:greenlightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:bluelightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:cyanlightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:brownlightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:graylightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightgraylightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightbluelightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:magentalightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:yellowlightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:pinklightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:purplelightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:orangelightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:limelightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:whitelightsteelblock", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:blackdoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:reddoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:greendoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:bluedoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:cyandoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:browndoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:graydoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:lightgraydoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:lightbluedoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:magentadoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:yellowdoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:pinkdoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:purpledoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:orangedoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:limedoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:whitedoublesteelblock", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:blacklightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:redlightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:greenlightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:bluelightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:cyanlightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:brownlightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:graylightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightgraylightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightbluelightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:magentalightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:yellowlightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:pinklightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:purplelightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:orangelightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:limelightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:whitelightsteelvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:blacksteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:redsteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:greensteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:bluesteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:cyansteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:brownsteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:graysteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:lightgraysteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:lightbluesteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:magentasteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:yellowsteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:pinksteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:purplesteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:orangesteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:limesteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:whitesteelvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:blacklightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:redlightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:greenlightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:bluelightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:cyanlightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:brownlightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:graylightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightgraylightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightbluelightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:magentalightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:yellowlightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:pinklightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:purplelightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:orangelightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:limelightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:whitelightsteelslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:blacksteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:redsteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:greensteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:bluesteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:cyansteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:brownsteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:graysteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:lightgraysteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:lightbluesteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:magentasteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:yellowsteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:pinksteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:purplesteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:orangesteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:limesteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:whitesteelslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:blacklightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:redlightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:greenlightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:bluelightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:cyanlightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:brownlightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:graylightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:lightgraylightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:lightbluelightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:magentalightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:yellowlightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:pinklightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:purplelightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:orangelightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:limelightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:whitelightsteelstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:blacksteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:redsteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:greensteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:bluesteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:cyansteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:brownsteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:graysteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:lightgraysteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:lightbluesteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:magentasteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:yellowsteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:pinksteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:purplesteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:orangesteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:limesteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:whitesteelstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelblockcolored_29", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelblockcolored_31", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelblockcolored_32", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelblockcolored_33", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelblockcoloredparade", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:doublesteelblockcolored_29", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:doublesteelblockcolored_31", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:doublesteelblockcolored_32", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:doublesteelblockcolored_33", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:doublesteelblockcoloredparade", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:lightsteelblockcolored_29", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelblockcolored_31", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelblockcolored_32", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelblockcolored_33", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelblockcoloredparade", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:hardsteelblockcolored_29", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:hardsteelblockcolored_31", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:hardsteelblockcolored_32", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:hardsteelblockcolored_33", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:hardsteelblockcoloredparade", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:steelvslabcolored_29", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelvslabcolored_31", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelvslabcolored_32", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelvslabcolored_33", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelvslabcoloredparade", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:lightsteelvslabcolored_29", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelvslabcolored_31", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelvslabcolored_32", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelvslabcolored_33", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelvslabcoloredparade", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:steelslabcolored_29", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelslabcolored_31", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelslabcolored_32", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelslabcolored_33", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelslabcoloredparade", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:lightsteelslabcolored_29", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelslabcolored_31", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelslabcolored_32", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelslabcolored_33", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelslabcoloredparade", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:steelstairscolored_29", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelstairscolored_31", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelstairscolored_32", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelstairscolored_33", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelstairscoloredparade", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:lightsteelstairscolored_29", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:lghtsteelstairscolored_31", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:lghtsteelstairscolored_32", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:lghtsteelstairscolored_33", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:lghtsteelstairscoloredparade", - "mass": 32340.0 + "mass": 3234.0 }, { "block": "s_a_b:doublesteelblockshipbottom", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:steelblockshipbottom", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:hardsteelblockshipbottom", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:lightsteelblockshipbottom", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:doublesteelblock_4bo", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:steelblock_4bo", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:hardsteelblock_4bo", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:lightsteelblock_4bo", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:doublesteelblockgelb", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:steelblockgelb", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:hardsteelblockgelb", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:lightsteelblockgelb", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:doublesteelblockpanzergrau", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:steelblockpanzergrau", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:hardsteelblockpanzergrau", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:lightsteelblockpanzergrau", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:doublesteelblockrotbraun", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:steelblockrotbraun", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:hardsteelblockrotbraun", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:lightsteelblockrotbraun", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:steelslabshipbottom", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelvslabshipbottom", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelstairsshipbottom", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:lightsteelslabshipbottom", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelvslabshipbottom", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelstairsshipbottom", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:steelslab_4bo", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelvslab_4bo", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelstairs_4bo", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:lightsteelslab_4bo", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelvslab_4bo", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelstairs_4bo", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:steelslabgelb", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelvslabgelb", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelstairsgelb", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:lightsteelslabgelb", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelvslabgelb", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelstairsgelb", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:steelslabpanzergrau", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelvslabpanzergrau", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelstairspanzergrau", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:lightsteelslabpanzergrau", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelvslabpanzergrau", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelstairspanzergrau", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:steelslabrotbraun", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelvslabrotbraun", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelstairsrotbraun", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:lightsteelslabrotbraun", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelvslabrotbraun", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:lightsteelstairsrotbraun", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:steelwl_29", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelwl_31", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelwl_32", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelwl_33", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelwlblack", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelwlgray", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:lightwl_29", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightwl_31", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightwl_32", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightwl_33", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightwlblack", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightwlgray", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:armorwl_29", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:armorwl_31", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:armorwl_32", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:armorwl_33", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:armorwlblack", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:armorwlgray", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:lightsteelblockcamoplains", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelcamoforest", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelcamosnow", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelcamodesert", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelcamomesa", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelcamoswamp", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelcamojungle", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:lightsteelcamotaiga", - "mass": 3920.0 + "mass": 392.0 }, { "block": "s_a_b:steelblockcamoplains", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelblockcamoforest", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelblockcamosnow", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelblockcamodesert", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelblockcamomesa", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelblockcamoswamp", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelblockcamojungle", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:steelblockcamotaiga", - "mass": 11760.0 + "mass": 1176.0 }, { "block": "s_a_b:doublesteelblockcamoplains", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:doublesteelblockcamoforest", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:doublesteelblockcamosnow", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:doublesteelblockcamodesert", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:doublesteelblockcamomesa", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:doublesteelblockcamoswamp", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:doublesteelblockcamojungle", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:doublesteelblockcamotaiga", - "mass": 27440.0 + "mass": 2744.0 }, { "block": "s_a_b:hardsteelblockcamoplains", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:hardsteelblockcamoforest", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:hardsteelblockcamosnow", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:hardsteelblockcamodesert", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:hardsteelblockcamomesa", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:hardsteelblockcamoswamp", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:hardsteelblockcamojungle", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:hardsteelblockcamotaiga", - "mass": 43120.0 + "mass": 4312.0 }, { "block": "s_a_b:iightsteelcamoplainsslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamoplainsvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamoplainsstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:iightsteelcamoforestslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamoforestvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamoforeststairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:iightsteelcamosnowslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamosnowvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamosnowstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:iightsteelcamodesertslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamodesertvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamodesertstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:iightsteelcamomesaslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamomesavslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamomesastairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:iightsteelcamoswampslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamoswampvslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamoswampstairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:iightsteelcamojungleslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamojunglevslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamojunglestairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:iightsteelcamotaigaslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamotaigavslab", - "mass": 1960.0 + "mass": 196.0 }, { "block": "s_a_b:iightsteelcamotaigastairs", - "mass": 2940.0 + "mass": 294.0 }, { "block": "s_a_b:steelcamoplainsslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamoplainsvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamoplainsstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelcamoforestslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamoforestvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamoforeststairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelcamosnowslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamosnowvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamosnowstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelcamodesertslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamodesertvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamodesertstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelcamomesaslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamomesavslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamomesastairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelcamoswampslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamoswampvslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamoswampstairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelcamojungleslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamojunglevslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamojunglestairs", - "mass": 8820.0 + "mass": 882.0 }, { "block": "s_a_b:steelcamotaigaslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamotaigavslab", - "mass": 5880.0 + "mass": 588.0 }, { "block": "s_a_b:steelcamotaigastairs", - "mass": 8820.0 + "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 } ] From e0fc0531ac8374d39ee973ebaef23097a0cc3f21 Mon Sep 17 00:00:00 2001 From: ThePlasticPotato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Mon, 25 Mar 2024 12:22:32 -0400 Subject: [PATCH 395/437] Reverted default weight to 100kg --- .../mod/common/DefaultBlockStateInfoProvider.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 34fff90ba..e408f6cf6 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/DefaultBlockStateInfoProvider.kt @@ -21,8 +21,8 @@ object DefaultBlockStateInfoProvider : BlockStateInfoProvider { override fun getBlockStateMass(blockState: BlockState): Double { if (blockState.isAir) return 0.0 - // By default make blocks weight 1000 kg - return 1000.0 + // By default make blocks weight 100 kg + return 100.0 } override fun getBlockStateType(blockState: BlockState): BlockType { From c1cfc5399c0099cbb9c37d5c47351cefb3c871c2 Mon Sep 17 00:00:00 2001 From: Rubydesic <rubydesic@gmail.com> Date: Tue, 26 Mar 2024 02:46:14 -0400 Subject: [PATCH 396/437] Update README.md --- README.md | 6 ------ 1 file changed, 6 deletions(-) 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 From 88d9088afa6e71e434a1c275bbec3fc85232a0cd Mon Sep 17 00:00:00 2001 From: MrSterner <32911664+mrsterner@users.noreply.github.com> Date: Wed, 27 Mar 2024 12:29:55 +0100 Subject: [PATCH 397/437] updated create to patch f (#776) --- .../valkyrienskies-common.mixins.json | 1 - .../client}/MixinTrackBlockOutline.java | 2 +- .../valkyrienskies-fabric.mixins.json | 1 + forge/gradle.properties | 2 +- .../create/client/MixinTrackBlockOutline.java | 127 ++++++++++++++++++ .../valkyrienskies-forge.mixins.json | 3 +- gradle.properties | 2 +- 7 files changed, 133 insertions(+), 5 deletions(-) rename {common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/client/trackOutlines => fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/client}/MixinTrackBlockOutline.java (98%) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinTrackBlockOutline.java diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 569f9e31a..68f271368 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.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.flywheel.InstancingEngineAccessor", "mod_compat.flywheel.MixinBlockEntityInstanceManager", 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/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/MixinTrackBlockOutline.java index 83141fca5..b5700a44b 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/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; 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 2cbfecb71..f94fba472 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -11,6 +11,7 @@ "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", "compat.create.MixinControlledContraptionEntity", + "compat.create.client.MixinTrackBlockOutline", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", "world.level.block.FireMixin" diff --git a/forge/gradle.properties b/forge/gradle.properties index 56f246d1f..897fc4466 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 +create_version=0.5.1.f-345 flywheel_version=0.6.10-105 registrate_version=MC1.18.2-1.1.3 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..ee8ccdd53 --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinTrackBlockOutline.java @@ -0,0 +1,127 @@ +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.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.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.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", 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(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 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 66795029a..4226ee8ae 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -28,7 +28,8 @@ "compat.create.client.MixinSuperGlueSelectionHandler", "compat.sodium.MixinRenderSectionManager", "compat.tis3d.MixinCasingTileEntityRender", - "compat.tis3d.MixinRenderContextImpl" + "compat.tis3d.MixinRenderContextImpl", + "compat.create.client.MixinTrackBlockOutline" ], "injectors": { "defaultRequire": 1 diff --git a/gradle.properties b/gradle.properties index 445da381d..d62d57b88 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ 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 +create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 vs_core_version=1.1.0+e26d9059c0 From daecb53270752e30f80ec2214a8f4f6f69e338e3 Mon Sep 17 00:00:00 2001 From: MrSterner <32911664+mrsterner@users.noreply.github.com> Date: Thu, 28 Mar 2024 14:40:43 +0100 Subject: [PATCH 398/437] Create build.yml --- .github/workflows/build.yml | 40 +++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..e2fa68a81 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,40 @@ +# Automatically build the project and run any configured tests for every push +# and submitted pull request. This can help catch issues that only occur on +# certain platforms or Java versions, and provides a first line of defence +# against bad commits. + +name: build +on: [pull_request, push] + +jobs: + build: + strategy: + matrix: + # Use these Java versions + java: [ + 17, # Current Java LTS & minimum supported by Minecraft + ] + # and run on both Linux and Windows + os: [ubuntu-22.04, windows-2022] + runs-on: ${{ matrix.os }} + steps: + - name: checkout repository + uses: actions/checkout@v3 + - name: validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: setup jdk ${{ matrix.java }} + uses: actions/setup-java@v3 + with: + java-version: ${{ matrix.java }} + distribution: 'microsoft' + - name: make gradle wrapper executable + if: ${{ runner.os != 'Windows' }} + run: chmod +x ./gradlew + - name: build + run: ./gradlew build + - name: capture build artifacts + if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS + uses: actions/upload-artifact@v3 + with: + name: Artifacts + path: build/libs/ From 48a563f99136da8b0448000f42be95dd9d5a2cf5 Mon Sep 17 00:00:00 2001 From: mrsterner <simon@sterner.dev> Date: Tue, 16 Apr 2024 00:27:40 +0200 Subject: [PATCH 399/437] fixed chute mixin --- .../valkyrienskies-common.mixins.json | 1 - .../compat/create}/MixinChuteBlockEntity.java | 18 +++--- .../valkyrienskies-fabric.mixins.json | 1 + forge/build.gradle | 3 +- .../compat/create/MixinChuteBlockEntity.java | 63 +++++++++++++++++++ .../valkyrienskies-forge.mixins.json | 5 +- 6 files changed, 79 insertions(+), 12 deletions(-) rename {common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity => fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create}/MixinChuteBlockEntity.java (85%) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/MixinChuteBlockEntity.java diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 328fe8370..c6d6570d4 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -75,7 +75,6 @@ "mod_compat.create.block.MixinRedstoneContactBlock", "mod_compat.create.block.MixinStickerBlock", "mod_compat.create.blockentity.IMixinMechanicalBearingTileEntity", - "mod_compat.create.blockentity.MixinChuteBlockEntity", "mod_compat.create.blockentity.MixinCrushingWheelControllerTileEntity", "mod_compat.create.blockentity.MixinEjectorTileEntity", "mod_compat.create.blockentity.MixinEncasedFanTileEntity", diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinChuteBlockEntity.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinChuteBlockEntity.java similarity index 85% rename from common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinChuteBlockEntity.java rename to fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinChuteBlockEntity.java index 10ed17e72..75dc5f991 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/blockentity/MixinChuteBlockEntity.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/compat/create/MixinChuteBlockEntity.java @@ -1,5 +1,6 @@ -package org.valkyrienskies.mod.mixin.mod_compat.create.blockentity; +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; @@ -13,20 +14,21 @@ 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.spongepowered.asm.mixin.injection.callback.LocalCapture; import org.valkyrienskies.core.api.ships.ServerShip; import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.mixin.mod_compat.create.accessors.ChuteBlockEntityAccessor; -@Mixin(ChuteBlockEntity.class) +@Mixin(value = ChuteBlockEntity.class, remap = false) public class MixinChuteBlockEntity { - @Inject(method = "findEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;<init>(Lnet/minecraft/world/phys/Vec3;Lnet/minecraft/world/phys/Vec3;)V", shift = Shift.AFTER), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, remap = false) - private void preFindEntities(float itemSpeed, CallbackInfo ci, Vec3 center) { - if (((ChuteBlockEntity) (Object) this).getLevel() != null) { - final ChuteBlockEntity be = (ChuteBlockEntity) (Object) this; + @Inject(method = "findEntities", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/phys/AABB;<init>(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 = ((ChuteBlockEntity) (Object) this).getLevel(); + Level level = be.getLevel(); BlockPos pos = be.getBlockPos(); diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 2cbfecb71..cf6e1702e 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -10,6 +10,7 @@ "compat.cc_restitched.MixinWirelessNetwork", "compat.create.MixinBlockBreakingKineticTileEntity", "compat.create.MixinBlocks", + "compat.create.MixinChuteBlockEntity", "compat.create.MixinControlledContraptionEntity", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", diff --git a/forge/build.gradle b/forge/build.gradle index 21f7d0fe4..e932fbda1 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -51,7 +51,8 @@ configurations { } dependencies { - include(forgeRuntimeLibrary(annotationProcessor(implementation("com.github.LlamaLad7:MixinExtras:0.1.1")))) + compileOnly(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}" 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;<init>(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/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index 66795029a..c6e1b7e68 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -10,13 +10,14 @@ "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.MixinContainerModularRouter", - "compat.mekanism.MixinRadiationManager", "feature.forge_interact.MixinIForgePlayer", "world.level.block.FireMixin" ], From 62ca22c658062d5bb050f44a09948c8d692b49ab Mon Sep 17 00:00:00 2001 From: mrsterner <simon@sterner.dev> Date: Tue, 16 Apr 2024 00:29:54 +0200 Subject: [PATCH 400/437] fixed chute mixin --- .github/workflows/build.yml | 40 ------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index e2fa68a81..000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,40 +0,0 @@ -# Automatically build the project and run any configured tests for every push -# and submitted pull request. This can help catch issues that only occur on -# certain platforms or Java versions, and provides a first line of defence -# against bad commits. - -name: build -on: [pull_request, push] - -jobs: - build: - strategy: - matrix: - # Use these Java versions - java: [ - 17, # Current Java LTS & minimum supported by Minecraft - ] - # and run on both Linux and Windows - os: [ubuntu-22.04, windows-2022] - runs-on: ${{ matrix.os }} - steps: - - name: checkout repository - uses: actions/checkout@v3 - - name: validate gradle wrapper - uses: gradle/wrapper-validation-action@v1 - - name: setup jdk ${{ matrix.java }} - uses: actions/setup-java@v3 - with: - java-version: ${{ matrix.java }} - distribution: 'microsoft' - - name: make gradle wrapper executable - if: ${{ runner.os != 'Windows' }} - run: chmod +x ./gradlew - - name: build - run: ./gradlew build - - name: capture build artifacts - if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS - uses: actions/upload-artifact@v3 - with: - name: Artifacts - path: build/libs/ From b2211ee382f2214b2733ace1179696a1151702a5 Mon Sep 17 00:00:00 2001 From: Merhaf <54317788+Merhaf@users.noreply.github.com> Date: Fri, 3 May 2024 08:59:03 +0900 Subject: [PATCH 401/437] Create ko_kr.json (#827) Korean localization add --- .../assets/valkyrienskies/lang/ko_kr.json | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 common/src/main/resources/assets/valkyrienskies/lang/ko_kr.json 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" +} From 3b5aedd4dd27deb244b6053663c1c2fefaf4feee Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 23 Jun 2024 12:14:10 -0400 Subject: [PATCH 402/437] update vscore, remove old splitting code, add new assembly --- .../mixin/server/world/MixinServerLevel.java | 21 --- .../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/assembly/SubShipAssembly.kt | 140 ----------------- gradle.properties | 2 +- 7 files changed, 278 insertions(+), 250 deletions(-) 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 delete mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SubShipAssembly.kt 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 c98ced9b7..20bf2a70d 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 @@ -7,7 +7,6 @@ import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; import java.util.ArrayList; import java.util.HashMap; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -48,13 +47,10 @@ import org.valkyrienskies.core.api.ships.LoadedServerShip; import org.valkyrienskies.core.api.ships.Wing; import org.valkyrienskies.core.api.ships.WingManager; -import org.valkyrienskies.core.api.ships.datastructures.ShipConnDataAttachment; import org.valkyrienskies.core.apigame.world.ServerShipWorldCore; import org.valkyrienskies.core.apigame.world.chunks.TerrainUpdate; -import org.valkyrienskies.core.util.datastructures.Breakage; import org.valkyrienskies.mod.common.IShipObjectWorldServerProvider; import org.valkyrienskies.mod.common.VSGameUtilsKt; -import org.valkyrienskies.mod.common.assembly.SubShipAssemblyKt; import org.valkyrienskies.mod.common.block.WingBlock; import org.valkyrienskies.mod.common.util.VSServerLevel; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; @@ -248,23 +244,6 @@ private void postTick(final BooleanSupplier shouldKeepTicking, final CallbackInf voxelShapeUpdates ); - // Process pending ship breakages - for (final LoadedServerShip loadedShip : shipObjectWorld.getLoadedShips()) { - if (loadedShip.getAttachment(ShipConnDataAttachment.class) instanceof ShipConnDataAttachment) { - ShipConnDataAttachment connData = loadedShip.getAttachment(ShipConnDataAttachment.class); - assert connData != null; - HashSet<Object> shipBreakages = (HashSet<Object>) connData.getBreakages(); - Iterator<Object> breakageIterator = shipBreakages.iterator(); - - while (breakageIterator.hasNext()) { - Object breakage = breakageIterator.next(); - if (breakage instanceof Breakage breaking) { - SubShipAssemblyKt.splitShip(VectorConversionsMCKt.toBlockPos(breaking.component1()), breaking.component2(), self, loadedShip); - breakageIterator.remove(); - } - } - } - } } @Override 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<Block?>(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<BlockPos>, 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<ChunkPos, Pair<ChunkPos, ChunkPos>>() - 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<BlockPos> = 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/assembly/SubShipAssembly.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SubShipAssembly.kt deleted file mode 100644 index ff859a5c1..000000000 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/SubShipAssembly.kt +++ /dev/null @@ -1,140 +0,0 @@ -package org.valkyrienskies.mod.common.assembly - -import net.minecraft.core.BlockPos -import net.minecraft.server.level.ServerLevel -import net.minecraft.world.level.ChunkPos -import org.joml.Vector3d -import org.joml.Vector3dc -import org.valkyrienskies.core.api.ships.ServerShip -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.core.util.x -import org.valkyrienskies.mod.common.dimensionId -import org.valkyrienskies.mod.common.executeIf -import org.valkyrienskies.mod.common.hooks.VSGameEvents -import org.valkyrienskies.mod.common.isTickingChunk -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.settings -import org.valkyrienskies.mod.common.util.toJOML -import org.valkyrienskies.mod.common.util.toJOMLD -import org.valkyrienskies.mod.util.relocateBlock -import org.valkyrienskies.mod.util.updateBlock - -fun splitShip(centerBlock: BlockPos, blocks: DenseBlockPosSet, level: ServerLevel, originalShip: ServerShip): 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<ChunkPos, Pair<ChunkPos, ChunkPos>>() - 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 shipChunkXUpdated = ship.chunkClaim.xMiddle - val shipChunkZUpdated = ship.chunkClaim.zMiddle - - val centerPosCentered = centerBlock.toJOMLD().add(0.5, 0.5, 0.5) - - val centerInShipUpdated: Vector3dc = Vector3d( - ((shipChunkXUpdated shl 4) + (centerBlock.x and 15).toDouble()), - centerBlock.y.toDouble(), - (shipChunkZUpdated shl 4) + (centerBlock.z and 15).toDouble() - ) - - val scaling = ship.transform.shipToWorldScaling - val offset: Vector3dc = - ship.inertiaData.centerOfMassInShip.sub(centerInShipUpdated, Vector3d()) - - val posInWorld = originalShip.transform.shipToWorld.transformPosition(centerPosCentered.add(offset, Vector3d()), Vector3d()) - val rotInWorld = originalShip.transform.shipToWorldRotation - val velVec = Vector3d(originalShip.velocity) - val omegaVec = Vector3d(originalShip.omega) - - val newShipTransform = ShipTransformImpl(posInWorld, ship.inertiaData.centerOfMassInShip, rotInWorld, scaling) - - ship.transform = newShipTransform - ship.physicsData.linearVelocity = velVec - ship.physicsData.angularVelocity = omegaVec - - val event = VSGameEvents.ShipSplitEvent(originalShip.id, ship.id, blocks) - VSGameEvents.shipSplit.emit(event) - - return ship -} diff --git a/gradle.properties b/gradle.properties index d62d57b88..331a677d1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -vs_core_version=1.1.0+e26d9059c0 +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 82ad879474b5759ce3ea92d7724f93d2735c1647 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Thu, 27 Jun 2024 13:52:48 -0400 Subject: [PATCH 403/437] uhh more stuff i forgot to commit --- common/build.gradle | 2 + .../mixin/server/MixinMinecraftServer.java | 20 +- .../mod/common/BlockStateInfoProvider.kt | 9 - .../common/DefaultBlockStateInfoProvider.kt | 26 +- .../mod/common/config/VSMassDataLoader.kt | 290 +++++++----------- .../mod/common/hooks/VSGameEvents.kt | 2 +- .../mod/compat/clothconfig/VSClothConfig.kt | 6 +- fabric/build.gradle | 8 + .../fabric/compat/modmenu/ValkyrienModMenu.kt | 7 +- .../forge/common/ValkyrienSkiesModForge.kt | 7 +- 10 files changed, 144 insertions(+), 233 deletions(-) diff --git a/common/build.gradle b/common/build.gradle index 4b0d5a6b3..2de1338c5 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 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..1e79554e9 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 @@ -124,6 +124,14 @@ public VSPipeline getVsPipeline() { ) ) private void postCreateLevels(final CallbackInfo ci) { + // Register blocks + if (!MassDatapackResolver.INSTANCE.getRegisteredBlocks()) { + final List<BlockState> 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 +148,6 @@ private void postCreateLevels(final CallbackInfo ci) { // Create ship world and VS Pipeline vsPipeline = shipSavedData.getPipeline(); - // Register blocks - if (!MassDatapackResolver.INSTANCE.getRegisteredBlocks()) { - final List<BlockState> 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/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<Lod1SolidBlockState> - val liquidBlockStates: List<Lod1LiquidBlockState> - val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> } 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 e408f6cf6..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,36 +1,26 @@ 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<Lod1SolidBlockState> - get() = TODO() - override val liquidBlockStates: List<Lod1LiquidBlockState> - get() = TODO() - override val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> - get() = TODO() override fun getBlockStateMass(blockState: BlockState): Double { if (blockState.isAir) return 0.0 - // By default make blocks weight 100 kg - return 100.0 + // By default make blocks weight 1000 kg + return 1000.0 } 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.noCollision + 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/config/VSMassDataLoader.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/config/VSMassDataLoader.kt index ccadba0f1..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 @@ -18,12 +18,16 @@ 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.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 @@ -31,18 +35,7 @@ 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<ResourceLocation, VSBlockStateInfo>() - private val _solidBlockStates: MutableList<Lod1SolidBlockState> = ArrayList() - private val _liquidBlockStates: MutableList<Lod1LiquidBlockState> = ArrayList() - private val _blockStateData: MutableList<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> = ArrayList() - private val blockStateToId: MutableMap<BlockState, BlockType> = HashMap() + private val mcBlockStateToVs: MutableMap<BlockState, VsBlockState> = HashMap() + + val blockStateData: Collection<VsBlockState> = 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<Lod1SolidBlockState> - get() = _solidBlockStates - override val liquidBlockStates: List<Lod1LiquidBlockState> - get() = _liquidBlockStates - override val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> - get() = _blockStateData - class VSMassDataLoader : SimpleJsonResourceReloadListener(Gson(), "vs_mass") { private val tags = mutableListOf<VSBlockStateInfo>() @@ -180,38 +167,38 @@ object MassDatapackResolver : BlockStateInfoProvider { } - private fun generateStairCollisionShapes(stairShapes: Array<VoxelShape>): Map<VoxelShape, Lod1SolidCollisionShape> { + private fun generateStairCollisionShapes(stairShapes: Array<VoxelShape>): Map<VoxelShape, SolidBlockShape> { 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<VoxelShape, Lod1SolidCollisionShape> = HashMap() + val map: MutableMap<VoxelShape, SolidBlockShape> = HashMap() stairShapes.forEach { stairShape -> val points: MutableList<CollisionPoint> = ArrayList() - val positiveBoxes: MutableList<LodBlockBoundingBox> = ArrayList() - val negativeBoxes: MutableList<LodBlockBoundingBox> = ArrayList() + val positiveBoxes: MutableList<AABBic> = ArrayList() + val negativeBoxes: MutableList<AABBic> = 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 @@ -223,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<LodBlockBoundingBox>() + private fun generateShapeFromVoxel(voxelShape: VoxelShape): BoxesBlockShape? { + val posBoxes = ArrayList<AABBic>() 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) { @@ -278,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<BlockState>) { - 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 { @@ -359,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<VoxelShape, Lod1SolidCollisionShape?>() - 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<VoxelShape, SolidBlockShape?>() + 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<FluidState, Pair<Lod1LiquidBlockStateId, BlockType>>() + val fluidStateToBlockTypeMap = HashMap<FluidState, LiquidState>() // Get the id of the fluid state/create a new fluid state if necessary - fun getFluidState(fluidState: FluidState): Pair<Lod1LiquidBlockStateId, BlockType> { + // 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) { @@ -424,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/hooks/VSGameEvents.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/VSGameEvents.kt index ae181f6dd..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 @@ -8,7 +8,7 @@ import net.minecraft.client.renderer.LevelRenderer.RenderChunkInfo import net.minecraft.client.renderer.RenderType import org.valkyrienskies.core.api.ships.ClientShip import org.valkyrienskies.core.api.ships.properties.ShipId -import org.valkyrienskies.core.impl.util.events.EventEmitterImpl +import org.valkyrienskies.core.util.events.EventEmitterImpl import org.valkyrienskies.core.util.datastructures.DenseBlockPosSet object VSGameEvents { 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..ead7d3c3b 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 @@ -17,14 +17,16 @@ 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 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 diff --git a/fabric/build.gradle b/fabric/build.gradle index 06289659f..1a08cab74 100644 --- a/fabric/build.gradle +++ b/fabric/build.gradle @@ -58,8 +58,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 Restitched modImplementation("curse.maven:cc-restitched-462672:3838648") 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/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ValkyrienSkiesModForge.kt b/forge/src/main/kotlin/org/valkyrienskies/mod/forge/common/ValkyrienSkiesModForge.kt index 9591baa35..b72fa2397 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 @@ -27,8 +27,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 @@ -103,8 +102,8 @@ class ValkyrienSkiesModForge { ConfigGuiFactory { _, parent -> VSClothConfig.createConfigScreenFor( parent, - VSConfigClass.getRegisteredConfig(VSCoreConfig::class.java), - VSConfigClass.getRegisteredConfig(VSGameConfig::class.java) + VSCoreConfig::class.java, + VSGameConfig::class.java ) } } From 41ac19566b03df859df31829f1e30338fb417771 Mon Sep 17 00:00:00 2001 From: FlamingAssembler <34496536+Endalion@users.noreply.github.com> Date: Sat, 29 Jun 2024 12:35:08 +0800 Subject: [PATCH 404/437] Fix Create, CBC contraption seats (#847) --- .../entity/MixinAbstractContraptionEntity.java | 16 +++++++++++++++- .../MixinPitchOrientedContraptionEntity.java | 9 +++++++++ 2 files changed, 24 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 da842738a..fed9b0f39 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 @@ -27,6 +27,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; @@ -43,10 +44,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; @@ -54,7 +58,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); @@ -81,6 +85,16 @@ public MixinAbstractContraptionEntity(EntityType<?> entityType, Level level) { @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<Vec3> cir) { + if (VSGameUtilsKt.getShipObjectManagingPos(passenger.level, toJOML(this.position())) != null) { + cir.setReturnValue(cir.getReturnValue().add(0,0.1,0)); + } + } } From ddedf39b98ce10fc358512fb8e0614a86031f68c Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Jun 2024 12:14:48 -0400 Subject: [PATCH 405/437] update vscore --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 331a677d1..69aa35fce 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -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 ea52cedb6557d96ec3f190e23a12a08024fe4147 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Jun 2024 12:46:44 -0400 Subject: [PATCH 406/437] ACTUALLY update vscore --- .../kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt | 5 ++--- .../org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt | 5 +---- .../mod/common/entity/ShipMountingEntity.kt | 6 ++++-- .../valkyrienskies/mod/common/entity/VSPhysicsEntity.kt | 5 ++--- .../mod/common/entity/handling/VSEntityManager.kt | 7 ++++--- .../valkyrienskies/mod/common/networking/VSGamePackets.kt | 8 +++----- .../mod/common/util/EntityShipCollisionUtils.kt | 3 +-- gradle.properties | 2 +- 8 files changed, 18 insertions(+), 23 deletions(-) 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..d917c4797 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt @@ -208,7 +208,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 +393,7 @@ fun Level?.getWorldCoordinates(blockPos: BlockPos, pos: Vector3d): Vector3d { } fun Level.getShipsIntersecting(aabb: AABB): Iterable<Ship> = getShipsIntersecting(aabb.toJOML()) -fun Level.getShipsIntersecting(aabb: AABBdc): Iterable<Ship> = allShips.getIntersecting(aabb).filter { it.chunkClaimDimension == dimensionId } - +fun Level.getShipsIntersecting(aabb: AABBdc): Iterable<Ship> = 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 { 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/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<ShipMountingEntity>, level: Level) : Entity(type, level) { // Decides if this entity controls the ship it is in. @@ -96,7 +96,9 @@ open class ShipMountingEntity(type: EntityType<ShipMountingEntity>, 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<VSPhysicsEntity>, level: Level) : En } val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY) val oldPhysicsEntityData = getMapper().readValue<PhysicsEntityData>(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<VSPhysicsEntity>, 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/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/gradle.properties b/gradle.properties index 69aa35fce..c51b57cb5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -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 242a3393405d4fccdfa14100a4e3ec6a5081ade7 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Jun 2024 12:52:55 -0400 Subject: [PATCH 407/437] these tiny reference changes will be the death of me --- .../org/valkyrienskies/mod/mixin/entity/MixinEntity.java | 5 ++--- 1 file changed, 2 insertions(+), 3 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 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(); } From ae1bd53baa859a66f8c73f6178c3d50985571143 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Jun 2024 12:57:38 -0400 Subject: [PATCH 408/437] pain --- .../mixin/compat/create/client/MixinTrackBlockOutline.java | 6 +++--- .../mixin/compat/create/client/MixinTrackBlockOutline.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) 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 b5700a44b..3e6283e6d 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 @@ -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); 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 ee8ccdd53..cd74e4391 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 @@ -23,8 +23,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; @@ -54,8 +54,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); From f6732112b38921dc1ef7afa229d63dd4727c9d88 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Jun 2024 12:58:53 -0400 Subject: [PATCH 409/437] fix: All of the references to renamed or relocated vscore classes --- .../mixin/compat/create/client/MixinTrackBlockOutline.java | 4 ++-- .../mixin/compat/create/client/MixinTrackBlockOutline.java | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) 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 3e6283e6d..535f54ba1 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 @@ -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/MixinTrackBlockOutline.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/create/client/MixinTrackBlockOutline.java index cd74e4391..599b00336 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 @@ -6,7 +6,6 @@ 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; @@ -110,8 +109,8 @@ private static void harvest(DrawSelectionEvent.HighlightBlock event, CallbackInf 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, From 2ef6f721a6d515e225cf7ad850dd7e32d2b66c53 Mon Sep 17 00:00:00 2001 From: Potato <77798144+ThePlasticPotato@users.noreply.github.com> Date: Sun, 30 Jun 2024 13:23:39 -0400 Subject: [PATCH 410/437] backporting api stuff more --- .../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/compat/clothconfig/VSClothConfig.kt | 6 +- 7 files changed, 176 insertions(+), 3 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/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<RegisterBlockStateEvent> + + @get:Experimental + val preRenderShipEvent: ListenableEvent<PreRenderShipEvent> + + @get:Experimental + val postRenderShipEvent: ListenableEvent<PostRenderShipEvent> + + 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<Pair<BlockState, VsBlockState>>() + + 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<RegisterBlockStateEvent>() + override val preRenderShipEvent = EventEmitterImpl<PreRenderShipEvent>() + override val postRenderShipEvent = EventEmitterImpl<PostRenderShipEvent>() + + 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/compat/clothconfig/VSClothConfig.kt b/common/src/main/kotlin/org/valkyrienskies/mod/compat/clothconfig/VSClothConfig.kt index ead7d3c3b..9bbe733a6 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 @@ -19,7 +19,6 @@ import org.apache.commons.lang3.StringUtils import org.valkyrienskies.core.impl.config.SidedVSConfigClass import org.valkyrienskies.core.impl.util.serialization.VSJacksonUtil import org.valkyrienskies.mod.common.vsCore - import java.util.Optional object VSClothConfig { @@ -27,6 +26,7 @@ object VSClothConfig { @JvmStatic fun createConfigScreenFor(parent: Screen, vararg configClassesJ: Class<*>): Screen { val configClasses = configClassesJ.map(vsCore::getRegisteredConfigLegacy) + return ConfigBuilder.create().apply { parentScreen = parent @@ -111,7 +111,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" -> { @@ -243,7 +243,7 @@ object VSClothConfig { val newValue = try { mapper.readTree(str) } catch (ex: JsonProcessingException) { - return@setErrorSupplier Optional.of(TextComponent(ex.message)) + return@setErrorSupplier Optional.of(TextComponent(ex.message ?: "")) } getValidationMessageComponent(newValue) From 1c62cccd2dd52dcd1daf998a3f8bc7ae5d5458b8 Mon Sep 17 00:00:00 2001 From: xiewuzhiying <92735961+xiewuzhiying@users.noreply.github.com> Date: Sun, 21 Jul 2024 09:09:50 +0800 Subject: [PATCH 411/437] Fix Computer Craft speaker (#889) * speaker sound fix * readme * em --- .../cc_restitched/MixinSpeakerPosition.java | 48 -------------- .../cc_restitched/MixinSpeakerSound.java | 64 +++++++++++++++++++ .../mixin/compat/cc_restitched/README.MD | 2 +- .../valkyrienskies-fabric.mixins.json | 2 +- .../cc_tweaked/MixinSpeakerPosition.java | 47 -------------- .../compat/cc_tweaked/MixinSpeakerSound.java | 64 +++++++++++++++++++ .../forge/mixin/compat/cc_tweaked/README.MD | 2 +- .../valkyrienskies-forge.mixins.json | 6 +- 8 files changed, 134 insertions(+), 101 deletions(-) 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 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 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<Vec3> 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/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index a4cadc46b..8a8fdc95e 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -4,7 +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", @@ -18,6 +17,7 @@ "world.level.block.FireMixin" ], "client": [ + "compat.cc_restitched.MixinSpeakerSound", "compat.create.client.MixinContraptionHandlerClient", "compat.create.client.MixinContraptionRenderInfo", "compat.create.client.MixinCullingBlockEntityIterator", 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<Vec3> 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/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index a2b9f0e36..a09fd8411 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -4,7 +4,6 @@ "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", @@ -23,14 +22,15 @@ ], "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", - "compat.create.client.MixinTrackBlockOutline" + "compat.tis3d.MixinRenderContextImpl" ], "injectors": { "defaultRequire": 1 From e8120aecee64ed3295ca5dc9fa6fbe26fa27760b Mon Sep 17 00:00:00 2001 From: ByThePowerOfScience <16433721+ByThePowerOfScience@users.noreply.github.com> Date: Sun, 21 Jul 2024 05:29:59 -0400 Subject: [PATCH 412/437] Minor fix, Urgent: Fix soft-overwrite preventing other mods' mobs from despawning with special conditions. (#907) * Update MixinPersistentEntitySectionManager.java Replace soft-overwrite Inject with compatible ModifyArg so we don't stop every other mob from despawning if we encounter an error. * Update MixinPersistentEntitySectionManager.java Rename method --- .../MixinPersistentEntitySectionManager.java | 38 +++++++++---------- 1 file changed, 18 insertions(+), 20 deletions(-) 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 index 0f7068745..e4adb38f4 100644 --- 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 @@ -3,6 +3,7 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; +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; @@ -53,24 +54,21 @@ private boolean processChunkUnload(final long l) { /** * 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(); - } + @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(LongPredicate par1) { + return (l) -> { + try { + return par1.test(l); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + }; + } } From 2d456ca5dbaa32acd4a143119c369a8a608c7b3b Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Sun, 21 Jul 2024 03:00:51 -0700 Subject: [PATCH 413/437] =?UTF-8?q?Revert=20"Minor=20fix,=20Urgent:=20Fix?= =?UTF-8?q?=20soft-overwrite=20preventing=20other=20mods'=20mobs=20fro?= =?UTF-8?q?=E2=80=A6"=20(#911)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e8120aecee64ed3295ca5dc9fa6fbe26fa27760b. --- .../MixinPersistentEntitySectionManager.java | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) 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 index e4adb38f4..0f7068745 100644 --- 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 @@ -3,7 +3,6 @@ import it.unimi.dsi.fastutil.longs.Long2ObjectMap; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; -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; @@ -54,21 +53,24 @@ private boolean processChunkUnload(final long l) { /** * 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(LongPredicate par1) { - return (l) -> { - try { - return par1.test(l); - } catch (Exception e) { - e.printStackTrace(); - return false; - } - }; - } + @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(); + } } From dcba513e6d0e8a49903a1b0be5dfb6baedb321f7 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 21 Jul 2024 12:35:04 -0700 Subject: [PATCH 414/437] Fixed PR #907 --- .../MixinPersistentEntitySectionManager.java | 58 ++++++------------- 1 file changed, 19 insertions(+), 39 deletions(-) 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 index 0f7068745..b0fca76da 100644 --- 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 @@ -1,20 +1,15 @@ 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.spongepowered.asm.mixin.injection.ModifyArg; import org.valkyrienskies.mod.mixinducks.world.OfLevel; @Mixin(PersistentEntitySectionManager.class) @@ -24,53 +19,38 @@ public abstract class MixinPersistentEntitySectionManager implements OfLevel { EntitySectionStorage<Entity> sectionStorage; @Unique - private Level level; + private Level valkyrienskies$level; @Override public Level getLevel() { - return level; + return valkyrienskies$level; } @Override public void setLevel(final Level level) { - this.level = level; + this.valkyrienskies$level = level; ((OfLevel) this.sectionStorage).setLevel(level); } - @Shadow - @Final - private LongSet chunksToUnload; - - @Shadow - @Final - private Long2ObjectMap<Visibility> 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 + @ModifyArg( + method = "processUnloads", + at = @At( + target = "Lit/unimi/dsi/fastutil/longs/LongSet;removeIf(Ljava/uti l/function/LongPredicate;)Z", + value = "INVOKE" + ) ) - 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); - } + private java.util.function.LongPredicate processUnloads_catchException( + final java.util.function.LongPredicate par1) { + return (l) -> { + try { + return par1.test(l); + } catch (final Exception e) { + e.printStackTrace(); + return false; } - chunksToUnload.removeAll(toRemove); - } catch (final Exception e) { - e.printStackTrace(); - } - ci.cancel(); + }; } } From 1681692eafe255b27c4dd57cde78ee9a100ec289 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sun, 21 Jul 2024 16:29:42 -0700 Subject: [PATCH 415/437] Fixed forge server --- .../valkyrienskies-common.mixins.json | 1 - .../MixinPersistentEntitySectionManager.java | 8 ++- .../valkyrienskies-fabric.mixins.json | 1 + .../MixinPersistentEntitySectionManager.java | 58 +++++++++++++++++++ .../valkyrienskies-forge.mixins.json | 1 + 5 files changed, 65 insertions(+), 4 deletions(-) rename {common/src/main/java/org/valkyrienskies/mod => fabric/src/main/java/org/valkyrienskies/mod/fabric}/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java (88%) create mode 100644 forge/src/main/java/org/valkyrienskies/mod/forge/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 43e69db8f..3260c9970 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -44,7 +44,6 @@ "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", diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java similarity index 88% rename from common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java rename to fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java index b0fca76da..3a98256bb 100644 --- a/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java +++ b/fabric/src/main/java/org/valkyrienskies/mod/fabric/mixin/feature/shipyard_entities/MixinPersistentEntitySectionManager.java @@ -1,5 +1,6 @@ -package org.valkyrienskies.mod.mixin.feature.shipyard_entities; +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; @@ -42,8 +43,9 @@ public void setLevel(final Level level) { value = "INVOKE" ) ) - private java.util.function.LongPredicate processUnloads_catchException( - final java.util.function.LongPredicate par1) { + private LongPredicate processUnloads_catchException( + final LongPredicate par1 + ) { return (l) -> { try { return par1.test(l); diff --git a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json index 8a8fdc95e..19ec9ef6f 100644 --- a/fabric/src/main/resources/valkyrienskies-fabric.mixins.json +++ b/fabric/src/main/resources/valkyrienskies-fabric.mixins.json @@ -14,6 +14,7 @@ "compat.create.client.MixinTrackBlockOutline", "compat.sodium.MixinRenderSectionManager", "feature.explosions.ClipContextMixin", + "feature.shipyard_entities.MixinPersistentEntitySectionManager", "world.level.block.FireMixin" ], "client": [ 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<Entity> 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/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index a09fd8411..76bf8fb5d 100644 --- a/forge/src/main/resources/valkyrienskies-forge.mixins.json +++ b/forge/src/main/resources/valkyrienskies-forge.mixins.json @@ -18,6 +18,7 @@ "compat.thermalexpansion.MixinTileCoFH", "compat.tis3d.MixinInfraredPacketEntity", "feature.forge_interact.MixinIForgePlayer", + "feature.shipyard_entities.MixinPersistentEntitySectionManager", "world.level.block.FireMixin" ], "client": [ From 6809a8037648a2082d697c3a6615a823cf8aa041 Mon Sep 17 00:00:00 2001 From: alex_s168 <63254202+alex-s168@users.noreply.github.com> Date: Fri, 26 Jul 2024 04:02:14 +0000 Subject: [PATCH 416/437] Weather 2 wind & storm affecting ships (#897) * weather 2 interop * move check --- common/build.gradle | 3 + .../mixin/server/MixinMinecraftServer.java | 4 + .../mod/common/config/VSGameConfig.kt | 24 ++++++ .../valkyrienskies/mod/compat/LoadedMods.kt | 3 + .../mod/compat/Weather2Compat.kt | 73 +++++++++++++++++++ forge/build.gradle | 4 + 6 files changed, 111 insertions(+) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/compat/Weather2Compat.kt diff --git a/common/build.gradle b/common/build.gradle index 2de1338c5..5978178a5 100644 --- a/common/build.gradle +++ b/common/build.gradle @@ -26,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}") 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 1e79554e9..1b1af8967 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,6 +62,8 @@ 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; @Mixin(MinecraftServer.class) @@ -229,6 +231,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/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/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<Any?, Boolean> { 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<GameTickForceApplier>()!! + + 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/forge/build.gradle b/forge/build.gradle index e932fbda1..f108a0c17 100644 --- a/forge/build.gradle +++ b/forge/build.gradle @@ -71,6 +71,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:5008370") + // CC Tweaked modCompileOnly("curse.maven:cc-tweaked-282001:4061947") From 9ec9b1cb98305c10f1d82e21dc1ade4ae23649cd Mon Sep 17 00:00:00 2001 From: ByThePowerOfScience <16433721+ByThePowerOfScience@users.noreply.github.com> Date: Sun, 28 Jul 2024 05:27:59 -0400 Subject: [PATCH 417/437] Stop Flywheel BatchingEngine crash (#893) Check if Flywheel is using the instancing engine before asserting that it is. --- .../mod_compat/flywheel/MixinBlockEntityInstanceManager.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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<Instance> 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<In vs$shipMaterialManagers.computeIfAbsent(ship, k -> 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)); } From eac19c84e2fe89f73e277e1383f3c164c7433829 Mon Sep 17 00:00:00 2001 From: FlamingAssembler <34496536+Endalion@users.noreply.github.com> Date: Thu, 8 Aug 2024 14:12:22 +0800 Subject: [PATCH 418/437] Fix Create Schematic placement, rendering on ships (#690) * initial ugly schematic mixins * added javadoc descriptions for the mixins * Fix the other operations and clean up 6 months is a long time huh --------- Co-authored-by: ewoudje <7384674+ewoudje@users.noreply.github.com> --- .../create/client/MixinDeployTool.java | 67 ++++++++++++++++++ .../create/client/MixinSchematicToolBase.java | 70 +++++++++++++++++++ .../client/MixinSchematicTransformation.java | 57 +++++++++++++++ .../valkyrienskies-common.mixins.json | 3 + 4 files changed, 197 insertions(+) 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 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) + * <p> + * 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<Vec3> 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 + * <p> + * 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/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index 3260c9970..152af005d 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -166,6 +166,9 @@ "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.trackOutlines.MixinBigOutlines", "mod_compat.create.client.MixinValueBox", "mod_compat.flywheel.InstancingEngineAccessor", From 968578a4fd3ee750e319ac8d8f85f54d716e8c07 Mon Sep 17 00:00:00 2001 From: StewStrong <83003027+StewStrong@users.noreply.github.com> Date: Mon, 2 Sep 2024 23:47:20 -0700 Subject: [PATCH 419/437] An attempt at fixing thread bugs (#954) --- .../mixin/world/chunk/MixinLevelChunk.java | 6 +++++- .../valkyrienskies/mod/common/VSGameUtils.kt | 20 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) 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<BlockState> 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/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt index d917c4797..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 @@ -408,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<Runnable> = if (!this.isClientSide) { + this.server!! as BlockableEventLoop<Runnable> + } 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) { From 91ec207962e3614f07550229373a10cdb4a28311 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sat, 7 Sep 2024 17:05:40 -0700 Subject: [PATCH 420/437] Only render ship chunk sections in the frustum, skip empty chunk sections --- .../sodium/MixinRenderSectionManager.java | 10 +++++++++ .../MixinLevelRendererVanilla.java | 21 +++++++++++++++++++ 2 files changed, 31 insertions(+) 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 abc72d5f5..2e38db372 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 @@ -27,8 +27,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; @@ -49,6 +52,7 @@ @Mixin(LevelRenderer.class) public abstract class MixinLevelRendererVanilla { + @Unique private final WeakHashMap<ClientShip, ObjectList<RenderChunkInfo>> shipRenderChunks = new WeakHashMap<>(); @Shadow private ClientLevel level; @@ -122,11 +126,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 = @@ -201,6 +221,7 @@ private ObjectArrayList<RenderChunkInfo> redirectRenderChunksInFrustum(final Lev return (ObjectArrayList<RenderChunkInfo>) 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<RenderChunkInfo> chunksToRender) { From 9255e4e0b9f07741fbd4353d08a4a60d6f640341 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sat, 7 Sep 2024 17:15:00 -0700 Subject: [PATCH 421/437] Update core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index c51b57cb5..5baf86046 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -vs_core_version=1.1.0+da86725858 +vs_core_version=1.1.0+b45878303a # 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 eac56407b3e356689565cf1dd3ef88736b82c35b Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Sat, 7 Sep 2024 23:05:15 -0700 Subject: [PATCH 422/437] Update core --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 5baf86046..9a8749045 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -vs_core_version=1.1.0+b45878303a +vs_core_version=1.1.0+04c69b50d2 # 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 be13687497e80201fb1d4c13198a3f005eddb3ee Mon Sep 17 00:00:00 2001 From: MoePus <547007249@qq.com> Date: Mon, 23 Sep 2024 12:29:32 +0800 Subject: [PATCH 423/437] call tryCheckInsideBlocks in redirectSetVelocity (#955) fix #867, #688 --- .../mod/mixin/feature/entity_collision/MixinEntity.java | 5 +++++ 1 file changed, 5 insertions(+) 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..f41afc4dd 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); From 686bd75c6fe996d7c7ec8a0ca33d31a830eb3fc6 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Tue, 24 Sep 2024 04:31:20 -0700 Subject: [PATCH 424/437] Make gravity dimension specific --- .../mod/mixin/server/MixinMinecraftServer.java | 4 +++- .../mod/mixin/server/world/MixinServerLevel.java | 8 ++++++-- .../main/kotlin/org/valkyrienskies/mod/util/McMathUtil.kt | 4 ++++ gradle.properties | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) 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 1b1af8967..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 @@ -65,6 +65,7 @@ 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 { @@ -159,7 +160,8 @@ private void postCreateLevels(final CallbackInfo ci) { getShipObjectWorld().addDimension( VSGameUtilsKt.getDimensionId(overworld()), - VSGameUtilsKt.getYRange(overworld()) + VSGameUtilsKt.getYRange(overworld()), + McMathUtilKt.getDEFAULT_WORLD_GRAVITY() ); } 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 20bf2a70d..af9fa6e19 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 @@ -56,6 +56,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 { @@ -95,8 +96,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() + ); } } 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/gradle.properties b/gradle.properties index 9a8749045..8f0f19c5d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -vs_core_version=1.1.0+04c69b50d2 +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 52443a1e6bd450d5907d3c80e3021d23d2eeb40c Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Tue, 24 Sep 2024 05:08:37 -0700 Subject: [PATCH 425/437] 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<InteractionResult> 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<InteractionResult> cir) { - if (context.getPlayer() == null) { - return; + private BlockState transformPlayerWhenPlacing( + final BlockItem _instance, final BlockPlaceContext _ctx, + final Operation<BlockState> 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<Entity> 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<Visibility> 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<Object> 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) + * <p> + * 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<Vec3> 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 + * <p> + * 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<Vec3> 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<Instance> 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<In vs$shipMaterialManagers.computeIfAbsent(ship, k -> 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<ClientShip, ObjectList<RenderChunkInfo>> 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<RenderChunkInfo> redirectRenderChunksInFrustum(final Lev return (ObjectArrayList<RenderChunkInfo>) 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<RenderChunkInfo> 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<BlockState> 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<BlockState> 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<BlockState> 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<RegisterBlockStateEvent> + + @get:Experimental + val preRenderShipEvent: ListenableEvent<PreRenderShipEvent> + + @get:Experimental + val postRenderShipEvent: ListenableEvent<PostRenderShipEvent> + + 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<Pair<BlockState, VsBlockState>>() + + 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<RegisterBlockStateEvent>() + override val preRenderShipEvent = EventEmitterImpl<PreRenderShipEvent>() + override val postRenderShipEvent = EventEmitterImpl<PostRenderShipEvent>() + + 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<Lod1SolidBlockState> - val liquidBlockStates: List<Lod1LiquidBlockState> - val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> } 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<Lod1SolidBlockState> - get() = TODO() - override val liquidBlockStates: List<Lod1LiquidBlockState> - get() = TODO() - override val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> - 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<Ship> = getShipsIntersecting(aabb.toJOML()) -fun Level.getShipsIntersecting(aabb: AABBdc): Iterable<Ship> = allShips.getIntersecting(aabb).filter { it.chunkClaimDimension == dimensionId } - +fun Level.getShipsIntersecting(aabb: AABBdc): Iterable<Ship> = 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<Runnable> = if (!this.isClientSide) { + this.server!! as BlockableEventLoop<Runnable> + } 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<Block?>(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<BlockPos>, 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<ChunkPos, Pair<ChunkPos, ChunkPos>>() - 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<BlockPos> = 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<ResourceLocation, VSBlockStateInfo>() - private val _solidBlockStates: MutableList<Lod1SolidBlockState> = ArrayList() - private val _liquidBlockStates: MutableList<Lod1LiquidBlockState> = ArrayList() - private val _blockStateData: MutableList<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> = ArrayList() - private val blockStateToId: MutableMap<BlockState, BlockType> = HashMap() + private val mcBlockStateToVs: MutableMap<BlockState, VsBlockState> = HashMap() + + val blockStateData: Collection<VsBlockState> = 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<Lod1SolidBlockState> - get() = _solidBlockStates - override val liquidBlockStates: List<Lod1LiquidBlockState> - get() = _liquidBlockStates - override val blockStateData: List<Triple<Lod1SolidBlockStateId, Lod1LiquidBlockStateId, Lod1BlockStateId>> - get() = _blockStateData - class VSMassDataLoader : SimpleJsonResourceReloadListener(Gson(), "vs_mass") { private val tags = mutableListOf<VSBlockStateInfo>() @@ -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<VoxelShape>): Map<VoxelShape, Lod1SolidCollisionShape> { + fun decideDefaultPriority(resourceLocation: ResourceLocation) = when { + resourceLocation.namespace.equals(ValkyrienSkiesMod.MOD_ID) -> 1000 + resourceLocation.namespace.equals("custom") -> 50 + else -> 100 + } + + + private fun generateStairCollisionShapes(stairShapes: Array<VoxelShape>): Map<VoxelShape, SolidBlockShape> { 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<VoxelShape, Lod1SolidCollisionShape> = HashMap() + val map: MutableMap<VoxelShape, SolidBlockShape> = HashMap() stairShapes.forEach { stairShape -> val points: MutableList<CollisionPoint> = ArrayList() - val positiveBoxes: MutableList<LodBlockBoundingBox> = ArrayList() - val negativeBoxes: MutableList<LodBlockBoundingBox> = ArrayList() + val positiveBoxes: MutableList<AABBic> = ArrayList() + val negativeBoxes: MutableList<AABBic> = 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<LodBlockBoundingBox>() + private fun generateShapeFromVoxel(voxelShape: VoxelShape): BoxesBlockShape? { + val posBoxes = ArrayList<AABBic>() 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<BlockState>) { - 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<VoxelShape, SolidBlockShape?>() + 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<VoxelShape, Lod1SolidCollisionShape?>() - 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<FluidState, Pair<Lod1LiquidBlockStateId, BlockType>>() + val fluidStateToBlockTypeMap = HashMap<FluidState, LiquidState>() // Get the id of the fluid state/create a new fluid state if necessary - fun getFluidState(fluidState: FluidState): Pair<Lod1LiquidBlockStateId, BlockType> { + // 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<ShipMountingEntity>, level: Level) : Entity(type, level) { // Decides if this entity controls the ship it is in. @@ -96,7 +96,9 @@ open class ShipMountingEntity(type: EntityType<ShipMountingEntity>, 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<VSPhysicsEntity>, level: Level) : En } val physicsEntityDataAsBytes: ByteArray = compoundTag.getByteArray(PHYS_DATA_NBT_KEY) val oldPhysicsEntityData = getMapper().readValue<PhysicsEntityData>(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<VSPhysicsEntity>, 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<ShipRenderEvent>() val shipsStartRendering = EventEmitterImpl<ShipStartRenderEvent>() + val shipSplit = EventEmitterImpl<ShipSplitEvent>() + data class ShipStartRenderEvent( val renderer: LevelRenderer, val renderType: RenderType, @@ -35,5 +39,11 @@ object VSGameEvents { val ship: ClientShip, val chunks: ObjectList<RenderChunkInfo> ) + + 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<Any?, Boolean> { 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<GameTickForceApplier>()!! + + 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<Vec3> 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;<init>(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<Boolean> 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<Entity> 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<Vec3> 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;<init>(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<Level> 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<Entity> 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 <stewstronger@gmail.com> Date: Wed, 25 Sep 2024 23:22:44 -0700 Subject: [PATCH 426/437] 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<Boolean> 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<ServerShip> 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 <stewstronger@gmail.com> Date: Wed, 25 Sep 2024 23:46:44 -0700 Subject: [PATCH 427/437] 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 d437831a280f170d81d2dda22a41b17bf5ca23b1 Mon Sep 17 00:00:00 2001 From: theplasticpotato <theplasticpotato@gmail.com> Date: Sat, 19 Oct 2024 13:22:57 -0400 Subject: [PATCH 428/437] Initial --- .../mod/common/BlockStateInfoProvider.kt | 21 +++++++++++++++++++ .../mod/common/assembly/AssemblyUtil.kt | 4 ++-- .../mod/common/assembly/ShipAssembler.kt | 2 +- .../mod/common/assembly/ShipAssembly.kt | 17 +-------------- gradle.properties | 2 +- 5 files changed, 26 insertions(+), 20 deletions(-) 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 129d47e3a..dd5384c63 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -3,6 +3,7 @@ package org.valkyrienskies.mod.common import com.mojang.serialization.Lifecycle import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.core.BlockPos +import net.minecraft.core.Direction import net.minecraft.core.MappedRegistry import net.minecraft.core.Registry import net.minecraft.resources.ResourceKey @@ -134,5 +135,25 @@ object BlockStateInfo { x, y, z, level.dimensionId, prevBlockType, newBlockType, prevBlockMass, newBlockMass ) + + if (level is ServerLevel) { + if (!prevBlockState.isAir && newBlockState.isAir){ + val blockNeighbors: HashSet<BlockPos> = HashSet() + for (dir in Direction.entries) { + val neighborPos = BlockPos(x, y, z).relative(dir) + val neighborState = level.getBlockState(neighborPos) + if (!neighborState.isAir) { + blockNeighbors.add(neighborPos) + } + } + for (neighborPos in blockNeighbors) { + for (otherNeighborPos in blockNeighbors) { + if (neighborPos != otherNeighborPos) { + + } + } + } + } + } } } 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 index 78199a624..2f3b7e397 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/AssemblyUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/AssemblyUtil.kt @@ -16,7 +16,7 @@ import org.joml.Vector3i private val AIR = Blocks.AIR.defaultBlockState() object AssemblyUtil { - fun setBlock(level: Level, pos: BlockPos, state: BlockState?) { + 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) @@ -29,7 +29,7 @@ object AssemblyUtil { setBlock(level, pos, Blocks.AIR.defaultBlockState()) } - fun copyBlock(level: Level, from: BlockPos?, to: BlockPos) { + fun copyBlock(level: Level, from: BlockPos, to: BlockPos) { val state = level.getBlockState(from) val blockentity = level.getBlockEntity(from) setBlock(level, to, state) 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 index 7ee1c79b1..c7af8af27 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembler.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembler.kt @@ -79,7 +79,7 @@ object ShipAssembler { 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 (relative.equals(BlockPos.ZERO)) centerBlockReplaced = true } } 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 b3ea1c640..e297942fc 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 @@ -2,26 +2,11 @@ package org.valkyrienskies.mod.common.assembly import net.minecraft.core.BlockPos 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.impl.game.ships.ShipData -import org.valkyrienskies.core.impl.game.ships.ShipTransformImpl 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 -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") +@Deprecated("Use [ShipAssembler.assembleToShip] instead") fun createNewShipWithBlocks( centerBlock: BlockPos, blocks: DenseBlockPosSet, level: ServerLevel ): ServerShip { diff --git a/gradle.properties b/gradle.properties index 8f0f19c5d..b2a85647c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -vs_core_version=1.1.0+cf7b0d3c5b +vs_core_version=1.1.0+2e644a6fea # 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 cf815ca370c001e71990658b7d0883e3150ea712 Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Thu, 24 Oct 2024 22:12:35 -0700 Subject: [PATCH 429/437] Fixed DenseBlockPosSet.iterator() --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 8f0f19c5d..e1e2e5bb4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -vs_core_version=1.1.0+cf7b0d3c5b +vs_core_version=1.1.0+bf19ff814e # 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 68764a2de7aa820fdda2517845309845be1c2f1b Mon Sep 17 00:00:00 2001 From: theplasticpotato <theplasticpotato@gmail.com> Date: Fri, 25 Oct 2024 14:30:34 -0400 Subject: [PATCH 430/437] Spliterating --- .../mod/common/BlockStateInfoProvider.kt | 176 ++++++++++++++++-- .../mod/common/ValkyrienSkiesMod.kt | 1 + .../mod/common/item/ConnectionCheckerItem.kt | 64 +++++++ .../assets/valkyrienskies/lang/en_us.json | 1 + .../models/item/connection_checker.json | 6 + .../fabric/common/ValkyrienSkiesModFabric.kt | 10 + .../forge/common/ValkyrienSkiesModForge.kt | 11 ++ gradle.properties | 2 +- 8 files changed, 259 insertions(+), 12 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/item/ConnectionCheckerItem.kt create mode 100644 common/src/main/resources/assets/valkyrienskies/models/item/connection_checker.json 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 dd5384c63..471c709de 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -6,6 +6,7 @@ import net.minecraft.core.BlockPos import net.minecraft.core.Direction import net.minecraft.core.MappedRegistry import net.minecraft.core.Registry +import net.minecraft.core.Vec3i import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerLevel @@ -14,10 +15,15 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import org.valkyrienskies.core.api.ships.Wing import org.valkyrienskies.core.api.ships.WingManager +import org.valkyrienskies.core.api.world.connectivity.ConnectionStatus.CONNECTED +import org.valkyrienskies.core.api.world.connectivity.ConnectionStatus.DISCONNECTED import org.valkyrienskies.core.apigame.world.chunks.BlockType +import org.valkyrienskies.core.util.expand +import org.valkyrienskies.mod.common.assembly.ShipAssembler import org.valkyrienskies.mod.common.block.WingBlock import org.valkyrienskies.mod.common.config.MassDatapackResolver import org.valkyrienskies.mod.common.hooks.VSGameEvents +import org.valkyrienskies.mod.common.util.toJOML import java.util.function.IntFunction // Other mods can then provide weights and types based on their added content @@ -137,19 +143,167 @@ object BlockStateInfo { ) if (level is ServerLevel) { - if (!prevBlockState.isAir && newBlockState.isAir){ - val blockNeighbors: HashSet<BlockPos> = HashSet() - for (dir in Direction.entries) { - val neighborPos = BlockPos(x, y, z).relative(dir) - val neighborState = level.getBlockState(neighborPos) - if (!neighborState.isAir) { - blockNeighbors.add(neighborPos) + val loadedShip = level.getShipObjectManagingPos(x shr 4, z shr 4) + if (loadedShip != null) { + if (!prevBlockState.isAir && newBlockState.isAir){ + val blockNeighbors: HashSet<BlockPos> = HashSet() + for (dir in Direction.entries) { + val shipBox = loadedShip.shipAABB?.expand(1) ?: continue + val neighborPos = BlockPos(x, y, z).relative(dir) + val neighborState = level.getBlockState(neighborPos) + if (!neighborState.isAir && neighborPos != BlockPos(x, y, z) && shipBox.containsPoint(neighborPos.toJOML())) { + blockNeighbors.add(neighborPos) + } + if (true) { //later: check block edge connectivity config + for (secondDir in Direction.entries) { + if (dir.axis != secondDir.axis) { + val secondNeighborPos = neighborPos.relative(secondDir) + val secondNeighborState = level.getBlockState(secondNeighborPos) + if (!secondNeighborState.isAir && secondNeighborPos != BlockPos(x, y, z) && shipBox.containsPoint(neighborPos.toJOML())) { + blockNeighbors.add(secondNeighborPos) + } + if (true) { //later: check block corner connectivity config + for (thirdDir in Direction.entries) { + if (dir.axis != secondDir.axis && dir.axis != thirdDir.axis && secondDir.axis != thirdDir.axis) { + val thirdNeighborPos = secondNeighborPos.relative(thirdDir) + val thirdNeighborState = level.getBlockState(thirdNeighborPos) + if (!thirdNeighborState.isAir && thirdNeighborPos != BlockPos(x, y, z) && shipBox.containsPoint(neighborPos.toJOML())) { + blockNeighbors.add(thirdNeighborPos) + } + } + } + } + } + } + } } - } - for (neighborPos in blockNeighbors) { - for (otherNeighborPos in blockNeighbors) { - if (neighborPos != otherNeighborPos) { + if (blockNeighbors.isNotEmpty()) { + //find largest remaining component + var largestComponentNode: BlockPos = blockNeighbors.first() + var largestComponentSize: Long = -1 + + for (neighborPos in blockNeighbors) { + print(level.shipObjectWorld.isIsolatedSolid(neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId)) + if (level.shipObjectWorld.isIsolatedSolid(neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) == DISCONNECTED) { + val size = level.shipObjectWorld.getSolidComponentSize(neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) + if (size > largestComponentSize) { + largestComponentNode = neighborPos + largestComponentSize = size + } + } + } + + if (largestComponentSize == -1L) { + return + } + + blockNeighbors.remove(largestComponentNode) + + // use largest as base + + //find all disconnected components + + val disconnected = HashSet<BlockPos>() + for (neighborPos in blockNeighbors) { + if (level.shipObjectWorld.isIsolatedSolid(neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) == DISCONNECTED) { + if (neighborPos != largestComponentNode) { + if (level.shipObjectWorld.isConnectedBySolid(largestComponentNode.x, largestComponentNode.y, largestComponentNode.z, neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) == DISCONNECTED) { + val component = HashSet<BlockPos>() + disconnected.add(neighborPos) + } + println("this is " + level.shipObjectWorld.isConnectedBySolid(largestComponentNode.x, largestComponentNode.y, largestComponentNode.z, neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId).toString()) + } + } + } + + //check if any disconnected components are connected + val toIgnore: HashSet<BlockPos> = HashSet() + for (component in disconnected) { + for (otherComponent in disconnected) { + if (component == otherComponent) { + continue + } + if (level.shipObjectWorld.isConnectedBySolid(component.x, component.y, component.z, otherComponent.x, otherComponent.y, otherComponent.z, level.dimensionId) == CONNECTED) { + if (!toIgnore.contains(otherComponent) && !toIgnore.contains(component)) { + toIgnore.add(component) + } + } + } + } + + disconnected.removeAll(toIgnore) + + if (disconnected.isEmpty()) { + return + } + + //begin the DFSing + + val offsetsToCheck: ArrayList<Vec3i> = arrayListOf( + Vec3i(1, 0, 0), + Vec3i(-1, 0, 0), + Vec3i(0, 1, 0), + Vec3i(0, -1, 0), + Vec3i(0, 0, 1), + Vec3i(0, 0, -1) + ) + if (true) { //later: check block edge connectivity config + offsetsToCheck.add(Vec3i(1, 1, 0)) + offsetsToCheck.add(Vec3i(1, -1, 0)) + offsetsToCheck.add(Vec3i(-1, 1, 0)) + offsetsToCheck.add(Vec3i(-1, -1, 0)) + offsetsToCheck.add(Vec3i(1, 0, 1)) + offsetsToCheck.add(Vec3i(1, 0, -1)) + offsetsToCheck.add(Vec3i(-1, 0, 1)) + offsetsToCheck.add(Vec3i(-1, 0, -1)) + offsetsToCheck.add(Vec3i(0, 1, 1)) + offsetsToCheck.add(Vec3i(0, 1, -1)) + offsetsToCheck.add(Vec3i(0, -1, 1)) + offsetsToCheck.add(Vec3i(0, -1, -1)) + } + if (true) { //later: check block corner connectivity config + offsetsToCheck.add(Vec3i(1, 1, 1)) + offsetsToCheck.add(Vec3i(1, 1, -1)) + offsetsToCheck.add(Vec3i(1, -1, 1)) + offsetsToCheck.add(Vec3i(1, -1, -1)) + offsetsToCheck.add(Vec3i(-1, 1, 1)) + offsetsToCheck.add(Vec3i(-1, 1, -1)) + offsetsToCheck.add(Vec3i(-1, -1, 1)) + offsetsToCheck.add(Vec3i(-1, -1, -1)) + } + + val toAssemble = HashSet<List<BlockPos>>() + + for (starter in disconnected) { + val visited = HashSet<BlockPos>() + val queuedPositions = HashSet<BlockPos>() + queuedPositions.add(starter) + + while (queuedPositions.isNotEmpty()) { + val current = queuedPositions.first() + queuedPositions.remove(current) + visited.add(current) + val toCheck = HashSet<BlockPos>() + for (offset in offsetsToCheck) { + toCheck.add(BlockPos(current.x + offset.x, current.y + offset.y, current.z + offset.z)) + } + for (check in toCheck) { + if (!visited.contains(check) && !level.getBlockState(check).isAir) { + queuedPositions.add(check) + } + } + } + //if we have visited all blocks in the component, we can split it + toAssemble.add(visited.toList()) + } + + if (toAssemble.isEmpty()) { + return + } + + for (component in toAssemble) { + ShipAssembler.assembleToShip(level, component, true, 1.0) } } } 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 f5f20b0b7..8adf43287 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -24,6 +24,7 @@ object ValkyrienSkiesMod { lateinit var TEST_FLAP: Block lateinit var TEST_WING: Block lateinit var TEST_SPHERE: Block + lateinit var CONNECTION_CHECKER_ITEM: Item lateinit var SHIP_CREATOR_ITEM: Item lateinit var SHIP_ASSEMBLER_ITEM: Item lateinit var SHIP_CREATOR_ITEM_SMALLER: Item diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ConnectionCheckerItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ConnectionCheckerItem.kt new file mode 100644 index 000000000..db86a4a09 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ConnectionCheckerItem.kt @@ -0,0 +1,64 @@ +package org.valkyrienskies.mod.common.item + +import net.minecraft.Util +import net.minecraft.network.chat.TextComponent +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.InteractionResult +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.context.UseOnContext +import net.minecraft.world.level.block.state.BlockState +import org.valkyrienskies.mod.common.dimensionId +import org.valkyrienskies.mod.common.getShipManagingPos +import org.valkyrienskies.mod.common.shipObjectWorld +import java.util.function.DoubleSupplier + +class ConnectionCheckerItem( + properties: Properties, private val scale: DoubleSupplier, private val minScaling: DoubleSupplier +) : Item(properties) { + + override fun isFoil(stack: ItemStack): Boolean { + return true + } + + override fun useOn(ctx: UseOnContext): InteractionResult { + val level = ctx.level as? ServerLevel ?: return super.useOn(ctx) + val blockPos = ctx.clickedPos + val blockState: BlockState = level.getBlockState(blockPos) + val item = ctx.itemInHand + + if (item.item !is ConnectionCheckerItem) { + return InteractionResult.FAIL + } + + if (!level.isClientSide) { + val parentShip = ctx.level.getShipManagingPos(blockPos) + if (!blockState.isAir) { + // Make a ship + val dimensionId = level.dimensionId + + if (parentShip != null) { + if (item.tag != null && item.tag!!.contains("firstPosX")) { + val firstPosX = item.tag!!.getInt("firstPosX") + val firstPosY = item.tag!!.getInt("firstPosY") + val firstPosZ = item.tag!!.getInt("firstPosZ") + val connected = level.shipObjectWorld.isConnectedBySolid(blockPos.x, blockPos.y, blockPos.z, firstPosX, firstPosY, firstPosZ, dimensionId) + ctx.player?.sendMessage(TextComponent("Connected: $connected"), Util.NIL_UUID) + item.tag!!.remove("firstPosX") + item.tag!!.remove("firstPosY") + item.tag!!.remove("firstPosZ") + } else { + item.tag = item.orCreateTag.apply { + putInt("firstPosX", blockPos.x) + putInt("firstPosY", blockPos.y) + putInt("firstPosZ", blockPos.z) + } + ctx.player?.sendMessage(TextComponent("First block selected: (${blockPos.x}, ${blockPos.y}, ${blockPos.z}"), Util.NIL_UUID) + } + } + } + } + + return super.useOn(ctx) + } +} 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..49a430a42 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_flap": "Debug Flap", "block.valkyrienskies.test_wing": "Debug Wing", "item.valkyrienskies.ship_creator": "Ship Creator", + "item.valkyrienskies.connection_checker": "Connection Checker", "item.valkyrienskies.ship_creator_smaller": "Mini Ship Creator", "item.valkyrienskies.physics_entity_creator": "Physics Entity Creator", "argument.valkyrienskies.ship.no_found": "Ship not found", diff --git a/common/src/main/resources/assets/valkyrienskies/models/item/connection_checker.json b/common/src/main/resources/assets/valkyrienskies/models/item/connection_checker.json new file mode 100644 index 000000000..f0dc3b971 --- /dev/null +++ b/common/src/main/resources/assets/valkyrienskies/models/item/connection_checker.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "minecraft:item/stick" + } +} \ No newline at end of file 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..55484159c 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 @@ -42,6 +42,7 @@ import org.valkyrienskies.mod.common.entity.ShipMountingEntity import org.valkyrienskies.mod.common.entity.VSPhysicsEntity import org.valkyrienskies.mod.common.entity.handling.VSEntityManager import org.valkyrienskies.mod.common.hooks.VSGameEvents +import org.valkyrienskies.mod.common.item.ConnectionCheckerItem import org.valkyrienskies.mod.common.item.PhysicsEntityCreatorItem import org.valkyrienskies.mod.common.item.ShipAssemblerItem import org.valkyrienskies.mod.common.item.ShipCreatorItem @@ -63,6 +64,11 @@ class ValkyrienSkiesModFabric : ModInitializer { ValkyrienSkiesMod.TEST_FLAP = TestFlapBlock ValkyrienSkiesMod.TEST_WING = TestWingBlock ValkyrienSkiesMod.TEST_SPHERE = TestSphereBlock + ValkyrienSkiesMod.CONNECTION_CHECKER_ITEM = ConnectionCheckerItem( + Properties().tab(CreativeModeTab.TAB_MISC), + { 1.0 }, + { VSGameConfig.SERVER.minScaling } + ) ValkyrienSkiesMod.SHIP_CREATOR_ITEM = ShipCreatorItem( Properties().tab(CreativeModeTab.TAB_MISC), { 1.0 }, @@ -114,6 +120,10 @@ class ValkyrienSkiesModFabric : ModInitializer { registerBlockAndItem("test_flap", ValkyrienSkiesMod.TEST_FLAP) registerBlockAndItem("test_wing", ValkyrienSkiesMod.TEST_WING) registerBlockAndItem("test_sphere", ValkyrienSkiesMod.TEST_SPHERE) + Registry.register( + Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "connection_checker"), + ValkyrienSkiesMod.CONNECTION_CHECKER_ITEM + ) Registry.register( Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_assembler"), ValkyrienSkiesMod.SHIP_ASSEMBLER_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 b72fa2397..601c4dd57 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 @@ -46,6 +46,7 @@ import org.valkyrienskies.mod.common.entity.ShipMountingEntity import org.valkyrienskies.mod.common.entity.VSPhysicsEntity import org.valkyrienskies.mod.common.entity.handling.VSEntityManager import org.valkyrienskies.mod.common.hooks.VSGameEvents +import org.valkyrienskies.mod.common.item.ConnectionCheckerItem import org.valkyrienskies.mod.common.item.PhysicsEntityCreatorItem import org.valkyrienskies.mod.common.item.ShipAssemblerItem import org.valkyrienskies.mod.common.item.ShipCreatorItem @@ -62,6 +63,7 @@ class ValkyrienSkiesModForge { private val TEST_FLAP_REGISTRY: RegistryObject<Block> private val TEST_WING_REGISTRY: RegistryObject<Block> private val TEST_SPHERE_REGISTRY: RegistryObject<Block> + private val CONNECTION_CHECKER_ITEM_REGISTRY: RegistryObject<Item> private val SHIP_CREATOR_ITEM_REGISTRY: RegistryObject<Item> private val SHIP_CREATOR_SMALLER_ITEM_REGISTRY: RegistryObject<Item> private val PHYSICS_ENTITY_CREATOR_ITEM_REGISTRY: RegistryObject<Item> @@ -119,6 +121,14 @@ class ValkyrienSkiesModForge { { 1.0 }, { VSGameConfig.SERVER.minScaling }) } + CONNECTION_CHECKER_ITEM_REGISTRY = + ITEMS.register("connection_checker") { + ConnectionCheckerItem( + Properties().tab(CreativeModeTab.TAB_MISC), + { 1.0 }, + { VSGameConfig.SERVER.minScaling } + ) + } SHIP_CREATOR_SMALLER_ITEM_REGISTRY = ITEMS.register("ship_creator_smaller") { ShipCreatorItem( @@ -206,5 +216,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.CONNECTION_CHECKER_ITEM = CONNECTION_CHECKER_ITEM_REGISTRY.get() } } diff --git a/gradle.properties b/gradle.properties index b2a85647c..d496f87d5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -vs_core_version=1.1.0+2e644a6fea +vs_core_version=1.1.0+9d576c0e71 # 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 7c6b8b6561549ebf954402fedbbac86e104a63d7 Mon Sep 17 00:00:00 2001 From: theplasticpotato <theplasticpotato@gmail.com> Date: Fri, 25 Oct 2024 19:54:48 -0400 Subject: [PATCH 431/437] Added area assembler, fixed splitting --- .../mod/common/BlockStateInfoProvider.kt | 176 +---------------- .../mod/common/ValkyrienSkiesMod.kt | 10 + .../mod/common/assembly/AssemblyUtil.kt | 4 +- .../mod/common/assembly/ShipAssembler.kt | 36 +++- .../mod/common/item/AreaAssemblerItem.kt | 88 +++++++++ .../mod/common/item/ConnectionCheckerItem.kt | 2 +- .../mod/common/util/SplitHandler.kt | 181 ++++++++++++++++++ .../util/SplittingDisablerAttachment.kt | 15 ++ .../assets/valkyrienskies/lang/en_us.json | 1 + .../models/item/area_assembler.json | 6 + .../fabric/common/ValkyrienSkiesModFabric.kt | 10 + .../forge/common/ValkyrienSkiesModForge.kt | 11 +- gradle.properties | 2 +- 13 files changed, 355 insertions(+), 187 deletions(-) create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/item/AreaAssemblerItem.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/util/SplitHandler.kt create mode 100644 common/src/main/kotlin/org/valkyrienskies/mod/common/util/SplittingDisablerAttachment.kt create mode 100644 common/src/main/resources/assets/valkyrienskies/models/item/area_assembler.json 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 471c709de..c88be2f65 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -3,10 +3,8 @@ package org.valkyrienskies.mod.common import com.mojang.serialization.Lifecycle import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap import net.minecraft.core.BlockPos -import net.minecraft.core.Direction import net.minecraft.core.MappedRegistry import net.minecraft.core.Registry -import net.minecraft.core.Vec3i import net.minecraft.resources.ResourceKey import net.minecraft.resources.ResourceLocation import net.minecraft.server.level.ServerLevel @@ -15,15 +13,10 @@ import net.minecraft.world.level.block.Block import net.minecraft.world.level.block.state.BlockState import org.valkyrienskies.core.api.ships.Wing import org.valkyrienskies.core.api.ships.WingManager -import org.valkyrienskies.core.api.world.connectivity.ConnectionStatus.CONNECTED -import org.valkyrienskies.core.api.world.connectivity.ConnectionStatus.DISCONNECTED import org.valkyrienskies.core.apigame.world.chunks.BlockType -import org.valkyrienskies.core.util.expand -import org.valkyrienskies.mod.common.assembly.ShipAssembler import org.valkyrienskies.mod.common.block.WingBlock import org.valkyrienskies.mod.common.config.MassDatapackResolver import org.valkyrienskies.mod.common.hooks.VSGameEvents -import org.valkyrienskies.mod.common.util.toJOML import java.util.function.IntFunction // Other mods can then provide weights and types based on their added content @@ -142,172 +135,9 @@ object BlockStateInfo { newBlockMass ) - if (level is ServerLevel) { - val loadedShip = level.getShipObjectManagingPos(x shr 4, z shr 4) - if (loadedShip != null) { - if (!prevBlockState.isAir && newBlockState.isAir){ - val blockNeighbors: HashSet<BlockPos> = HashSet() - for (dir in Direction.entries) { - val shipBox = loadedShip.shipAABB?.expand(1) ?: continue - val neighborPos = BlockPos(x, y, z).relative(dir) - val neighborState = level.getBlockState(neighborPos) - if (!neighborState.isAir && neighborPos != BlockPos(x, y, z) && shipBox.containsPoint(neighborPos.toJOML())) { - blockNeighbors.add(neighborPos) - } - if (true) { //later: check block edge connectivity config - for (secondDir in Direction.entries) { - if (dir.axis != secondDir.axis) { - val secondNeighborPos = neighborPos.relative(secondDir) - val secondNeighborState = level.getBlockState(secondNeighborPos) - if (!secondNeighborState.isAir && secondNeighborPos != BlockPos(x, y, z) && shipBox.containsPoint(neighborPos.toJOML())) { - blockNeighbors.add(secondNeighborPos) - } - if (true) { //later: check block corner connectivity config - for (thirdDir in Direction.entries) { - if (dir.axis != secondDir.axis && dir.axis != thirdDir.axis && secondDir.axis != thirdDir.axis) { - val thirdNeighborPos = secondNeighborPos.relative(thirdDir) - val thirdNeighborState = level.getBlockState(thirdNeighborPos) - if (!thirdNeighborState.isAir && thirdNeighborPos != BlockPos(x, y, z) && shipBox.containsPoint(neighborPos.toJOML())) { - blockNeighbors.add(thirdNeighborPos) - } - } - } - } - } - } - } - } - - if (blockNeighbors.isNotEmpty()) { - //find largest remaining component - var largestComponentNode: BlockPos = blockNeighbors.first() - var largestComponentSize: Long = -1 - - for (neighborPos in blockNeighbors) { - print(level.shipObjectWorld.isIsolatedSolid(neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId)) - if (level.shipObjectWorld.isIsolatedSolid(neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) == DISCONNECTED) { - val size = level.shipObjectWorld.getSolidComponentSize(neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) - if (size > largestComponentSize) { - largestComponentNode = neighborPos - largestComponentSize = size - } - } - } - - if (largestComponentSize == -1L) { - return - } - - blockNeighbors.remove(largestComponentNode) - - // use largest as base - - //find all disconnected components - - val disconnected = HashSet<BlockPos>() - for (neighborPos in blockNeighbors) { - if (level.shipObjectWorld.isIsolatedSolid(neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) == DISCONNECTED) { - if (neighborPos != largestComponentNode) { - if (level.shipObjectWorld.isConnectedBySolid(largestComponentNode.x, largestComponentNode.y, largestComponentNode.z, neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) == DISCONNECTED) { - val component = HashSet<BlockPos>() - disconnected.add(neighborPos) - } - println("this is " + level.shipObjectWorld.isConnectedBySolid(largestComponentNode.x, largestComponentNode.y, largestComponentNode.z, neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId).toString()) - } - } - } - - //check if any disconnected components are connected - val toIgnore: HashSet<BlockPos> = HashSet() - for (component in disconnected) { - for (otherComponent in disconnected) { - if (component == otherComponent) { - continue - } - if (level.shipObjectWorld.isConnectedBySolid(component.x, component.y, component.z, otherComponent.x, otherComponent.y, otherComponent.z, level.dimensionId) == CONNECTED) { - if (!toIgnore.contains(otherComponent) && !toIgnore.contains(component)) { - toIgnore.add(component) - } - } - } - } - - disconnected.removeAll(toIgnore) - - if (disconnected.isEmpty()) { - return - } - - //begin the DFSing - - val offsetsToCheck: ArrayList<Vec3i> = arrayListOf( - Vec3i(1, 0, 0), - Vec3i(-1, 0, 0), - Vec3i(0, 1, 0), - Vec3i(0, -1, 0), - Vec3i(0, 0, 1), - Vec3i(0, 0, -1) - ) - if (true) { //later: check block edge connectivity config - offsetsToCheck.add(Vec3i(1, 1, 0)) - offsetsToCheck.add(Vec3i(1, -1, 0)) - offsetsToCheck.add(Vec3i(-1, 1, 0)) - offsetsToCheck.add(Vec3i(-1, -1, 0)) - offsetsToCheck.add(Vec3i(1, 0, 1)) - offsetsToCheck.add(Vec3i(1, 0, -1)) - offsetsToCheck.add(Vec3i(-1, 0, 1)) - offsetsToCheck.add(Vec3i(-1, 0, -1)) - offsetsToCheck.add(Vec3i(0, 1, 1)) - offsetsToCheck.add(Vec3i(0, 1, -1)) - offsetsToCheck.add(Vec3i(0, -1, 1)) - offsetsToCheck.add(Vec3i(0, -1, -1)) - } - if (true) { //later: check block corner connectivity config - offsetsToCheck.add(Vec3i(1, 1, 1)) - offsetsToCheck.add(Vec3i(1, 1, -1)) - offsetsToCheck.add(Vec3i(1, -1, 1)) - offsetsToCheck.add(Vec3i(1, -1, -1)) - offsetsToCheck.add(Vec3i(-1, 1, 1)) - offsetsToCheck.add(Vec3i(-1, 1, -1)) - offsetsToCheck.add(Vec3i(-1, -1, 1)) - offsetsToCheck.add(Vec3i(-1, -1, -1)) - } - - val toAssemble = HashSet<List<BlockPos>>() - - for (starter in disconnected) { - val visited = HashSet<BlockPos>() - val queuedPositions = HashSet<BlockPos>() - queuedPositions.add(starter) - - while (queuedPositions.isNotEmpty()) { - val current = queuedPositions.first() - queuedPositions.remove(current) - visited.add(current) - val toCheck = HashSet<BlockPos>() - for (offset in offsetsToCheck) { - toCheck.add(BlockPos(current.x + offset.x, current.y + offset.y, current.z + offset.z)) - } - for (check in toCheck) { - if (!visited.contains(check) && !level.getBlockState(check).isAir) { - queuedPositions.add(check) - } - } - } - //if we have visited all blocks in the component, we can split it - toAssemble.add(visited.toList()) - } - - if (toAssemble.isEmpty()) { - return - } - - for (component in toAssemble) { - ShipAssembler.assembleToShip(level, component, true, 1.0) - } - } - } - } + // todo check if splitting is enabled, dolt + if (true) { + ValkyrienSkiesMod.splitHandler.split(level, x, y, z, prevBlockState, newBlockState) } } } 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 8adf43287..312af3a0d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/ValkyrienSkiesMod.kt @@ -15,6 +15,8 @@ import org.valkyrienskies.mod.common.entity.ShipMountingEntity import org.valkyrienskies.mod.common.entity.VSPhysicsEntity import org.valkyrienskies.mod.common.networking.VSGamePackets import org.valkyrienskies.mod.common.util.GameTickForceApplier +import org.valkyrienskies.mod.common.util.SplitHandler +import org.valkyrienskies.mod.common.util.SplittingDisablerAttachment object ValkyrienSkiesMod { const val MOD_ID = "valkyrienskies" @@ -28,6 +30,7 @@ object ValkyrienSkiesMod { lateinit var SHIP_CREATOR_ITEM: Item lateinit var SHIP_ASSEMBLER_ITEM: Item lateinit var SHIP_CREATOR_ITEM_SMALLER: Item + lateinit var AREA_ASSEMBLER_ITEM: Item lateinit var PHYSICS_ENTITY_CREATOR_ITEM: Item lateinit var SHIP_MOUNTING_ENTITY_TYPE: EntityType<ShipMountingEntity> lateinit var PHYSICS_ENTITY_TYPE: EntityType<VSPhysicsEntity> @@ -42,6 +45,9 @@ object ValkyrienSkiesMod { @JvmStatic val vsCoreClient get() = vsCore as VSCoreClient + @JvmStatic + lateinit var splitHandler: SplitHandler + fun init(core: VSCore) { this.vsCore = core @@ -50,8 +56,12 @@ object ValkyrienSkiesMod { VSGamePackets.registerHandlers() core.registerConfigLegacy("vs", VSGameConfig::class.java) + + splitHandler = SplitHandler(this.vsCore.hooks.enableBlockEdgeConnectivity, this.vsCore.hooks.enableBlockCornerConnectivity) + VSEvents.ShipLoadEvent.on { event -> event.ship.setAttachment(GameTickForceApplier()) + event.ship.setAttachment(SplittingDisablerAttachment(true)) } } } 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 index 2f3b7e397..326c333ea 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/AssemblyUtil.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/AssemblyUtil.kt @@ -26,13 +26,13 @@ object AssemblyUtil { fun removeBlock(level: Level, pos: BlockPos) { level.removeBlockEntity(pos) - setBlock(level, pos, Blocks.AIR.defaultBlockState()) + level.getChunk(pos).setBlockState(pos, Blocks.AIR.defaultBlockState(), false) } fun copyBlock(level: Level, from: BlockPos, to: BlockPos) { val state = level.getBlockState(from) val blockentity = level.getBlockEntity(from) - setBlock(level, to, state) + level.getChunk(to).setBlockState(to, state, false) // Transfer pending schedule-ticks if (level.blockTicks.hasScheduledTick(from, state.block)) { 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 index c7af8af27..31f00fd00 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembler.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembler.kt @@ -6,15 +6,20 @@ 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.Vector3dc 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.api.ships.getAttachment 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 +import org.valkyrienskies.mod.common.util.SplittingDisablerAttachment +import org.valkyrienskies.mod.common.util.toJOMLD +import org.valkyrienskies.mod.util.logger object ShipAssembler { @@ -31,11 +36,11 @@ object ShipAssembler { } - fun assembleToShip(level: Level, blocks: List<BlockPos>, removeOriginal: Boolean, scale: Double): ServerShip { - assert(level is ServerLevel) { "Can't manage contraptions on client side!" } + fun assembleToShip(level: Level, blocks: List<BlockPos>, removeOriginal: Boolean, scale: Double = 1.0, shouldDisableSplitting: Boolean = false): ServerShip { + assert(level is ServerLevel) { "Can't create ships clientside!" } val sLevel: ServerLevel = level as ServerLevel if (blocks.isEmpty()) { - throw IllegalArgumentException() + throw IllegalArgumentException("No blocks to assemble.") } val existingShip = sLevel.getShipObjectManagingPos(blocks.find { !sLevel.getBlockState(it).isAir } ?: throw IllegalArgumentException()) @@ -66,7 +71,10 @@ object ShipAssembler { val newShip: Ship = (level as ServerLevel).server.shipObjectWorld .createNewShipAtBlock(contraptionWorldPos, false, scale, level.dimensionId) - // Stone for safety reasons + if (shouldDisableSplitting) { + level.shipObjectWorld.loadedShips.getById(newShip.id)?.getAttachment<SplittingDisablerAttachment>()?.disableSplitting() + + } 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()) @@ -84,9 +92,9 @@ object ShipAssembler { } // If center block got not replaced, remove the stone block - if (!centerBlockReplaced) { - level.setBlock(contraptionBlockPos, Blocks.AIR.defaultBlockState(), 3) - } + // if (!centerBlockReplaced) { + // level.setBlock(contraptionBlockPos, Blocks.AIR.defaultBlockState(), 3) + // } // Remove original blocks if (removeOriginal) { @@ -104,9 +112,19 @@ object ShipAssembler { AssemblyUtil.updateBlock(level,itPos,shipPos,level.getBlockState(shipPos)) } + val spawnWorldPos: Vector3dc = AssemblyUtil.getMiddle(structureCornerMin.toJOMLD(), structureCornerMax.toJOMLD()).add(0.5, 0.5, 0.5) + + if (existingShip != null) { + sLevel.server.shipObjectWorld + .teleportShip(newShip as ServerShip, ShipTeleportDataImpl(existingShip.shipToWorld.transformPosition(spawnWorldPos, Vector3d()), existingShip.transform.shipToWorldRotation, existingShip.velocity, existingShip.omega, existingShip.chunkClaimDimension)) - sLevel.server.shipObjectWorld - .teleportShip(newShip as ServerShip, ShipTeleportDataImpl(Vector3d(contraptionWorldPos.x.toDouble(),contraptionWorldPos.y.toDouble(),contraptionWorldPos.z.toDouble()))) + } else { + sLevel.server.shipObjectWorld + .teleportShip(newShip as ServerShip, ShipTeleportDataImpl(spawnWorldPos)) + } + if (shouldDisableSplitting) { + level.shipObjectWorld.loadedShips.getById(newShip.id)?.getAttachment<SplittingDisablerAttachment>()?.enableSplitting() + } return newShip as ServerShip } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/AreaAssemblerItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/AreaAssemblerItem.kt new file mode 100644 index 000000000..51c64bdc4 --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/AreaAssemblerItem.kt @@ -0,0 +1,88 @@ +package org.valkyrienskies.mod.common.item + +import net.minecraft.Util +import net.minecraft.core.BlockPos +import net.minecraft.core.Vec3i +import net.minecraft.network.chat.TextComponent +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.InteractionResult +import net.minecraft.world.item.Item +import net.minecraft.world.item.ItemStack +import net.minecraft.world.item.context.UseOnContext +import net.minecraft.world.level.block.state.BlockState +import org.joml.primitives.AABBi +import org.valkyrienskies.mod.common.assembly.ShipAssembler +import org.valkyrienskies.mod.common.dimensionId +import org.valkyrienskies.mod.common.getShipManagingPos +import org.valkyrienskies.mod.common.getShipObjectManagingPos +import org.valkyrienskies.mod.common.shipObjectWorld +import org.valkyrienskies.mod.common.util.toJOML +import java.util.function.DoubleSupplier + +class AreaAssemblerItem( + properties: Properties, private val scale: DoubleSupplier, private val minScaling: DoubleSupplier +) : Item(properties) { + + override fun isFoil(stack: ItemStack): Boolean { + return true + } + + override fun useOn(ctx: UseOnContext): InteractionResult { + val level = ctx.level as? ServerLevel ?: return super.useOn(ctx) + val blockPos = ctx.clickedPos + val blockState: BlockState = level.getBlockState(blockPos) + val item = ctx.itemInHand + + if (item.item !is AreaAssemblerItem) { + return InteractionResult.FAIL + } + + if (!level.isClientSide) { + if (!blockState.isAir) { + // Make a ship + val dimensionId = level.dimensionId + + if (item.tag != null && item.tag!!.contains("firstPosX")) { + val firstPosX = item.tag!!.getInt("firstPosX") + val firstPosY = item.tag!!.getInt("firstPosY") + val firstPosZ = item.tag!!.getInt("firstPosZ") + if (level.shipObjectWorld.isBlockInShipyard(blockPos.x, blockPos.y, blockPos.z, dimensionId) != level.shipObjectWorld.isBlockInShipyard(firstPosX, firstPosY, firstPosZ, dimensionId)) { + ctx.player?.sendMessage(TextComponent("Cannot assemble between ship and world!"), Util.NIL_UUID) + } else if (level.getShipObjectManagingPos(blockPos) != level.getShipObjectManagingPos(Vec3i(firstPosX, firstPosY, firstPosZ))) { + ctx.player?.sendMessage(TextComponent("Cannot assemble something between two ships!"), Util.NIL_UUID) + } else { + val blockAABB = AABBi(blockPos.toJOML(), Vec3i(firstPosX, firstPosY, firstPosZ).toJOML()) + blockAABB.correctBounds() + val blocks = ArrayList<BlockPos>() + + for (x in blockAABB.minX..blockAABB.maxX) { + for (y in blockAABB.minY..blockAABB.maxY) { + for (z in blockAABB.minZ..blockAABB.maxZ) { + if (level.getBlockState(BlockPos(x, y, z)).isAir) { + continue + } + blocks.add(BlockPos(x, y, z)) + } + } + } + ctx.player?.sendMessage(TextComponent("Assembling (${blockPos.x}, ${blockPos.y}, ${blockPos.z}) to ($firstPosX, $firstPosY, $firstPosZ)!"), Util.NIL_UUID) + ShipAssembler.assembleToShip(level, blocks, true, scale.asDouble) + } + item.tag!!.remove("firstPosX") + item.tag!!.remove("firstPosY") + item.tag!!.remove("firstPosZ") + } else { + item.tag = item.orCreateTag.apply { + putInt("firstPosX", blockPos.x) + putInt("firstPosY", blockPos.y) + putInt("firstPosZ", blockPos.z) + } + ctx.player?.sendMessage( + TextComponent("First block selected: (${blockPos.x}, ${blockPos.y}, ${blockPos.z})"), Util.NIL_UUID) + } + } + } + + return super.useOn(ctx) + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ConnectionCheckerItem.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ConnectionCheckerItem.kt index db86a4a09..4c141aa5d 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ConnectionCheckerItem.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/item/ConnectionCheckerItem.kt @@ -53,7 +53,7 @@ class ConnectionCheckerItem( putInt("firstPosY", blockPos.y) putInt("firstPosZ", blockPos.z) } - ctx.player?.sendMessage(TextComponent("First block selected: (${blockPos.x}, ${blockPos.y}, ${blockPos.z}"), Util.NIL_UUID) + ctx.player?.sendMessage(TextComponent("First block selected: (${blockPos.x}, ${blockPos.y}, ${blockPos.z})"), Util.NIL_UUID) } } } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/SplitHandler.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/SplitHandler.kt new file mode 100644 index 000000000..48f34c8ee --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/SplitHandler.kt @@ -0,0 +1,181 @@ +package org.valkyrienskies.mod.common.util + +import net.minecraft.core.BlockPos +import net.minecraft.core.Vec3i +import net.minecraft.server.level.ServerLevel +import net.minecraft.world.level.Level +import net.minecraft.world.level.block.state.BlockState +import org.joml.primitives.AABBi +import org.valkyrienskies.core.api.ships.getAttachment +import org.valkyrienskies.core.api.world.connectivity.ConnectionStatus.CONNECTED +import org.valkyrienskies.core.api.world.connectivity.ConnectionStatus.DISCONNECTED +import org.valkyrienskies.core.util.expand +import org.valkyrienskies.mod.common.assembly.ShipAssembler +import org.valkyrienskies.mod.common.dimensionId +import org.valkyrienskies.mod.common.getShipObjectManagingPos +import org.valkyrienskies.mod.common.shipObjectWorld + +class SplitHandler(private val doEdges: Boolean, private val doCorners: Boolean) { + + fun split(level: Level, x: Int, y: Int, z: Int, prevBlockState: BlockState, newBlockState: BlockState) { + if (level is ServerLevel) { + val loadedShip = level.getShipObjectManagingPos(x shr 4, z shr 4) + if (loadedShip != null && loadedShip.getAttachment<SplittingDisablerAttachment>()?.canSplit() != false) { + if (!prevBlockState.isAir && newBlockState.isAir) { + val blockNeighbors: HashSet<BlockPos> = HashSet() + + val shipBox = loadedShip.shipAABB?.expand(1, AABBi()) ?: return + + for (neighborOffset in getOffsets(doEdges, doCorners)) { + val neighborPos = BlockPos(x + neighborOffset.x, y + neighborOffset.y, z + neighborOffset.z) + val neighborState = level.getBlockState(neighborPos) + if (!neighborState.isAir && neighborPos != BlockPos(x, y, z) && shipBox.containsPoint(neighborPos.toJOML())) { + blockNeighbors.add(neighborPos) + } + } + + if (blockNeighbors.isNotEmpty()) { + //find largest remaining component + var largestComponentNode: BlockPos = blockNeighbors.first() + var largestComponentSize: Long = -1 + + for (neighborPos in blockNeighbors) { + if (level.shipObjectWorld.isIsolatedSolid(neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) == DISCONNECTED) { + val size = level.shipObjectWorld.getSolidComponentSize(neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) + if (size > largestComponentSize) { + largestComponentNode = neighborPos + largestComponentSize = size + } + } + } + + if (largestComponentSize == -1L) { + return + } + + blockNeighbors.remove(largestComponentNode) + + // use largest as base + + //find all disconnected components + + val disconnected = HashSet<BlockPos>() + for (neighborPos in blockNeighbors) { + if (level.shipObjectWorld.isIsolatedSolid(neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) == DISCONNECTED) { + if (neighborPos != largestComponentNode) { + if (level.shipObjectWorld.isConnectedBySolid(largestComponentNode.x, largestComponentNode.y, largestComponentNode.z, neighborPos.x, neighborPos.y, neighborPos.z, level.dimensionId) == DISCONNECTED) { + disconnected.add(neighborPos) + } + } + } + } + + //check if any disconnected components are connected + val toIgnore: HashSet<BlockPos> = HashSet() + toIgnore.add(BlockPos(x, y, z)) + for (component in disconnected) { + for (otherComponent in disconnected) { + if (component == otherComponent) { + continue + } + if (level.shipObjectWorld.isConnectedBySolid(component.x, component.y, component.z, otherComponent.x, otherComponent.y, otherComponent.z, level.dimensionId) == CONNECTED) { + if (!toIgnore.contains(otherComponent) && !toIgnore.contains(component)) { + toIgnore.add(component) + } + } + } + } + + disconnected.removeAll(toIgnore) + + if (disconnected.isEmpty()) { + return + } else { + loadedShip.getAttachment(SplittingDisablerAttachment::class.java)?.disableSplitting() + } + + //begin the DFSing + + val toAssemble = HashSet<List<BlockPos>>() + + for (starter in disconnected) { + val visited = HashSet<BlockPos>() + val queuedPositions = HashSet<BlockPos>() + queuedPositions.add(starter) + + while (queuedPositions.isNotEmpty()) { + val current = queuedPositions.first() + queuedPositions.remove(current) + visited.add(current) + val toCheck = HashSet<BlockPos>() + for (offset in getOffsets(doEdges, doCorners)) { + toCheck.add( + BlockPos(current.x + offset.x, current.y + offset.y, current.z + offset.z) + ) + } + for (check in toCheck) { + if (!visited.contains(check) && !level.getBlockState(check).isAir) { + queuedPositions.add(check) + } + } + } + //if we have visited all blocks in the component, we can split it + toAssemble.add(visited.toList()) + } + + if (toAssemble.isEmpty()) { + loadedShip.getAttachment(SplittingDisablerAttachment::class.java)?.enableSplitting() + return + } + + for (component in toAssemble) { + ShipAssembler.assembleToShip(level, component, true, 1.0, true) + } + + loadedShip.getAttachment(SplittingDisablerAttachment::class.java)?.enableSplitting() + } + } + } + } + } + + companion object { + val offsetsToCheck: ArrayList<Vec3i> = arrayListOf( + Vec3i(1, 0, 0), + Vec3i(-1, 0, 0), + Vec3i(0, 1, 0), + Vec3i(0, -1, 0), + Vec3i(0, 0, 1), + Vec3i(0, 0, -1) + ) + + fun getOffsets(doEdges: Boolean, doCorners: Boolean): ArrayList<Vec3i> { + val list = ArrayList<Vec3i>(offsetsToCheck) + if (doEdges) { //later: check block edge connectivity config + list.add(Vec3i(1, 1, 0)) + list.add(Vec3i(1, -1, 0)) + list.add(Vec3i(-1, 1, 0)) + list.add(Vec3i(-1, -1, 0)) + list.add(Vec3i(1, 0, 1)) + list.add(Vec3i(1, 0, -1)) + list.add(Vec3i(-1, 0, 1)) + list.add(Vec3i(-1, 0, -1)) + list.add(Vec3i(0, 1, 1)) + list.add(Vec3i(0, 1, -1)) + list.add(Vec3i(0, -1, 1)) + list.add(Vec3i(0, -1, -1)) + } + if (doCorners) { //later: check block corner connectivity config + list.add(Vec3i(1, 1, 1)) + list.add(Vec3i(1, 1, -1)) + list.add(Vec3i(1, -1, 1)) + list.add(Vec3i(1, -1, -1)) + list.add(Vec3i(-1, 1, 1)) + list.add(Vec3i(-1, 1, -1)) + list.add(Vec3i(-1, -1, 1)) + list.add(Vec3i(-1, -1, -1)) + } + return list + } + } +} diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/util/SplittingDisablerAttachment.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/SplittingDisablerAttachment.kt new file mode 100644 index 000000000..42959258a --- /dev/null +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/util/SplittingDisablerAttachment.kt @@ -0,0 +1,15 @@ +package org.valkyrienskies.mod.common.util + +data class SplittingDisablerAttachment(private var splitt: Boolean) { + fun enableSplitting() { + splitt = true + } + + fun disableSplitting() { + splitt = false + } + + fun canSplit(): Boolean { + return splitt + } +} 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 49a430a42..96ccb3af3 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_flap": "Debug Flap", "block.valkyrienskies.test_wing": "Debug Wing", "item.valkyrienskies.ship_creator": "Ship Creator", + "item.valkyrienskies.area_assembler": "Area Assembler", "item.valkyrienskies.connection_checker": "Connection Checker", "item.valkyrienskies.ship_creator_smaller": "Mini Ship Creator", "item.valkyrienskies.physics_entity_creator": "Physics Entity Creator", diff --git a/common/src/main/resources/assets/valkyrienskies/models/item/area_assembler.json b/common/src/main/resources/assets/valkyrienskies/models/item/area_assembler.json new file mode 100644 index 000000000..f0dc3b971 --- /dev/null +++ b/common/src/main/resources/assets/valkyrienskies/models/item/area_assembler.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:item/handheld", + "textures": { + "layer0": "minecraft:item/stick" + } +} \ No newline at end of file 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 55484159c..cdee8650b 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 @@ -42,6 +42,7 @@ import org.valkyrienskies.mod.common.entity.ShipMountingEntity import org.valkyrienskies.mod.common.entity.VSPhysicsEntity import org.valkyrienskies.mod.common.entity.handling.VSEntityManager import org.valkyrienskies.mod.common.hooks.VSGameEvents +import org.valkyrienskies.mod.common.item.AreaAssemblerItem import org.valkyrienskies.mod.common.item.ConnectionCheckerItem import org.valkyrienskies.mod.common.item.PhysicsEntityCreatorItem import org.valkyrienskies.mod.common.item.ShipAssemblerItem @@ -75,6 +76,11 @@ class ValkyrienSkiesModFabric : ModInitializer { { VSGameConfig.SERVER.minScaling } ) ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM = ShipAssemblerItem(Properties().tab(CreativeModeTab.TAB_MISC)) + ValkyrienSkiesMod.AREA_ASSEMBLER_ITEM = AreaAssemblerItem( + Properties().tab(CreativeModeTab.TAB_MISC), + { 1.0 }, + { VSGameConfig.SERVER.minScaling } + ) ValkyrienSkiesMod.SHIP_CREATOR_ITEM_SMALLER = ShipCreatorItem( Properties().tab(CreativeModeTab.TAB_MISC), { VSGameConfig.SERVER.miniShipSize }, @@ -124,6 +130,10 @@ class ValkyrienSkiesModFabric : ModInitializer { Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "connection_checker"), ValkyrienSkiesMod.CONNECTION_CHECKER_ITEM ) + Registry.register( + Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "area_assembler"), + ValkyrienSkiesMod.AREA_ASSEMBLER_ITEM + ) Registry.register( Registry.ITEM, ResourceLocation(ValkyrienSkiesMod.MOD_ID, "ship_assembler"), ValkyrienSkiesMod.SHIP_ASSEMBLER_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 601c4dd57..438bfec90 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 @@ -46,6 +46,7 @@ import org.valkyrienskies.mod.common.entity.ShipMountingEntity import org.valkyrienskies.mod.common.entity.VSPhysicsEntity import org.valkyrienskies.mod.common.entity.handling.VSEntityManager import org.valkyrienskies.mod.common.hooks.VSGameEvents +import org.valkyrienskies.mod.common.item.AreaAssemblerItem import org.valkyrienskies.mod.common.item.ConnectionCheckerItem import org.valkyrienskies.mod.common.item.PhysicsEntityCreatorItem import org.valkyrienskies.mod.common.item.ShipAssemblerItem @@ -66,6 +67,7 @@ class ValkyrienSkiesModForge { private val CONNECTION_CHECKER_ITEM_REGISTRY: RegistryObject<Item> private val SHIP_CREATOR_ITEM_REGISTRY: RegistryObject<Item> private val SHIP_CREATOR_SMALLER_ITEM_REGISTRY: RegistryObject<Item> + private val AREA_ASSEMBLER_ITEM_REGISTRY: RegistryObject<Item> private val PHYSICS_ENTITY_CREATOR_ITEM_REGISTRY: RegistryObject<Item> private val SHIP_MOUNTING_ENTITY_REGISTRY: RegistryObject<EntityType<ShipMountingEntity>> private val PHYSICS_ENTITY_TYPE_REGISTRY: RegistryObject<EntityType<VSPhysicsEntity>> @@ -137,7 +139,13 @@ class ValkyrienSkiesModForge { { VSGameConfig.SERVER.minScaling } ) } - + AREA_ASSEMBLER_ITEM_REGISTRY = ITEMS.register("area_assembler") { + AreaAssemblerItem( + Properties().tab(CreativeModeTab.TAB_MISC), + { 1.0 }, + { VSGameConfig.SERVER.minScaling } + ) + } PHYSICS_ENTITY_CREATOR_ITEM_REGISTRY = ITEMS.register("physics_entity_creator") { PhysicsEntityCreatorItem( @@ -217,5 +225,6 @@ class ValkyrienSkiesModForge { ValkyrienSkiesMod.SHIP_ASSEMBLER_ITEM = SHIP_ASSEMBLER_ITEM_REGISTRY.get() ValkyrienSkiesMod.TEST_HINGE_BLOCK_ENTITY_TYPE = TEST_HINGE_BLOCK_ENTITY_TYPE_REGISTRY.get() ValkyrienSkiesMod.CONNECTION_CHECKER_ITEM = CONNECTION_CHECKER_ITEM_REGISTRY.get() + ValkyrienSkiesMod.AREA_ASSEMBLER_ITEM = AREA_ASSEMBLER_ITEM_REGISTRY.get() } } diff --git a/gradle.properties b/gradle.properties index d496f87d5..0396b7a8c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -vs_core_version=1.1.0+9d576c0e71 +vs_core_version=1.1.0+6df41559a1 # 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 8450cfc531b7d9797e1cac45856270466dffa337 Mon Sep 17 00:00:00 2001 From: theplasticpotato <theplasticpotato@gmail.com> Date: Fri, 25 Oct 2024 20:28:42 -0400 Subject: [PATCH 432/437] Update VSCore --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 0396b7a8c..7c52e1b13 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -vs_core_version=1.1.0+6df41559a1 +vs_core_version=1.1.0+13b73ea871 # 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 78a95356935170753a800c21fb5bf6ebe61fe915 Mon Sep 17 00:00:00 2001 From: theplasticpotato <theplasticpotato@gmail.com> Date: Fri, 25 Oct 2024 20:37:32 -0400 Subject: [PATCH 433/437] Missed a tiny bit --- .../mod/common/hooks/CommonHooksImpl.kt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/CommonHooksImpl.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/CommonHooksImpl.kt index 980a24c0d..490f306f5 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/CommonHooksImpl.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/hooks/CommonHooksImpl.kt @@ -10,9 +10,26 @@ import org.valkyrienskies.core.apigame.hooks.PlayState.CLIENT_TITLESCREEN import org.valkyrienskies.core.apigame.hooks.PlayState.SERVERSIDE import org.valkyrienskies.mod.common.ValkyrienSkiesMod import org.valkyrienskies.mod.common.shipObjectWorld +import org.valkyrienskies.mod.common.vsCore abstract class CommonHooksImpl : CoreHooksOut { + override var enableBlockEdgeConnectivity: Boolean + get() = vsCore.hooks.enableBlockEdgeConnectivity + set(value) {} + + override var enableBlockCornerConnectivity: Boolean + get() = vsCore.hooks.enableBlockCornerConnectivity + set(value) {} + + override var enableConnectivity: Boolean + get() = vsCore.hooks.enableConnectivity + set(value) {} + + override var enableWorldConnectivity: Boolean + get() = vsCore.hooks.enableWorldConnectivity + set(value) {} + override val playState: PlayState get() { if (!isPhysicalClient) { From 1edb9df58c028811d00f884d2ccdc20b62d7a386 Mon Sep 17 00:00:00 2001 From: theplasticpotato <theplasticpotato@gmail.com> Date: Fri, 25 Oct 2024 20:40:46 -0400 Subject: [PATCH 434/437] Another quick miss --- .../org/valkyrienskies/mod/common/BlockStateInfoProvider.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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 c88be2f65..9178dfb7a 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/BlockStateInfoProvider.kt @@ -135,8 +135,7 @@ object BlockStateInfo { newBlockMass ) - // todo check if splitting is enabled, dolt - if (true) { + if (ValkyrienSkiesMod.vsCore.hooks.enableConnectivity) { ValkyrienSkiesMod.splitHandler.split(level, x, y, z, prevBlockState, newBlockState) } } From a0517bae1e11bf69695d92c0230dd139241ba37b Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Mon, 28 Oct 2024 01:34:00 -0700 Subject: [PATCH 435/437] Fixed ShipAssembler.assembleToShip() --- .../mixin/server/MixinMinecraftServer.java | 1 + .../mod/common/assembly/ShipAssembler.kt | 28 ++++++++++--------- gradle.properties | 2 +- 3 files changed, 17 insertions(+), 14 deletions(-) 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 c5642f5f3..c3ff37678 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 @@ -305,6 +305,7 @@ private void shipChangeDimension(@NotNull final ServerLevel srcLevel, @NotNull f new Vector3d(), new Vector3d(), VSGameUtilsKt.getDimensionId(destLevel), + null, null ); shipWorld.teleportShip(shipObject, shipTeleportData); 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 index 31f00fd00..6ee1d6579 100644 --- a/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembler.kt +++ b/common/src/main/kotlin/org/valkyrienskies/mod/common/assembly/ShipAssembler.kt @@ -3,10 +3,8 @@ 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.Vector3dc import org.joml.Vector3i import org.joml.Vector3ic import org.valkyrienskies.core.api.ships.ServerShip @@ -18,8 +16,6 @@ import org.valkyrienskies.mod.common.dimensionId import org.valkyrienskies.mod.common.getShipObjectManagingPos import org.valkyrienskies.mod.common.shipObjectWorld import org.valkyrienskies.mod.common.util.SplittingDisablerAttachment -import org.valkyrienskies.mod.common.util.toJOMLD -import org.valkyrienskies.mod.util.logger object ShipAssembler { @@ -45,20 +41,25 @@ object ShipAssembler { val existingShip = sLevel.getShipObjectManagingPos(blocks.find { !sLevel.getBlockState(it).isAir } ?: throw IllegalArgumentException()) - var structureCornerMin: BlockPos = blocks[0] - var structureCornerMax: BlockPos = blocks[0] + var structureCornerMin: BlockPos? = null + var structureCornerMax: BlockPos? = null 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) + if (structureCornerMin == null) { + structureCornerMin = itPos + structureCornerMax = itPos + } else { + 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) + 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() @@ -112,15 +113,16 @@ object ShipAssembler { AssemblyUtil.updateBlock(level,itPos,shipPos,level.getBlockState(shipPos)) } - val spawnWorldPos: Vector3dc = AssemblyUtil.getMiddle(structureCornerMin.toJOMLD(), structureCornerMax.toJOMLD()).add(0.5, 0.5, 0.5) - + val shipCenterPos = ((newShip as ServerShip).inertiaData.centerOfMassInShip).add(0.5, 0.5, 0.5, Vector3d()) + // This is giga sus, but whatever + val shipPos = Vector3d(contraptionOGPos).add(0.5, 0.5, 0.5) if (existingShip != null) { sLevel.server.shipObjectWorld - .teleportShip(newShip as ServerShip, ShipTeleportDataImpl(existingShip.shipToWorld.transformPosition(spawnWorldPos, Vector3d()), existingShip.transform.shipToWorldRotation, existingShip.velocity, existingShip.omega, existingShip.chunkClaimDimension)) + .teleportShip(newShip as ServerShip, ShipTeleportDataImpl(existingShip.shipToWorld.transformPosition(shipPos, Vector3d()), existingShip.transform.shipToWorldRotation, existingShip.velocity, existingShip.omega, existingShip.chunkClaimDimension, newScale = existingShip.transform.shipToWorldScaling.x(), newPosInShip = shipCenterPos)) } else { sLevel.server.shipObjectWorld - .teleportShip(newShip as ServerShip, ShipTeleportDataImpl(spawnWorldPos)) + .teleportShip(newShip as ServerShip, ShipTeleportDataImpl(newPos = shipPos, newPosInShip = shipCenterPos)) } if (shouldDisableSplitting) { level.shipObjectWorld.loadedShips.getById(newShip.id)?.getAttachment<SplittingDisablerAttachment>()?.enableSplitting() diff --git a/gradle.properties b/gradle.properties index 7c52e1b13..868595b10 100644 --- a/gradle.properties +++ b/gradle.properties @@ -11,7 +11,7 @@ forge_version=1.18.2-40.2.4 create_fabric_version=0.5.1-f-build.1333+mc1.18.2 flywheel_version_fabric=0.6.9-38 createbigcannons_version= 0.5.2-nightly-e815ca4 -vs_core_version=1.1.0+13b73ea871 +vs_core_version=1.1.0+2a62e6a823 # 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 cf1ea8631c237f79702b5ddd63a0de91ced6753c Mon Sep 17 00:00:00 2001 From: StewStrong <stewstronger@gmail.com> Date: Mon, 28 Oct 2024 01:54:31 -0700 Subject: [PATCH 436/437] Fix create forge not working --- .../mixin/compat/create/client/MixinTrackBlockOutline.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 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 599b00336..362177c3b 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 @@ -28,7 +28,7 @@ import org.valkyrienskies.mod.common.VSGameUtilsKt; import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; -@Mixin(value = TrackBlockOutline.class, remap = false) +@Mixin(value = TrackBlockOutline.class) public class MixinTrackBlockOutline { @Unique private static Vec3 valkyrienskies$cameraVec3; @@ -37,7 +37,7 @@ public class MixinTrackBlockOutline { @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) + @Inject(method = "drawCurveSelection", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/trains/track/TrackBlockOutline$BezierPointSelection;angles()Lnet/minecraft/world/phys/Vec3;"), locals = LocalCapture.CAPTURE_FAILHARD, remap = false) private static void harvestDrawCurveSelection(final PoseStack ms, final MultiBufferSource buffer, final Vec3 camera, final CallbackInfo ci, final Minecraft mc, final BezierPointSelection result, final VertexConsumer vb, final Vec3 vec) { @@ -48,7 +48,8 @@ private static void harvestDrawCurveSelection(final PoseStack ms, final MultiBuf @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) + index = 1, + remap = false) private static PoseStack redirectTransformStackTranslate(final PoseStack ms) { final Level level = Minecraft.getInstance().level; From 5032dbf00d74c536c38d4276057c173389e37ce4 Mon Sep 17 00:00:00 2001 From: millennIumAMbiguity <37588844+millennIumAMbiguity@users.noreply.github.com> Date: Tue, 29 Oct 2024 05:02:56 +0100 Subject: [PATCH 437/437] Fixed changed tag (#995) in 1.19 22w13a carpets block and item tag were renamed to wool_carpets. --- common/src/main/resources/data/valkyrienskies/vs_mass/misc.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7c91c380f..bb16407e9 100644 --- a/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json +++ b/common/src/main/resources/data/valkyrienskies/vs_mass/misc.json @@ -375,7 +375,7 @@ "elasticity": 0.5 }, { - "tag": "minecraft:carpets", + "tag": "minecraft:wool_carpets", "mass": 2.0, "friction": 0.6, "elasticity": 0.05