Skip to content

Commit 7b29c96

Browse files
authored
[Fabric] Bug fixes (#63)
- RedRouter Blocks can't conduct outside redstone signals anymore & now will emit strong redstone signals when one side is powered. - Scroller Panes now can be used in Adventure mode as well. - They also won't push a `"scroller_changed"` event anymore, when a Computer changes the value. - Create dependency's version got updated to something that makes more sense
1 parent 2a7943d commit 7b29c96

File tree

7 files changed

+56
-18
lines changed

7 files changed

+56
-18
lines changed

fabric/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
org.gradle.jvmargs=-Xmx2G
33

44
# Mod Properties
5-
mod_version=1.6.0
5+
mod_version=1.6.1
66
maven_group=cc.tweaked_programs
77
archives_base_name=cccbridge
88

@@ -19,7 +19,7 @@ parchment_version=2023.07.16
1919
# Dependencies
2020
fabric_version=0.86.0
2121
cc_version=1.106.1
22-
create_version=0.5.1-c-build.1113
22+
create_version=0.5.1-d-build.1130
2323
create_version_production=0.5.1-c
2424

2525
# Mod Menu - https://modrinth.com/mod/modmenu/versions

fabric/src/main/java/cc/tweaked_programs/cccbridge/common/computercraft/peripherals/ScrollerBlockPeripheral.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ public final int getValue() {
7171
@LuaFunction
7272
public final void setValue(int value) {
7373
ScrollerBlockEntity be = getTarget();
74-
if (be != null)
74+
if (be != null) {
75+
be.nextChangeQuietly();
7576
be.setValue(value);
77+
}
7678
}
7779

7880
/**

fabric/src/main/java/cc/tweaked_programs/cccbridge/common/minecraft/block/RedRouterBlock.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.jetbrains.annotations.NotNull;
2727

2828
public class RedRouterBlock extends HorizontalDirectionalBlock implements EntityBlock, IWrenchable {
29-
public static final Properties REDROUTER_BLOCK_PROPERTIES = FabricBlockSettings.create().strength(1.3f).sound(SoundType.STONE).noOcclusion();
29+
public static final Properties REDROUTER_BLOCK_PROPERTIES = FabricBlockSettings.create().strength(1.3f).sound(SoundType.STONE).noOcclusion().isRedstoneConductor((state, view, pos) -> false);
3030
public static final int FACE_AMOUNT = 16;
3131
public static final IntegerProperty FACE = IntegerProperty.create("face", 0, FACE_AMOUNT);
3232
public RedRouterBlock(Properties properties) {
@@ -73,6 +73,11 @@ public int getSignal(@NotNull BlockState state, BlockGetter world, @NotNull Bloc
7373
return redrouter.getPower(dir);
7474
}
7575

76+
@Override
77+
public int getDirectSignal(BlockState state, BlockGetter level, BlockPos pos, Direction direction) {
78+
return getSignal(state, level, pos, direction);
79+
}
80+
7681
@Override
7782
public InteractionResult onWrenched(BlockState state, UseOnContext context) {
7883
BlockEntity tileentity = context.getLevel().getBlockEntity(context.getClickedPos());

fabric/src/main/java/cc/tweaked_programs/cccbridge/common/minecraft/blockEntity/ScrollerBlockEntity.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@
2727
public class ScrollerBlockEntity extends SmartBlockEntity implements PeripheralBlockEntity {
2828
private ScrollerBlockPeripheral peripheral;
2929
private boolean locked = false;
30+
private boolean quietly = false;
3031
private boolean updateLock = false;
31-
private boolean playTickSound = false;
3232
private LuaScrollValueBehaviour scroller;
3333

3434
public ScrollerBlockEntity(BlockPos pos, BlockState state) {
@@ -54,8 +54,16 @@ public void setValue(int value) {
5454
scroller.setValue(value);
5555
}
5656

57+
public void nextChangeQuietly() {
58+
quietly = true;
59+
}
60+
5761
public void fireUpdateValueEvent() {
58-
if (peripheral != null)
62+
if (quietly) {
63+
quietly = false;
64+
return;
65+
}
66+
if (peripheral != null )
5967
peripheral.sendEvent("scroller_changed", scroller.getValue());
6068
}
6169

@@ -74,16 +82,6 @@ public static void tick(Level world, BlockPos blockPos, BlockState state, BlockE
7482
world.setBlock(blockPos, state.setValue(BlockStateProperties.LOCKED, scroller.locked), 19); // 19 = BLOCK_UPDATE_FLAGS
7583
scroller.updateLock = false;
7684
}
77-
if (scroller.playTickSound) {
78-
world.playSound(
79-
null,
80-
blockPos,
81-
AllSoundEvents.SCROLL_VALUE.getMainEvent(),
82-
SoundSource.BLOCKS,
83-
0.25f,
84-
1.5f);
85-
scroller.playTickSound = false;
86-
}
8785
}
8886

8987
@Override
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package cc.tweaked_programs.cccbridge.common.mixin;
2+
3+
import cc.tweaked_programs.cccbridge.common.minecraft.blockEntity.ScrollerBlockEntity;
4+
import com.simibubi.create.foundation.utility.AdventureUtil;
5+
import net.minecraft.world.entity.player.Player;
6+
import net.minecraft.world.level.Level;
7+
import net.minecraft.world.level.block.entity.BlockEntity;
8+
import net.minecraft.world.phys.BlockHitResult;
9+
import net.minecraft.world.phys.HitResult;
10+
import org.spongepowered.asm.mixin.Mixin;
11+
import org.spongepowered.asm.mixin.injection.At;
12+
import org.spongepowered.asm.mixin.injection.Inject;
13+
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
14+
15+
@Mixin(AdventureUtil.class)
16+
public abstract class MixinAdventureUtil {
17+
@Inject(method = "isAdventure", at = @At("HEAD"), cancellable = true, remap = false)
18+
private static void cccbridge$isAdventure(Player player, CallbackInfoReturnable<Boolean> cir) {
19+
if (player.isSpectator())
20+
return;
21+
22+
Level level = player.level();
23+
HitResult hitResult = player.pick(5, 1, false);
24+
25+
if (hitResult instanceof BlockHitResult blockHit) {
26+
BlockEntity blockEntity = level.getBlockEntity(blockHit.getBlockPos());
27+
28+
if (blockEntity instanceof ScrollerBlockEntity)
29+
cir.setReturnValue(false);
30+
}
31+
}
32+
}

fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/CarriageContraptionMixin.java renamed to fabric/src/main/java/cc/tweaked_programs/cccbridge/common/mixin/MixinCarriageContraption.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import java.util.List;
1919

2020
@Mixin(CarriageContraption.class)
21-
public abstract class CarriageContraptionMixin extends Contraption {
21+
public abstract class MixinCarriageContraption extends Contraption {
2222
@Shadow
2323
private List<BlockPos> assembledBlazeBurners;
2424

fabric/src/main/resources/cccbridge.mixins.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"package": "cc.tweaked_programs.cccbridge.common.mixin",
55
"compatibilityLevel": "JAVA_17",
66
"mixins": [
7-
"CarriageContraptionMixin"
7+
"MixinCarriageContraption",
8+
"MixinAdventureUtil"
89
],
910
"client": [
1011
],

0 commit comments

Comments
 (0)