update to 24w33a

This commit is contained in:
gnembon committed 2024-08-18 19:10:40 +02:00
1 parent 9940feb7d3
commit d11586fdaf
58 files changed
+379 -875

No files matched your search

@@ -1,9 +1,13 @@
package carpet.mixins;
import carpet.CarpetSettings;
import carpet.fakes.DefaultRedstoneWireEvaluatorInferface;
import carpet.fakes.RedstoneWireBlockInterface;
import carpet.helpers.RedstoneWireTurbo;
import com.google.common.collect.Sets;
import net.minecraft.world.level.redstone.DefaultRedstoneWireEvaluator;
import net.minecraft.world.level.redstone.Orientation;
import net.minecraft.world.level.redstone.RedstoneWireEvaluator;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Accessor;
@@ -21,16 +25,15 @@ import net.minecraft.world.level.block.RedStoneWireBlock;
import net.minecraft.world.level.block.state.BlockBehaviour;
import net.minecraft.world.level.block.state.BlockState;
import javax.annotation.Nullable;
import static net.minecraft.world.level.block.RedStoneWireBlock.POWER;
@Mixin(RedStoneWireBlock.class)
public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockInterface {
@Shadow
private void updatePowerStrength(Level world_1, BlockPos blockPos_1, BlockState blockState_1) { }
@Shadow
private int calculateTargetStrength(Level world, BlockPos pos) { return 0; }
private void updatePowerStrength(Level world_1, BlockPos blockPos_1, BlockState blockState_1, @Nullable final Orientation orientation) { }
@Override
@Accessor("shouldSignal")
@@ -40,6 +43,8 @@ public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockIn
@Accessor("shouldSignal")
public abstract boolean getWiresGivePower();
private RedstoneWireEvaluator legacy = new DefaultRedstoneWireEvaluator((RedStoneWireBlock)(Object) this);
// =
private RedstoneWireTurbo wireTurbo = null;
@@ -52,20 +57,22 @@ public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockIn
// =
public void fastUpdate(Level world, BlockPos pos, BlockState state, BlockPos source) {
public void fastUpdate(Level world, BlockPos pos, BlockState state, Orientation o) {
// [CM] fastRedstoneDust -- update based on carpet rule
if (CarpetSettings.fastRedstoneDust) {
BlockPos source = null; // todo this probably removes all improvements from the original method
// so needs to be evaluated if its worth keeping
wireTurbo.updateSurroundingRedstone(world, pos, state, source);
return;
}
updatePowerStrength(world, pos, state);
updatePowerStrength(world, pos, state, o);
}
/**
* @author theosib, soykaf, gnembon
*/
@Inject(method = "updatePowerStrength", at = @At("HEAD"), cancellable = true)
private void updateLogicAlternative(Level world, BlockPos pos, BlockState state, CallbackInfo cir) {
private void updateLogicAlternative(Level world, BlockPos pos, BlockState state, Orientation orientation, CallbackInfo cir) {
if (CarpetSettings.fastRedstoneDust) {
updateLogicPublic(world, pos, state);
cir.cancel();
@@ -74,7 +81,7 @@ public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockIn
@Override
public BlockState updateLogicPublic(Level world_1, BlockPos blockPos_1, BlockState blockState_1) {
int i = this.calculateTargetStrength(world_1, blockPos_1);
int i = ((DefaultRedstoneWireEvaluatorInferface)legacy).calculateTargetStrengthCM(world_1, blockPos_1);
BlockState blockState = blockState_1;
if (blockState_1.getValue(POWER) != i) {
blockState_1 = blockState_1.setValue(POWER, i);
@@ -107,28 +114,33 @@ public abstract class RedstoneWireBlock_fastMixin implements RedstoneWireBlockIn
// =
@Redirect(method = "onPlace", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V"))
private void redirectOnBlockAddedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1) {
fastUpdate(world_1, blockPos_1, blockState_1, null);
@Redirect(method = "onPlace", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;)V"))
private void redirectOnBlockAddedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1, Orientation o) {
fastUpdate(world_1, blockPos_1, blockState_1, o);
}
@Redirect(method = "onRemove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V"))
private void redirectOnStateReplacedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1) {
fastUpdate(world_1, blockPos_1, blockState_1, null);
@Redirect(method = "onRemove", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;)V"))
private void redirectOnStateReplacedUpdate(RedStoneWireBlock self, Level world_1, BlockPos blockPos_1, BlockState blockState_1, Orientation o) {
fastUpdate(world_1, blockPos_1, blockState_1, o);
}
@Redirect(method = "neighborChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;)V"))
@Redirect(method = "neighborChanged", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/level/block/RedStoneWireBlock;updatePowerStrength(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/level/redstone/Orientation;)V"))
//private void red(final RedStoneWireBlock instance, final Level level,
// final BlockPos blockPos, final BlockState blockState, final Orientation orientation)
private void redirectNeighborUpdateUpdate(
RedStoneWireBlock self,
Level world_1,
BlockPos blockPos_1,
BlockState blockState_1,
Orientation o,
BlockState blockState_2,
Level world_2,
BlockPos blockPos_2,
Block block_1,
BlockPos blockPos_3,
boolean boolean_1) {
fastUpdate(world_1, blockPos_1, blockState_1, blockPos_3);
Orientation o2,
boolean b
)
{
fastUpdate(world_1, blockPos_1, blockState_1, o);
}
}