Migrate the Carpet codebase to Mojang Mappings

This commit is contained in:
altrisi committed 2022-01-24 20:33:16 +01:00
1 parent a1a2488bc3
commit 06af9ce8b1
346 files changed
+8353 -8492

No files matched your search

@@ -1,54 +1,54 @@
package carpet.mixins;
import carpet.CarpetSettings;
import net.minecraft.block.BarrierBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.PoweredRailBlock;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import org.spongepowered.asm.mixin.Mixin;
import java.util.Random;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.BarrierBlock;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.block.PoweredRailBlock;
import net.minecraft.world.level.block.state.BlockState;
@Mixin(BarrierBlock.class)
public class BarrierBlock_updateSuppressionBlockMixin extends Block {
private boolean shouldPower = false;
public BarrierBlock_updateSuppressionBlockMixin(Settings settings) { super(settings); }
public BarrierBlock_updateSuppressionBlockMixin(Properties settings) { super(settings); }
@Override
public int getWeakRedstonePower(BlockState state, BlockView world, BlockPos pos, Direction direction) {
public int getSignal(BlockState state, BlockGetter world, BlockPos pos, Direction direction) {
return (shouldPower && direction == Direction.DOWN) ? 15 : 0;
}
@Override
public void neighborUpdate(BlockState state, World world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
public void neighborChanged(BlockState state, Level world, BlockPos pos, Block block, BlockPos fromPos, boolean notify) {
if (CarpetSettings.updateSuppressionBlockSetting != -1) {
if (fromPos.equals(pos.up())) {
if (fromPos.equals(pos.above())) {
BlockState stateAbove = world.getBlockState(fromPos);
if (stateAbove.isOf(Blocks.ACTIVATOR_RAIL) && !stateAbove.get(PoweredRailBlock.POWERED)) {
if (stateAbove.is(Blocks.ACTIVATOR_RAIL) && !stateAbove.getValue(PoweredRailBlock.POWERED)) {
if (CarpetSettings.updateSuppressionBlockSetting > 0) {
world.createAndScheduleBlockTick(pos, this, CarpetSettings.updateSuppressionBlockSetting);
world.scheduleTick(pos, this, CarpetSettings.updateSuppressionBlockSetting);
}
throw new StackOverflowError("updateSuppressionBlock");
}
}
}
super.neighborUpdate(state, world, pos, block, fromPos, notify);
super.neighborChanged(state, world, pos, block, fromPos, notify);
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
BlockPos posAbove = pos.up();
public void tick(BlockState state, ServerLevel world, BlockPos pos, Random random) {
BlockPos posAbove = pos.above();
BlockState stateAbove = world.getBlockState(posAbove);
if (stateAbove.isOf(Blocks.ACTIVATOR_RAIL) && !stateAbove.get(PoweredRailBlock.POWERED)) {
if (stateAbove.is(Blocks.ACTIVATOR_RAIL) && !stateAbove.getValue(PoweredRailBlock.POWERED)) {
shouldPower = true;
world.setBlockState(posAbove, stateAbove.with(PoweredRailBlock.POWERED, true), 3);
world.setBlock(posAbove, stateAbove.setValue(PoweredRailBlock.POWERED, true), 3);
shouldPower = false;
}
}