3
0
Mirror von https://github.com/PaperMC/Paper.git synchronisiert 2024-12-21 05:50:05 +01:00
Paper/nms-patches/BlockCauldron.patch

176 Zeilen
8.6 KiB
Diff

2016-02-29 22:32:46 +01:00
--- a/net/minecraft/server/BlockCauldron.java
+++ b/net/minecraft/server/BlockCauldron.java
2016-05-10 13:47:39 +02:00
@@ -3,6 +3,7 @@
2016-02-29 22:32:46 +01:00
import java.util.List;
import java.util.Random;
2016-05-10 13:47:39 +02:00
import javax.annotation.Nullable;
2016-02-29 22:32:46 +01:00
+import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit
public class BlockCauldron extends Block {
2016-05-10 13:47:39 +02:00
@@ -43,8 +44,13 @@
2016-02-29 22:32:46 +01:00
float f = (float) blockposition.getY() + (6.0F + (float) (3 * i)) / 16.0F;
if (!world.isClientSide && entity.isBurning() && i > 0 && entity.getBoundingBox().b <= (double) f) {
+ // 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
}
}
2016-11-17 02:41:03 +01:00
@@ -60,18 +66,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)) {
+ return true;
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
entityhuman.a(enumhand, new ItemStack(Items.BUCKET));
}
entityhuman.b(StatisticList.K);
- this.a(world, blockposition, iblockdata, 3);
+ // this.a(world, blockposition, iblockdata, 3);
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
world.a((EntityHuman) null, blockposition, SoundEffects.N, SoundCategory.BLOCKS, 1.0F, 1.0F);
2016-02-29 22:32:46 +01:00
}
return true;
} else if (item == Items.BUCKET) {
if (i == 3 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, 0, entityhuman, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) {
+ return true;
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
2016-11-17 02:41:03 +01:00
itemstack.subtract(1);
if (itemstack.isEmpty()) {
@@ -82,7 +97,8 @@
2016-02-29 22:32:46 +01:00
}
entityhuman.b(StatisticList.L);
- this.a(world, blockposition, iblockdata, 0);
+ // this.a(world, blockposition, iblockdata, 0);
+ // CraftBukkit end
2016-11-17 02:41:03 +01:00
world.a((EntityHuman) null, blockposition, SoundEffects.P, SoundCategory.BLOCKS, 1.0F, 1.0F);
2016-02-29 22:32:46 +01:00
}
2016-11-17 02:41:03 +01:00
@@ -92,6 +108,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)) {
+ return true;
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.b);
entityhuman.b(StatisticList.L);
2016-11-17 02:41:03 +01:00
@@ -106,12 +126,17 @@
2016-02-29 22:32:46 +01:00
}
2016-11-17 02:41:03 +01:00
world.a((EntityHuman) null, blockposition, SoundEffects.K, 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
}
return true;
2016-11-17 02:41:03 +01:00
} else if (item == Items.POTION && PotionUtil.d(itemstack) == Potions.b) {
if (i < 3 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i + 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
+ return true;
+ }
if (!entityhuman.abilities.canInstantlyBuild) {
itemstack1 = new ItemStack(Items.GLASS_BOTTLE);
entityhuman.b(StatisticList.L);
@@ -122,7 +147,8 @@
}
world.a((EntityHuman) null, blockposition, SoundEffects.J, SoundCategory.BLOCKS, 1.0F, 1.0F);
- this.a(world, blockposition, iblockdata, i + 1);
+ // this.a(world, blockposition, iblockdata, i + 1);
+ // CraftBukkit end
}
return true;
@@ -131,8 +157,13 @@
2016-02-29 22:32:46 +01:00
ItemArmor itemarmor = (ItemArmor) item;
if (itemarmor.d() == ItemArmor.EnumArmorMaterial.LEATHER && itemarmor.e_(itemstack) && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
+ return true;
+ }
2016-11-17 02:41:03 +01:00
itemarmor.d(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
entityhuman.b(StatisticList.M);
return true;
}
2016-11-17 02:41:03 +01:00
@@ -140,13 +171,18 @@
2016-02-29 22:32:46 +01:00
2016-11-17 02:41:03 +01:00
if (i > 0 && item instanceof ItemBanner) {
if (TileEntityBanner.b(itemstack) > 0 && !world.isClientSide) {
+ // CraftBukkit start
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
+ return true;
+ }
itemstack1 = itemstack.cloneItemStack();
itemstack1.setCount(1);
TileEntityBanner.c(itemstack1);
entityhuman.b(StatisticList.N);
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()) {
@@ -167,9 +203,25 @@
2016-02-29 22:32:46 +01:00
}
}
+ // CraftBukkit start
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
- world.setTypeAndData(blockposition, iblockdata.set(BlockCauldron.LEVEL, Integer.valueOf(MathHelper.clamp(i, 0, 3))), 2);
+ 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;
+ }
+ world.setTypeAndData(blockposition, iblockdata.set(BlockCauldron.LEVEL, newLevel), 2);
world.updateAdjacentComparators(blockposition, this);
+ return true;
+ // CraftBukkit end
}
public void h(World world, BlockPosition blockposition) {
2016-11-17 02:41:03 +01:00
@@ -180,7 +232,7 @@
2016-02-29 22:32:46 +01:00
IBlockData iblockdata = world.getType(blockposition);
if (((Integer) iblockdata.get(BlockCauldron.LEVEL)).intValue() < 3) {
- world.setTypeAndData(blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2);
2016-11-17 02:41:03 +01:00
+ this.a(world, blockposition, iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
2016-02-29 22:32:46 +01:00
}
}