diff --git a/fabric/gradle.properties b/fabric/gradle.properties index 2a368a7..548eb30 100644 --- a/fabric/gradle.properties +++ b/fabric/gradle.properties @@ -2,7 +2,7 @@ org.gradle.jvmargs=-Xmx2G # Mod Properties -mod_version=1.6.0 +mod_version=1.6.1 maven_group=cc.tweaked_programs archives_base_name=cccbridge @@ -19,7 +19,7 @@ parchment_version=2023.07.16 # Dependencies fabric_version=0.86.0 cc_version=1.106.1 -create_version=0.5.1-c-build.1113 +create_version=0.5.1-d-build.1130 create_version_production=0.5.1-c # Mod Menu - https://modrinth.com/mod/modmenu/versions diff --git a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/computercraft/peripherals/ScrollerBlockPeripheral.java b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/computercraft/peripherals/ScrollerBlockPeripheral.java index 8970bae..c13d563 100644 --- a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/computercraft/peripherals/ScrollerBlockPeripheral.java +++ b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/computercraft/peripherals/ScrollerBlockPeripheral.java @@ -71,8 +71,10 @@ public final int getValue() { @LuaFunction public final void setValue(int value) { ScrollerBlockEntity be = getTarget(); - if (be != null) + if (be != null) { + be.nextChangeQuietly(); be.setValue(value); + } } /** diff --git a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/minecraft/block/RedRouterBlock.java b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/minecraft/block/RedRouterBlock.java index 0403913..fe89346 100644 --- a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/minecraft/block/RedRouterBlock.java +++ b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/minecraft/block/RedRouterBlock.java @@ -26,7 +26,7 @@ import org.jetbrains.annotations.NotNull; public class RedRouterBlock extends HorizontalDirectionalBlock implements EntityBlock, IWrenchable { - public static final Properties REDROUTER_BLOCK_PROPERTIES = FabricBlockSettings.create().strength(1.3f).sound(SoundType.STONE).noOcclusion(); + public static final Properties REDROUTER_BLOCK_PROPERTIES = FabricBlockSettings.create().strength(1.3f).sound(SoundType.STONE).noOcclusion().isRedstoneConductor((state, view, pos) -> false); public static final int FACE_AMOUNT = 16; public static final IntegerProperty FACE = IntegerProperty.create("face", 0, FACE_AMOUNT); public RedRouterBlock(Properties properties) { @@ -73,6 +73,11 @@ public int getSignal(@NotNull BlockState state, BlockGetter world, @NotNull Bloc return redrouter.getPower(dir); } + @Override + public int getDirectSignal(BlockState state, BlockGetter level, BlockPos pos, Direction direction) { + return getSignal(state, level, pos, direction); + } + @Override public InteractionResult onWrenched(BlockState state, UseOnContext context) { BlockEntity tileentity = context.getLevel().getBlockEntity(context.getClickedPos()); diff --git a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/minecraft/blockEntity/ScrollerBlockEntity.java b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/minecraft/blockEntity/ScrollerBlockEntity.java index 2458703..b70e141 100644 --- a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/minecraft/blockEntity/ScrollerBlockEntity.java +++ b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/minecraft/blockEntity/ScrollerBlockEntity.java @@ -27,8 +27,8 @@ public class ScrollerBlockEntity extends SmartBlockEntity implements PeripheralBlockEntity { private ScrollerBlockPeripheral peripheral; private boolean locked = false; + private boolean quietly = false; private boolean updateLock = false; - private boolean playTickSound = false; private LuaScrollValueBehaviour scroller; public ScrollerBlockEntity(BlockPos pos, BlockState state) { @@ -54,8 +54,16 @@ public void setValue(int value) { scroller.setValue(value); } + public void nextChangeQuietly() { + quietly = true; + } + public void fireUpdateValueEvent() { - if (peripheral != null) + if (quietly) { + quietly = false; + return; + } + if (peripheral != null ) peripheral.sendEvent("scroller_changed", scroller.getValue()); } @@ -74,16 +82,6 @@ public static void tick(Level world, BlockPos blockPos, BlockState state, BlockE world.setBlock(blockPos, state.setValue(BlockStateProperties.LOCKED, scroller.locked), 19); // 19 = BLOCK_UPDATE_FLAGS scroller.updateLock = false; } - if (scroller.playTickSound) { - world.playSound( - null, - blockPos, - AllSoundEvents.SCROLL_VALUE.getMainEvent(), - SoundSource.BLOCKS, - 0.25f, - 1.5f); - scroller.playTickSound = false; - } } @Override 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 new file mode 100644 index 0000000..87d2011 --- /dev/null +++ b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinAdventureUtil.java @@ -0,0 +1,32 @@ +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/CarriageContraptionMixin.java b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinCarriageContraption.java similarity index 95% rename from fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/CarriageContraptionMixin.java rename to fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinCarriageContraption.java index 0aad7b6..b909f21 100644 --- a/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/CarriageContraptionMixin.java +++ b/fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinCarriageContraption.java @@ -18,7 +18,7 @@ import java.util.List; @Mixin(CarriageContraption.class) -public abstract class CarriageContraptionMixin extends Contraption { +public abstract class MixinCarriageContraption extends Contraption { @Shadow private List assembledBlazeBurners; diff --git a/fabric/src/main/resources/cccbridge.mixins.json b/fabric/src/main/resources/cccbridge.mixins.json index 72df839..85db893 100644 --- a/fabric/src/main/resources/cccbridge.mixins.json +++ b/fabric/src/main/resources/cccbridge.mixins.json @@ -4,7 +4,8 @@ "package": "cc.tweaked_programs.cccbridge.common.mixin", "compatibilityLevel": "JAVA_17", "mixins": [ - "CarriageContraptionMixin" + "MixinCarriageContraption", + "MixinAdventureUtil" ], "client": [ ],