From 126241369b72870c1d111ef9b550f76f65f66881 Mon Sep 17 00:00:00 2001 From: Sammy Date: Sun, 13 Aug 2023 01:50:03 +0200 Subject: [PATCH] Fabric; Fixed crash on server side --- fabric/gradle.properties | 2 +- .../common/mixin/MixinAdventureUtil.java | 32 ------------------ .../mixin/MixinCarriageContraption.java | 33 ------------------- .../scroller/MixinScrollValueRenderer.java | 5 ++- .../MixinValueSettingsInputHandler.java | 3 +- 5 files changed, 4 insertions(+), 71 deletions(-) delete mode 100644 fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinAdventureUtil.java delete mode 100644 fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinCarriageContraption.java diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 742c431..56d6f96 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2G # Mod Properties -mod_version=1.6.2 +mod_version=1.6.2a maven_group=cc.tweaked_programs archives_base_name=cccbridge diff --git a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinAdventureUtil.java b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinAdventureUtil.java deleted file mode 100644 index 87d2011..0000000 --- a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinAdventureUtil.java +++ /dev/null @@ -1,32 +0,0 @@ -package cc.tweaked_programs.cccbridge.common.mixin; - -import cc.tweaked_programs.cccbridge.common.minecraft.blockEntity.ScrollerBlockEntity; -import com.simibubi.create.foundation.utility.AdventureUtil; -import net.minecraft.world.entity.player.Player; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.phys.BlockHitResult; -import net.minecraft.world.phys.HitResult; -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; - -@Mixin(AdventureUtil.class) -public abstract class MixinAdventureUtil { - @Inject(method = "isAdventure", at = @At("HEAD"), cancellable = true, remap = false) - private static void cccbridge$isAdventure(Player player, CallbackInfoReturnable cir) { - if (player.isSpectator()) - return; - - Level level = player.level(); - HitResult hitResult = player.pick(5, 1, false); - - if (hitResult instanceof BlockHitResult blockHit) { - BlockEntity blockEntity = level.getBlockEntity(blockHit.getBlockPos()); - - if (blockEntity instanceof ScrollerBlockEntity) - cir.setReturnValue(false); - } - } -} diff --git a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinCarriageContraption.java b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinCarriageContraption.java deleted file mode 100644 index b909f21..0000000 --- a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinCarriageContraption.java +++ /dev/null @@ -1,33 +0,0 @@ -package cc.tweaked_programs.cccbridge.common.mixin; - -import cc.tweaked_programs.cccbridge.common.minecraft.block.AnimatronicBlock; -import com.simibubi.create.content.contraptions.Contraption; -import com.simibubi.create.content.trains.entity.CarriageContraption; -import net.minecraft.core.BlockPos; -import net.minecraft.world.level.Level; -import net.minecraft.world.level.block.entity.BlockEntity; -import net.minecraft.world.level.block.state.BlockState; -import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; -import org.apache.commons.lang3.tuple.Pair; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import java.util.List; - -@Mixin(CarriageContraption.class) -public abstract class MixinCarriageContraption extends Contraption { - @Shadow - private List assembledBlazeBurners; - - @Inject(method = "capture", at = @At("HEAD"), remap = false) - public void cccbridge$capture(Level world, BlockPos pos, CallbackInfoReturnable> cir) { - BlockState blockState = world.getBlockState(pos); - - if (blockState.getBlock() instanceof AnimatronicBlock) { - assembledBlazeBurners.add(toLocalPos(pos)); - } - } -} diff --git a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinScrollValueRenderer.java b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinScrollValueRenderer.java index 732a2d1..7f0ad20 100644 --- a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinScrollValueRenderer.java +++ b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinScrollValueRenderer.java @@ -4,7 +4,6 @@ import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueBehaviour; import com.simibubi.create.foundation.blockEntity.behaviour.scrollValue.ScrollValueRenderer; import com.simibubi.create.foundation.utility.AdventureUtil; -import net.minecraft.client.Minecraft; import net.minecraft.client.multiplayer.ClientLevel; import net.minecraft.core.BlockPos; import net.minecraft.core.Direction; @@ -22,8 +21,8 @@ private static boolean isPhysicalPlayer(Player player) { @Redirect(method = "addBox", at = @At(value = "INVOKE", target = "Lcom/simibubi/create/foundation/utility/AdventureUtil;isAdventure(Lnet/minecraft/world/entity/player/Player;)Z"), remap = false) private static boolean cccbridge$addBox$redirectIsAdventure(Player player, ClientLevel world, BlockPos pos, Direction face, ScrollValueBehaviour behaviour, boolean highlight) { if (world.getBlockState(pos).getBlock() instanceof ScrollerBlock) - return isPhysicalPlayer(Minecraft.getInstance().player); + return isPhysicalPlayer(player); - return AdventureUtil.isAdventure(Minecraft.getInstance().player); + return AdventureUtil.isAdventure(player); } } diff --git a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinValueSettingsInputHandler.java b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinValueSettingsInputHandler.java index 0f2ff56..13466a2 100644 --- a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinValueSettingsInputHandler.java +++ b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/scroller/MixinValueSettingsInputHandler.java @@ -3,7 +3,6 @@ import cc.tweaked_programs.cccbridge.common.minecraft.blockEntity.ScrollerBlockEntity; import com.simibubi.create.foundation.blockEntity.behaviour.ValueSettingsInputHandler; import com.simibubi.create.foundation.utility.AdventureUtil; -import net.minecraft.client.Minecraft; import net.minecraft.world.entity.player.Player; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.entity.BlockEntity; @@ -28,7 +27,7 @@ private static boolean isPhysicalPlayer(Player player) { BlockEntity blockEntity = level.getBlockEntity(blockHit.getBlockPos()); if (blockEntity instanceof ScrollerBlockEntity) - return !isPhysicalPlayer(Minecraft.getInstance().player); + return !isPhysicalPlayer(player); } return !AdventureUtil.isAdventure(player);