mirror of
https://github.com/barkeser2002/CatServer.git
synced 2026-09-25 01:39:52 +03:00
172 lines
7.8 KiB
Diff
172 lines
7.8 KiB
Diff
--- ../src-base/minecraft/net/minecraft/block/BlockCauldron.java
|
|
+++ ../src-work/minecraft/net/minecraft/block/BlockCauldron.java
|
|
@@ -31,6 +31,7 @@
|
|
import net.minecraft.util.math.MathHelper;
|
|
import net.minecraft.world.IBlockAccess;
|
|
import net.minecraft.world.World;
|
|
+import org.bukkit.event.block.CauldronLevelChangeEvent;
|
|
|
|
public class BlockCauldron extends Block
|
|
{
|
|
@@ -78,8 +79,11 @@
|
|
|
|
if (!worldIn.isRemote && entityIn.isBurning() && i > 0 && entityIn.getEntityBoundingBox().minY <= (double)f)
|
|
{
|
|
+ if (!this.changeLevel(worldIn, pos, state, i - 1, entityIn, CauldronLevelChangeEvent.ChangeReason.EXTINGUISH)) {
|
|
+ return;
|
|
+ }
|
|
entityIn.extinguish();
|
|
- this.setWaterLevel(worldIn, pos, state, i - 1);
|
|
+// this.setWaterLevel(worldIn, pos, state, i - 1);
|
|
}
|
|
}
|
|
|
|
@@ -100,13 +104,16 @@
|
|
{
|
|
if (i < 3 && !worldIn.isRemote)
|
|
{
|
|
+ if (!this.changeLevel(worldIn, pos, state, 3, playerIn, CauldronLevelChangeEvent.ChangeReason.BUCKET_EMPTY)) {
|
|
+ return true;
|
|
+ }
|
|
if (!playerIn.capabilities.isCreativeMode)
|
|
{
|
|
playerIn.setHeldItem(hand, new ItemStack(Items.BUCKET));
|
|
}
|
|
|
|
playerIn.addStat(StatList.CAULDRON_FILLED);
|
|
- this.setWaterLevel(worldIn, pos, state, 3);
|
|
+// this.setWaterLevel(worldIn, pos, state, 3);
|
|
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
|
}
|
|
|
|
@@ -116,6 +123,9 @@
|
|
{
|
|
if (i == 3 && !worldIn.isRemote)
|
|
{
|
|
+ if (!this.changeLevel(worldIn, pos, state, 0, playerIn, CauldronLevelChangeEvent.ChangeReason.BUCKET_FILL)) {
|
|
+ return true;
|
|
+ }
|
|
if (!playerIn.capabilities.isCreativeMode)
|
|
{
|
|
itemstack.shrink(1);
|
|
@@ -131,7 +141,7 @@
|
|
}
|
|
|
|
playerIn.addStat(StatList.CAULDRON_USED);
|
|
- this.setWaterLevel(worldIn, pos, state, 0);
|
|
+// this.setWaterLevel(worldIn, pos, state, 0);
|
|
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
|
}
|
|
|
|
@@ -141,6 +151,9 @@
|
|
{
|
|
if (i > 0 && !worldIn.isRemote)
|
|
{
|
|
+ if (!this.changeLevel(worldIn, pos, state, i - 1, playerIn, CauldronLevelChangeEvent.ChangeReason.BOTTLE_FILL)) {
|
|
+ return true;
|
|
+ }
|
|
if (!playerIn.capabilities.isCreativeMode)
|
|
{
|
|
ItemStack itemstack3 = PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), PotionTypes.WATER);
|
|
@@ -162,7 +175,7 @@
|
|
}
|
|
|
|
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
|
- this.setWaterLevel(worldIn, pos, state, i - 1);
|
|
+// this.setWaterLevel(worldIn, pos, state, i - 1);
|
|
}
|
|
|
|
return true;
|
|
@@ -171,6 +184,9 @@
|
|
{
|
|
if (i < 3 && !worldIn.isRemote)
|
|
{
|
|
+ if (!this.changeLevel(worldIn, pos, state, i + 1, playerIn, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
|
|
+ return true;
|
|
+ }
|
|
if (!playerIn.capabilities.isCreativeMode)
|
|
{
|
|
ItemStack itemstack2 = new ItemStack(Items.GLASS_BOTTLE);
|
|
@@ -184,7 +200,7 @@
|
|
}
|
|
|
|
worldIn.playSound((EntityPlayer)null, pos, SoundEvents.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
|
- this.setWaterLevel(worldIn, pos, state, i + 1);
|
|
+// this.setWaterLevel(worldIn, pos, state, i + 1);
|
|
}
|
|
|
|
return true;
|
|
@@ -197,8 +213,11 @@
|
|
|
|
if (itemarmor.getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER && itemarmor.hasColor(itemstack) && !worldIn.isRemote)
|
|
{
|
|
+ if (!this.changeLevel(worldIn, pos, state, i - 1, playerIn, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
|
|
+ return true;
|
|
+ }
|
|
itemarmor.removeColor(itemstack);
|
|
- this.setWaterLevel(worldIn, pos, state, i - 1);
|
|
+// this.setWaterLevel(worldIn, pos, state, i - 1);
|
|
playerIn.addStat(StatList.ARMOR_CLEANED);
|
|
return true;
|
|
}
|
|
@@ -208,6 +227,9 @@
|
|
{
|
|
if (TileEntityBanner.getPatterns(itemstack) > 0 && !worldIn.isRemote)
|
|
{
|
|
+ if (!this.changeLevel(worldIn, pos, state, i - 1, playerIn, CauldronLevelChangeEvent.ChangeReason.BANNER_WASH)) {
|
|
+ return true;
|
|
+ }
|
|
ItemStack itemstack1 = itemstack.copy();
|
|
itemstack1.setCount(1);
|
|
TileEntityBanner.removeBannerData(itemstack1);
|
|
@@ -216,7 +238,7 @@
|
|
if (!playerIn.capabilities.isCreativeMode)
|
|
{
|
|
itemstack.shrink(1);
|
|
- this.setWaterLevel(worldIn, pos, state, i - 1);
|
|
+// this.setWaterLevel(worldIn, pos, state, i - 1);
|
|
}
|
|
|
|
if (itemstack.isEmpty())
|
|
@@ -245,10 +267,29 @@
|
|
|
|
public void setWaterLevel(World worldIn, BlockPos pos, IBlockState state, int level)
|
|
{
|
|
- worldIn.setBlockState(pos, state.withProperty(LEVEL, Integer.valueOf(MathHelper.clamp(level, 0, 3))), 2);
|
|
- worldIn.updateComparatorOutputLevel(pos, this);
|
|
+ this.changeLevel(worldIn, pos, state, level, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN);
|
|
}
|
|
|
|
+ public void changeLevel(World world, BlockPos blockposition, IBlockState iblockdata, int i) {
|
|
+ this.changeLevel(world, blockposition, iblockdata, i, null, CauldronLevelChangeEvent.ChangeReason.UNKNOWN);
|
|
+ }
|
|
+
|
|
+ private boolean changeLevel(World world, BlockPos blockposition, IBlockState 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()),
|
|
+ (entity == null) ? null : entity.getBukkitEntity(), reason, iblockdata.getValue(BlockCauldron.LEVEL), newLevel
|
|
+ );
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
+ if (event.isCancelled()) {
|
|
+ return false;
|
|
+ }
|
|
+ world.setBlockState(blockposition, iblockdata.withProperty(BlockCauldron.LEVEL, event.getNewLevel()), 2);
|
|
+ world.updateComparatorOutputLevel(blockposition, this);
|
|
+ world.updateComparatorOutputLevel(blockposition, this);
|
|
+ return true;
|
|
+ }
|
|
+
|
|
public void fillWithRain(World worldIn, BlockPos pos)
|
|
{
|
|
if (worldIn.rand.nextInt(20) == 1)
|
|
@@ -261,7 +302,7 @@
|
|
|
|
if (((Integer)iblockstate.getValue(LEVEL)).intValue() < 3)
|
|
{
|
|
- worldIn.setBlockState(pos, iblockstate.cycleProperty(LEVEL), 2);
|
|
+ this.changeLevel(worldIn, pos, iblockstate.cycleProperty(LEVEL), 2);
|
|
}
|
|
}
|
|
}
|