Allow setting qc range with quasiConnectivity setting (#1617)
* add quasiConnectivityRange setting * make sure qc range respects different world heights * check if source == null in qc range validator * merge the two qc settings * Set minimum range down to zero (no qc)
This commit is contained in:
1 parent
f2c658bf03
commit
0e2f6df4d3
4 files changed
+86
-34
No files matched your search
@@ -1,25 +1,29 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.DispenserBlock;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
import carpet.helpers.QuasiConnectivity;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
import net.minecraft.world.level.block.DispenserBlock;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
|
||||
@Mixin(DispenserBlock.class)
|
||||
public class DispenserBlock_qcMixin
|
||||
{
|
||||
@Redirect(method = "neighborChanged", at = @At(
|
||||
public class DispenserBlock_qcMixin {
|
||||
|
||||
@Redirect(
|
||||
method = "neighborChanged",
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/Level;hasNeighborSignal(Lnet/minecraft/core/BlockPos;)Z",
|
||||
ordinal = 1
|
||||
))
|
||||
private boolean checkUpPower(Level world, BlockPos blockPos_1)
|
||||
{
|
||||
if (!CarpetSettings.quasiConnectivity)
|
||||
return false;
|
||||
return world.hasNeighborSignal(blockPos_1);
|
||||
ordinal = 1,
|
||||
target = "Lnet/minecraft/world/level/Level;hasNeighborSignal(Lnet/minecraft/core/BlockPos;)Z"
|
||||
)
|
||||
)
|
||||
private boolean carpet_hasQuasiSignal(Level _level, BlockPos above, BlockState state, Level level, BlockPos pos, Block neighborBlock, BlockPos neighborPos, boolean movedByPiston) {
|
||||
return QuasiConnectivity.hasQuasiSignal(level, pos);
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,29 @@
|
||||
package carpet.mixins;
|
||||
|
||||
import carpet.CarpetSettings;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.piston.PistonBaseBlock;
|
||||
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;
|
||||
|
||||
import carpet.helpers.QuasiConnectivity;
|
||||
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Direction;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.piston.PistonBaseBlock;
|
||||
|
||||
@Mixin(PistonBaseBlock.class)
|
||||
public class PistonBaseBlock_qcMixin
|
||||
{
|
||||
@Inject(method = "getNeighborSignal", cancellable = true, at = @At(
|
||||
public class PistonBaseBlock_qcMixin {
|
||||
|
||||
@Inject(
|
||||
method = "getNeighborSignal",
|
||||
cancellable = true,
|
||||
at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/core/BlockPos;above()Lnet/minecraft/core/BlockPos;"
|
||||
))
|
||||
private void cancelUpCheck(Level world_1, BlockPos blockPos_1, Direction direction_1, CallbackInfoReturnable<Boolean> cir)
|
||||
{
|
||||
if (!CarpetSettings.quasiConnectivity)
|
||||
{
|
||||
cir.setReturnValue(false);
|
||||
cir.cancel();
|
||||
}
|
||||
)
|
||||
)
|
||||
private void carpet_checkQuasiSignal(Level level, BlockPos pos, Direction facing, CallbackInfoReturnable<Boolean> cir) {
|
||||
cir.setReturnValue(QuasiConnectivity.hasQuasiSignal(level, pos));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user