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/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 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 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/shipyard_entities/MixinEntityRenderDispatcher.java b/common/src/main/java/org/valkyrienskies/mod/mixin/feature/shipyard_entities/MixinEntityRenderDispatcher.java index c04a1fe09..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 @@ -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,53 @@ 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 entityRenderer) { + final EntityRenderer entityRenderer + ) { + final ShipMountedToData shipMountedToData = VSGameUtilsKt.getShipMountedToData(entity, partialTicks); - final ClientShip ship = - (ClientShip) VSGameUtilsKt.getShipObjectManagingPos(entity.level, entity.blockPosition()); - if (ship != null) { + if (shipMountedToData != 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); + final ShipTransform renderTransform = ((ClientShip) shipMountedToData.getShipMountedTo()).getRenderTransform(); + + 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); + } } } } 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..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 @@ -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 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 class MixinPersistentEntitySectionManager implements OfLevel { +public abstract class MixinPersistentEntitySectionManager implements OfLevel { @Shadow @Final EntitySectionStorage sectionStorage; @@ -29,4 +36,41 @@ public void setLevel(final Level level) { this.level = level; ((OfLevel) this.sectionStorage).setLevel(level); } + + @Shadow + @Final + private LongSet chunksToUnload; + + @Shadow + @Final + private Long2ObjectMap chunkVisibility; + + @Shadow + private boolean processChunkUnload(final long l) { + throw new IllegalStateException("This should not be invoked"); + } + + /** + * This fixes this function randomly crashing. I'm not sure why but the removeIf() function is buggy + */ + @Inject( + method = "processUnloads", at = @At(value = "HEAD"), cancellable = true + ) + private void replaceProcessUnloads(final CallbackInfo ci) { + // I don't know why this crashes, try-catch please help me! + try { + final LongSet toRemove = new LongOpenHashSet(); + for (final long key : this.chunksToUnload) { + if (this.chunkVisibility.get(key) != Visibility.HIDDEN) { + toRemove.add(key); + } else if (this.processChunkUnload(key)) { + toRemove.add(key); + } + } + chunksToUnload.removeAll(toRemove); + } catch (final Exception e) { + e.printStackTrace(); + } + ci.cancel(); + } } diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/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/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. 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 { - 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); } } } 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 operation) { + final ClientShip ship = VSClientGameUtils.getClientShip(x, y, z); + if (ship != null) { + final var camera = Minecraft.getInstance().gameRenderer.getMainCamera().getPosition(); + VSClientGameUtils.transformRenderWithShip(ship.getRenderTransform(), instance, pos.getX(),pos.getY(),pos.getZ(), camera.x, camera.y, camera.z ); + } else { + operation.call(instance, x, y, z); + } + } +} diff --git a/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinAbstractContraptionEntity.java b/common/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/create/entity/MixinAbstractContraptionEntity.java index f8511fd70..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 @@ -8,7 +8,6 @@ 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; @@ -104,25 +103,6 @@ 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))); - } - } - 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 cir) { @@ -302,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(); + } } } } 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/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java b/common/src/main/java/org/valkyrienskies/mod/mixin/server/world/MixinServerLevel.java index b3e4c96e9..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 @@ -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.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; @@ -243,6 +247,24 @@ 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 shipBreakages = (HashSet) connData.getBreakages(); + Iterator 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/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/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt b/common/src/main/kotlin/org/valkyrienskies/mod/common/VSGameUtils.kt index 8a51aa7e5..9368ad3fd 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, partialTicks) + } + 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/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>() + 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/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..852499f0b --- /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, partialTicks: Float?): ShipMountedToData? +} 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() val shipsStartRendering = EventEmitterImpl() + val shipSplit = EventEmitterImpl() + data class ShipStartRenderEvent( val renderer: LevelRenderer, val renderType: RenderType, @@ -35,5 +39,11 @@ object VSGameEvents { val ship: ClientShip, val chunks: ObjectList ) + + data class ShipSplitEvent( + val ship: ShipId, + val newShip: ShipId, + val blocks: DenseBlockPosSet + ) } diff --git a/common/src/main/kotlin/org/valkyrienskies/mod/common/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) { 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/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 } } 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/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 } 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, 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 + } +] diff --git a/common/src/main/resources/valkyrienskies-common.mixins.json b/common/src/main/resources/valkyrienskies-common.mixins.json index ad3590d7e..44005a881 100644 --- a/common/src/main/resources/valkyrienskies-common.mixins.json +++ b/common/src/main/resources/valkyrienskies-common.mixins.json @@ -79,6 +79,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/build.gradle b/forge/build.gradle index 11e0a1807..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') @@ -107,11 +110,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/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/java/org/valkyrienskies/mod/forge/mixin/compat/mekanism/MixinRadiationManager.java b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mekanism/MixinRadiationManager.java new file mode 100644 index 000000000..229a7d65f --- /dev/null +++ b/forge/src/main/java/org/valkyrienskies/mod/forge/mixin/compat/mekanism/MixinRadiationManager.java @@ -0,0 +1,31 @@ +package org.valkyrienskies.mod.forge.mixin.compat.mekanism; + +import java.util.Objects; +import mekanism.api.Coord4D; +import mekanism.common.lib.radiation.RadiationManager; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceKey; +import net.minecraft.world.level.Level; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; +import org.valkyrienskies.core.api.ships.Ship; +import org.valkyrienskies.mod.common.VSGameUtilsKt; +import org.valkyrienskies.mod.common.ValkyrienSkiesMod; +import org.valkyrienskies.mod.common.util.VectorConversionsMCKt; + +@Mixin(RadiationManager.class) +public class MixinRadiationManager { + @ModifyVariable(remap = false, ordinal = 0, method = "radiate(Lmekanism/api/Coord4D;D)V", at = @At("HEAD"), argsOnly = true) + private Coord4D MixinDumpRadiation(final Coord4D coord4D) { + final ResourceKey resourceKey = coord4D.dimension; + final Level level = Objects.requireNonNull(ValkyrienSkiesMod.getCurrentServer()).getLevel(resourceKey); + final Ship ship = VSGameUtilsKt.getShipManagingPos(level, coord4D.getPos()); + if (ship == null){ + return coord4D; + }else{ + return new Coord4D(new BlockPos( + VectorConversionsMCKt.toMinecraft(VSGameUtilsKt.toWorldCoordinates(ship, coord4D.getPos()))), coord4D.dimension); + } + } +} diff --git a/forge/src/main/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) diff --git a/forge/src/main/resources/valkyrienskies-forge.mixins.json b/forge/src/main/resources/valkyrienskies-forge.mixins.json index c678251a6..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" ], @@ -25,7 +26,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" diff --git a/gradle.properties b/gradle.properties index a45897e04..95399fe74 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.6 maven_group=org.valkyrienskies.mod architectury_version=4.10.86 fabric_loader_version=0.14.11 @@ -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