-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Putting CC: Tweaked Mixins in Common (#1046)
* Moved CC: Tweaked Mixins and dependency to common and replaced with updated Mixins from `1.18.2/main` * Removed old Mixin paths from Forge and Fabric * Fixed both Turtles ability to leave Ships and re-implemented Turtles ability to collide with Ships and pass through their empty spaces * Ship-On-Ship Action (Turtles can not pass through and detect Ships while on other Ships
- Loading branch information
1 parent
63c80e4
commit acb035c
Showing
23 changed files
with
158 additions
and
528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
...on/src/main/java/org/valkyrienskies/mod/mixin/mod_compat/cc_tweaked/MixinTurtleBrain.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package org.valkyrienskies.mod.mixin.mod_compat.cc_tweaked; | ||
|
||
import dan200.computercraft.shared.turtle.blocks.TurtleBlockEntity; | ||
import dan200.computercraft.shared.turtle.core.TurtleBrain; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.core.Direction; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.joml.Vector3d; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Pseudo; | ||
import org.spongepowered.asm.mixin.Shadow; | ||
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.api.ValkyrienSkies; | ||
import org.valkyrienskies.mod.common.config.VSGameConfig; | ||
|
||
@Pseudo | ||
@Mixin(TurtleBrain.class) | ||
public abstract class MixinTurtleBrain { | ||
@Shadow(remap = false) | ||
public abstract TurtleBlockEntity getOwner(); | ||
|
||
@Shadow(remap = false) | ||
public abstract void setOwner(TurtleBlockEntity owner); | ||
|
||
@Shadow | ||
public abstract Level getLevel(); | ||
|
||
@ModifyVariable( | ||
method = "teleportTo(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;)Z", | ||
at = @At(value = "HEAD"), | ||
index = 2, | ||
argsOnly = true, | ||
remap = false | ||
) | ||
private BlockPos ValkyrienSkies2$teleportToBlockPos(final BlockPos pos) { | ||
final TurtleBlockEntity currentOwner = getOwner(); | ||
final BlockPos oldPos = currentOwner.getBlockPos(); | ||
final Level world = getLevel(); | ||
|
||
final Ship ship = ValkyrienSkies.getShipManagingBlock(world, oldPos); | ||
if (ship != null) { | ||
// THERE IS A SHIP | ||
|
||
final Vector3d transformedDirection = ship.getShipToWorld().transformDirection( | ||
ValkyrienSkies.toJOMLd(currentOwner.getDirection().getNormal()) | ||
); | ||
if (!ship.getShipAABB().containsPoint(ValkyrienSkies.toJOML(pos))) { | ||
// POSITION IS OUTSIDE THE SHIP'S AABB | ||
|
||
currentOwner.setDirection( | ||
Direction.getNearest(transformedDirection.x, transformedDirection.y, transformedDirection.z)); | ||
setOwner(currentOwner); | ||
|
||
final boolean isShipScaled = !ship.getTransform().getShipToWorldScaling().equals(1.000E+0, 1.000E+0, 1.000E+0); | ||
|
||
if (isShipScaled) { | ||
// SHIP IS SCALED | ||
|
||
if (VSGameConfig.SERVER.getComputerCraft().getCanTurtlesLeaveScaledShips()) { | ||
// TURTLES CAN LEAVE SCALED SHIPS | ||
|
||
return BlockPos.containing(ValkyrienSkies.positionToWorld(ship, Vec3.atCenterOf(pos))); | ||
} | ||
} else { | ||
// SHIP ISNT SCALED | ||
|
||
return BlockPos.containing(ValkyrienSkies.positionToWorld(ship, Vec3.atCenterOf(pos))); | ||
} | ||
} | ||
} | ||
return pos; | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
.../main/java/org/valkyrienskies/mod/mixin/mod_compat/cc_tweaked/MixinTurtleMoveCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package org.valkyrienskies.mod.mixin.mod_compat.cc_tweaked; | ||
|
||
import com.google.common.collect.Streams; | ||
import dan200.computercraft.api.turtle.TurtleCommandResult; | ||
import dan200.computercraft.shared.turtle.core.TurtleMoveCommand; | ||
import dan200.computercraft.shared.turtle.core.TurtlePlayer; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import net.minecraft.core.BlockPos; | ||
import net.minecraft.server.level.ServerLevel; | ||
import net.minecraft.world.level.ChunkPos; | ||
import org.joml.Vector3d; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Pseudo; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
import org.valkyrienskies.core.api.ships.Ship; | ||
import org.valkyrienskies.mod.api.ValkyrienSkies; | ||
|
||
@Pseudo | ||
@Mixin(TurtleMoveCommand.class) | ||
public abstract class MixinTurtleMoveCommand { | ||
@Inject(method = "canEnter", at = @At("RETURN"), remap = false, cancellable = true) | ||
private static void ValkyrienSkies2$canEnter( | ||
TurtlePlayer turtlePlayer, ServerLevel world, BlockPos position, | ||
CallbackInfoReturnable<TurtleCommandResult> cir) { | ||
if (cir.getReturnValue().isSuccess()) { | ||
final Ship ship = ValkyrienSkies.getShipManagingBlock(world, position); | ||
Vector3d testPosition = ValkyrienSkies.toJOML(position.getCenter()); | ||
|
||
if (ship != null) { | ||
final ChunkPos chunk = world.getChunkAt(position).getPos(); | ||
if (!ship.getChunkClaim().contains(chunk.x, chunk.z)) { | ||
cir.setReturnValue(TurtleCommandResult.failure("Out of ship chunk")); | ||
} | ||
|
||
testPosition = ValkyrienSkies.positionToWorld(ship, testPosition); | ||
} | ||
|
||
final List<Vector3d> nearbyShips = | ||
new ArrayList<>(Streams.stream(ValkyrienSkies.positionToNearbyShips(world, | ||
testPosition.x, testPosition.y, testPosition.z, 0.1)).toList()); | ||
|
||
final boolean notInAir = !nearbyShips.isEmpty() && nearbyShips | ||
.stream() | ||
.map(ValkyrienSkies::toMinecraft) | ||
.map(BlockPos::containing) | ||
.map(world::getBlockState) | ||
.anyMatch(state -> !state.isAir()); | ||
|
||
if (notInAir) { | ||
cir.setReturnValue(TurtleCommandResult.failure("Movement obstructed by ship")); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 0 additions & 65 deletions
65
...main/java/org/valkyrienskies/mod/fabric/mixin/compat/cc_restitched/MixinSpeakerSound.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.