From bee74680e607c2e29b038329f62181238911cd83 Mon Sep 17 00:00:00 2001 From: MiniDigger | Martin Date: Sun, 14 Jan 2024 11:04:49 +0100 Subject: add remapped patches as a test --- .../world/level/block/CommandBlock.java.patch | 359 +++++++++++++++++++++ 1 file changed, 359 insertions(+) create mode 100644 patch-remap/mache-spigotflower/net/minecraft/world/level/block/CommandBlock.java.patch (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/CommandBlock.java.patch') diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CommandBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CommandBlock.java.patch new file mode 100644 index 0000000000..9074b40b42 --- /dev/null +++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/CommandBlock.java.patch @@ -0,0 +1,359 @@ +--- a/net/minecraft/world/level/block/CommandBlock.java ++++ b/net/minecraft/world/level/block/CommandBlock.java +@@ -9,7 +9,7 @@ + import net.minecraft.server.level.ServerLevel; + import net.minecraft.util.RandomSource; + import net.minecraft.util.StringUtil; +-import net.minecraft.world.InteractionHand; ++import net.minecraft.world.EnumHand; + import net.minecraft.world.InteractionResult; + import net.minecraft.world.entity.LivingEntity; + import net.minecraft.world.entity.player.Player; +@@ -22,7 +22,7 @@ + import net.minecraft.world.level.block.entity.BlockEntity; + import net.minecraft.world.level.block.entity.CommandBlockEntity; + import net.minecraft.world.level.block.state.BlockBehaviour; +-import net.minecraft.world.level.block.state.BlockState; ++import net.minecraft.world.level.block.state.IBlockData; + import net.minecraft.world.level.block.state.StateDefinition; + import net.minecraft.world.level.block.state.properties.BlockStateProperties; + import net.minecraft.world.level.block.state.properties.BooleanProperty; +@@ -30,55 +30,63 @@ + import net.minecraft.world.phys.BlockHitResult; + import org.slf4j.Logger; + ++import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit ++ + public class CommandBlock extends BaseEntityBlock implements GameMasterBlock { + + public static final MapCodec CODEC = RecordCodecBuilder.mapCodec((instance) -> { +- return instance.group(Codec.BOOL.fieldOf("automatic").forGetter((commandblock) -> { +- return commandblock.automatic; ++ return instance.group(Codec.BOOL.fieldOf("automatic").forGetter((blockcommand) -> { ++ return blockcommand.automatic; + }), propertiesCodec()).apply(instance, CommandBlock::new); + }); + private static final Logger LOGGER = LogUtils.getLogger(); +- public static final DirectionProperty FACING = DirectionalBlock.FACING; ++ public static final DirectionProperty FACING = BlockDirectional.FACING; + public static final BooleanProperty CONDITIONAL = BlockStateProperties.CONDITIONAL; + private final boolean automatic; + + @Override +- @Override + public MapCodec codec() { + return CommandBlock.CODEC; + } + +- public CommandBlock(boolean flag, BlockBehaviour.Properties blockbehaviour_properties) { +- super(blockbehaviour_properties); +- this.registerDefaultState((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(CommandBlock.FACING, Direction.NORTH)).setValue(CommandBlock.CONDITIONAL, false)); ++ public CommandBlock(boolean flag, BlockBehaviour.Properties blockbase_info) { ++ super(blockbase_info); ++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(CommandBlock.FACING, Direction.NORTH)).setValue(CommandBlock.CONDITIONAL, false)); + this.automatic = flag; + } + + @Override +- @Override +- public BlockEntity newBlockEntity(BlockPos blockpos, BlockState blockstate) { +- CommandBlockEntity commandblockentity = new CommandBlockEntity(blockpos, blockstate); ++ public BlockEntity newBlockEntity(BlockPos pos, IBlockData state) { ++ CommandBlockEntity tileentitycommand = new CommandBlockEntity(pos, state); + +- commandblockentity.setAutomatic(this.automatic); +- return commandblockentity; ++ tileentitycommand.setAutomatic(this.automatic); ++ return tileentitycommand; + } + + @Override +- @Override +- public void neighborChanged(BlockState blockstate, Level level, BlockPos blockpos, Block block, BlockPos blockpos1, boolean flag) { ++ public void neighborChanged(IBlockData state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) { + if (!level.isClientSide) { +- BlockEntity blockentity = level.getBlockEntity(blockpos); ++ BlockEntity tileentity = level.getBlockEntity(pos); + +- if (blockentity instanceof CommandBlockEntity) { +- CommandBlockEntity commandblockentity = (CommandBlockEntity) blockentity; +- boolean flag1 = level.hasNeighborSignal(blockpos); +- boolean flag2 = commandblockentity.isPowered(); ++ if (tileentity instanceof CommandBlockEntity) { ++ CommandBlockEntity tileentitycommand = (CommandBlockEntity) tileentity; ++ boolean flag1 = level.hasNeighborSignal(pos); ++ boolean flag2 = tileentitycommand.isPowered(); ++ // CraftBukkit start ++ org.bukkit.block.Block bukkitBlock = level.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); ++ int old = flag2 ? 15 : 0; ++ int current = flag1 ? 15 : 0; + +- commandblockentity.setPowered(flag1); +- if (!flag2 && !commandblockentity.isAutomatic() && commandblockentity.getMode() != CommandBlockEntity.Mode.SEQUENCE) { ++ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current); ++ level.getCraftServer().getPluginManager().callEvent(eventRedstone); ++ flag1 = eventRedstone.getNewCurrent() > 0; ++ // CraftBukkit end ++ ++ tileentitycommand.setPowered(flag1); ++ if (!flag2 && !tileentitycommand.isAutomatic() && tileentitycommand.getMode() != CommandBlockEntity.Type.SEQUENCE) { + if (flag1) { +- commandblockentity.markConditionMet(); +- level.scheduleTick(blockpos, (Block) this, 1); ++ tileentitycommand.markConditionMet(); ++ level.scheduleTick(pos, (Block) this, 1); + } + + } +@@ -87,58 +95,56 @@ + } + + @Override +- @Override +- public void tick(BlockState blockstate, ServerLevel serverlevel, BlockPos blockpos, RandomSource randomsource) { +- BlockEntity blockentity = serverlevel.getBlockEntity(blockpos); ++ public void tick(IBlockData state, ServerLevel level, BlockPos pos, RandomSource random) { ++ BlockEntity tileentity = level.getBlockEntity(pos); + +- if (blockentity instanceof CommandBlockEntity) { +- CommandBlockEntity commandblockentity = (CommandBlockEntity) blockentity; +- BaseCommandBlock basecommandblock = commandblockentity.getCommandBlock(); +- boolean flag = !StringUtil.isNullOrEmpty(basecommandblock.getCommand()); +- CommandBlockEntity.Mode commandblockentity_mode = commandblockentity.getMode(); +- boolean flag1 = commandblockentity.wasConditionMet(); ++ if (tileentity instanceof CommandBlockEntity) { ++ CommandBlockEntity tileentitycommand = (CommandBlockEntity) tileentity; ++ BaseCommandBlock commandblocklistenerabstract = tileentitycommand.getCommandBlock(); ++ boolean flag = !StringUtil.isNullOrEmpty(commandblocklistenerabstract.getCommand()); ++ CommandBlockEntity.Type tileentitycommand_type = tileentitycommand.getMode(); ++ boolean flag1 = tileentitycommand.wasConditionMet(); + +- if (commandblockentity_mode == CommandBlockEntity.Mode.AUTO) { +- commandblockentity.markConditionMet(); ++ if (tileentitycommand_type == CommandBlockEntity.Type.AUTO) { ++ tileentitycommand.markConditionMet(); + if (flag1) { +- this.execute(blockstate, serverlevel, blockpos, basecommandblock, flag); +- } else if (commandblockentity.isConditional()) { +- basecommandblock.setSuccessCount(0); ++ this.execute(state, level, pos, commandblocklistenerabstract, flag); ++ } else if (tileentitycommand.isConditional()) { ++ commandblocklistenerabstract.setSuccessCount(0); + } + +- if (commandblockentity.isPowered() || commandblockentity.isAutomatic()) { +- serverlevel.scheduleTick(blockpos, (Block) this, 1); ++ if (tileentitycommand.isPowered() || tileentitycommand.isAutomatic()) { ++ level.scheduleTick(pos, (Block) this, 1); + } +- } else if (commandblockentity_mode == CommandBlockEntity.Mode.REDSTONE) { ++ } else if (tileentitycommand_type == CommandBlockEntity.Type.REDSTONE) { + if (flag1) { +- this.execute(blockstate, serverlevel, blockpos, basecommandblock, flag); +- } else if (commandblockentity.isConditional()) { +- basecommandblock.setSuccessCount(0); ++ this.execute(state, level, pos, commandblocklistenerabstract, flag); ++ } else if (tileentitycommand.isConditional()) { ++ commandblocklistenerabstract.setSuccessCount(0); + } + } + +- serverlevel.updateNeighbourForOutputSignal(blockpos, this); ++ level.updateNeighbourForOutputSignal(pos, this); + } + + } + +- private void execute(BlockState blockstate, Level level, BlockPos blockpos, BaseCommandBlock basecommandblock, boolean flag) { +- if (flag) { +- basecommandblock.performCommand(level); ++ private void execute(IBlockData state, Level level, BlockPos pos, BaseCommandBlock logic, boolean canTrigger) { ++ if (canTrigger) { ++ logic.performCommand(level); + } else { +- basecommandblock.setSuccessCount(0); ++ logic.setSuccessCount(0); + } + +- executeChain(level, blockpos, (Direction) blockstate.getValue(CommandBlock.FACING)); ++ executeChain(level, pos, (Direction) state.getValue(CommandBlock.FACING)); + } + + @Override +- @Override +- public InteractionResult use(BlockState blockstate, Level level, BlockPos blockpos, Player player, InteractionHand interactionhand, BlockHitResult blockhitresult) { +- BlockEntity blockentity = level.getBlockEntity(blockpos); ++ public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) { ++ BlockEntity tileentity = level.getBlockEntity(pos); + +- if (blockentity instanceof CommandBlockEntity && player.canUseGameMasterBlocks()) { +- player.openCommandBlock((CommandBlockEntity) blockentity); ++ if (tileentity instanceof CommandBlockEntity && player.canUseGameMasterBlocks()) { ++ player.openCommandBlock((CommandBlockEntity) tileentity); + return InteractionResult.sidedSuccess(level.isClientSide); + } else { + return InteractionResult.PASS; +@@ -146,42 +152,39 @@ + } + + @Override +- @Override +- public boolean hasAnalogOutputSignal(BlockState blockstate) { ++ public boolean hasAnalogOutputSignal(IBlockData state) { + return true; + } + + @Override +- @Override +- public int getAnalogOutputSignal(BlockState blockstate, Level level, BlockPos blockpos) { +- BlockEntity blockentity = level.getBlockEntity(blockpos); ++ public int getAnalogOutputSignal(IBlockData blockState, Level level, BlockPos pos) { ++ BlockEntity tileentity = level.getBlockEntity(pos); + +- return blockentity instanceof CommandBlockEntity ? ((CommandBlockEntity) blockentity).getCommandBlock().getSuccessCount() : 0; ++ return tileentity instanceof CommandBlockEntity ? ((CommandBlockEntity) tileentity).getCommandBlock().getSuccessCount() : 0; + } + + @Override +- @Override +- public void setPlacedBy(Level level, BlockPos blockpos, BlockState blockstate, LivingEntity livingentity, ItemStack itemstack) { +- BlockEntity blockentity = level.getBlockEntity(blockpos); ++ public void setPlacedBy(Level level, BlockPos pos, IBlockData state, LivingEntity placer, ItemStack stack) { ++ BlockEntity tileentity = level.getBlockEntity(pos); + +- if (blockentity instanceof CommandBlockEntity) { +- CommandBlockEntity commandblockentity = (CommandBlockEntity) blockentity; +- BaseCommandBlock basecommandblock = commandblockentity.getCommandBlock(); ++ if (tileentity instanceof CommandBlockEntity) { ++ CommandBlockEntity tileentitycommand = (CommandBlockEntity) tileentity; ++ BaseCommandBlock commandblocklistenerabstract = tileentitycommand.getCommandBlock(); + +- if (itemstack.hasCustomHoverName()) { +- basecommandblock.setName(itemstack.getHoverName()); ++ if (stack.hasCustomHoverName()) { ++ commandblocklistenerabstract.setName(stack.getHoverName()); + } + + if (!level.isClientSide) { +- if (BlockItem.getBlockEntityData(itemstack) == null) { +- basecommandblock.setTrackOutput(level.getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK)); +- commandblockentity.setAutomatic(this.automatic); ++ if (BlockItem.getBlockEntityData(stack) == null) { ++ commandblocklistenerabstract.setTrackOutput(level.getGameRules().getBoolean(GameRules.RULE_SENDCOMMANDFEEDBACK)); ++ tileentitycommand.setAutomatic(this.automatic); + } + +- if (commandblockentity.getMode() == CommandBlockEntity.Mode.SEQUENCE) { +- boolean flag = level.hasNeighborSignal(blockpos); ++ if (tileentitycommand.getMode() == CommandBlockEntity.Type.SEQUENCE) { ++ boolean flag = level.hasNeighborSignal(pos); + +- commandblockentity.setPowered(flag); ++ tileentitycommand.setPowered(flag); + } + } + +@@ -189,74 +192,69 @@ + } + + @Override +- @Override +- public RenderShape getRenderShape(BlockState blockstate) { +- return RenderShape.MODEL; ++ public EnumRenderType getRenderShape(IBlockData state) { ++ return EnumRenderType.MODEL; + } + + @Override +- @Override +- public BlockState rotate(BlockState blockstate, Rotation rotation) { +- return (BlockState) blockstate.setValue(CommandBlock.FACING, rotation.rotate((Direction) blockstate.getValue(CommandBlock.FACING))); ++ public IBlockData rotate(IBlockData state, Rotation rotation) { ++ return (IBlockData) state.setValue(CommandBlock.FACING, rotation.rotate((Direction) state.getValue(CommandBlock.FACING))); + } + + @Override +- @Override +- public BlockState mirror(BlockState blockstate, Mirror mirror) { +- return blockstate.rotate(mirror.getRotation((Direction) blockstate.getValue(CommandBlock.FACING))); ++ public IBlockData mirror(IBlockData state, Mirror mirror) { ++ return state.rotate(mirror.getRotation((Direction) state.getValue(CommandBlock.FACING))); + } + + @Override +- @Override +- protected void createBlockStateDefinition(StateDefinition.Builder statedefinition_builder) { +- statedefinition_builder.add(CommandBlock.FACING, CommandBlock.CONDITIONAL); ++ protected void createBlockStateDefinition(StateDefinition.Builder builder) { ++ builder.add(CommandBlock.FACING, CommandBlock.CONDITIONAL); + } + + @Override +- @Override +- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) { +- return (BlockState) this.defaultBlockState().setValue(CommandBlock.FACING, blockplacecontext.getNearestLookingDirection().getOpposite()); ++ public IBlockData getStateForPlacement(BlockPlaceContext context) { ++ return (IBlockData) this.defaultBlockState().setValue(CommandBlock.FACING, context.getNearestLookingDirection().getOpposite()); + } + +- private static void executeChain(Level level, BlockPos blockpos, Direction direction) { +- BlockPos.MutableBlockPos blockpos_mutableblockpos = blockpos.mutable(); ++ private static void executeChain(Level level, BlockPos pos, Direction direction) { ++ BlockPos.MutableBlockPos blockposition_mutableblockposition = pos.mutable(); + GameRules gamerules = level.getGameRules(); + +- BlockState blockstate; ++ IBlockData iblockdata; + int i; + +- for (i = gamerules.getInt(GameRules.RULE_MAX_COMMAND_CHAIN_LENGTH); i-- > 0; direction = (Direction) blockstate.getValue(CommandBlock.FACING)) { +- blockpos_mutableblockpos.move(direction); +- blockstate = level.getBlockState(blockpos_mutableblockpos); +- Block block = blockstate.getBlock(); ++ for (i = gamerules.getInt(GameRules.RULE_MAX_COMMAND_CHAIN_LENGTH); i-- > 0; direction = (Direction) iblockdata.getValue(CommandBlock.FACING)) { ++ blockposition_mutableblockposition.move(direction); ++ iblockdata = level.getBlockState(blockposition_mutableblockposition); ++ Block block = iblockdata.getBlock(); + +- if (!blockstate.is(Blocks.CHAIN_COMMAND_BLOCK)) { ++ if (!iblockdata.is(Blocks.CHAIN_COMMAND_BLOCK)) { + break; + } + +- BlockEntity blockentity = level.getBlockEntity(blockpos_mutableblockpos); ++ BlockEntity tileentity = level.getBlockEntity(blockposition_mutableblockposition); + +- if (!(blockentity instanceof CommandBlockEntity)) { ++ if (!(tileentity instanceof CommandBlockEntity)) { + break; + } + +- CommandBlockEntity commandblockentity = (CommandBlockEntity) blockentity; ++ CommandBlockEntity tileentitycommand = (CommandBlockEntity) tileentity; + +- if (commandblockentity.getMode() != CommandBlockEntity.Mode.SEQUENCE) { ++ if (tileentitycommand.getMode() != CommandBlockEntity.Type.SEQUENCE) { + break; + } + +- if (commandblockentity.isPowered() || commandblockentity.isAutomatic()) { +- BaseCommandBlock basecommandblock = commandblockentity.getCommandBlock(); ++ if (tileentitycommand.isPowered() || tileentitycommand.isAutomatic()) { ++ BaseCommandBlock commandblocklistenerabstract = tileentitycommand.getCommandBlock(); + +- if (commandblockentity.markConditionMet()) { +- if (!basecommandblock.performCommand(level)) { ++ if (tileentitycommand.markConditionMet()) { ++ if (!commandblocklistenerabstract.performCommand(level)) { + break; + } + +- level.updateNeighbourForOutputSignal(blockpos_mutableblockpos, block); +- } else if (commandblockentity.isConditional()) { +- basecommandblock.setSuccessCount(0); ++ level.updateNeighbourForOutputSignal(blockposition_mutableblockposition, block); ++ } else if (tileentitycommand.isConditional()) { ++ commandblocklistenerabstract.setSuccessCount(0); + } + } + } -- cgit v1.2.3