13
0
geforkt von Mirrors/Paper
Paper/nms-patches/BlockCauldron.patch

176 Zeilen
9.0 KiB
Diff

2016-02-29 22:32:46 +01:00
--- a/net/minecraft/server/BlockCauldron.java
+++ b/net/minecraft/server/BlockCauldron.java
2018-07-15 02:00:00 +02:00
@@ -1,5 +1,7 @@
package net.minecraft.server;
2016-02-29 22:32:46 +01:00
2018-07-15 02:00:00 +02:00
+import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit
+
2016-02-29 22:32:46 +01:00
public class BlockCauldron extends Block {
2020-06-25 02:00:00 +02:00
public static final BlockStateInteger LEVEL = BlockProperties.ar;
2019-12-10 23:00:00 +01:00
@@ -27,8 +29,13 @@
2016-02-29 22:32:46 +01:00
float f = (float) blockposition.getY() + (6.0F + (float) (3 * i)) / 16.0F;
2019-12-10 23:00:00 +01:00
if (!world.isClientSide && entity.isBurning() && i > 0 && entity.locY() <= (double) f) {
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entity, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) {
+ return;
+ }
entity.extinguish();
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
}
}
2019-12-10 23:00:00 +01:00
@@ -45,18 +52,27 @@
2016-02-29 22:32:46 +01:00
if (item == Items.WATER_BUCKET) {
if (i < 3 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, 3, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) {
2019-12-10 23:00:00 +01:00
+ return EnumInteractionResult.SUCCESS;
2016-02-29 22:32:46 +01:00
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
entityhuman.a(enumhand, new ItemStack(Items.BUCKET));
}
2018-07-15 02:00:00 +02:00
entityhuman.a(StatisticList.FILL_CAULDRON);
2016-02-29 22:32:46 +01:00
- this.a(world, blockposition, iblockdata, 3);
+ // this.a(world, blockposition, iblockdata, 3);
+ // CraftBukkit end
2019-07-20 01:00:00 +02:00
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
2016-02-29 22:32:46 +01:00
}
2020-06-25 02:00:00 +02:00
return EnumInteractionResult.a(world.isClientSide);
2016-02-29 22:32:46 +01:00
} else if (item == Items.BUCKET) {
if (i == 3 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, 0, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) {
2019-12-10 23:00:00 +01:00
+ return EnumInteractionResult.SUCCESS;
2016-02-29 22:32:46 +01:00
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
2016-11-17 02:41:03 +01:00
itemstack.subtract(1);
if (itemstack.isEmpty()) {
2019-12-10 23:00:00 +01:00
@@ -67,7 +83,8 @@
2016-02-29 22:32:46 +01:00
}
2018-07-15 02:00:00 +02:00
entityhuman.a(StatisticList.USE_CAULDRON);
2016-02-29 22:32:46 +01:00
- this.a(world, blockposition, iblockdata, 0);
+ // this.a(world, blockposition, iblockdata, 0);
+ // CraftBukkit end
2019-07-20 01:00:00 +02:00
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
2016-02-29 22:32:46 +01:00
}
2019-12-10 23:00:00 +01:00
@@ -77,6 +94,10 @@
2016-02-29 22:32:46 +01:00
if (item == Items.GLASS_BOTTLE) {
if (i > 0 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) {
2019-12-10 23:00:00 +01:00
+ return EnumInteractionResult.SUCCESS;
2016-02-29 22:32:46 +01:00
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
2019-05-27 22:30:00 +02:00
itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.WATER);
2018-07-15 02:00:00 +02:00
entityhuman.a(StatisticList.USE_CAULDRON);
2019-12-10 23:00:00 +01:00
@@ -91,12 +112,17 @@
2016-02-29 22:32:46 +01:00
}
2019-07-20 01:00:00 +02:00
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
2016-02-29 22:32:46 +01:00
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
}
2020-06-25 02:00:00 +02:00
return EnumInteractionResult.a(world.isClientSide);
2019-05-27 22:30:00 +02:00
} else if (item == Items.POTION && PotionUtil.d(itemstack) == Potions.WATER) {
2016-11-17 02:41:03 +01:00
if (i < 3 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i + 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
2019-12-10 23:00:00 +01:00
+ return EnumInteractionResult.SUCCESS;
2016-11-17 02:41:03 +01:00
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = new ItemStack(Items.GLASS_BOTTLE);
2018-07-15 02:00:00 +02:00
entityhuman.a(StatisticList.USE_CAULDRON);
2019-12-10 23:00:00 +01:00
@@ -107,7 +133,8 @@
2016-11-17 02:41:03 +01:00
}
2019-07-20 01:00:00 +02:00
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
2016-11-17 02:41:03 +01:00
- this.a(world, blockposition, iblockdata, i + 1);
+ // this.a(world, blockposition, iblockdata, i + 1);
+ // CraftBukkit end
}
2020-06-25 02:00:00 +02:00
return EnumInteractionResult.a(world.isClientSide);
2019-12-10 23:00:00 +01:00
@@ -116,8 +143,13 @@
2019-04-23 04:00:00 +02:00
IDyeable idyeable = (IDyeable) item;
2016-02-29 22:32:46 +01:00
2019-04-23 04:00:00 +02:00
if (idyeable.a(itemstack) && !world.isClientSide) {
2016-02-29 22:32:46 +01:00
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
2019-12-10 23:00:00 +01:00
+ return EnumInteractionResult.SUCCESS;
2016-02-29 22:32:46 +01:00
+ }
2019-04-23 04:00:00 +02:00
idyeable.c(itemstack);
2016-02-29 22:32:46 +01:00
- this.a(world, blockposition, iblockdata, i - 1);
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
2018-07-15 02:00:00 +02:00
entityhuman.a(StatisticList.CLEAN_ARMOR);
2019-12-10 23:00:00 +01:00
return EnumInteractionResult.SUCCESS;
2016-02-29 22:32:46 +01:00
}
2019-12-10 23:00:00 +01:00
@@ -125,13 +157,18 @@
2016-02-29 22:32:46 +01:00
2016-11-17 02:41:03 +01:00
if (i > 0 && item instanceof ItemBanner) {
2020-01-21 22:00:00 +01:00
if (TileEntityBanner.b(itemstack) > 0 && !world.isClientSide) {
2016-11-17 02:41:03 +01:00
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
2019-12-10 23:00:00 +01:00
+ return EnumInteractionResult.SUCCESS;
2016-11-17 02:41:03 +01:00
+ }
itemstack1 = itemstack.cloneItemStack();
itemstack1.setCount(1);
2020-01-21 22:00:00 +01:00
TileEntityBanner.c(itemstack1);
2018-07-15 02:00:00 +02:00
entityhuman.a(StatisticList.CLEAN_BANNER);
2016-02-29 22:32:46 +01:00
if (!entityhuman.abilities.canInstantlyBuild) {
2016-11-17 02:41:03 +01:00
itemstack.subtract(1);
2016-02-29 22:32:46 +01:00
- this.a(world, blockposition, iblockdata, i - 1);
2016-11-17 02:41:03 +01:00
+ // this.a(world, blockposition, iblockdata, i - 1);
+ // CraftBukkit end
2016-02-29 22:32:46 +01:00
}
2016-11-17 02:41:03 +01:00
if (itemstack.isEmpty()) {
2019-12-10 23:00:00 +01:00
@@ -169,9 +206,25 @@
2016-02-29 22:32:46 +01:00
}
}
+ // CraftBukkit start
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
2018-12-06 00:00:00 +01:00
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, MathHelper.clamp(i, 0, 3)), 2);
2016-02-29 22:32:46 +01:00
+ this.changeLevel(world, blockposition, iblockdata, i, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN);
+ }
+
+ private boolean changeLevel(World world, BlockPosition blockposition, IBlockData iblockdata, int i, Entity entity, CauldronLevelChangeEvent.ChangeReason reason) {
+ int newLevel = Integer.valueOf(MathHelper.clamp(i, 0, 3));
+ CauldronLevelChangeEvent event = new CauldronLevelChangeEvent(
+ world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()),
2016-03-01 20:31:11 +01:00
+ (entity == null) ? null : entity.getBukkitEntity(), reason, iblockdata.get(BlockCauldron.LEVEL), newLevel
2016-02-29 22:32:46 +01:00
+ );
+ world.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled()) {
+ return false;
+ }
2018-07-15 02:00:00 +02:00
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, event.getNewLevel()), 2);
2016-02-29 22:32:46 +01:00
world.updateAdjacentComparators(blockposition, this);
+ return true;
+ // CraftBukkit end
}
2019-04-23 04:00:00 +02:00
@Override
2019-12-10 23:00:00 +01:00
@@ -183,7 +236,7 @@
2016-02-29 22:32:46 +01:00
IBlockData iblockdata = world.getType(blockposition);
2018-12-06 00:00:00 +01:00
if ((Integer) iblockdata.get(BlockCauldron.LEVEL) < 3) {
2018-07-15 02:00:00 +02:00
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2);
+ this.a(world, blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
2016-02-29 22:32:46 +01:00
}
}