aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/world/level/block/NoteBlock.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/world/level/block/NoteBlock.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/world/level/block/NoteBlock.java.patch226
1 files changed, 226 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/world/level/block/NoteBlock.java.patch b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/NoteBlock.java.patch
new file mode 100644
index 0000000000..527baf7acd
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/world/level/block/NoteBlock.java.patch
@@ -0,0 +1,226 @@
+--- a/net/minecraft/world/level/block/NoteBlock.java
++++ b/net/minecraft/world/level/block/NoteBlock.java
+@@ -11,7 +11,7 @@
+ import net.minecraft.sounds.SoundSource;
+ import net.minecraft.stats.Stats;
+ import net.minecraft.tags.ItemTags;
+-import net.minecraft.world.InteractionHand;
++import net.minecraft.world.EnumHand;
+ import net.minecraft.world.InteractionResult;
+ import net.minecraft.world.entity.Entity;
+ 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.SkullBlockEntity;
+ 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;
+@@ -41,146 +41,145 @@
+ public static final int NOTE_VOLUME = 3;
+
+ @Override
+- @Override
+ public MapCodec<NoteBlock> codec() {
+ return NoteBlock.CODEC;
+ }
+
+- public NoteBlock(BlockBehaviour.Properties blockbehaviour_properties) {
+- super(blockbehaviour_properties);
+- this.registerDefaultState((BlockState) ((BlockState) ((BlockState) ((BlockState) this.stateDefinition.any()).setValue(NoteBlock.INSTRUMENT, NoteBlockInstrument.HARP)).setValue(NoteBlock.NOTE, 0)).setValue(NoteBlock.POWERED, false));
++ public NoteBlock(BlockBehaviour.Properties properties) {
++ super(properties);
++ this.registerDefaultState((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.stateDefinition.any()).setValue(NoteBlock.INSTRUMENT, NoteBlockInstrument.HARP)).setValue(NoteBlock.NOTE, 0)).setValue(NoteBlock.POWERED, false));
+ }
+
+- private BlockState setInstrument(LevelAccessor levelaccessor, BlockPos blockpos, BlockState blockstate) {
+- NoteBlockInstrument noteblockinstrument = levelaccessor.getBlockState(blockpos.above()).instrument();
++ private IBlockData setInstrument(LevelAccessor level, BlockPos pos, IBlockData state) {
++ NoteBlockInstrument blockpropertyinstrument = level.getBlockState(pos.above()).instrument();
+
+- if (noteblockinstrument.worksAboveNoteBlock()) {
+- return (BlockState) blockstate.setValue(NoteBlock.INSTRUMENT, noteblockinstrument);
++ if (blockpropertyinstrument.worksAboveNoteBlock()) {
++ return (IBlockData) state.setValue(NoteBlock.INSTRUMENT, blockpropertyinstrument);
+ } else {
+- NoteBlockInstrument noteblockinstrument1 = levelaccessor.getBlockState(blockpos.below()).instrument();
+- NoteBlockInstrument noteblockinstrument2 = noteblockinstrument1.worksAboveNoteBlock() ? NoteBlockInstrument.HARP : noteblockinstrument1;
++ NoteBlockInstrument blockpropertyinstrument1 = level.getBlockState(pos.below()).instrument();
++ NoteBlockInstrument blockpropertyinstrument2 = blockpropertyinstrument1.worksAboveNoteBlock() ? NoteBlockInstrument.HARP : blockpropertyinstrument1;
+
+- return (BlockState) blockstate.setValue(NoteBlock.INSTRUMENT, noteblockinstrument2);
++ return (IBlockData) state.setValue(NoteBlock.INSTRUMENT, blockpropertyinstrument2);
+ }
+ }
+
+ @Override
+- @Override
+- public BlockState getStateForPlacement(BlockPlaceContext blockplacecontext) {
+- return this.setInstrument(blockplacecontext.getLevel(), blockplacecontext.getClickedPos(), this.defaultBlockState());
++ public IBlockData getStateForPlacement(BlockPlaceContext context) {
++ return this.setInstrument(context.getLevel(), context.getClickedPos(), this.defaultBlockState());
+ }
+
+ @Override
+- @Override
+- public BlockState updateShape(BlockState blockstate, Direction direction, BlockState blockstate1, LevelAccessor levelaccessor, BlockPos blockpos, BlockPos blockpos1) {
+- boolean flag = direction.getAxis() == Direction.Axis.Y;
++ public IBlockData updateShape(IBlockData state, Direction facing, IBlockData facingState, LevelAccessor level, BlockPos currentPos, BlockPos facingPos) {
++ boolean flag = facing.getAxis() == Direction.Axis.Y;
+
+- return flag ? this.setInstrument(levelaccessor, blockpos, blockstate) : super.updateShape(blockstate, direction, blockstate1, levelaccessor, blockpos, blockpos1);
++ return flag ? this.setInstrument(level, currentPos, state) : super.updateShape(state, facing, facingState, level, currentPos, facingPos);
+ }
+
+ @Override
+- @Override
+- public void neighborChanged(BlockState blockstate, Level level, BlockPos blockpos, Block block, BlockPos blockpos1, boolean flag) {
+- boolean flag1 = level.hasNeighborSignal(blockpos);
++ public void neighborChanged(IBlockData state, Level level, BlockPos pos, Block block, BlockPos fromPos, boolean isMoving) {
++ boolean flag1 = level.hasNeighborSignal(pos);
+
+- if (flag1 != (Boolean) blockstate.getValue(NoteBlock.POWERED)) {
++ if (flag1 != (Boolean) state.getValue(NoteBlock.POWERED)) {
+ if (flag1) {
+- this.playNote((Entity) null, blockstate, level, blockpos);
++ this.playNote((Entity) null, state, level, pos);
++ state = level.getBlockState(pos); // CraftBukkit - SPIGOT-5617: update in case changed in event
+ }
+
+- level.setBlock(blockpos, (BlockState) blockstate.setValue(NoteBlock.POWERED, flag1), 3);
++ level.setBlock(pos, (IBlockData) state.setValue(NoteBlock.POWERED, flag1), 3);
+ }
+
+ }
+
+- private void playNote(@Nullable Entity entity, BlockState blockstate, Level level, BlockPos blockpos) {
+- if (((NoteBlockInstrument) blockstate.getValue(NoteBlock.INSTRUMENT)).worksAboveNoteBlock() || level.getBlockState(blockpos.above()).isAir()) {
+- level.blockEvent(blockpos, this, 0, 0);
+- level.gameEvent(entity, GameEvent.NOTE_BLOCK_PLAY, blockpos);
++ private void playNote(@Nullable Entity entity, IBlockData state, Level level, BlockPos pos) {
++ if (((NoteBlockInstrument) state.getValue(NoteBlock.INSTRUMENT)).worksAboveNoteBlock() || level.getBlockState(pos.above()).isAir()) {
++ // CraftBukkit start
++ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(level, pos, state.getValue(NoteBlock.INSTRUMENT), state.getValue(NoteBlock.NOTE));
++ if (event.isCancelled()) {
++ return;
++ }
++ // CraftBukkit end
++ level.blockEvent(pos, this, 0, 0);
++ level.gameEvent(entity, GameEvent.NOTE_BLOCK_PLAY, pos);
+ }
+
+ }
+
+ @Override
+- @Override
+- public InteractionResult use(BlockState blockstate, Level level, BlockPos blockpos, Player player, InteractionHand interactionhand, BlockHitResult blockhitresult) {
+- ItemStack itemstack = player.getItemInHand(interactionhand);
++ public InteractionResult use(IBlockData state, Level level, BlockPos pos, Player player, EnumHand hand, BlockHitResult hit) {
++ ItemStack itemstack = player.getItemInHand(hand);
+
+- if (itemstack.is(ItemTags.NOTE_BLOCK_TOP_INSTRUMENTS) && blockhitresult.getDirection() == Direction.UP) {
++ if (itemstack.is(ItemTags.NOTE_BLOCK_TOP_INSTRUMENTS) && hit.getDirection() == Direction.UP) {
+ return InteractionResult.PASS;
+ } else if (level.isClientSide) {
+ return InteractionResult.SUCCESS;
+ } else {
+- blockstate = (BlockState) blockstate.cycle(NoteBlock.NOTE);
+- level.setBlock(blockpos, blockstate, 3);
+- this.playNote(player, blockstate, level, blockpos);
++ state = (IBlockData) state.cycle(NoteBlock.NOTE);
++ level.setBlock(pos, state, 3);
++ this.playNote(player, state, level, pos);
+ player.awardStat(Stats.TUNE_NOTEBLOCK);
+ return InteractionResult.CONSUME;
+ }
+ }
+
+ @Override
+- @Override
+- public void attack(BlockState blockstate, Level level, BlockPos blockpos, Player player) {
++ public void attack(IBlockData state, Level level, BlockPos pos, Player player) {
+ if (!level.isClientSide) {
+- this.playNote(player, blockstate, level, blockpos);
++ this.playNote(player, state, level, pos);
+ player.awardStat(Stats.PLAY_NOTEBLOCK);
+ }
+ }
+
+- public static float getPitchFromNote(int i) {
+- return (float) Math.pow(2.0D, (double) (i - 12) / 12.0D);
++ public static float getPitchFromNote(int note) {
++ return (float) Math.pow(2.0D, (double) (note - 12) / 12.0D);
+ }
+
+ @Override
+- @Override
+- public boolean triggerEvent(BlockState blockstate, Level level, BlockPos blockpos, int i, int j) {
+- NoteBlockInstrument noteblockinstrument = (NoteBlockInstrument) blockstate.getValue(NoteBlock.INSTRUMENT);
++ public boolean triggerEvent(IBlockData state, Level level, BlockPos pos, int id, int param) {
++ NoteBlockInstrument blockpropertyinstrument = (NoteBlockInstrument) state.getValue(NoteBlock.INSTRUMENT);
+ float f;
+
+- if (noteblockinstrument.isTunable()) {
+- int k = (Integer) blockstate.getValue(NoteBlock.NOTE);
++ if (blockpropertyinstrument.isTunable()) {
++ int k = (Integer) state.getValue(NoteBlock.NOTE);
+
+ f = getPitchFromNote(k);
+- level.addParticle(ParticleTypes.NOTE, (double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 1.2D, (double) blockpos.getZ() + 0.5D, (double) k / 24.0D, 0.0D, 0.0D);
++ level.addParticle(ParticleTypes.NOTE, (double) pos.getX() + 0.5D, (double) pos.getY() + 1.2D, (double) pos.getZ() + 0.5D, (double) k / 24.0D, 0.0D, 0.0D);
+ } else {
+ f = 1.0F;
+ }
+
+ Holder holder;
+
+- if (noteblockinstrument.hasCustomSound()) {
+- ResourceLocation resourcelocation = this.getCustomSoundId(level, blockpos);
++ if (blockpropertyinstrument.hasCustomSound()) {
++ ResourceLocation minecraftkey = this.getCustomSoundId(level, pos);
+
+- if (resourcelocation == null) {
++ if (minecraftkey == null) {
+ return false;
+ }
+
+- holder = Holder.direct(SoundEvent.createVariableRangeEvent(resourcelocation));
++ holder = Holder.direct(SoundEvent.createVariableRangeEvent(minecraftkey));
+ } else {
+- holder = noteblockinstrument.getSoundEvent();
++ holder = blockpropertyinstrument.getSoundEvent();
+ }
+
+- level.playSeededSound((Player) null, (double) blockpos.getX() + 0.5D, (double) blockpos.getY() + 0.5D, (double) blockpos.getZ() + 0.5D, holder, SoundSource.RECORDS, 3.0F, f, level.random.nextLong());
++ level.playSeededSound((Player) null, (double) pos.getX() + 0.5D, (double) pos.getY() + 0.5D, (double) pos.getZ() + 0.5D, holder, SoundSource.RECORDS, 3.0F, f, level.random.nextLong());
+ return true;
+ }
+
+ @Nullable
+- private ResourceLocation getCustomSoundId(Level level, BlockPos blockpos) {
+- BlockEntity blockentity = level.getBlockEntity(blockpos.above());
++ private ResourceLocation getCustomSoundId(Level level, BlockPos pos) {
++ BlockEntity tileentity = level.getBlockEntity(pos.above());
+
+- if (blockentity instanceof SkullBlockEntity) {
+- SkullBlockEntity skullblockentity = (SkullBlockEntity) blockentity;
++ if (tileentity instanceof SkullBlockEntity) {
++ SkullBlockEntity tileentityskull = (SkullBlockEntity) tileentity;
+
+- return skullblockentity.getNoteBlockSound();
++ return tileentityskull.getNoteBlockSound();
+ } else {
+ return null;
+ }
+ }
+
+ @Override
+- @Override
+- protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> statedefinition_builder) {
+- statedefinition_builder.add(NoteBlock.INSTRUMENT, NoteBlock.POWERED, NoteBlock.NOTE);
++ protected void createBlockStateDefinition(StateDefinition.Builder<Block, IBlockData> builder) {
++ builder.add(NoteBlock.INSTRUMENT, NoteBlock.POWERED, NoteBlock.NOTE);
+ }
+ }