Skip to content

Commit

Permalink
fix splitting on contraption assembly but like for real this time
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePlasticPotato committed Dec 21, 2024
1 parent 1c98bb0 commit c41d894
Showing 1 changed file with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.Level;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
Expand All @@ -17,6 +18,9 @@

@Mixin(Contraption.class)
public class MixinContraption {
@Shadow
public BlockPos anchor;

@Redirect(method = "onEntityCreated", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/Level;addFreshEntity(Lnet/minecraft/world/entity/Entity;)Z"))
private boolean wrapOp(Level level, Entity entity) {
// BlockPos anchor = blockFace.getConnectedPos();
Expand All @@ -33,8 +37,8 @@ private boolean wrapOp(Level level, Entity entity) {

@Inject(method = "removeBlocksFromWorld", at = @At("HEAD"))
private void preRemoveBlocksFromWorld(Level world, BlockPos pos, CallbackInfo ci) {
if (world instanceof ServerLevel sWorld) {
LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(sWorld, pos);
if (world instanceof ServerLevel sWorld && this.anchor != null) {
LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(sWorld, this.anchor);
if (ship != null) {
SplittingDisablerAttachment attachment = ship.getAttachment(SplittingDisablerAttachment.class);
if (attachment != null) {
Expand All @@ -44,10 +48,10 @@ private void preRemoveBlocksFromWorld(Level world, BlockPos pos, CallbackInfo ci
}
}

@Inject(method = "removeBlocksFromWorld", at = @At("RETURN"))
@Inject(method = "removeBlocksFromWorld", at = @At("TAIL"))
private void postRemoveBlocksFromWorld(Level world, BlockPos pos, CallbackInfo ci) {
if (world instanceof ServerLevel sWorld) {
LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(sWorld, pos);
if (world instanceof ServerLevel sWorld && this.anchor != null) {
LoadedServerShip ship = VSGameUtilsKt.getShipObjectManagingPos(sWorld, this.anchor);
if (ship != null) {
SplittingDisablerAttachment attachment = ship.getAttachment(SplittingDisablerAttachment.class);
if (attachment != null) {
Expand Down

0 comments on commit c41d894

Please sign in to comment.