Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ plugins {
id "architectury-plugin" version "3.4.+"
id "dev.architectury.loom" version "1.7.+" apply false
// Kotlin
id "org.jetbrains.kotlin.jvm" version "1.9.10" apply false
id "org.jetbrains.kotlin.jvm" version "2.0.0" apply false
// Kotlin linter
id "org.jlleitschuh.gradle.ktlint" version "10.3.0"
// Java linter
Expand Down Expand Up @@ -161,3 +161,4 @@ allprojects {
options.release = 17
}
}

19 changes: 16 additions & 3 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ dependencies {
modImplementation "net.fabricmc:fabric-loader:${rootProject.fabric_loader_version}"
// Remove the next line if you don't want to depend on the API
// modApi "me.shedaniel:architectury:${rootProject.architectury_version}"
modApi("org.valkyrienskies:valkyrienskies-120-common:${rootProject.vs2_version}")
modApi("org.valkyrienskies:valkyrienskies-120-common:${rootProject.vs2_version}") {
exclude(group: "com.simibubi.create")
}

compileOnly("org.valkyrienskies.core:api:${rootProject.vs_core_version}")
compileOnly("org.valkyrienskies.core:api-game:${rootProject.vs_core_version}")
compileOnly("org.valkyrienskies.core:internal:${rootProject.vs_core_version}")
compileOnly("org.valkyrienskies.core:util:${rootProject.vs_core_version}")
compileOnly("org.valkyrienskies.core:impl:${rootProject.vs_core_version}")

Expand All @@ -36,7 +38,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.simibubi.create:create-fabric-${minecraft_version}:${create_fabric_version}")
modCompileOnly("com.simibubi.create:create-fabric:${create_fabric_version}")
{ exclude group: 'com.github.AlphaMode', module: 'fakeconfigtoml'
exclude group: 'dev.engine-room.flywheel' }
modCompileOnly("net.fabricmc.fabric-api:fabric-api:${fabric_api_version}")
Expand Down Expand Up @@ -87,3 +89,14 @@ publishing {
}
}
}

compileKotlin {
compilerOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
jvmToolchain(17)
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
package org.valkyrienskies.create_interactive;

import net.minecraft.client.gui.screens.Screen;
import net.minecraft.core.BlockPos;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.Level;
import org.valkyrienskies.core.api.ships.ServerShip;
import org.valkyrienskies.core.impl.config.VSConfigClass;
import org.valkyrienskies.mod.common.VSGameUtilsKt;
import org.valkyrienskies.mod.compat.clothconfig.VSClothConfig;

/**
* This only exists because forge gradle is broken and I can't be bothered to fix it
Expand All @@ -21,7 +18,7 @@ public static ServerShip getShipById(final ServerLevel serverLevel, final long i
return VSGameUtilsKt.getShipObjectWorld(serverLevel).getAllShips().getById(id);
}

public static Screen createConfigScreenFor(final Screen parent, final VSConfigClass... configClasses) {
return VSClothConfig.createConfigScreenFor(parent, configClasses);
}
// public static Screen createConfigScreenFor(final Screen parent, final VSConfigClass... configClasses) {
// return VSConfig.createConfigScreenFor(parent, configClasses);
// }
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.simibubi.create.content.trains.bogey.AbstractBogeyBlock;
import com.simibubi.create.content.trains.entity.CarriageBogey;
import com.simibubi.create.foundation.utility.animation.LerpedFloat;
import net.createmod.catnip.animation.LerpedFloat;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

@Mixin(CarriageContraption.class)
public interface CarriageContraptionAccessor {
@Accessor(value = "assembledBlazeBurners", remap = false)
@Accessor(value = "assembledBlockConductors", remap = false)
List<BlockPos> getAssembledBlazeBurners();

@Accessor(value = "assembledBlazeBurners", remap = false)
@Accessor(value = "assembledBlockConductors", remap = false)
void setAssembledBlazeBurners(List<BlockPos> assembledBlazeBurners);
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.valkyrienskies.create_interactive.mixin;

import com.simibubi.create.content.trains.entity.CarriageSyncData;
import com.simibubi.create.foundation.utility.Couple;
import com.simibubi.create.foundation.utility.Pair;
import net.createmod.catnip.data.Couple;
import net.createmod.catnip.data.Pair;
import net.minecraft.world.phys.Vec3;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package org.valkyrienskies.create_interactive.mixin;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.simibubi.create.api.behaviour.movement.MovementBehaviour;
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.Contraption;
import com.simibubi.create.content.contraptions.MountedStorageManager;
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
import kotlin.Pair;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.player.Player;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
import net.minecraft.world.phys.Vec3;
Expand Down Expand Up @@ -156,6 +160,15 @@ private void preGetPassengerPosition(final Entity passenger, final float partial
MixinAbstractContraptionEntityLogic.INSTANCE.preGetPassengerPosition$create_interactive(AbstractContraptionEntity.class.cast(this), passenger, partialTicks, cir);
}

@WrapOperation(
method = "handlePlayerInteraction",
at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/contraptions/MountedStorageManager;handlePlayerStorageInteraction(Lcom/simibubi/create/content/contraptions/Contraption;Lnet/minecraft/world/entity/player/Player;Lnet/minecraft/core/BlockPos;)Z"),
remap = false
)
private boolean preHandleStorageInteraction(MountedStorageManager storageManager, Contraption contraption, Player player, BlockPos blockPos, Operation<Boolean> original){
return MixinAbstractContraptionEntityLogic.INSTANCE.preStorageInteraction$create_interactive(AbstractContraptionEntity.class.cast(this), storageManager, contraption, player, blockPos, original);
}

@Override
public boolean ci$hasTickedThisTick() {
return ci$hasTickedThisTick;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package org.valkyrienskies.create_interactive.mixin;

import com.simibubi.create.AllInteractionBehaviours;
import com.simibubi.create.content.contraptions.behaviour.MovingInteractionBehaviour;
import com.simibubi.create.api.behaviour.interaction.MovingInteractionBehaviour;
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.create_interactive.mixin_logic.MixinAllInteractionBehavioursLogic;

@Mixin(AllInteractionBehaviours.class)
@Mixin(MovingInteractionBehaviour.class)
public class MixinAllInteractionBehaviours {
/**
* @author Triode
* @reason Disable the dumb ones
*/
@Inject(method = "getBehaviour", at = @At("RETURN"), cancellable = true)
private static void postGetBehaviour(final CallbackInfoReturnable<MovingInteractionBehaviour> cir) {
cir.setReturnValue(MixinAllInteractionBehavioursLogic.INSTANCE.postGetBehavior$create_interactive(cir.getReturnValue()));
}
// @Inject(method = "getBehaviour", at = @At("RETURN"), cancellable = true)
// private static void postGetBehaviour(final CallbackInfoReturnable<MovingInteractionBehaviour> cir) {
// cir.setReturnValue(MixinAllInteractionBehavioursLogic.INSTANCE.postGetBehavior$create_interactive(cir.getReturnValue()));
// }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.valkyrienskies.create_interactive.mixin;

import com.simibubi.create.content.contraptions.BlockMovementChecks;
import com.simibubi.create.api.contraption.BlockMovementChecks;
import net.minecraft.core.BlockPos;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -15,13 +15,13 @@ public class MixinBlockMovementChecks {
/**
* Allow track blocks to be relocated
*/
@Inject(method = "isMovementAllowedFallback", at = @At("HEAD"), cancellable = true)
@Inject(method = "isMovementAllowed", at = @At("HEAD"), cancellable = true)
private static void preIsMovementAllowedFallback(
BlockState state,
Level world,
BlockPos pos,
CallbackInfoReturnable<Boolean> cir
) {
MixinBlockMovementChecksLogic.INSTANCE.preIsMovementAllowedFallback$create_interactive(state, cir);
MixinBlockMovementChecksLogic.INSTANCE.preIsMovementAllowed$create_interactive(state, cir);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.valkyrienskies.create_interactive.mixin_logic.MixinCarriageContraptionEntityLogic;
import org.valkyrienskies.create_interactive.mixinducks.AbstractContraptionEntityDuck;
import org.valkyrienskies.mod.common.VSGameUtilsKt;
import org.valkyrienskies.mod.common.ValkyrienSkiesMod;

@Mixin(CarriageContraptionEntity.class)
public abstract class MixinCarriageContraptionEntity extends OrientedContraptionEntity implements AbstractContraptionEntityDuck {
Expand All @@ -30,8 +31,6 @@ private void redirectAlignEntity(final Carriage.DimensionalCarriageEntity instan
}
}

@Unique
private Integer ci$forceConstraintId = null;

/**
* Create the constraints between train cars
Expand All @@ -42,15 +41,16 @@ private void preTick(final CallbackInfo ci) {
return;
}
final CarriageContraptionEntity thisAs = CarriageContraptionEntity.class.cast(this);
Integer ci$jointId = MixinCarriageContraptionEntityLogic.INSTANCE.getJointId(thisAs);
if (CreateInteractiveUtil.INSTANCE.isTrainDerailed(thisAs)) {
if (ci$forceConstraintId == null) {
if (ci$jointId == null) {
// Compute this just in time to account for the distance between cars changing slightly during turns
ci$forceConstraintId = MixinCarriageContraptionEntityLogic.INSTANCE.preTick$create_interactive(thisAs);
MixinCarriageContraptionEntityLogic.INSTANCE.preTick$create_interactive(thisAs);
}
} else {
if (ci$forceConstraintId != null) {
VSGameUtilsKt.getShipObjectWorld((ServerLevel) level()).removeConstraint(ci$forceConstraintId);
ci$forceConstraintId = null;
if (ci$jointId != null) {
ValkyrienSkiesMod.getOrCreateGTPA(VSGameUtilsKt.getDimensionId(level())).removeJoint(ci$jointId);
MixinCarriageContraptionEntityLogic.INSTANCE.setJointId(thisAs, null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.valkyrienskies.create_interactive.mixin;

import com.simibubi.create.api.behaviour.interaction.MovingInteractionBehaviour;
import com.simibubi.create.content.contraptions.AbstractContraptionEntity;
import com.simibubi.create.content.contraptions.Contraption;
import com.simibubi.create.content.contraptions.StructureTransform;
import com.simibubi.create.content.contraptions.behaviour.MovementContext;
import com.simibubi.create.content.contraptions.behaviour.MovingInteractionBehaviour;
import kotlin.Unit;
import net.minecraft.core.BlockPos;
import net.minecraft.nbt.CompoundTag;
Expand Down Expand Up @@ -53,6 +53,9 @@ public abstract class MixinContraption implements ContraptionDuck {
@Shadow
protected abstract CompoundTag getBlockEntityNBT(final Level world, final BlockPos pos);

@Shadow
public abstract void invalidateClientContraptionChildren();

@Inject(method = "<init>", at = @At("RETURN"), remap = false)
private void postInit(final CallbackInfo ci) {
ci$changedActors = new HashSet<>();
Expand Down Expand Up @@ -105,6 +108,11 @@ private void postAddBlocksToWorld(final Level world, final StructureTransform tr
interactors,
Contraption.class.cast(this)
);
// Invalidate the children, to add/remove actor visuals
if(!ci$changedActors.isEmpty()) {
invalidateClientContraptionChildren();
ci$clearChangedActors();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.valkyrienskies.create_interactive.mixin;

import com.simibubi.create.content.trains.track.ITrackBlock;
import com.simibubi.create.foundation.utility.Pair;
import net.createmod.catnip.data.Pair;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import com.simibubi.create.content.trains.track.ITrackBlock;
import com.simibubi.create.content.trains.track.TrackPlacement;
import com.simibubi.create.foundation.utility.Pair;
import net.createmod.catnip.data.Pair;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -42,7 +42,7 @@ private static Vec3 redirectTryConnectInvokeGetLookAngle(
/**
* Fix placing rails on rotated ships part 2. Because of our mixin to getNearestTrackAxis we need to re-invoke without transforming the player look vector
*/
@WrapOperation(method = "tryConnect", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/trains/track/ITrackBlock;getNearestTrackAxis(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/phys/Vec3;)Lcom/simibubi/create/foundation/utility/Pair;"))
@WrapOperation(method = "tryConnect", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/content/trains/track/ITrackBlock;getNearestTrackAxis(Lnet/minecraft/world/level/BlockGetter;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/phys/Vec3;)Lnet/createmod/catnip/data/Pair;"))
private static Pair<Vec3, Direction.AxisDirection> redirectTryConnectInvokeGetNearestTrackAxis(
final ITrackBlock iTrackBlock,
final BlockGetter world,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package org.valkyrienskies.create_interactive.mixin.client;

import com.simibubi.create.content.contraptions.Contraption;
import com.simibubi.create.content.contraptions.ContraptionWorld;
import com.simibubi.create.content.contraptions.render.ContraptionVisual;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;

@Mixin(FlwContraption.ContraptionInstanceWorld.class)
@Mixin(Contraption.class)
public interface ContraptionInstanceWorldAccessor {
@Accessor(value = "blockEntityInstanceManager",remap = false)
ContraptionVisual getBlockEntityInstanceManager();
@Accessor(value = "collisionLevel",remap = false)
ContraptionWorld getBlockEntityInstanceManager();
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
package org.valkyrienskies.create_interactive.mixin.client;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderDispatcher;
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.world.level.block.entity.BlockEntity;
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.create_interactive.mixin_logic.client.MixinBlockEntityRenderDispatcherLogic;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import org.valkyrienskies.create_interactive.mixin_logic.client.MixinVisualManagerLogic;

/**
* Disable rendering of block entities with actors in contraption shadow ships
*/
@Mixin(BlockEntityRenderDispatcher.class)
public class MixinBlockEntityRenderDispatcher {
@Inject(method = "render", at = @At("HEAD"), cancellable = true)
private <E extends BlockEntity> void preRender(final E blockEntity, final float partialTick, final PoseStack poseStack, final MultiBufferSource bufferSource, final CallbackInfo ci) {
MixinBlockEntityRenderDispatcherLogic.INSTANCE.preRender$create_interactive(blockEntity, ci);
@Inject(method = "getRenderer", at = @At("HEAD"), cancellable = true)
private <E extends BlockEntity> void preGetRenderer(E blockEntity, CallbackInfoReturnable<BlockEntityRenderer<E>> cir) {
if(MixinVisualManagerLogic.INSTANCE.shouldRemoveBlockEntityInShip$create_interactive(blockEntity)) {
cir.setReturnValue(null);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

@Mixin(CarriageContraptionEntityRenderer.class)
public class MixinCarriageContraptionEntityRenderer {
@Inject(method = "translateBogey", at = @At("HEAD"), cancellable = true)
@Inject(method = "translateBogey", at = @At("HEAD"), cancellable = true, remap = false)
private static void preTranslateBogey(
final PoseStack ms,
final CarriageBogey bogey,
Expand All @@ -21,7 +21,7 @@ private static void preTranslateBogey(
final float partialTicks,
final CallbackInfo ci
) {
MixinCarriageContraptionEntityRendererLogic.INSTANCE.preTranslateBogey$create_interactive_mod_common_main(
MixinCarriageContraptionEntityRendererLogic.INSTANCE.preTranslateBogey$create_interactive(
ms, bogey, partialTicks, ci
);
}
Expand Down
Loading
Loading