mirror of https://github.com/PaperMC/Paper.git
235 lines
14 KiB
Diff
235 lines
14 KiB
Diff
--- a/net/minecraft/core/cauldron/CauldronInteraction.java
|
|
+++ b/net/minecraft/core/cauldron/CauldronInteraction.java
|
|
@@ -33,6 +33,10 @@
|
|
import net.minecraft.world.level.block.state.BlockState;
|
|
import net.minecraft.world.level.gameevent.GameEvent;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.event.block.CauldronLevelChangeEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public interface CauldronInteraction {
|
|
|
|
Map<String, CauldronInteraction.InteractionMap> INTERACTIONS = new Object2ObjectArrayMap();
|
|
@@ -47,6 +53,8 @@
|
|
CauldronInteraction SHULKER_BOX;
|
|
CauldronInteraction BANNER;
|
|
CauldronInteraction DYED_ITEM;
|
|
+ */
|
|
+ // CraftBukkit end
|
|
|
|
static CauldronInteraction.InteractionMap newInteractionMap(String s) {
|
|
Object2ObjectOpenHashMap<Item, CauldronInteraction> object2objectopenhashmap = new Object2ObjectOpenHashMap();
|
|
@@ -70,15 +78,20 @@
|
|
if (PotionUtils.getPotion(itemstack) != Potions.WATER) {
|
|
return InteractionResult.PASS;
|
|
} else {
|
|
- if (!level.isClientSide) {
|
|
+ if (!world.isClientSide) {
|
|
+ // CraftBukkit start
|
|
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, Blocks.WATER_CAULDRON.defaultBlockState(), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
Item item = itemstack.getItem();
|
|
|
|
- player.setItemInHand(interactionhand, ItemUtils.createFilledResult(itemstack, player, new ItemStack(Items.GLASS_BOTTLE)));
|
|
- player.awardStat(Stats.USE_CAULDRON);
|
|
- player.awardStat(Stats.ITEM_USED.get(item));
|
|
- level.setBlockAndUpdate(blockpos, Blocks.WATER_CAULDRON.defaultBlockState());
|
|
- level.playSound((Player) null, blockpos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
- level.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockpos);
|
|
+ entityhuman.setItemInHand(enumhand, ItemUtils.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE)));
|
|
+ entityhuman.awardStat(Stats.USE_CAULDRON);
|
|
+ entityhuman.awardStat(Stats.ITEM_USED.get(item));
|
|
+ // world.setBlockAndUpdate(blockposition, Blocks.WATER_CAULDRON.defaultBlockState()); // CraftBukkit
|
|
+ world.playSound((Player) null, blockposition, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
+ world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockposition);
|
|
}
|
|
|
|
return InteractionResult.sidedSuccess(level.isClientSide);
|
|
@@ -92,29 +105,39 @@
|
|
return (Integer) blockstate1.getValue(LayeredCauldronBlock.LEVEL) == 3;
|
|
}, SoundEvents.BUCKET_FILL);
|
|
});
|
|
- map1.put(Items.GLASS_BOTTLE, (blockstate, level, blockpos, player, interactionhand, itemstack) -> {
|
|
- if (!level.isClientSide) {
|
|
+ map1.put(Items.GLASS_BOTTLE, (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
|
+ if (!world.isClientSide) {
|
|
+ // CraftBukkit start
|
|
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) {
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
Item item = itemstack.getItem();
|
|
|
|
- player.setItemInHand(interactionhand, ItemUtils.createFilledResult(itemstack, player, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)));
|
|
- player.awardStat(Stats.USE_CAULDRON);
|
|
- player.awardStat(Stats.ITEM_USED.get(item));
|
|
- LayeredCauldronBlock.lowerFillLevel(blockstate, level, blockpos);
|
|
- level.playSound((Player) null, blockpos, SoundEvents.BOTTLE_FILL, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
- level.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockpos);
|
|
+ entityhuman.setItemInHand(enumhand, ItemUtils.createFilledResult(itemstack, entityhuman, PotionUtils.setPotion(new ItemStack(Items.POTION), Potions.WATER)));
|
|
+ entityhuman.awardStat(Stats.USE_CAULDRON);
|
|
+ entityhuman.awardStat(Stats.ITEM_USED.get(item));
|
|
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
|
+ world.playSound((Player) null, blockposition, SoundEvents.BOTTLE_FILL, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
+ world.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockposition);
|
|
}
|
|
|
|
return InteractionResult.sidedSuccess(level.isClientSide);
|
|
});
|
|
- map1.put(Items.POTION, (blockstate, level, blockpos, player, interactionhand, itemstack) -> {
|
|
- if ((Integer) blockstate.getValue(LayeredCauldronBlock.LEVEL) != 3 && PotionUtils.getPotion(itemstack) == Potions.WATER) {
|
|
- if (!level.isClientSide) {
|
|
- player.setItemInHand(interactionhand, ItemUtils.createFilledResult(itemstack, player, new ItemStack(Items.GLASS_BOTTLE)));
|
|
- player.awardStat(Stats.USE_CAULDRON);
|
|
- player.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
|
|
- level.setBlockAndUpdate(blockpos, (BlockState) blockstate.cycle(LayeredCauldronBlock.LEVEL));
|
|
- level.playSound((Player) null, blockpos, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
- level.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockpos);
|
|
+ map1.put(Items.POTION, (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
|
+ if ((Integer) iblockdata.getValue(LayeredCauldronBlock.LEVEL) != 3 && PotionUtils.getPotion(itemstack) == Potions.WATER) {
|
|
+ if (!world.isClientSide) {
|
|
+ // CraftBukkit start
|
|
+ if (!LayeredCauldronBlock.changeLevel(iblockdata, world, blockposition, iblockdata.cycle(LayeredCauldronBlock.LEVEL), entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+ entityhuman.setItemInHand(enumhand, ItemUtils.createFilledResult(itemstack, entityhuman, new ItemStack(Items.GLASS_BOTTLE)));
|
|
+ entityhuman.awardStat(Stats.USE_CAULDRON);
|
|
+ entityhuman.awardStat(Stats.ITEM_USED.get(itemstack.getItem()));
|
|
+ // world.setBlockAndUpdate(blockposition, (IBlockData) iblockdata.cycle(LayeredCauldronBlock.LEVEL)); // CraftBukkit
|
|
+ world.playSound((Player) null, blockposition, SoundEvents.BOTTLE_EMPTY, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
+ world.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockposition);
|
|
}
|
|
|
|
return InteractionResult.sidedSuccess(level.isClientSide);
|
|
@@ -188,14 +211,19 @@
|
|
return InteractionResult.PASS;
|
|
} else {
|
|
if (!level.isClientSide) {
|
|
- Item item = itemstack.getItem();
|
|
+ // CraftBukkit start
|
|
+ if (!LayeredCauldronBlock.changeLevel(blockState, level, pos, Blocks.CAULDRON.defaultBlockState(), player, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) {
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+ Item item = emptyStack.getItem();
|
|
|
|
player.setItemInHand(interactionhand, ItemUtils.createFilledResult(itemstack, player, itemstack1));
|
|
player.awardStat(Stats.USE_CAULDRON);
|
|
player.awardStat(Stats.ITEM_USED.get(item));
|
|
- level.setBlockAndUpdate(blockpos, Blocks.CAULDRON.defaultBlockState());
|
|
- level.playSound((Player) null, blockpos, soundevent, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
- level.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, blockpos);
|
|
+ // world.setBlockAndUpdate(blockposition, Blocks.CAULDRON.defaultBlockState()); // CraftBukkit
|
|
+ level.playSound((Player) null, pos, fillSound, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
+ level.gameEvent((Entity) null, GameEvent.FLUID_PICKUP, pos);
|
|
}
|
|
|
|
return InteractionResult.sidedSuccess(level.isClientSide);
|
|
@@ -204,14 +232,19 @@
|
|
|
|
static InteractionResult emptyBucket(Level level, BlockPos blockpos, Player player, InteractionHand interactionhand, ItemStack itemstack, BlockState blockstate, SoundEvent soundevent) {
|
|
if (!level.isClientSide) {
|
|
- Item item = itemstack.getItem();
|
|
+ // CraftBukkit start
|
|
+ if (!LayeredCauldronBlock.changeLevel(state, level, pos, state, player, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) {
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+ Item item = filledStack.getItem();
|
|
|
|
player.setItemInHand(interactionhand, ItemUtils.createFilledResult(itemstack, player, new ItemStack(Items.BUCKET)));
|
|
player.awardStat(Stats.FILL_CAULDRON);
|
|
player.awardStat(Stats.ITEM_USED.get(item));
|
|
- level.setBlockAndUpdate(blockpos, blockstate);
|
|
- level.playSound((Player) null, blockpos, soundevent, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
- level.gameEvent((Entity) null, GameEvent.FLUID_PLACE, blockpos);
|
|
+ // world.setBlockAndUpdate(blockposition, iblockdata); // CraftBukkit
|
|
+ level.playSound((Player) null, pos, emptySound, SoundSource.BLOCKS, 1.0F, 1.0F);
|
|
+ level.gameEvent((Entity) null, GameEvent.FLUID_PLACE, pos);
|
|
}
|
|
|
|
return InteractionResult.sidedSuccess(level.isClientSide);
|
|
@@ -236,22 +266,28 @@
|
|
FILL_POWDER_SNOW = (blockstate, level, blockpos, player, interactionhand, itemstack) -> {
|
|
return emptyBucket(level, blockpos, player, interactionhand, itemstack, (BlockState) Blocks.POWDER_SNOW_CAULDRON.defaultBlockState().setValue(LayeredCauldronBlock.LEVEL, 3), SoundEvents.BUCKET_EMPTY_POWDER_SNOW);
|
|
};
|
|
- SHULKER_BOX = (blockstate, level, blockpos, player, interactionhand, itemstack) -> {
|
|
+ CauldronInteraction SHULKER_BOX = (iblockdata, world, blockposition, entityhuman, enumhand, itemstack) -> {
|
|
+ // CraftBukkit end
|
|
Block block = Block.byItem(itemstack.getItem());
|
|
|
|
if (!(block instanceof ShulkerBoxBlock)) {
|
|
return InteractionResult.PASS;
|
|
} else {
|
|
- if (!level.isClientSide) {
|
|
+ if (!world.isClientSide) {
|
|
+ // CraftBukkit start
|
|
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.SHULKER_WASH)) {
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
ItemStack itemstack1 = new ItemStack(Blocks.SHULKER_BOX);
|
|
|
|
if (itemstack.hasTag()) {
|
|
itemstack1.setTag(itemstack.getTag().copy());
|
|
}
|
|
|
|
- player.setItemInHand(interactionhand, itemstack1);
|
|
- player.awardStat(Stats.CLEAN_SHULKER_BOX);
|
|
- LayeredCauldronBlock.lowerFillLevel(blockstate, level, blockpos);
|
|
+ entityhuman.setItemInHand(enumhand, itemstack1);
|
|
+ entityhuman.awardStat(Stats.CLEAN_SHULKER_BOX);
|
|
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
|
}
|
|
|
|
return InteractionResult.sidedSuccess(level.isClientSide);
|
|
@@ -261,7 +297,12 @@
|
|
if (BannerBlockEntity.getPatternCount(itemstack) <= 0) {
|
|
return InteractionResult.PASS;
|
|
} else {
|
|
- if (!level.isClientSide) {
|
|
+ if (!world.isClientSide) {
|
|
+ // CraftBukkit start
|
|
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
ItemStack itemstack1 = itemstack.copyWithCount(1);
|
|
|
|
BannerBlockEntity.removeLastPattern(itemstack1);
|
|
@@ -277,8 +318,8 @@
|
|
player.drop(itemstack1, false);
|
|
}
|
|
|
|
- player.awardStat(Stats.CLEAN_BANNER);
|
|
- LayeredCauldronBlock.lowerFillLevel(blockstate, level, blockpos);
|
|
+ entityhuman.awardStat(Stats.CLEAN_BANNER);
|
|
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
|
}
|
|
|
|
return InteractionResult.sidedSuccess(level.isClientSide);
|
|
@@ -295,10 +336,15 @@
|
|
if (!dyeableleatheritem.hasCustomColor(itemstack)) {
|
|
return InteractionResult.PASS;
|
|
} else {
|
|
- if (!level.isClientSide) {
|
|
- dyeableleatheritem.clearColor(itemstack);
|
|
- player.awardStat(Stats.CLEAN_ARMOR);
|
|
- LayeredCauldronBlock.lowerFillLevel(blockstate, level, blockpos);
|
|
+ if (!world.isClientSide) {
|
|
+ // CraftBukkit start
|
|
+ if (!LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
|
|
+ return InteractionResult.SUCCESS;
|
|
+ }
|
|
+ // CraftBukkit end
|
|
+ idyeable.clearColor(itemstack);
|
|
+ entityhuman.awardStat(Stats.CLEAN_ARMOR);
|
|
+ // LayeredCauldronBlock.lowerFillLevel(iblockdata, world, blockposition); // CraftBukkit
|
|
}
|
|
|
|
return InteractionResult.sidedSuccess(level.isClientSide);
|