@@ -0,0 +1,39 @@
|
||||
--- a/net/minecraft/server/Block.java
|
||||
+++ b/net/minecraft/server/Block.java
|
||||
@@ -209,7 +209,13 @@
|
||||
EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + d0, (double) blockposition.getY() + d1, (double) blockposition.getZ() + d2, itemstack);
|
||||
|
||||
entityitem.defaultPickupDelay();
|
||||
- world.addEntity(entityitem);
|
||||
+ // CraftBukkit start
|
||||
+ if (world.captureDrops != null) {
|
||||
+ world.captureDrops.add(entityitem);
|
||||
+ } else {
|
||||
+ world.addEntity(entityitem);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
@@ -240,7 +246,7 @@
|
||||
|
||||
public void a(World world, EntityHuman entityhuman, BlockPosition blockposition, IBlockData iblockdata, @Nullable TileEntity tileentity, ItemStack itemstack) {
|
||||
entityhuman.b(StatisticList.BLOCK_MINED.b(this));
|
||||
- entityhuman.applyExhaustion(0.005F);
|
||||
+ entityhuman.applyExhaustion(0.005F, org.bukkit.event.entity.EntityExhaustionEvent.ExhaustionReason.BLOCK_MINED); // CraftBukkit - EntityExhaustionEvent
|
||||
dropItems(iblockdata, world, blockposition, tileentity, entityhuman, itemstack);
|
||||
}
|
||||
|
||||
@@ -336,6 +342,12 @@
|
||||
return this;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
|
||||
+ return 0;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static final class a {
|
||||
|
||||
private final IBlockData a;
|
||||
@@ -0,0 +1,39 @@
|
||||
--- a/net/minecraft/server/BlockBamboo.java
|
||||
+++ b/net/minecraft/server/BlockBamboo.java
|
||||
@@ -170,14 +170,18 @@
|
||||
BlockPosition blockposition1 = blockposition.down(2);
|
||||
IBlockData iblockdata2 = world.getType(blockposition1);
|
||||
BlockPropertyBambooSize blockpropertybamboosize = BlockPropertyBambooSize.NONE;
|
||||
+ boolean shouldUpdateOthers = false; // CraftBukkit
|
||||
|
||||
if (i >= 1) {
|
||||
if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.e) != BlockPropertyBambooSize.NONE) {
|
||||
if (iblockdata1.a(Blocks.BAMBOO) && iblockdata1.get(BlockBamboo.e) != BlockPropertyBambooSize.NONE) {
|
||||
blockpropertybamboosize = BlockPropertyBambooSize.LARGE;
|
||||
if (iblockdata2.a(Blocks.BAMBOO)) {
|
||||
- world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3);
|
||||
- world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.e, BlockPropertyBambooSize.NONE), 3);
|
||||
+ // CraftBukkit start - moved down
|
||||
+ // world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3);
|
||||
+ // world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.e, BlockPropertyBambooSize.NONE), 3);
|
||||
+ shouldUpdateOthers = true;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -188,7 +192,14 @@
|
||||
int j = (Integer) iblockdata.get(BlockBamboo.d) != 1 && !iblockdata2.a(Blocks.BAMBOO) ? 0 : 1;
|
||||
int k = (i < 11 || random.nextFloat() >= 0.25F) && i != 15 ? 0 : 1;
|
||||
|
||||
- world.setTypeAndData(blockposition.up(), (IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockBamboo.d, j)).set(BlockBamboo.e, blockpropertybamboosize)).set(BlockBamboo.f, k), 3);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.up(), (IBlockData) ((IBlockData) ((IBlockData) this.getBlockData().set(BlockBamboo.d, j)).set(BlockBamboo.e, blockpropertybamboosize)).set(BlockBamboo.f, k), 3)) {
|
||||
+ if (shouldUpdateOthers) {
|
||||
+ world.setTypeAndData(blockposition.down(), (IBlockData) iblockdata1.set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3);
|
||||
+ world.setTypeAndData(blockposition1, (IBlockData) iblockdata2.set(BlockBamboo.e, BlockPropertyBambooSize.NONE), 3);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
protected int a(IBlockAccess iblockaccess, BlockPosition blockposition) {
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/server/BlockBambooSapling.java
|
||||
+++ b/net/minecraft/server/BlockBambooSapling.java
|
||||
@@ -69,6 +69,6 @@
|
||||
}
|
||||
|
||||
protected void a(World world, BlockPosition blockposition) {
|
||||
- world.setTypeAndData(blockposition.up(), (IBlockData) Blocks.BAMBOO.getBlockData().set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(world, blockposition, blockposition.up(), (IBlockData) Blocks.BAMBOO.getBlockData().set(BlockBamboo.e, BlockPropertyBambooSize.SMALL), 3); // CraftBukkit - BlockSpreadEvent
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
--- a/net/minecraft/server/BlockBed.java
|
||||
+++ b/net/minecraft/server/BlockBed.java
|
||||
@@ -39,7 +39,8 @@
|
||||
}
|
||||
}
|
||||
|
||||
- if (!a(world)) {
|
||||
+ // CraftBukkit - moved world and biome check into EntityHuman
|
||||
+ if (false && !a(world)) {
|
||||
world.a(blockposition, false);
|
||||
BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite());
|
||||
|
||||
@@ -56,7 +57,16 @@
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ IBlockData finaliblockdata = iblockdata;
|
||||
+ BlockPosition finalblockposition = blockposition;
|
||||
+ // CraftBukkit end
|
||||
entityhuman.sleep(blockposition).ifLeft((entityhuman_enumbedresult) -> {
|
||||
+ // CraftBukkit start - handling bed explosion from below here
|
||||
+ if (entityhuman_enumbedresult == EntityHuman.EnumBedResult.NOT_POSSIBLE_HERE) {
|
||||
+ this.explodeBed(finaliblockdata, world, finalblockposition);
|
||||
+ } else
|
||||
+ // CraftBukkit end
|
||||
if (entityhuman_enumbedresult != null) {
|
||||
entityhuman.a(entityhuman_enumbedresult.a(), true);
|
||||
}
|
||||
@@ -67,8 +77,27 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ private EnumInteractionResult explodeBed(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
||||
+ {
|
||||
+ {
|
||||
+ world.a(blockposition, false);
|
||||
+ BlockPosition blockposition1 = blockposition.shift(((EnumDirection) iblockdata.get(BlockBed.FACING)).opposite());
|
||||
+
|
||||
+ if (world.getType(blockposition1).getBlock() == this) {
|
||||
+ world.a(blockposition1, false);
|
||||
+ }
|
||||
+
|
||||
+ world.createExplosion((Entity) null, DamageSource.a(), (ExplosionDamageCalculator) null, (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0F, true, Explosion.Effect.DESTROY);
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public static boolean a(World world) {
|
||||
- return world.getDimensionManager().isBedWorks();
|
||||
+ // CraftBukkit - moved world and biome check into EntityHuman
|
||||
+ return true || world.getDimensionManager().isBedWorks();
|
||||
}
|
||||
|
||||
private boolean a(World world, BlockPosition blockposition) {
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/BlockBeehive.java
|
||||
+++ b/net/minecraft/server/BlockBeehive.java
|
||||
@@ -55,7 +55,7 @@
|
||||
EntityBee entitybee = (EntityBee) iterator.next();
|
||||
|
||||
if (entitybee.getGoalTarget() == null) {
|
||||
- entitybee.setGoalTarget((EntityLiving) list1.get(world.random.nextInt(i)));
|
||||
+ entitybee.setGoalTarget((EntityLiving) list1.get(world.random.nextInt(i)), org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
--- a/net/minecraft/server/BlockButtonAbstract.java
|
||||
+++ b/net/minecraft/server/BlockButtonAbstract.java
|
||||
@@ -4,6 +4,11 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
+import org.bukkit.event.entity.EntityInteractEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class BlockButtonAbstract extends BlockAttachable {
|
||||
|
||||
public static final BlockStateBoolean POWERED = BlockProperties.w;
|
||||
@@ -70,6 +75,19 @@
|
||||
if ((Boolean) iblockdata.get(BlockButtonAbstract.POWERED)) {
|
||||
return EnumInteractionResult.CONSUME;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ boolean powered = ((Boolean) iblockdata.get(POWERED));
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ int old = (powered) ? 15 : 0;
|
||||
+ int current = (!powered) ? 15 : 0;
|
||||
+
|
||||
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
|
||||
+ world.getServer().getPluginManager().callEvent(eventRedstone);
|
||||
+
|
||||
+ if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.d(iblockdata, world, blockposition);
|
||||
this.a(entityhuman, world, blockposition, true);
|
||||
return EnumInteractionResult.a(world.isClientSide);
|
||||
@@ -120,6 +138,16 @@
|
||||
if (this.v) {
|
||||
this.e(iblockdata, (World) worldserver, blockposition);
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+
|
||||
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
|
||||
+ worldserver.getServer().getPluginManager().callEvent(eventRedstone);
|
||||
+
|
||||
+ if (eventRedstone.getNewCurrent() > 0) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, false), 3);
|
||||
this.f(iblockdata, (World) worldserver, blockposition);
|
||||
this.a((EntityHuman) null, worldserver, blockposition, false);
|
||||
@@ -140,7 +168,44 @@
|
||||
boolean flag = !list.isEmpty();
|
||||
boolean flag1 = (Boolean) iblockdata.get(BlockButtonAbstract.POWERED);
|
||||
|
||||
+ // CraftBukkit start - Call interact event when arrows turn on wooden buttons
|
||||
+ if (flag1 != flag && flag) {
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ boolean allowed = false;
|
||||
+
|
||||
+ // If all of the events are cancelled block the button press, else allow
|
||||
+ for (Object object : list) {
|
||||
+ if (object != null) {
|
||||
+ EntityInteractEvent event = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ allowed = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!allowed) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (flag != flag1) {
|
||||
+ // CraftBukkit start
|
||||
+ boolean powered = flag1;
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ int old = (powered) ? 15 : 0;
|
||||
+ int current = (!powered) ? 15 : 0;
|
||||
+
|
||||
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
|
||||
+ world.getServer().getPluginManager().callEvent(eventRedstone);
|
||||
+
|
||||
+ if ((flag && eventRedstone.getNewCurrent() <= 0) || (!flag && eventRedstone.getNewCurrent() > 0)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockButtonAbstract.POWERED, flag), 3);
|
||||
this.f(iblockdata, world, blockposition);
|
||||
this.a((EntityHuman) null, world, blockposition, flag);
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/server/BlockCactus.java
|
||||
+++ b/net/minecraft/server/BlockCactus.java
|
||||
@@ -3,6 +3,8 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class BlockCactus extends Block {
|
||||
|
||||
public static final BlockStateInteger AGE = BlockProperties.aj;
|
||||
@@ -37,7 +39,7 @@
|
||||
int j = (Integer) iblockdata.get(BlockCactus.AGE);
|
||||
|
||||
if (j == 15) {
|
||||
- worldserver.setTypeUpdate(blockposition1, this.getBlockData());
|
||||
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.getBlockData()); // CraftBukkit
|
||||
IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockCactus.AGE, 0);
|
||||
|
||||
worldserver.setTypeAndData(blockposition, iblockdata1, 4);
|
||||
@@ -94,7 +96,9 @@
|
||||
|
||||
@Override
|
||||
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
||||
+ CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit
|
||||
entity.damageEntity(DamageSource.CACTUS, 1.0F);
|
||||
+ CraftEventFactory.blockDamage = null; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/net/minecraft/server/BlockCake.java
|
||||
+++ b/net/minecraft/server/BlockCake.java
|
||||
@@ -37,7 +37,18 @@
|
||||
return EnumInteractionResult.PASS;
|
||||
} else {
|
||||
entityhuman.a(StatisticList.EAT_CAKE_SLICE);
|
||||
- entityhuman.getFoodData().eat(2, 0.1F);
|
||||
+ // CraftBukkit start
|
||||
+ // entityhuman.getFoodData().eat(2, 0.1F);
|
||||
+ int oldFoodLevel = entityhuman.getFoodData().foodLevel;
|
||||
+
|
||||
+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(entityhuman, 2 + oldFoodLevel);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ entityhuman.getFoodData().eat(event.getFoodLevel() - oldFoodLevel, 0.1F);
|
||||
+ }
|
||||
+
|
||||
+ ((EntityPlayer) entityhuman).getBukkitEntity().sendHealthUpdate();
|
||||
+ // CraftBukkit end
|
||||
int i = (Integer) iblockdata.get(BlockCake.BITES);
|
||||
|
||||
if (i < 6) {
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/BlockCampfire.java
|
||||
+++ b/net/minecraft/server/BlockCampfire.java
|
||||
@@ -144,6 +144,11 @@
|
||||
if (flag && !(Boolean) iblockdata.get(BlockCampfire.LIT) && !(Boolean) iblockdata.get(BlockCampfire.d)) {
|
||||
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(world, blockposition, iprojectile).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockProperties.r, true), 11);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
--- a/net/minecraft/server/BlockCauldron.java
|
||||
+++ b/net/minecraft/server/BlockCauldron.java
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+import org.bukkit.event.block.CauldronLevelChangeEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockCauldron extends Block {
|
||||
|
||||
public static final BlockStateInteger LEVEL = BlockProperties.ar;
|
||||
@@ -27,8 +29,13 @@
|
||||
float f = (float) blockposition.getY() + (6.0F + (float) (3 * i)) / 16.0F;
|
||||
|
||||
if (!world.isClientSide && entity.isBurning() && i > 0 && entity.locY() <= (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
|
||||
}
|
||||
|
||||
}
|
||||
@@ -45,18 +52,27 @@
|
||||
|
||||
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 EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
entityhuman.a(enumhand, new ItemStack(Items.BUCKET));
|
||||
}
|
||||
|
||||
entityhuman.a(StatisticList.FILL_CAULDRON);
|
||||
- this.a(world, blockposition, iblockdata, 3);
|
||||
+ // this.a(world, blockposition, iblockdata, 3);
|
||||
+ // CraftBukkit end
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
return EnumInteractionResult.a(world.isClientSide);
|
||||
} 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 EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack.subtract(1);
|
||||
if (itemstack.isEmpty()) {
|
||||
@@ -67,7 +83,8 @@
|
||||
}
|
||||
|
||||
entityhuman.a(StatisticList.USE_CAULDRON);
|
||||
- this.a(world, blockposition, iblockdata, 0);
|
||||
+ // this.a(world, blockposition, iblockdata, 0);
|
||||
+ // CraftBukkit end
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BUCKET_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
|
||||
@@ -77,6 +94,10 @@
|
||||
|
||||
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 EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack1 = PotionUtil.a(new ItemStack(Items.POTION), Potions.WATER);
|
||||
entityhuman.a(StatisticList.USE_CAULDRON);
|
||||
@@ -91,12 +112,17 @@
|
||||
}
|
||||
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_FILL, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
- this.a(world, blockposition, iblockdata, i - 1);
|
||||
+ // this.a(world, blockposition, iblockdata, i - 1);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return EnumInteractionResult.a(world.isClientSide);
|
||||
} else if (item == Items.POTION && PotionUtil.d(itemstack) == Potions.WATER) {
|
||||
if (i < 3 && !world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.changeLevel(world, blockposition, iblockdata, i + 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.BOTTLE_EMPTY)) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack1 = new ItemStack(Items.GLASS_BOTTLE);
|
||||
entityhuman.a(StatisticList.USE_CAULDRON);
|
||||
@@ -107,7 +133,8 @@
|
||||
}
|
||||
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_BOTTLE_EMPTY, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
- this.a(world, blockposition, iblockdata, i + 1);
|
||||
+ // this.a(world, blockposition, iblockdata, i + 1);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
return EnumInteractionResult.a(world.isClientSide);
|
||||
@@ -116,8 +143,13 @@
|
||||
IDyeable idyeable = (IDyeable) item;
|
||||
|
||||
if (idyeable.a(itemstack) && !world.isClientSide) {
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.changeLevel(world, blockposition, iblockdata, i - 1, entityhuman, CauldronLevelChangeEvent.ChangeReason.ARMOR_WASH)) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
idyeable.c(itemstack);
|
||||
- this.a(world, blockposition, iblockdata, i - 1);
|
||||
+ // this.a(world, blockposition, iblockdata, i - 1);
|
||||
+ // CraftBukkit end
|
||||
entityhuman.a(StatisticList.CLEAN_ARMOR);
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
}
|
||||
@@ -125,13 +157,18 @@
|
||||
|
||||
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 EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
itemstack1 = itemstack.cloneItemStack();
|
||||
itemstack1.setCount(1);
|
||||
TileEntityBanner.c(itemstack1);
|
||||
entityhuman.a(StatisticList.CLEAN_BANNER);
|
||||
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||
itemstack.subtract(1);
|
||||
- this.a(world, blockposition, iblockdata, i - 1);
|
||||
+ // this.a(world, blockposition, iblockdata, i - 1);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
if (itemstack.isEmpty()) {
|
||||
@@ -169,9 +206,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, int i) {
|
||||
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, 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()),
|
||||
+ (entity == null) ? null : entity.getBukkitEntity(), reason, iblockdata.get(BlockCauldron.LEVEL), newLevel
|
||||
+ );
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCauldron.LEVEL, event.getNewLevel()), 2);
|
||||
world.updateAdjacentComparators(blockposition, this);
|
||||
+ return true;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,7 +236,7 @@
|
||||
IBlockData iblockdata = world.getType(blockposition);
|
||||
|
||||
if ((Integer) iblockdata.get(BlockCauldron.LEVEL) < 3) {
|
||||
- world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2);
|
||||
+ this.a(world, blockposition, (IBlockData) iblockdata.a((IBlockState) BlockCauldron.LEVEL), 2); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
--- a/net/minecraft/server/BlockChest.java
|
||||
+++ b/net/minecraft/server/BlockChest.java
|
||||
@@ -35,24 +35,7 @@
|
||||
public Optional<ITileInventory> a(final TileEntityChest tileentitychest, final TileEntityChest tileentitychest1) {
|
||||
final InventoryLargeChest inventorylargechest = new InventoryLargeChest(tileentitychest, tileentitychest1);
|
||||
|
||||
- return Optional.of(new ITileInventory() {
|
||||
- @Nullable
|
||||
- @Override
|
||||
- public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {
|
||||
- if (tileentitychest.e(entityhuman) && tileentitychest1.e(entityhuman)) {
|
||||
- tileentitychest.d(playerinventory.player);
|
||||
- tileentitychest1.d(playerinventory.player);
|
||||
- return ContainerChest.b(i, playerinventory, inventorylargechest);
|
||||
- } else {
|
||||
- return null;
|
||||
- }
|
||||
- }
|
||||
-
|
||||
- @Override
|
||||
- public IChatBaseComponent getScoreboardDisplayName() {
|
||||
- return (IChatBaseComponent) (tileentitychest.hasCustomName() ? tileentitychest.getScoreboardDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getScoreboardDisplayName() : new ChatMessage("container.chestDouble")));
|
||||
- }
|
||||
- });
|
||||
+ return Optional.of(new DoubleInventory(tileentitychest, tileentitychest1, inventorylargechest)); // CraftBukkit
|
||||
}
|
||||
|
||||
public Optional<ITileInventory> a(TileEntityChest tileentitychest) {
|
||||
@@ -65,6 +48,38 @@
|
||||
}
|
||||
};
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ public static class DoubleInventory implements ITileInventory {
|
||||
+
|
||||
+ private final TileEntityChest tileentitychest;
|
||||
+ private final TileEntityChest tileentitychest1;
|
||||
+ public final InventoryLargeChest inventorylargechest;
|
||||
+
|
||||
+ public DoubleInventory(TileEntityChest tileentitychest, TileEntityChest tileentitychest1, InventoryLargeChest inventorylargechest) {
|
||||
+ this.tileentitychest = tileentitychest;
|
||||
+ this.tileentitychest1 = tileentitychest1;
|
||||
+ this.inventorylargechest = inventorylargechest;
|
||||
+ }
|
||||
+
|
||||
+ @Nullable
|
||||
+ @Override
|
||||
+ public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {
|
||||
+ if (tileentitychest.e(entityhuman) && tileentitychest1.e(entityhuman)) {
|
||||
+ tileentitychest.d(playerinventory.player);
|
||||
+ tileentitychest1.d(playerinventory.player);
|
||||
+ return ContainerChest.b(i, playerinventory, inventorylargechest);
|
||||
+ } else {
|
||||
+ return null;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public IChatBaseComponent getScoreboardDisplayName() {
|
||||
+ return (IChatBaseComponent) (tileentitychest.hasCustomName() ? tileentitychest.getScoreboardDisplayName() : (tileentitychest1.hasCustomName() ? tileentitychest1.getScoreboardDisplayName() : new ChatMessage("container.chestDouble")));
|
||||
+ }
|
||||
+ };
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected BlockChest(BlockBase.Info blockbase_info, Supplier<TileEntityTypes<? extends TileEntityChest>> supplier) {
|
||||
super(blockbase_info, supplier);
|
||||
this.j((IBlockData) ((IBlockData) ((IBlockData) ((IBlockData) this.blockStateList.getBlockData()).set(BlockChest.FACING, EnumDirection.NORTH)).set(BlockChest.c, BlockPropertyChestType.SINGLE)).set(BlockChest.d, false));
|
||||
@@ -218,7 +233,7 @@
|
||||
}
|
||||
|
||||
public DoubleBlockFinder.Result<? extends TileEntityChest> a(IBlockData iblockdata, World world, BlockPosition blockposition, boolean flag) {
|
||||
- BiPredicate bipredicate;
|
||||
+ BiPredicate<GeneratorAccess, BlockPosition> bipredicate; // CraftBukkit - decompile error
|
||||
|
||||
if (flag) {
|
||||
bipredicate = (generatoraccess, blockposition1) -> {
|
||||
@@ -0,0 +1,61 @@
|
||||
--- a/net/minecraft/server/BlockChorusFlower.java
|
||||
+++ b/net/minecraft/server/BlockChorusFlower.java
|
||||
@@ -4,6 +4,8 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class BlockChorusFlower extends Block {
|
||||
|
||||
public static final BlockStateInteger AGE = BlockProperties.ah;
|
||||
@@ -68,8 +70,12 @@
|
||||
}
|
||||
|
||||
if (flag && b((IWorldReader) worldserver, blockposition1, (EnumDirection) null) && worldserver.isEmpty(blockposition.up(2))) {
|
||||
- worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2);
|
||||
- this.a(worldserver, blockposition1, i);
|
||||
+ // CraftBukkit start - add event
|
||||
+ if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i)), 2)) {
|
||||
+ worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2);
|
||||
+ this.a(worldserver, blockposition1, i);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
} else if (i < 4) {
|
||||
j = random.nextInt(4);
|
||||
if (flag1) {
|
||||
@@ -83,18 +89,30 @@
|
||||
BlockPosition blockposition2 = blockposition.shift(enumdirection);
|
||||
|
||||
if (worldserver.isEmpty(blockposition2) && worldserver.isEmpty(blockposition2.down()) && b((IWorldReader) worldserver, blockposition2, enumdirection.opposite())) {
|
||||
- this.a(worldserver, blockposition2, i + 1);
|
||||
- flag2 = true;
|
||||
+ // CraftBukkit start - add event
|
||||
+ if (CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(i + 1)), 2)) {
|
||||
+ this.a(worldserver, blockposition2, i + 1);
|
||||
+ flag2 = true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
if (flag2) {
|
||||
worldserver.setTypeAndData(blockposition, this.b.a((IBlockAccess) worldserver, blockposition), 2);
|
||||
} else {
|
||||
- this.a((World) worldserver, blockposition);
|
||||
+ // CraftBukkit - add event
|
||||
+ if (CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) {
|
||||
+ this.a((World) worldserver, blockposition);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
} else {
|
||||
- this.a((World) worldserver, blockposition);
|
||||
+ // CraftBukkit - add event
|
||||
+ if (CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.getBlockData().set(BlockChorusFlower.AGE, Integer.valueOf(5)), 2)) {
|
||||
+ this.a((World) worldserver, blockposition);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/BlockCocoa.java
|
||||
+++ b/net/minecraft/server/BlockCocoa.java
|
||||
@@ -3,6 +3,8 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class BlockCocoa extends BlockFacingHorizontal implements IBlockFragilePlantElement {
|
||||
|
||||
public static final BlockStateInteger AGE = BlockProperties.af;
|
||||
@@ -27,7 +29,7 @@
|
||||
int i = (Integer) iblockdata.get(BlockCocoa.AGE);
|
||||
|
||||
if (i < 2) {
|
||||
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, i + 1), 2);
|
||||
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, i + 1), 2); // CraftBukkkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +99,7 @@
|
||||
|
||||
@Override
|
||||
public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, (Integer) iblockdata.get(BlockCocoa.AGE) + 1), 2);
|
||||
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockCocoa.AGE, (Integer) iblockdata.get(BlockCocoa.AGE) + 1), 2); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,27 @@
|
||||
--- a/net/minecraft/server/BlockCommand.java
|
||||
+++ b/net/minecraft/server/BlockCommand.java
|
||||
@@ -4,6 +4,8 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockCommand extends BlockTileEntity {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -32,6 +34,15 @@
|
||||
TileEntityCommand tileentitycommand = (TileEntityCommand) tileentity;
|
||||
boolean flag1 = world.isBlockIndirectlyPowered(blockposition);
|
||||
boolean flag2 = tileentitycommand.f();
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ int old = flag2 ? 15 : 0;
|
||||
+ int current = flag1 ? 15 : 0;
|
||||
+
|
||||
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
|
||||
+ world.getServer().getPluginManager().callEvent(eventRedstone);
|
||||
+ flag1 = eventRedstone.getNewCurrent() > 0;
|
||||
+ // CraftBukkit end
|
||||
|
||||
tileentitycommand.a(flag1);
|
||||
if (!flag2 && !tileentitycommand.g() && tileentitycommand.m() != TileEntityCommand.Type.SEQUENCE) {
|
||||
@@ -0,0 +1,138 @@
|
||||
--- a/net/minecraft/server/BlockComposter.java
|
||||
+++ b/net/minecraft/server/BlockComposter.java
|
||||
@@ -5,12 +5,17 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftBlockInventoryHolder;
|
||||
+import org.bukkit.craftbukkit.util.DummyGeneratorAccess;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockComposter extends Block implements IInventoryHolder {
|
||||
|
||||
public static final BlockStateInteger a = BlockProperties.as;
|
||||
public static final Object2FloatMap<IMaterial> b = new Object2FloatOpenHashMap();
|
||||
private static final VoxelShape c = VoxelShapes.b();
|
||||
- private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((Object) (new VoxelShape[9]), (avoxelshape) -> {
|
||||
+ private static final VoxelShape[] d = (VoxelShape[]) SystemUtils.a((new VoxelShape[9]), (avoxelshape) -> { // CraftBukkit - decompile error
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
avoxelshape[i] = VoxelShapes.a(BlockComposter.c, Block.a(2.0D, (double) Math.max(2, 1 + i * 2), 2.0D, 14.0D, 16.0D, 14.0D), OperatorBoolean.ONLY_FIRST);
|
||||
}
|
||||
@@ -156,18 +161,25 @@
|
||||
|
||||
return EnumInteractionResult.a(world.isClientSide);
|
||||
} else if (i == 8) {
|
||||
- d(iblockdata, world, blockposition);
|
||||
+ d(iblockdata, world, blockposition, (Entity) null); // CraftBukkit - no event for players
|
||||
return EnumInteractionResult.a(world.isClientSide);
|
||||
} else {
|
||||
return EnumInteractionResult.PASS;
|
||||
}
|
||||
}
|
||||
|
||||
- public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition) {
|
||||
+ public static IBlockData a(IBlockData iblockdata, WorldServer worldserver, ItemStack itemstack, BlockPosition blockposition, Entity entity) { // CraftBukkit
|
||||
int i = (Integer) iblockdata.get(BlockComposter.a);
|
||||
|
||||
if (i < 7 && BlockComposter.b.containsKey(itemstack.getItem())) {
|
||||
- IBlockData iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack);
|
||||
+ // CraftBukkit start
|
||||
+ double rand = worldserver.getRandom().nextDouble();
|
||||
+ IBlockData iblockdata1 = b(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition, itemstack, rand);
|
||||
+ if (iblockdata == iblockdata1 || org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
|
||||
+ return iblockdata;
|
||||
+ }
|
||||
+ iblockdata1 = b(iblockdata, (GeneratorAccess) worldserver, blockposition, itemstack, rand);
|
||||
+ // CraftBukkit end
|
||||
|
||||
itemstack.subtract(1);
|
||||
return iblockdata1;
|
||||
@@ -176,7 +188,15 @@
|
||||
}
|
||||
}
|
||||
|
||||
- public static IBlockData d(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
||||
+ // CraftBukkit start
|
||||
+ public static IBlockData d(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
||||
+ if (entity != null) {
|
||||
+ IBlockData iblockdata1 = d(iblockdata, DummyGeneratorAccess.INSTANCE, blockposition);
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata1).isCancelled()) {
|
||||
+ return iblockdata;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (!world.isClientSide) {
|
||||
float f = 0.7F;
|
||||
double d0 = (double) (world.random.nextFloat() * 0.7F) + 0.15000000596046448D;
|
||||
@@ -202,10 +222,16 @@
|
||||
}
|
||||
|
||||
private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack) {
|
||||
+ // CraftBukkit start
|
||||
+ return b(iblockdata, generatoraccess, blockposition, itemstack, generatoraccess.getRandom().nextDouble());
|
||||
+ }
|
||||
+
|
||||
+ private static IBlockData b(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition, ItemStack itemstack, double rand) {
|
||||
+ // CraftBukkit end
|
||||
int i = (Integer) iblockdata.get(BlockComposter.a);
|
||||
float f = BlockComposter.b.getFloat(itemstack.getItem());
|
||||
|
||||
- if ((i != 0 || f <= 0.0F) && generatoraccess.getRandom().nextDouble() >= (double) f) {
|
||||
+ if ((i != 0 || f <= 0.0F) && rand >= (double) f) {
|
||||
return iblockdata;
|
||||
} else {
|
||||
int j = i + 1;
|
||||
@@ -253,7 +279,8 @@
|
||||
public IWorldInventory a(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
||||
int i = (Integer) iblockdata.get(BlockComposter.a);
|
||||
|
||||
- return (IWorldInventory) (i == 8 ? new BlockComposter.ContainerOutput(iblockdata, generatoraccess, blockposition, new ItemStack(Items.BONE_MEAL)) : (i < 7 ? new BlockComposter.ContainerInput(iblockdata, generatoraccess, blockposition) : new BlockComposter.ContainerEmpty()));
|
||||
+ // CraftBukkit - empty generatoraccess, blockposition
|
||||
+ return (IWorldInventory) (i == 8 ? new BlockComposter.ContainerOutput(iblockdata, generatoraccess, blockposition, new ItemStack(Items.BONE_MEAL)) : (i < 7 ? new BlockComposter.ContainerInput(iblockdata, generatoraccess, blockposition) : new BlockComposter.ContainerEmpty(generatoraccess, blockposition)));
|
||||
}
|
||||
|
||||
static class ContainerInput extends InventorySubcontainer implements IWorldInventory {
|
||||
@@ -265,6 +292,7 @@
|
||||
|
||||
public ContainerInput(IBlockData iblockdata, GeneratorAccess generatoraccess, BlockPosition blockposition) {
|
||||
super(1);
|
||||
+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit
|
||||
this.a = iblockdata;
|
||||
this.b = generatoraccess;
|
||||
this.c = blockposition;
|
||||
@@ -317,6 +345,7 @@
|
||||
this.blockData = iblockdata;
|
||||
this.generatorAccess = generatoraccess;
|
||||
this.blockPosition = blockposition;
|
||||
+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -341,15 +370,23 @@
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
- BlockComposter.d(this.blockData, this.generatorAccess, this.blockPosition);
|
||||
- this.emptied = true;
|
||||
+ // CraftBukkit start - allow putting items back (eg cancelled InventoryMoveItemEvent)
|
||||
+ if (this.isEmpty()) {
|
||||
+ BlockComposter.d(this.blockData, this.generatorAccess, this.blockPosition);
|
||||
+ this.emptied = true;
|
||||
+ } else {
|
||||
+ this.generatorAccess.setTypeAndData(this.blockPosition, this.blockData, 3);
|
||||
+ this.emptied = false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
|
||||
static class ContainerEmpty extends InventorySubcontainer implements IWorldInventory {
|
||||
|
||||
- public ContainerEmpty() {
|
||||
+ public ContainerEmpty(GeneratorAccess generatoraccess, BlockPosition blockposition) { // CraftBukkit
|
||||
super(0);
|
||||
+ this.bukkitOwner = new CraftBlockInventoryHolder(generatoraccess, blockposition, this); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,74 @@
|
||||
--- a/net/minecraft/server/BlockConcretePowder.java
|
||||
+++ b/net/minecraft/server/BlockConcretePowder.java
|
||||
@@ -1,5 +1,10 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
+import org.bukkit.event.block.BlockFormEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockConcretePowder extends BlockFalling {
|
||||
|
||||
private final IBlockData a;
|
||||
@@ -12,7 +17,7 @@
|
||||
@Override
|
||||
public void a(World world, BlockPosition blockposition, IBlockData iblockdata, IBlockData iblockdata1, EntityFallingBlock entityfallingblock) {
|
||||
if (canHarden(world, blockposition, iblockdata1)) {
|
||||
- world.setTypeAndData(blockposition, this.a, 3);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, this.a, 3); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +28,24 @@
|
||||
BlockPosition blockposition = blockactioncontext.getClickPosition();
|
||||
IBlockData iblockdata = world.getType(blockposition);
|
||||
|
||||
- return canHarden(world, blockposition, iblockdata) ? this.a : super.getPlacedState(blockactioncontext);
|
||||
+ // CraftBukkit start
|
||||
+ if (!canHarden(world, blockposition, iblockdata)) {
|
||||
+ return super.getPlacedState(blockactioncontext);
|
||||
+ }
|
||||
+
|
||||
+ // TODO: An event factory call for methods like this
|
||||
+ CraftBlockState blockState = CraftBlockState.getBlockState(world, blockposition);
|
||||
+ blockState.setData(this.a);
|
||||
+
|
||||
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
|
||||
+ world.getMinecraftServer().server.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ return blockState.getHandle();
|
||||
+ }
|
||||
+
|
||||
+ return super.getPlacedState(blockactioncontext);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
private static boolean canHarden(IBlockAccess iblockaccess, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
@@ -59,6 +81,24 @@
|
||||
|
||||
@Override
|
||||
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
|
||||
- return a((IBlockAccess) generatoraccess, blockposition) ? this.a : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
|
||||
+ // CraftBukkit start
|
||||
+ if (a((IBlockAccess) generatoraccess, blockposition)) {
|
||||
+ // Suppress during worldgen
|
||||
+ if (!(generatoraccess instanceof World)) {
|
||||
+ return this.a;
|
||||
+ }
|
||||
+ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
|
||||
+ blockState.setData(this.a);
|
||||
+
|
||||
+ BlockFormEvent event = new BlockFormEvent(blockState.getBlock(), blockState);
|
||||
+ ((World) generatoraccess).getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ return blockState.getHandle();
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/BlockCoral.java
|
||||
+++ b/net/minecraft/server/BlockCoral.java
|
||||
@@ -15,6 +15,11 @@
|
||||
@Override
|
||||
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
if (!this.a((IBlockAccess) worldserver, blockposition)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.a.getBlockData()).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, this.a.getBlockData(), 2);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/BlockCoralFan.java
|
||||
+++ b/net/minecraft/server/BlockCoralFan.java
|
||||
@@ -19,6 +19,11 @@
|
||||
@Override
|
||||
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.a.getBlockData().set(BlockCoralFan.b, false)).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) this.a.getBlockData().set(BlockCoralFan.b, false), 2);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/BlockCoralFanWall.java
|
||||
+++ b/net/minecraft/server/BlockCoralFanWall.java
|
||||
@@ -19,6 +19,11 @@
|
||||
@Override
|
||||
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.c.getBlockData().set(BlockCoralFanWall.b, false).set(BlockCoralFanWall.a, iblockdata.get(BlockCoralFanWall.a))).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) ((IBlockData) this.c.getBlockData().set(BlockCoralFanWall.b, false)).set(BlockCoralFanWall.a, iblockdata.get(BlockCoralFanWall.a)), 2);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/BlockCoralPlant.java
|
||||
+++ b/net/minecraft/server/BlockCoralPlant.java
|
||||
@@ -20,6 +20,11 @@
|
||||
@Override
|
||||
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
if (!c(iblockdata, (IBlockAccess) worldserver, blockposition)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, this.c.getBlockData().set(BlockCoralPlant.b, false)).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) this.c.getBlockData().set(BlockCoralPlant.b, false), 2);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
--- a/net/minecraft/server/BlockCrops.java
|
||||
+++ b/net/minecraft/server/BlockCrops.java
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class BlockCrops extends BlockPlant implements IBlockFragilePlantElement {
|
||||
|
||||
public static final BlockStateInteger AGE = BlockProperties.ai;
|
||||
@@ -56,7 +58,7 @@
|
||||
float f = a((Block) this, (IBlockAccess) worldserver, blockposition);
|
||||
|
||||
if (random.nextInt((int) (25.0F / f) + 1) == 0) {
|
||||
- worldserver.setTypeAndData(blockposition, this.setAge(i + 1), 2);
|
||||
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, this.setAge(i + 1), 2); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,7 +73,7 @@
|
||||
i = j;
|
||||
}
|
||||
|
||||
- world.setTypeAndData(blockposition, this.setAge(i), 2);
|
||||
+ CraftEventFactory.handleBlockGrowEvent(world, blockposition, this.setAge(i), 2); // CraftBukkit
|
||||
}
|
||||
|
||||
protected int a(World world) {
|
||||
@@ -129,7 +131,7 @@
|
||||
|
||||
@Override
|
||||
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
||||
- if (entity instanceof EntityRavager && world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) {
|
||||
+ if (entity instanceof EntityRavager && !CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData(), !world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)).isCancelled()) { // CraftBukkit
|
||||
world.a(blockposition, true, entity);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/server/BlockDaylightDetector.java
|
||||
+++ b/net/minecraft/server/BlockDaylightDetector.java
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
i = MathHelper.clamp(i, 0, 15);
|
||||
if ((Integer) iblockdata.get(BlockDaylightDetector.POWER) != i) {
|
||||
+ i = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, blockposition, ((Integer) iblockdata.get(POWER)), i).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDaylightDetector.POWER, i), 3);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/server/BlockDiodeAbstract.java
|
||||
+++ b/net/minecraft/server/BlockDiodeAbstract.java
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public abstract class BlockDiodeAbstract extends BlockFacingHorizontal {
|
||||
|
||||
protected static final VoxelShape b = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 2.0D, 16.0D);
|
||||
@@ -28,8 +30,18 @@
|
||||
boolean flag1 = this.a((World) worldserver, blockposition, iblockdata);
|
||||
|
||||
if (flag && !flag1) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 15, 0).getNewCurrent() != 0) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, false), 2);
|
||||
} else if (!flag) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 0, 15).getNewCurrent() != 15) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockDiodeAbstract.c, true), 2);
|
||||
if (!flag1) {
|
||||
worldserver.getBlockTickList().a(blockposition, this, this.g(iblockdata), TickListPriority.VERY_HIGH);
|
||||
@@ -0,0 +1,23 @@
|
||||
--- a/net/minecraft/server/BlockDirtSnowSpreadable.java
|
||||
+++ b/net/minecraft/server/BlockDirtSnowSpreadable.java
|
||||
@@ -32,6 +32,11 @@
|
||||
@Override
|
||||
public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
if (!b(iblockdata, (IWorldReader) worldserver, blockposition)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeUpdate(blockposition, Blocks.DIRT.getBlockData());
|
||||
} else {
|
||||
if (worldserver.getLightLevel(blockposition.up()) >= 9) {
|
||||
@@ -41,7 +46,7 @@
|
||||
BlockPosition blockposition1 = blockposition.b(random.nextInt(3) - 1, random.nextInt(5) - 3, random.nextInt(3) - 1);
|
||||
|
||||
if (worldserver.getType(blockposition1).a(Blocks.DIRT) && c(iblockdata1, (IWorldReader) worldserver, blockposition1)) {
|
||||
- worldserver.setTypeUpdate(blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, worldserver.getType(blockposition1.up()).a(Blocks.SNOW)));
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata1.set(BlockDirtSnowSpreadable.a, worldserver.getType(blockposition1.up()).a(Blocks.SNOW))); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/net/minecraft/server/BlockDispenser.java
|
||||
+++ b/net/minecraft/server/BlockDispenser.java
|
||||
@@ -8,9 +8,10 @@
|
||||
|
||||
public static final BlockStateDirection FACING = BlockDirectional.FACING;
|
||||
public static final BlockStateBoolean TRIGGERED = BlockProperties.A;
|
||||
- public static final Map<Item, IDispenseBehavior> REGISTRY = (Map) SystemUtils.a((Object) (new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> {
|
||||
+ public static final Map<Item, IDispenseBehavior> REGISTRY = (Map) SystemUtils.a((new Object2ObjectOpenHashMap()), (object2objectopenhashmap) -> { // CraftBukkit - decompile error
|
||||
object2objectopenhashmap.defaultReturnValue(new DispenseBehaviorItem());
|
||||
});
|
||||
+ public static boolean eventFired = false; // CraftBukkit
|
||||
|
||||
public static void a(IMaterial imaterial, IDispenseBehavior idispensebehavior) {
|
||||
BlockDispenser.REGISTRY.put(imaterial.getItem(), idispensebehavior);
|
||||
@@ -53,6 +54,7 @@
|
||||
IDispenseBehavior idispensebehavior = this.a(itemstack);
|
||||
|
||||
if (idispensebehavior != IDispenseBehavior.NONE) {
|
||||
+ eventFired = false; // CraftBukkit - reset event status
|
||||
tileentitydispenser.setItem(i, idispensebehavior.dispense(sourceblock, itemstack));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
--- a/net/minecraft/server/BlockDoor.java
|
||||
+++ b/net/minecraft/server/BlockDoor.java
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockDoor extends Block {
|
||||
|
||||
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
|
||||
@@ -157,9 +159,24 @@
|
||||
|
||||
@Override
|
||||
public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) {
|
||||
- boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || world.isBlockIndirectlyPowered(blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN));
|
||||
+ // CraftBukkit start
|
||||
+ BlockPosition otherHalf = blockposition.shift(iblockdata.get(BlockDoor.HALF) == BlockPropertyDoubleBlockHalf.LOWER ? EnumDirection.UP : EnumDirection.DOWN);
|
||||
+
|
||||
+ org.bukkit.World bworld = world.getWorld();
|
||||
+ org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ org.bukkit.block.Block blockTop = bworld.getBlockAt(otherHalf.getX(), otherHalf.getY(), otherHalf.getZ());
|
||||
+
|
||||
+ int power = bukkitBlock.getBlockPower();
|
||||
+ int powerTop = blockTop.getBlockPower();
|
||||
+ if (powerTop > power) power = powerTop;
|
||||
+ int oldPower = (Boolean) iblockdata.get(BlockDoor.POWERED) ? 15 : 0;
|
||||
+
|
||||
+ if (oldPower == 0 ^ power == 0) {
|
||||
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
|
||||
+ world.getServer().getPluginManager().callEvent(eventRedstone);
|
||||
|
||||
- if (block != this && flag1 != (Boolean) iblockdata.get(BlockDoor.POWERED)) {
|
||||
+ boolean flag1 = eventRedstone.getNewCurrent() > 0;
|
||||
+ // CraftBukkit end
|
||||
if (flag1 != (Boolean) iblockdata.get(BlockDoor.OPEN)) {
|
||||
this.a(world, blockposition, flag1);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/BlockDragonEgg.java
|
||||
+++ b/net/minecraft/server/BlockDragonEgg.java
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockDragonEgg extends BlockFalling {
|
||||
|
||||
protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 16.0D, 15.0D);
|
||||
@@ -29,6 +31,18 @@
|
||||
BlockPosition blockposition1 = blockposition.b(world.random.nextInt(16) - world.random.nextInt(16), world.random.nextInt(8) - world.random.nextInt(8), world.random.nextInt(16) - world.random.nextInt(16));
|
||||
|
||||
if (world.getType(blockposition1).isAir()) {
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.Block from = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ org.bukkit.block.Block to = world.getWorld().getBlockAt(blockposition1.getX(), blockposition1.getY(), blockposition1.getZ());
|
||||
+ BlockFromToEvent event = new BlockFromToEvent(from, to);
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ blockposition1 = new BlockPosition(event.getToBlock().getX(), event.getToBlock().getY(), event.getToBlock().getZ());
|
||||
+ // CraftBukkit end
|
||||
if (world.isClientSide) {
|
||||
for (int j = 0; j < 128; ++j) {
|
||||
double d0 = world.random.nextDouble();
|
||||
@@ -0,0 +1,41 @@
|
||||
--- a/net/minecraft/server/BlockDropper.java
|
||||
+++ b/net/minecraft/server/BlockDropper.java
|
||||
@@ -1,5 +1,10 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockDropper extends BlockDispenser {
|
||||
|
||||
private static final IDispenseBehavior c = new DispenseBehaviorItem();
|
||||
@@ -37,8 +42,25 @@
|
||||
if (iinventory == null) {
|
||||
itemstack1 = BlockDropper.c.dispense(sourceblock, itemstack);
|
||||
} else {
|
||||
- itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, itemstack.cloneItemStack().cloneAndSubtract(1), enumdirection.opposite());
|
||||
- if (itemstack1.isEmpty()) {
|
||||
+ // CraftBukkit start - Fire event when pushing items into other inventories
|
||||
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.cloneItemStack().cloneAndSubtract(1));
|
||||
+
|
||||
+ org.bukkit.inventory.Inventory destinationInventory;
|
||||
+ // Have to special case large chests as they work oddly
|
||||
+ if (iinventory instanceof InventoryLargeChest) {
|
||||
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
|
||||
+ } else {
|
||||
+ destinationInventory = iinventory.getOwner().getInventory();
|
||||
+ }
|
||||
+
|
||||
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
|
||||
+ worldserver.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ itemstack1 = TileEntityHopper.addItem(tileentitydispenser, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection.opposite());
|
||||
+ if (event.getItem().equals(oitemstack) && itemstack1.isEmpty()) {
|
||||
+ // CraftBukkit end
|
||||
itemstack1 = itemstack.cloneItemStack();
|
||||
itemstack1.subtract(1);
|
||||
} else {
|
||||
@@ -0,0 +1,38 @@
|
||||
--- a/net/minecraft/server/BlockEnderPortal.java
|
||||
+++ b/net/minecraft/server/BlockEnderPortal.java
|
||||
@@ -1,5 +1,10 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPortalEnterEvent;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockEnderPortal extends BlockTileEntity {
|
||||
|
||||
protected static final VoxelShape a = Block.a(0.0D, 0.0D, 0.0D, 16.0D, 12.0D, 16.0D);
|
||||
@@ -21,13 +26,22 @@
|
||||
@Override
|
||||
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
||||
if (world instanceof WorldServer && !entity.isPassenger() && !entity.isVehicle() && entity.canPortal() && VoxelShapes.c(VoxelShapes.a(entity.getBoundingBox().d((double) (-blockposition.getX()), (double) (-blockposition.getY()), (double) (-blockposition.getZ()))), iblockdata.getShape(world, blockposition), OperatorBoolean.AND)) {
|
||||
- ResourceKey<World> resourcekey = world.getDimensionKey() == World.THE_END ? World.OVERWORLD : World.THE_END;
|
||||
+ ResourceKey<World> resourcekey = world.getTypeKey() == DimensionManager.THE_END ? World.OVERWORLD : World.THE_END; // CraftBukkit - SPIGOT-6152: send back to main overworld in custom ends
|
||||
WorldServer worldserver = ((WorldServer) world).getMinecraftServer().getWorldServer(resourcekey);
|
||||
|
||||
if (worldserver == null) {
|
||||
- return;
|
||||
+ // return; // CraftBukkit - always fire event in case plugins wish to change it
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Entity in portal
|
||||
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (entity instanceof EntityPlayer) {
|
||||
+ ((EntityPlayer) entity).b(worldserver, PlayerTeleportEvent.TeleportCause.END_PORTAL);
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entity.b(worldserver);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/server/BlockFenceGate.java
|
||||
+++ b/net/minecraft/server/BlockFenceGate.java
|
||||
@@ -103,6 +103,17 @@
|
||||
public void doPhysics(IBlockData iblockdata, World world, BlockPosition blockposition, Block block, BlockPosition blockposition1, boolean flag) {
|
||||
if (!world.isClientSide) {
|
||||
boolean flag1 = world.isBlockIndirectlyPowered(blockposition);
|
||||
+ // CraftBukkit start
|
||||
+ boolean oldPowered = iblockdata.get(BlockFenceGate.POWERED);
|
||||
+ if (oldPowered != flag1) {
|
||||
+ int newPower = flag1 ? 15 : 0;
|
||||
+ int oldPower = oldPowered ? 15 : 0;
|
||||
+ org.bukkit.block.Block bukkitBlock = org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition);
|
||||
+ org.bukkit.event.block.BlockRedstoneEvent eventRedstone = new org.bukkit.event.block.BlockRedstoneEvent(bukkitBlock, oldPower, newPower);
|
||||
+ world.getServer().getPluginManager().callEvent(eventRedstone);
|
||||
+ flag1 = eventRedstone.getNewCurrent() > 0;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if ((Boolean) iblockdata.get(BlockFenceGate.POWERED) != flag1) {
|
||||
world.setTypeAndData(blockposition, (IBlockData) ((IBlockData) iblockdata.set(BlockFenceGate.POWERED, flag1)).set(BlockFenceGate.OPEN, flag1), 2);
|
||||
@@ -0,0 +1,141 @@
|
||||
--- a/net/minecraft/server/BlockFire.java
|
||||
+++ b/net/minecraft/server/BlockFire.java
|
||||
@@ -8,6 +8,13 @@
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.block.BlockBurnEvent;
|
||||
+import org.bukkit.event.block.BlockFadeEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockFire extends BlockFireAbstract {
|
||||
|
||||
public static final BlockStateInteger AGE = BlockProperties.aj;
|
||||
@@ -64,7 +71,24 @@
|
||||
|
||||
@Override
|
||||
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
|
||||
- return this.canPlace(iblockdata, generatoraccess, blockposition) ? this.a(generatoraccess, blockposition, (Integer) iblockdata.get(BlockFire.AGE)) : Blocks.AIR.getBlockData();
|
||||
+ // CraftBukkit start
|
||||
+ if (!this.canPlace(iblockdata, generatoraccess, blockposition)) {
|
||||
+ // Suppress during worldgen
|
||||
+ if (!(generatoraccess instanceof World)) {
|
||||
+ return Blocks.AIR.getBlockData();
|
||||
+ }
|
||||
+ CraftBlockState blockState = CraftBlockState.getBlockState(generatoraccess, blockposition);
|
||||
+ blockState.setData(Blocks.AIR.getBlockData());
|
||||
+
|
||||
+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
|
||||
+ ((World) generatoraccess).getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ return blockState.getHandle();
|
||||
+ }
|
||||
+ }
|
||||
+ return this.a(generatoraccess, blockposition, (Integer) iblockdata.get(BlockFire.AGE));
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -113,7 +137,7 @@
|
||||
worldserver.getBlockTickList().a(blockposition, this, a(worldserver.random));
|
||||
if (worldserver.getGameRules().getBoolean(GameRules.DO_FIRE_TICK)) {
|
||||
if (!iblockdata.canPlace(worldserver, blockposition)) {
|
||||
- worldserver.a(blockposition, false);
|
||||
+ fireExtinguished(worldserver, blockposition); // CraftBukkit - invalid place location
|
||||
}
|
||||
|
||||
IBlockData iblockdata1 = worldserver.getType(blockposition.down());
|
||||
@@ -121,7 +145,7 @@
|
||||
int i = (Integer) iblockdata.get(BlockFire.AGE);
|
||||
|
||||
if (!flag && worldserver.isRaining() && this.a((World) worldserver, blockposition) && random.nextFloat() < 0.2F + (float) i * 0.03F) {
|
||||
- worldserver.a(blockposition, false);
|
||||
+ fireExtinguished(worldserver, blockposition); // CraftBukkit - extinguished by rain
|
||||
} else {
|
||||
int j = Math.min(15, i + random.nextInt(3) / 2);
|
||||
|
||||
@@ -135,14 +159,14 @@
|
||||
BlockPosition blockposition1 = blockposition.down();
|
||||
|
||||
if (!worldserver.getType(blockposition1).d(worldserver, blockposition1, EnumDirection.UP) || i > 3) {
|
||||
- worldserver.a(blockposition, false);
|
||||
+ fireExtinguished(worldserver, blockposition); // CraftBukkit
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (i == 15 && random.nextInt(4) == 0 && !this.e(worldserver.getType(blockposition.down()))) {
|
||||
- worldserver.a(blockposition, false);
|
||||
+ fireExtinguished(worldserver, blockposition); // CraftBukkit
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -150,12 +174,14 @@
|
||||
boolean flag1 = worldserver.u(blockposition);
|
||||
int k = flag1 ? -50 : 0;
|
||||
|
||||
- this.trySpread(worldserver, blockposition.east(), 300 + k, random, i);
|
||||
- this.trySpread(worldserver, blockposition.west(), 300 + k, random, i);
|
||||
- this.trySpread(worldserver, blockposition.down(), 250 + k, random, i);
|
||||
- this.trySpread(worldserver, blockposition.up(), 250 + k, random, i);
|
||||
- this.trySpread(worldserver, blockposition.north(), 300 + k, random, i);
|
||||
- this.trySpread(worldserver, blockposition.south(), 300 + k, random, i);
|
||||
+ // CraftBukkit start - add source blockposition to burn calls
|
||||
+ this.trySpread(worldserver, blockposition.east(), 300 + k, random, i, blockposition);
|
||||
+ this.trySpread(worldserver, blockposition.west(), 300 + k, random, i, blockposition);
|
||||
+ this.trySpread(worldserver, blockposition.down(), 250 + k, random, i, blockposition);
|
||||
+ this.trySpread(worldserver, blockposition.up(), 250 + k, random, i, blockposition);
|
||||
+ this.trySpread(worldserver, blockposition.north(), 300 + k, random, i, blockposition);
|
||||
+ this.trySpread(worldserver, blockposition.south(), 300 + k, random, i, blockposition);
|
||||
+ // CraftBukkit end
|
||||
BlockPosition.MutableBlockPosition blockposition_mutableblockposition = new BlockPosition.MutableBlockPosition();
|
||||
|
||||
for (int l = -1; l <= 1; ++l) {
|
||||
@@ -181,7 +207,15 @@
|
||||
if (i2 > 0 && random.nextInt(k1) <= i2 && (!worldserver.isRaining() || !this.a((World) worldserver, (BlockPosition) blockposition_mutableblockposition))) {
|
||||
int j2 = Math.min(15, i + random.nextInt(5) / 4);
|
||||
|
||||
- worldserver.setTypeAndData(blockposition_mutableblockposition, this.a(worldserver, blockposition_mutableblockposition, j2), 3);
|
||||
+ // CraftBukkit start - Call to stop spread of fire
|
||||
+ if (worldserver.getType(blockposition_mutableblockposition).getBlock() != Blocks.FIRE) {
|
||||
+ if (CraftEventFactory.callBlockIgniteEvent(worldserver, blockposition_mutableblockposition, blockposition).isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition_mutableblockposition, this.a(worldserver, blockposition_mutableblockposition, j2), 3); // CraftBukkit
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -205,12 +239,24 @@
|
||||
return iblockdata.b(BlockProperties.C) && (Boolean) iblockdata.get(BlockProperties.C) ? 0 : this.flameChances.getInt(iblockdata.getBlock());
|
||||
}
|
||||
|
||||
- private void trySpread(World world, BlockPosition blockposition, int i, Random random, int j) {
|
||||
+ private void trySpread(World world, BlockPosition blockposition, int i, Random random, int j, BlockPosition sourceposition) { // CraftBukkit add sourceposition
|
||||
int k = this.getBurnChance(world.getType(blockposition));
|
||||
|
||||
if (random.nextInt(i) < k) {
|
||||
IBlockData iblockdata = world.getType(blockposition);
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.Block theBlock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ org.bukkit.block.Block sourceBlock = world.getWorld().getBlockAt(sourceposition.getX(), sourceposition.getY(), sourceposition.getZ());
|
||||
+
|
||||
+ BlockBurnEvent event = new BlockBurnEvent(theBlock, sourceBlock);
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (random.nextInt(j + 10) < 5 && !world.isRainingAt(blockposition)) {
|
||||
int l = Math.min(j + random.nextInt(5) / 4, 15);
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
--- a/net/minecraft/server/BlockFireAbstract.java
|
||||
+++ b/net/minecraft/server/BlockFireAbstract.java
|
||||
@@ -36,7 +36,14 @@
|
||||
if (!entity.isFireProof()) {
|
||||
entity.setFireTicks(entity.getFireTicks() + 1);
|
||||
if (entity.getFireTicks() == 0) {
|
||||
- entity.setOnFire(8);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.entity.EntityCombustEvent event = new org.bukkit.event.entity.EntityCombustByBlockEvent(org.bukkit.craftbukkit.block.CraftBlock.at(world, blockposition), entity.getBukkitEntity(), 8);
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (!event.isCancelled()) {
|
||||
+ entity.setOnFire(event.getDuration(), false);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
entity.damageEntity(DamageSource.FIRE, this.b);
|
||||
@@ -58,14 +65,14 @@
|
||||
}
|
||||
|
||||
if (!iblockdata.canPlace(world, blockposition)) {
|
||||
- world.a(blockposition, false);
|
||||
+ fireExtinguished(world, blockposition); // CraftBukkit - fuel block broke
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean a(World world) {
|
||||
- return world.getDimensionKey() == World.OVERWORLD || world.getDimensionKey() == World.THE_NETHER;
|
||||
+ return world.getTypeKey() == DimensionManager.OVERWORLD || world.getTypeKey() == DimensionManager.THE_NETHER; // CraftBukkit - getTypeKey()
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -109,4 +116,12 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ protected void fireExtinguished(GeneratorAccess world, BlockPosition position) {
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, position, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
+ world.a(position, false);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
--- a/net/minecraft/server/BlockFluids.java
|
||||
+++ b/net/minecraft/server/BlockFluids.java
|
||||
@@ -113,14 +113,20 @@
|
||||
if (world.getFluid(blockposition1).a((Tag) TagsFluid.WATER)) {
|
||||
Block block = world.getFluid(blockposition).isSource() ? Blocks.OBSIDIAN : Blocks.COBBLESTONE;
|
||||
|
||||
- world.setTypeUpdate(blockposition, block.getBlockData());
|
||||
- this.fizz(world, blockposition);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, block.getBlockData())) {
|
||||
+ this.fizz(world, blockposition);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flag && world.getType(blockposition1).a(Blocks.BLUE_ICE)) {
|
||||
- world.setTypeUpdate(blockposition, Blocks.BASALT.getBlockData());
|
||||
- this.fizz(world, blockposition);
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockFormEvent(world, blockposition, Blocks.BASALT.getBlockData())) {
|
||||
+ this.fizz(world, blockposition);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/server/BlockFungi.java
|
||||
+++ b/net/minecraft/server/BlockFungi.java
|
||||
@@ -38,6 +38,13 @@
|
||||
|
||||
@Override
|
||||
public void a(WorldServer worldserver, Random random, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
+ // CraftBukkit start
|
||||
+ if (this == Blocks.WARPED_FUNGUS) {
|
||||
+ BlockSapling.treeType = org.bukkit.TreeType.WARPED_FUNGUS;
|
||||
+ } else if (this == Blocks.CRIMSON_FUNGUS) {
|
||||
+ BlockSapling.treeType = org.bukkit.TreeType.CRIMSON_FUNGUS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
((WorldGenFeatureConfigured) this.b.get()).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), random, blockposition);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/BlockGrass.java
|
||||
+++ b/net/minecraft/server/BlockGrass.java
|
||||
@@ -64,7 +64,7 @@
|
||||
}
|
||||
|
||||
if (iblockdata3.canPlace(worldserver, blockposition2)) {
|
||||
- worldserver.setTypeAndData(blockposition2, iblockdata3, 3);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition2, iblockdata3, 3); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/BlockGrassPath.java
|
||||
+++ b/net/minecraft/server/BlockGrassPath.java
|
||||
@@ -31,6 +31,11 @@
|
||||
|
||||
@Override
|
||||
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
+ // CraftBukkit start - do not fade if the block is valid here
|
||||
+ if (iblockdata.canPlace(worldserver, blockposition)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
BlockSoil.fade(iblockdata, worldserver, blockposition);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/BlockGrowingTop.java
|
||||
+++ b/net/minecraft/server/BlockGrowingTop.java
|
||||
@@ -29,7 +29,7 @@
|
||||
BlockPosition blockposition1 = blockposition.shift(this.a);
|
||||
|
||||
if (this.h(worldserver.getType(blockposition1))) {
|
||||
- worldserver.setTypeUpdate(blockposition1, (IBlockData) iblockdata.a((IBlockState) BlockGrowingTop.d));
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, (IBlockData) iblockdata.a((IBlockState) BlockGrowingTop.d)); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/BlockIce.java
|
||||
+++ b/net/minecraft/server/BlockIce.java
|
||||
@@ -36,6 +36,11 @@
|
||||
}
|
||||
|
||||
protected void melt(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(world, blockposition, world.getDimensionManager().isNether() ? Blocks.AIR.getBlockData() : Blocks.WATER.getBlockData()).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if (world.getDimensionManager().isNether()) {
|
||||
world.a(blockposition, false);
|
||||
} else {
|
||||
@@ -0,0 +1,17 @@
|
||||
--- a/net/minecraft/server/BlockJukeBox.java
|
||||
+++ b/net/minecraft/server/BlockJukeBox.java
|
||||
@@ -42,7 +42,13 @@
|
||||
TileEntity tileentity = generatoraccess.getTileEntity(blockposition);
|
||||
|
||||
if (tileentity instanceof TileEntityJukeBox) {
|
||||
- ((TileEntityJukeBox) tileentity).setRecord(itemstack.cloneItemStack());
|
||||
+ // CraftBukkit start - There can only be one
|
||||
+ itemstack = itemstack.cloneItemStack();
|
||||
+ if (!itemstack.isEmpty()) {
|
||||
+ itemstack.setCount(1);
|
||||
+ }
|
||||
+ ((TileEntityJukeBox) tileentity).setRecord(itemstack);
|
||||
+ // CraftBukkit end
|
||||
generatoraccess.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockJukeBox.HAS_RECORD, true), 2);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
--- a/net/minecraft/server/BlockLeaves.java
|
||||
+++ b/net/minecraft/server/BlockLeaves.java
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockLeaves extends Block {
|
||||
|
||||
public static final BlockStateInteger DISTANCE = BlockProperties.an;
|
||||
@@ -25,6 +27,14 @@
|
||||
@Override
|
||||
public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
if (!(Boolean) iblockdata.get(BlockLeaves.PERSISTENT) && (Integer) iblockdata.get(BlockLeaves.DISTANCE) == 7) {
|
||||
+ // CraftBukkit start
|
||||
+ LeavesDecayEvent event = new LeavesDecayEvent(worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
+ worldserver.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled() || worldserver.getType(blockposition).getBlock() != this) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
c(iblockdata, (World) worldserver, blockposition);
|
||||
worldserver.a(blockposition, false);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
--- a/net/minecraft/server/BlockLectern.java
|
||||
+++ b/net/minecraft/server/BlockLectern.java
|
||||
@@ -165,12 +165,13 @@
|
||||
}
|
||||
|
||||
private void d(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
||||
- TileEntity tileentity = world.getTileEntity(blockposition);
|
||||
+ TileEntity tileentity = world.getTileEntity(blockposition, false); // CraftBukkit - don't validate, type may be changed already
|
||||
|
||||
if (tileentity instanceof TileEntityLectern) {
|
||||
TileEntityLectern tileentitylectern = (TileEntityLectern) tileentity;
|
||||
EnumDirection enumdirection = (EnumDirection) iblockdata.get(BlockLectern.a);
|
||||
ItemStack itemstack = tileentitylectern.getBook().cloneItemStack();
|
||||
+ if (itemstack.isEmpty()) return; // CraftBukkit - SPIGOT-5500
|
||||
float f = 0.25F * (float) enumdirection.getAdjacentX();
|
||||
float f1 = 0.25F * (float) enumdirection.getAdjacentZ();
|
||||
EntityItem entityitem = new EntityItem(world, (double) blockposition.getX() + 0.5D + (double) f, (double) (blockposition.getY() + 1), (double) blockposition.getZ() + 0.5D + (double) f1, itemstack);
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/server/BlockLever.java
|
||||
+++ b/net/minecraft/server/BlockLever.java
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockLever extends BlockAttachable {
|
||||
|
||||
public static final BlockStateBoolean POWERED = BlockProperties.w;
|
||||
@@ -64,6 +66,20 @@
|
||||
|
||||
return EnumInteractionResult.SUCCESS;
|
||||
} else {
|
||||
+ // CraftBukkit start - Interact Lever
|
||||
+ boolean powered = iblockdata.get(BlockLever.POWERED); // Old powered state
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ int old = (powered) ? 15 : 0;
|
||||
+ int current = (!powered) ? 15 : 0;
|
||||
+
|
||||
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
|
||||
+ world.getServer().getPluginManager().callEvent(eventRedstone);
|
||||
+
|
||||
+ if ((eventRedstone.getNewCurrent() > 0) != (!powered)) {
|
||||
+ return EnumInteractionResult.SUCCESS;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
iblockdata1 = this.d(iblockdata, world, blockposition);
|
||||
float f = (Boolean) iblockdata1.get(BlockLever.POWERED) ? 0.6F : 0.5F;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
--- a/net/minecraft/server/BlockMagma.java
|
||||
+++ b/net/minecraft/server/BlockMagma.java
|
||||
@@ -11,7 +11,9 @@
|
||||
@Override
|
||||
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
|
||||
if (!entity.isFireProof() && entity instanceof EntityLiving && !EnchantmentManager.i((EntityLiving) entity)) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()); // CraftBukkit
|
||||
entity.damageEntity(DamageSource.HOT_FLOOR, 1.0F);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.blockDamage = null; // CraftBukkit
|
||||
}
|
||||
|
||||
super.stepOn(world, blockposition, entity);
|
||||
@@ -0,0 +1,28 @@
|
||||
--- a/net/minecraft/server/BlockMinecartDetector.java
|
||||
+++ b/net/minecraft/server/BlockMinecartDetector.java
|
||||
@@ -6,6 +6,8 @@
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockMinecartDetector extends BlockMinecartTrackAbstract {
|
||||
|
||||
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.ad;
|
||||
@@ -58,6 +60,16 @@
|
||||
}
|
||||
|
||||
IBlockData iblockdata1;
|
||||
+ // CraftBukkit start
|
||||
+ if (flag != flag1) {
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+
|
||||
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 15 : 0, flag1 ? 15 : 0);
|
||||
+ world.getServer().getPluginManager().callEvent(eventRedstone);
|
||||
+
|
||||
+ flag1 = eventRedstone.getNewCurrent() > 0;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (flag1 && !flag) {
|
||||
iblockdata1 = (IBlockData) iblockdata.set(BlockMinecartDetector.POWERED, true);
|
||||
@@ -0,0 +1,22 @@
|
||||
--- a/net/minecraft/server/BlockMobSpawner.java
|
||||
+++ b/net/minecraft/server/BlockMobSpawner.java
|
||||
@@ -14,9 +14,19 @@
|
||||
@Override
|
||||
public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
|
||||
super.dropNaturally(iblockdata, worldserver, blockposition, itemstack);
|
||||
+ /* CraftBukkit start - Delegate to getExpDrop
|
||||
int i = 15 + worldserver.random.nextInt(15) + worldserver.random.nextInt(15);
|
||||
|
||||
this.dropExperience(worldserver, blockposition, i);
|
||||
+ */
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
|
||||
+ int i = 15 + worldserver.random.nextInt(15) + worldserver.random.nextInt(15);
|
||||
+
|
||||
+ return i;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,20 @@
|
||||
--- a/net/minecraft/server/BlockMonsterEggs.java
|
||||
+++ b/net/minecraft/server/BlockMonsterEggs.java
|
||||
@@ -3,6 +3,8 @@
|
||||
import com.google.common.collect.Maps;
|
||||
import java.util.Map;
|
||||
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason; // CraftBukkit
|
||||
+
|
||||
public class BlockMonsterEggs extends Block {
|
||||
|
||||
private final Block a;
|
||||
@@ -26,7 +28,7 @@
|
||||
EntitySilverfish entitysilverfish = (EntitySilverfish) EntityTypes.SILVERFISH.a((World) worldserver);
|
||||
|
||||
entitysilverfish.setPositionRotation((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, 0.0F, 0.0F);
|
||||
- worldserver.addEntity(entitysilverfish);
|
||||
+ worldserver.addEntity(entitysilverfish, SpawnReason.SILVERFISH_BLOCK); // CraftBukkit - add SpawnReason
|
||||
entitysilverfish.doSpawnEffect();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
--- a/net/minecraft/server/BlockMushroom.java
|
||||
+++ b/net/minecraft/server/BlockMushroom.java
|
||||
@@ -3,6 +3,10 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.TreeType;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockMushroom extends BlockPlant implements IBlockFragilePlantElement {
|
||||
|
||||
protected static final VoxelShape a = Block.a(5.0D, 0.0D, 5.0D, 11.0D, 6.0D, 11.0D);
|
||||
@@ -45,7 +49,7 @@
|
||||
}
|
||||
|
||||
if (worldserver.isEmpty(blockposition2) && iblockdata.canPlace(worldserver, blockposition2)) {
|
||||
- worldserver.setTypeAndData(blockposition2, iblockdata, 2);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, iblockdata, 2); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,6 +73,7 @@
|
||||
WorldGenFeatureConfigured worldgenfeatureconfigured;
|
||||
|
||||
if (this == Blocks.BROWN_MUSHROOM) {
|
||||
+ BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit
|
||||
worldgenfeatureconfigured = BiomeDecoratorGroups.HUGE_BROWN_MUSHROOM;
|
||||
} else {
|
||||
if (this != Blocks.RED_MUSHROOM) {
|
||||
@@ -76,6 +81,7 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
+ BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit
|
||||
worldgenfeatureconfigured = BiomeDecoratorGroups.HUGE_RED_MUSHROOM;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/BlockNetherWart.java
|
||||
+++ b/net/minecraft/server/BlockNetherWart.java
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
if (i < 3 && random.nextInt(10) == 0) {
|
||||
iblockdata = (IBlockData) iblockdata.set(BlockNetherWart.AGE, i + 1);
|
||||
- worldserver.setTypeAndData(blockposition, iblockdata, 2);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata, 2); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
--- a/net/minecraft/server/BlockNote.java
|
||||
+++ b/net/minecraft/server/BlockNote.java
|
||||
@@ -27,7 +27,8 @@
|
||||
|
||||
if (flag1 != (Boolean) iblockdata.get(BlockNote.POWERED)) {
|
||||
if (flag1) {
|
||||
- this.play(world, blockposition);
|
||||
+ this.play(world, blockposition, iblockdata); // CraftBukkit
|
||||
+ iblockdata = world.getType(blockposition); // CraftBukkit - SPIGOT-5617: update in case changed in event
|
||||
}
|
||||
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockNote.POWERED, flag1), 3);
|
||||
@@ -35,9 +36,14 @@
|
||||
|
||||
}
|
||||
|
||||
- private void play(World world, BlockPosition blockposition) {
|
||||
+ private void play(World world, BlockPosition blockposition, IBlockData data) { // CraftBukkit
|
||||
if (world.getType(blockposition.up()).isAir()) {
|
||||
- world.playBlockAction(blockposition, this, 0, 0);
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.event.block.NotePlayEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callNotePlayEvent(world, blockposition, data.get(BlockNote.INSTRUMENT), data.get(BlockNote.NOTE));
|
||||
+ if (!event.isCancelled()) {
|
||||
+ world.playBlockAction(blockposition, this, 0, 0);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -49,7 +55,7 @@
|
||||
} else {
|
||||
iblockdata = (IBlockData) iblockdata.a((IBlockState) BlockNote.NOTE);
|
||||
world.setTypeAndData(blockposition, iblockdata, 3);
|
||||
- this.play(world, blockposition);
|
||||
+ this.play(world, blockposition, iblockdata); // CraftBukkit
|
||||
entityhuman.a(StatisticList.TUNE_NOTEBLOCK);
|
||||
return EnumInteractionResult.CONSUME;
|
||||
}
|
||||
@@ -58,7 +64,7 @@
|
||||
@Override
|
||||
public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) {
|
||||
if (!world.isClientSide) {
|
||||
- this.play(world, blockposition);
|
||||
+ this.play(world, blockposition, iblockdata); // CraftBukkit
|
||||
entityhuman.a(StatisticList.PLAY_NOTEBLOCK);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
--- a/net/minecraft/server/BlockObserver.java
|
||||
+++ b/net/minecraft/server/BlockObserver.java
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class BlockObserver extends BlockDirectional {
|
||||
|
||||
public static final BlockStateBoolean b = BlockProperties.w;
|
||||
@@ -29,8 +31,18 @@
|
||||
@Override
|
||||
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
if ((Boolean) iblockdata.get(BlockObserver.b)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 15, 0).getNewCurrent() != 0) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.b, false), 2);
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 0, 15).getNewCurrent() != 15) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockObserver.b, true), 2);
|
||||
worldserver.getBlockTickList().a(blockposition, this, 2);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
--- a/net/minecraft/server/BlockOre.java
|
||||
+++ b/net/minecraft/server/BlockOre.java
|
||||
@@ -15,6 +15,7 @@
|
||||
@Override
|
||||
public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
|
||||
super.dropNaturally(iblockdata, worldserver, blockposition, itemstack);
|
||||
+ /* CraftBukkit start - Delegated to getExpDrop
|
||||
if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
|
||||
int i = this.a(worldserver.random);
|
||||
|
||||
@@ -22,6 +23,21 @@
|
||||
this.dropExperience(worldserver, blockposition, i);
|
||||
}
|
||||
}
|
||||
+ // */
|
||||
|
||||
}
|
||||
+
|
||||
+ @Override
|
||||
+ public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
|
||||
+ if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
|
||||
+ int i = this.a(worldserver.random);
|
||||
+
|
||||
+ if (i > 0) {
|
||||
+ return i;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return 0;
|
||||
+ // CraftBukkit end
|
||||
+ }
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
--- a/net/minecraft/server/BlockPlant.java
|
||||
+++ b/net/minecraft/server/BlockPlant.java
|
||||
@@ -12,7 +12,14 @@
|
||||
|
||||
@Override
|
||||
public IBlockData updateState(IBlockData iblockdata, EnumDirection enumdirection, IBlockData iblockdata1, GeneratorAccess generatoraccess, BlockPosition blockposition, BlockPosition blockposition1) {
|
||||
- return !iblockdata.canPlace(generatoraccess, blockposition) ? Blocks.AIR.getBlockData() : super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
|
||||
+ // CraftBukkit start
|
||||
+ if (!iblockdata.canPlace(generatoraccess, blockposition)) {
|
||||
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(generatoraccess, blockposition).isCancelled()) {
|
||||
+ return Blocks.AIR.getBlockData();
|
||||
+ }
|
||||
+ }
|
||||
+ return super.updateState(iblockdata, enumdirection, iblockdata1, generatoraccess, blockposition, blockposition1);
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,34 @@
|
||||
--- a/net/minecraft/server/BlockPortal.java
|
||||
+++ b/net/minecraft/server/BlockPortal.java
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityPortalEnterEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockPortal extends Block {
|
||||
|
||||
public static final BlockStateEnum<EnumDirection.EnumAxis> AXIS = BlockProperties.E;
|
||||
@@ -32,7 +36,8 @@
|
||||
}
|
||||
|
||||
if (worldserver.getType(blockposition).a((IBlockAccess) worldserver, blockposition, EntityTypes.ZOMBIFIED_PIGLIN)) {
|
||||
- Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false);
|
||||
+ // CraftBukkit - set spawn reason to NETHER_PORTAL
|
||||
+ Entity entity = EntityTypes.ZOMBIFIED_PIGLIN.spawnCreature(worldserver, (NBTTagCompound) null, (IChatBaseComponent) null, (EntityHuman) null, blockposition.up(), EnumMobSpawn.STRUCTURE, false, false, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.NETHER_PORTAL);
|
||||
|
||||
if (entity != null) {
|
||||
entity.resetPortalCooldown();
|
||||
@@ -54,6 +59,10 @@
|
||||
@Override
|
||||
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
||||
if (!entity.isPassenger() && !entity.isVehicle() && entity.canPortal()) {
|
||||
+ // CraftBukkit start - Entity in portal
|
||||
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(entity.getBukkitEntity(), new org.bukkit.Location(world.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+ // CraftBukkit end
|
||||
entity.d(blockposition);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
--- a/net/minecraft/server/BlockPoweredRail.java
|
||||
+++ b/net/minecraft/server/BlockPoweredRail.java
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class BlockPoweredRail extends BlockMinecartTrackAbstract {
|
||||
|
||||
public static final BlockStateEnum<BlockPropertyTrackPosition> SHAPE = BlockProperties.ad;
|
||||
@@ -102,6 +104,13 @@
|
||||
boolean flag1 = world.isBlockIndirectlyPowered(blockposition) || this.a(world, blockposition, iblockdata, true, 0) || this.a(world, blockposition, iblockdata, false, 0);
|
||||
|
||||
if (flag1 != flag) {
|
||||
+ // CraftBukkit start
|
||||
+ int power = flag ? 15 : 0;
|
||||
+ int newPower = CraftEventFactory.callRedstoneChange(world, blockposition, power, 15 - power).getNewCurrent();
|
||||
+ if (newPower == power) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockPoweredRail.POWERED, flag1), 3);
|
||||
world.applyPhysics(blockposition.down(), this);
|
||||
if (((BlockPropertyTrackPosition) iblockdata.get(BlockPoweredRail.SHAPE)).c()) {
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/server/BlockPressurePlateAbstract.java
|
||||
+++ b/net/minecraft/server/BlockPressurePlateAbstract.java
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
+
|
||||
public abstract class BlockPressurePlateAbstract extends Block {
|
||||
|
||||
protected static final VoxelShape a = Block.a(1.0D, 0.0D, 1.0D, 15.0D, 0.5D, 15.0D);
|
||||
@@ -65,6 +67,19 @@
|
||||
boolean flag = i > 0;
|
||||
boolean flag1 = j > 0;
|
||||
|
||||
+ // CraftBukkit start - Interact Pressure Plate
|
||||
+ org.bukkit.World bworld = world.getWorld();
|
||||
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
|
||||
+
|
||||
+ if (flag != flag1) {
|
||||
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), i, j);
|
||||
+ manager.callEvent(eventRedstone);
|
||||
+
|
||||
+ flag1 = eventRedstone.getNewCurrent() > 0;
|
||||
+ j = eventRedstone.getNewCurrent();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (i != j) {
|
||||
IBlockData iblockdata1 = this.a(iblockdata, j);
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
--- a/net/minecraft/server/BlockPressurePlateBinary.java
|
||||
+++ b/net/minecraft/server/BlockPressurePlateBinary.java
|
||||
@@ -3,6 +3,8 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockPressurePlateBinary extends BlockPressurePlateAbstract {
|
||||
|
||||
public static final BlockStateBoolean POWERED = BlockProperties.w;
|
||||
@@ -66,6 +68,26 @@
|
||||
while (iterator.hasNext()) {
|
||||
Entity entity = (Entity) iterator.next();
|
||||
|
||||
+ // CraftBukkit start - Call interact event when turning on a pressure plate
|
||||
+ if (this.getPower(world.getType(blockposition)) == 0) {
|
||||
+ org.bukkit.World bworld = world.getWorld();
|
||||
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
|
||||
+ org.bukkit.event.Cancellable cancellable;
|
||||
+
|
||||
+ if (entity instanceof EntityHuman) {
|
||||
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
|
||||
+ } else {
|
||||
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
+ manager.callEvent((EntityInteractEvent) cancellable);
|
||||
+ }
|
||||
+
|
||||
+ // We only want to block turning the plate on if all events are cancelled
|
||||
+ if (cancellable.isCancelled()) {
|
||||
+ continue;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (!entity.isIgnoreBlockTrigger()) {
|
||||
return 15;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
--- a/net/minecraft/server/BlockPressurePlateWeighted.java
|
||||
+++ b/net/minecraft/server/BlockPressurePlateWeighted.java
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockPressurePlateWeighted extends BlockPressurePlateAbstract {
|
||||
|
||||
public static final BlockStateInteger POWER = BlockProperties.az;
|
||||
@@ -13,7 +15,31 @@
|
||||
|
||||
@Override
|
||||
protected int b(World world, BlockPosition blockposition) {
|
||||
- int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
|
||||
+ // CraftBukkit start
|
||||
+ // int i = Math.min(world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).size(), this.weight);
|
||||
+ int i = 0;
|
||||
+ java.util.Iterator iterator = world.a(Entity.class, BlockPressurePlateWeighted.c.a(blockposition)).iterator();
|
||||
+
|
||||
+ while (iterator.hasNext()) {
|
||||
+ Entity entity = (Entity) iterator.next();
|
||||
+
|
||||
+ org.bukkit.event.Cancellable cancellable;
|
||||
+
|
||||
+ if (entity instanceof EntityHuman) {
|
||||
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
|
||||
+ } else {
|
||||
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
|
||||
+ }
|
||||
+
|
||||
+ // We only want to block turning the plate on if all events are cancelled
|
||||
+ if (!cancellable.isCancelled()) {
|
||||
+ i++;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ i = Math.min(i, this.weight);
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (i > 0) {
|
||||
float f = (float) Math.min(this.weight, i) / (float) this.weight;
|
||||
@@ -0,0 +1,74 @@
|
||||
--- a/net/minecraft/server/BlockPumpkinCarved.java
|
||||
+++ b/net/minecraft/server/BlockPumpkinCarved.java
|
||||
@@ -4,6 +4,11 @@
|
||||
import java.util.function.Predicate;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockPumpkinCarved extends BlockFacingHorizontal implements ItemWearable {
|
||||
|
||||
public static final BlockStateDirection a = BlockFacingHorizontal.FACING;
|
||||
@@ -42,19 +47,28 @@
|
||||
EntityPlayer entityplayer;
|
||||
int j;
|
||||
|
||||
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator
|
||||
if (shapedetector_shapedetectorcollection != null) {
|
||||
for (i = 0; i < this.getSnowmanShape().b(); ++i) {
|
||||
ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(0, i, 0);
|
||||
|
||||
- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2);
|
||||
- world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a()));
|
||||
+ blockList.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
|
||||
+ // world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); // CraftBukkit
|
||||
}
|
||||
|
||||
EntitySnowman entitysnowman = (EntitySnowman) EntityTypes.SNOW_GOLEM.a(world);
|
||||
BlockPosition blockposition1 = shapedetector_shapedetectorcollection.a(0, 2, 0).getPosition();
|
||||
|
||||
entitysnowman.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.05D, (double) blockposition1.getZ() + 0.5D, 0.0F, 0.0F);
|
||||
- world.addEntity(entitysnowman);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ for (BlockPosition pos : blockList.getBlocks()) {
|
||||
+ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos)));
|
||||
+ }
|
||||
+ blockList.updateList();
|
||||
+ // CraftBukkit end
|
||||
iterator = world.a(EntityPlayer.class, entitysnowman.getBoundingBox().g(5.0D)).iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -74,8 +88,8 @@
|
||||
for (int k = 0; k < this.getIronGolemShape().b(); ++k) {
|
||||
ShapeDetectorBlock shapedetectorblock2 = shapedetector_shapedetectorcollection.a(i, k, 0);
|
||||
|
||||
- world.setTypeAndData(shapedetectorblock2.getPosition(), Blocks.AIR.getBlockData(), 2);
|
||||
- world.triggerEffect(2001, shapedetectorblock2.getPosition(), Block.getCombinedId(shapedetectorblock2.a()));
|
||||
+ blockList.setTypeAndData(shapedetectorblock2.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
|
||||
+ // world.triggerEffect(2001, shapedetectorblock2.getPosition(), Block.getCombinedId(shapedetectorblock2.a())); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,7 +98,15 @@
|
||||
|
||||
entityirongolem.setPlayerCreated(true);
|
||||
entityirongolem.setPositionRotation((double) blockposition2.getX() + 0.5D, (double) blockposition2.getY() + 0.05D, (double) blockposition2.getZ() + 0.5D, 0.0F, 0.0F);
|
||||
- world.addEntity(entityirongolem);
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ for (BlockPosition pos : blockList.getBlocks()) {
|
||||
+ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos)));
|
||||
+ }
|
||||
+ blockList.updateList();
|
||||
+ // CraftBukkit end
|
||||
iterator = world.a(EntityPlayer.class, entityirongolem.getBoundingBox().g(5.0D)).iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -0,0 +1,40 @@
|
||||
--- a/net/minecraft/server/BlockRedstoneComparator.java
|
||||
+++ b/net/minecraft/server/BlockRedstoneComparator.java
|
||||
@@ -4,6 +4,8 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class BlockRedstoneComparator extends BlockDiodeAbstract implements ITileEntity {
|
||||
|
||||
public static final BlockStateEnum<BlockPropertyComparatorMode> MODE = BlockProperties.aG;
|
||||
@@ -67,7 +69,8 @@
|
||||
|
||||
@Nullable
|
||||
private EntityItemFrame a(World world, EnumDirection enumdirection, BlockPosition blockposition) {
|
||||
- List<EntityItemFrame> list = world.a(EntityItemFrame.class, new AxisAlignedBB((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), (double) (blockposition.getX() + 1), (double) (blockposition.getY() + 1), (double) (blockposition.getZ() + 1)), (entityitemframe) -> {
|
||||
+ // CraftBukkit - decompile error
|
||||
+ List<EntityItemFrame> list = world.a(EntityItemFrame.class, new AxisAlignedBB((double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), (double) (blockposition.getX() + 1), (double) (blockposition.getY() + 1), (double) (blockposition.getZ() + 1)), (java.util.function.Predicate<EntityItemFrame>) (entityitemframe) -> {
|
||||
return entityitemframe != null && entityitemframe.getDirection() == enumdirection;
|
||||
});
|
||||
|
||||
@@ -122,8 +125,18 @@
|
||||
boolean flag1 = (Boolean) iblockdata.get(BlockRedstoneComparator.c);
|
||||
|
||||
if (flag1 && !flag) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callRedstoneChange(world, blockposition, 15, 0).getNewCurrent() != 0) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.c, false), 2);
|
||||
} else if (!flag1 && flag) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneComparator.c, true), 2);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
--- a/net/minecraft/server/BlockRedstoneLamp.java
|
||||
+++ b/net/minecraft/server/BlockRedstoneLamp.java
|
||||
@@ -3,6 +3,8 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class BlockRedstoneLamp extends Block {
|
||||
|
||||
public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
|
||||
@@ -27,6 +29,11 @@
|
||||
if (flag1) {
|
||||
world.getBlockTickList().a(blockposition, this, 4);
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callRedstoneChange(world, blockposition, 0, 15).getNewCurrent() != 15) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2);
|
||||
}
|
||||
}
|
||||
@@ -37,6 +44,11 @@
|
||||
@Override
|
||||
public void tickAlways(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
if ((Boolean) iblockdata.get(BlockRedstoneLamp.a) && !worldserver.isBlockIndirectlyPowered(blockposition)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callRedstoneChange(worldserver, blockposition, 15, 0).getNewCurrent() != 0) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.a((IBlockState) BlockRedstoneLamp.a), 2);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
--- a/net/minecraft/server/BlockRedstoneOre.java
|
||||
+++ b/net/minecraft/server/BlockRedstoneOre.java
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.event.entity.EntityInteractEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockRedstoneOre extends Block {
|
||||
|
||||
public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
|
||||
@@ -13,14 +18,30 @@
|
||||
|
||||
@Override
|
||||
public void attack(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman) {
|
||||
- interact(iblockdata, world, blockposition);
|
||||
+ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman
|
||||
super.attack(iblockdata, world, blockposition, entityhuman);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
|
||||
- interact(world.getType(blockposition), world, blockposition);
|
||||
- super.stepOn(world, blockposition, entity);
|
||||
+ // CraftBukkit start
|
||||
+ // interact(world.getType(blockposition), world, blockposition);
|
||||
+ // super.stepOn(world, blockposition, entity);
|
||||
+ if (entity instanceof EntityHuman) {
|
||||
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ interact(world.getType(blockposition), world, blockposition, entity); // add entity
|
||||
+ super.stepOn(world, blockposition, entity);
|
||||
+ }
|
||||
+ } else {
|
||||
+ EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (!event.isCancelled()) {
|
||||
+ interact(world.getType(blockposition), world, blockposition, entity); // add entity
|
||||
+ super.stepOn(world, blockposition, entity);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -28,7 +49,7 @@
|
||||
if (world.isClientSide) {
|
||||
playEffect(world, blockposition);
|
||||
} else {
|
||||
- interact(iblockdata, world, blockposition);
|
||||
+ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman
|
||||
}
|
||||
|
||||
ItemStack itemstack = entityhuman.b(enumhand);
|
||||
@@ -36,9 +57,14 @@
|
||||
return itemstack.getItem() instanceof ItemBlock && (new BlockActionContext(entityhuman, enumhand, itemstack, movingobjectpositionblock)).b() ? EnumInteractionResult.PASS : EnumInteractionResult.SUCCESS;
|
||||
}
|
||||
|
||||
- private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
||||
+ private static void interact(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity
|
||||
playEffect(world, blockposition);
|
||||
if (!(Boolean) iblockdata.get(BlockRedstoneOre.a)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.a, true)).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, true), 3);
|
||||
}
|
||||
|
||||
@@ -52,6 +78,11 @@
|
||||
@Override
|
||||
public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
if ((Boolean) iblockdata.get(BlockRedstoneOre.a)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, iblockdata.set(BlockRedstoneOre.a, false)).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, false), 3);
|
||||
}
|
||||
|
||||
@@ -60,12 +91,25 @@
|
||||
@Override
|
||||
public void dropNaturally(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
|
||||
super.dropNaturally(iblockdata, worldserver, blockposition, itemstack);
|
||||
+ /* CraftBukkit start - Delegated to getExpDrop
|
||||
if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
|
||||
int i = 1 + worldserver.random.nextInt(5);
|
||||
|
||||
this.dropExperience(worldserver, blockposition, i);
|
||||
}
|
||||
+ // */
|
||||
+
|
||||
+ }
|
||||
|
||||
+ @Override
|
||||
+ public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack) {
|
||||
+ if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
|
||||
+ int i = 1 + worldserver.random.nextInt(5);
|
||||
+
|
||||
+ return i;
|
||||
+ }
|
||||
+ return 0;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
private static void playEffect(World world, BlockPosition blockposition) {
|
||||
@@ -0,0 +1,52 @@
|
||||
--- a/net/minecraft/server/BlockRedstoneTorch.java
|
||||
+++ b/net/minecraft/server/BlockRedstoneTorch.java
|
||||
@@ -6,6 +6,8 @@
|
||||
import java.util.Random;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockRedstoneTorch extends BlockTorch {
|
||||
|
||||
public static final BlockStateBoolean LIT = BlockProperties.r;
|
||||
@@ -62,8 +64,24 @@
|
||||
list.remove(0);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.plugin.PluginManager manager = worldserver.getServer().getPluginManager();
|
||||
+ org.bukkit.block.Block block = worldserver.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ int oldCurrent = ((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)).booleanValue() ? 15 : 0;
|
||||
+
|
||||
+ BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent);
|
||||
+ // CraftBukkit end
|
||||
if ((Boolean) iblockdata.get(BlockRedstoneTorch.LIT)) {
|
||||
if (flag) {
|
||||
+ // CraftBukkit start
|
||||
+ if (oldCurrent != 0) {
|
||||
+ event.setNewCurrent(0);
|
||||
+ manager.callEvent(event);
|
||||
+ if (event.getNewCurrent() != 0) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, false), 3);
|
||||
if (a(worldserver, blockposition, true)) {
|
||||
worldserver.triggerEffect(1502, blockposition, 0);
|
||||
@@ -71,6 +89,15 @@
|
||||
}
|
||||
}
|
||||
} else if (!flag && !a(worldserver, blockposition, false)) {
|
||||
+ // CraftBukkit start
|
||||
+ if (oldCurrent != 15) {
|
||||
+ event.setNewCurrent(15);
|
||||
+ manager.callEvent(event);
|
||||
+ if (event.getNewCurrent() != 15) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneTorch.LIT, true), 3);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/BlockRedstoneWire.java
|
||||
+++ b/net/minecraft/server/BlockRedstoneWire.java
|
||||
@@ -9,6 +9,8 @@
|
||||
import java.util.Set;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockRedstoneWire extends Block {
|
||||
|
||||
public static final BlockStateEnum<BlockPropertyRedstoneSide> NORTH = BlockProperties.X;
|
||||
@@ -213,7 +215,16 @@
|
||||
private void a(World world, BlockPosition blockposition, IBlockData iblockdata) {
|
||||
int i = this.a(world, blockposition);
|
||||
|
||||
- if ((Integer) iblockdata.get(BlockRedstoneWire.POWER) != i) {
|
||||
+ // CraftBukkit start
|
||||
+ int oldPower = (Integer) iblockdata.get(BlockRedstoneWire.POWER);
|
||||
+ if (oldPower != i) {
|
||||
+ BlockRedstoneEvent event = new BlockRedstoneEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), oldPower, i);
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ i = event.getNewCurrent();
|
||||
+ }
|
||||
+ if (oldPower != i) {
|
||||
+ // CraftBukkit end
|
||||
if (world.getType(blockposition) == iblockdata) {
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneWire.POWER, i), 2);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/BlockReed.java
|
||||
+++ b/net/minecraft/server/BlockReed.java
|
||||
@@ -39,7 +39,7 @@
|
||||
int j = (Integer) iblockdata.get(BlockReed.AGE);
|
||||
|
||||
if (j == 15) {
|
||||
- worldserver.setTypeUpdate(blockposition.up(), this.getBlockData());
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition.up(), this.getBlockData()); // CraftBukkit
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockReed.AGE, 0), 4);
|
||||
} else {
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockReed.AGE, j + 1), 4);
|
||||
@@ -0,0 +1,53 @@
|
||||
--- a/net/minecraft/server/BlockSapling.java
|
||||
+++ b/net/minecraft/server/BlockSapling.java
|
||||
@@ -2,11 +2,19 @@
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.TreeType;
|
||||
+import org.bukkit.block.BlockState;
|
||||
+import org.bukkit.event.world.StructureGrowEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockSapling extends BlockPlant implements IBlockFragilePlantElement {
|
||||
|
||||
public static final BlockStateInteger STAGE = BlockProperties.aA;
|
||||
protected static final VoxelShape b = Block.a(2.0D, 0.0D, 2.0D, 14.0D, 12.0D, 14.0D);
|
||||
private final WorldGenTreeProvider c;
|
||||
+ public static TreeType treeType; // CraftBukkit
|
||||
|
||||
protected BlockSapling(WorldGenTreeProvider worldgentreeprovider, BlockBase.Info blockbase_info) {
|
||||
super(blockbase_info);
|
||||
@@ -22,7 +30,30 @@
|
||||
@Override
|
||||
public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
if (worldserver.getLightLevel(blockposition.up()) >= 9 && random.nextInt(7) == 0) {
|
||||
+ // CraftBukkit start
|
||||
+ worldserver.captureTreeGeneration = true;
|
||||
+ // CraftBukkit end
|
||||
this.grow(worldserver, blockposition, iblockdata, random);
|
||||
+ // CraftBukkit start
|
||||
+ worldserver.captureTreeGeneration = false;
|
||||
+ if (worldserver.capturedBlockStates.size() > 0) {
|
||||
+ TreeType treeType = BlockSapling.treeType;
|
||||
+ BlockSapling.treeType = null;
|
||||
+ Location location = new Location(worldserver.getWorld(), blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ java.util.List<BlockState> blocks = new java.util.ArrayList<>(worldserver.capturedBlockStates.values());
|
||||
+ worldserver.capturedBlockStates.clear();
|
||||
+ StructureGrowEvent event = null;
|
||||
+ if (treeType != null) {
|
||||
+ event = new StructureGrowEvent(location, treeType, false, null, blocks);
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
||||
+ }
|
||||
+ if (event == null || !event.isCancelled()) {
|
||||
+ for (BlockState blockstate : blocks) {
|
||||
+ blockstate.update(true);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/BlockScaffolding.java
|
||||
+++ b/net/minecraft/server/BlockScaffolding.java
|
||||
@@ -73,7 +73,7 @@
|
||||
int i = a((IBlockAccess) worldserver, blockposition);
|
||||
IBlockData iblockdata1 = (IBlockData) ((IBlockData) iblockdata.set(BlockScaffolding.a, i)).set(BlockScaffolding.c, this.a(worldserver, blockposition, i));
|
||||
|
||||
- if ((Integer) iblockdata1.get(BlockScaffolding.a) == 7) {
|
||||
+ if ((Integer) iblockdata1.get(BlockScaffolding.a) == 7 && !org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit - BlockFadeEvent
|
||||
if ((Integer) iblockdata.get(BlockScaffolding.a) == 7) {
|
||||
worldserver.addEntity(new EntityFallingBlock(worldserver, (double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D, (IBlockData) iblockdata1.set(BlockScaffolding.b, false)));
|
||||
} else {
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/BlockSnow.java
|
||||
+++ b/net/minecraft/server/BlockSnow.java
|
||||
@@ -67,6 +67,11 @@
|
||||
@Override
|
||||
public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
||||
if (worldserver.getBrightness(EnumSkyBlock.BLOCK, blockposition) > 11) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
c(iblockdata, (World) worldserver, blockposition);
|
||||
worldserver.a(blockposition, false);
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
--- a/net/minecraft/server/BlockSoil.java
|
||||
+++ b/net/minecraft/server/BlockSoil.java
|
||||
@@ -3,6 +3,11 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.Random;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityInteractEvent;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockSoil extends Block {
|
||||
|
||||
public static final BlockStateInteger MOISTURE = BlockProperties.aw;
|
||||
@@ -58,26 +63,49 @@
|
||||
|
||||
if (!a((IWorldReader) worldserver, blockposition) && !worldserver.isRainingAt(blockposition.up())) {
|
||||
if (i > 0) {
|
||||
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, i - 1), 2); // CraftBukkit
|
||||
} else if (!a((IBlockAccess) worldserver, blockposition)) {
|
||||
fade(iblockdata, worldserver, blockposition);
|
||||
}
|
||||
} else if (i < 7) {
|
||||
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2);
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleMoistureChangeEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSoil.MOISTURE, 7), 2); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fallOn(World world, BlockPosition blockposition, Entity entity, float f) {
|
||||
+ super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved here as game rules / events shouldn't affect fall damage.
|
||||
if (!world.isClientSide && world.random.nextFloat() < f - 0.5F && entity instanceof EntityLiving && (entity instanceof EntityHuman || world.getGameRules().getBoolean(GameRules.MOB_GRIEFING)) && entity.getWidth() * entity.getWidth() * entity.getHeight() > 0.512F) {
|
||||
+ // CraftBukkit start - Interact soil
|
||||
+ org.bukkit.event.Cancellable cancellable;
|
||||
+ if (entity instanceof EntityHuman) {
|
||||
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
|
||||
+ } else {
|
||||
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
||||
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
|
||||
+ }
|
||||
+
|
||||
+ if (cancellable.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
fade(world.getType(blockposition), world, blockposition);
|
||||
}
|
||||
|
||||
- super.fallOn(world, blockposition, entity, f);
|
||||
+ // super.fallOn(world, blockposition, entity, f); // CraftBukkit - moved up
|
||||
}
|
||||
|
||||
public static void fade(IBlockData iblockdata, World world, BlockPosition blockposition) {
|
||||
+ // CraftBukkit start
|
||||
+ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, Blocks.DIRT.getBlockData()).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.setTypeUpdate(blockposition, a(iblockdata, Blocks.DIRT.getBlockData(), world, blockposition));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
--- a/net/minecraft/server/BlockSponge.java
|
||||
+++ b/net/minecraft/server/BlockSponge.java
|
||||
@@ -3,6 +3,13 @@
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.Queue;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.List;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
|
||||
+import org.bukkit.event.block.SpongeAbsorbEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockSponge extends Block {
|
||||
|
||||
protected BlockSponge(BlockBase.Info blockbase_info) {
|
||||
@@ -35,6 +42,7 @@
|
||||
|
||||
queue.add(new Tuple<>(blockposition, 0));
|
||||
int i = 0;
|
||||
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world); // CraftBukkit - Use BlockStateListPopulator
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
Tuple<BlockPosition, Integer> tuple = (Tuple) queue.poll();
|
||||
@@ -46,27 +54,31 @@
|
||||
for (int l = 0; l < k; ++l) {
|
||||
EnumDirection enumdirection = aenumdirection[l];
|
||||
BlockPosition blockposition2 = blockposition1.shift(enumdirection);
|
||||
- IBlockData iblockdata = world.getType(blockposition2);
|
||||
- Fluid fluid = world.getFluid(blockposition2);
|
||||
+ // CraftBukkit start
|
||||
+ IBlockData iblockdata = blockList.getType(blockposition2);
|
||||
+ Fluid fluid = blockList.getFluid(blockposition2);
|
||||
+ // CraftBukkit end
|
||||
Material material = iblockdata.getMaterial();
|
||||
|
||||
if (fluid.a((Tag) TagsFluid.WATER)) {
|
||||
- if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(world, blockposition2, iblockdata) != FluidTypes.EMPTY) {
|
||||
+ if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata) != FluidTypes.EMPTY) { // CraftBukkit
|
||||
++i;
|
||||
if (j < 6) {
|
||||
queue.add(new Tuple<>(blockposition2, j + 1));
|
||||
}
|
||||
} else if (iblockdata.getBlock() instanceof BlockFluids) {
|
||||
- world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3);
|
||||
+ blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3); // CraftBukkit
|
||||
++i;
|
||||
if (j < 6) {
|
||||
queue.add(new Tuple<>(blockposition2, j + 1));
|
||||
}
|
||||
} else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
|
||||
- TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
|
||||
+ // CraftBukkit start
|
||||
+ // TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
|
||||
|
||||
- a(iblockdata, (GeneratorAccess) world, blockposition2, tileentity);
|
||||
- world.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3);
|
||||
+ // a(iblockdata, (GeneratorAccess) world, blockposition2, tileentity);
|
||||
+ blockList.setTypeAndData(blockposition2, Blocks.AIR.getBlockData(), 3);
|
||||
+ // CraftBukkit end
|
||||
++i;
|
||||
if (j < 6) {
|
||||
queue.add(new Tuple<>(blockposition2, j + 1));
|
||||
@@ -79,6 +91,39 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
+ // CraftBukkit start
|
||||
+ List<CraftBlockState> blocks = blockList.getList(); // Is a clone
|
||||
+ if (!blocks.isEmpty()) {
|
||||
+ final org.bukkit.block.Block bblock = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+
|
||||
+ SpongeAbsorbEvent event = new SpongeAbsorbEvent(bblock, (List<org.bukkit.block.BlockState>) (List) blocks);
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ for (CraftBlockState block : blocks) {
|
||||
+ BlockPosition blockposition2 = block.getPosition();
|
||||
+ IBlockData iblockdata = world.getType(blockposition2);
|
||||
+ Fluid fluid = world.getFluid(blockposition2);
|
||||
+ Material material = iblockdata.getMaterial();
|
||||
+
|
||||
+ if (fluid.a(TagsFluid.WATER)) {
|
||||
+ if (iblockdata.getBlock() instanceof IFluidSource && ((IFluidSource) iblockdata.getBlock()).removeFluid(blockList, blockposition2, iblockdata) != FluidTypes.EMPTY) {
|
||||
+ // NOP
|
||||
+ } else if (iblockdata.getBlock() instanceof BlockFluids) {
|
||||
+ // NOP
|
||||
+ } else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
|
||||
+ TileEntity tileentity = iblockdata.getBlock().isTileEntity() ? world.getTileEntity(blockposition2) : null;
|
||||
+
|
||||
+ a(iblockdata, world, blockposition2, tileentity);
|
||||
+ }
|
||||
+ }
|
||||
+ world.setTypeAndData(blockposition2, block.getHandle(), block.getFlag());
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
return i > 0;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
--- a/net/minecraft/server/BlockStem.java
|
||||
+++ b/net/minecraft/server/BlockStem.java
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class BlockStem extends BlockPlant implements IBlockFragilePlantElement {
|
||||
|
||||
public static final BlockStateInteger AGE = BlockProperties.ai;
|
||||
@@ -34,14 +36,18 @@
|
||||
|
||||
if (i < 7) {
|
||||
iblockdata = (IBlockData) iblockdata.set(BlockStem.AGE, i + 1);
|
||||
- worldserver.setTypeAndData(blockposition, iblockdata, 2);
|
||||
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata, 2); // CraftBukkit
|
||||
} else {
|
||||
EnumDirection enumdirection = EnumDirection.EnumDirectionLimit.HORIZONTAL.a(random);
|
||||
BlockPosition blockposition1 = blockposition.shift(enumdirection);
|
||||
IBlockData iblockdata1 = worldserver.getType(blockposition1.down());
|
||||
|
||||
if (worldserver.getType(blockposition1).isAir() && (iblockdata1.a(Blocks.FARMLAND) || iblockdata1.a(Blocks.DIRT) || iblockdata1.a(Blocks.COARSE_DIRT) || iblockdata1.a(Blocks.PODZOL) || iblockdata1.a(Blocks.GRASS_BLOCK))) {
|
||||
- worldserver.setTypeUpdate(blockposition1, this.blockFruit.getBlockData());
|
||||
+ // CraftBukkit start
|
||||
+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition1, this.blockFruit.getBlockData())) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.setTypeUpdate(blockposition, (IBlockData) this.blockFruit.d().getBlockData().set(BlockFacingHorizontal.FACING, enumdirection));
|
||||
}
|
||||
}
|
||||
@@ -65,7 +71,7 @@
|
||||
int i = Math.min(7, (Integer) iblockdata.get(BlockStem.AGE) + MathHelper.nextInt(worldserver.random, 2, 5));
|
||||
IBlockData iblockdata1 = (IBlockData) iblockdata.set(BlockStem.AGE, i);
|
||||
|
||||
- worldserver.setTypeAndData(blockposition, iblockdata1, 2);
|
||||
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata1, 2); // CraftBukkit
|
||||
if (i == 7) {
|
||||
iblockdata1.b(worldserver, blockposition, worldserver.random);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
--- a/net/minecraft/server/BlockSweetBerryBush.java
|
||||
+++ b/net/minecraft/server/BlockSweetBerryBush.java
|
||||
@@ -2,6 +2,14 @@
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.Collections;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.player.PlayerHarvestBlockEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockSweetBerryBush extends BlockPlant implements IBlockFragilePlantElement {
|
||||
|
||||
public static final BlockStateInteger a = BlockProperties.ag;
|
||||
@@ -28,7 +36,7 @@
|
||||
int i = (Integer) iblockdata.get(BlockSweetBerryBush.a);
|
||||
|
||||
if (i < 3 && random.nextInt(5) == 0 && worldserver.getLightLevel(blockposition.up(), 0) >= 9) {
|
||||
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, i + 1), 2);
|
||||
+ CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, i + 1), 2); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,7 +50,9 @@
|
||||
double d1 = Math.abs(entity.locZ() - entity.F);
|
||||
|
||||
if (d0 >= 0.003000000026077032D || d1 >= 0.003000000026077032D) {
|
||||
+ CraftEventFactory.blockDamage = CraftBlock.at(world, blockposition); // CraftBukkit
|
||||
entity.damageEntity(DamageSource.SWEET_BERRY_BUSH, 1.0F);
|
||||
+ CraftEventFactory.blockDamage = null; // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +69,15 @@
|
||||
} else if (i > 1) {
|
||||
int j = 1 + world.random.nextInt(2);
|
||||
|
||||
- a(world, blockposition, new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0)));
|
||||
+ // CraftBukkit start
|
||||
+ PlayerHarvestBlockEvent event = CraftEventFactory.callPlayerHarvestBlockEvent(world, blockposition, entityhuman, Collections.singletonList(new ItemStack(Items.SWEET_BERRIES, j + (flag ? 1 : 0))));
|
||||
+ if (event.isCancelled()) {
|
||||
+ return EnumInteractionResult.SUCCESS; // We need to return a success either way, because making it PASS or FAIL will result in a bug where cancelling while harvesting w/ block in hand places block
|
||||
+ }
|
||||
+ for (org.bukkit.inventory.ItemStack itemStack : event.getItemsHarvested()) {
|
||||
+ a(world, blockposition, CraftItemStack.asNMSCopy(itemStack));
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
world.playSound((EntityHuman) null, blockposition, SoundEffects.ITEM_SWEET_BERRIES_PICK_FROM_BUSH, SoundCategory.BLOCKS, 1.0F, 0.8F + world.random.nextFloat() * 0.4F);
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockSweetBerryBush.a, 1), 2);
|
||||
return EnumInteractionResult.a(world.isClientSide);
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/BlockTNT.java
|
||||
+++ b/net/minecraft/server/BlockTNT.java
|
||||
@@ -94,6 +94,11 @@
|
||||
|
||||
if (iprojectile.isBurning()) {
|
||||
BlockPosition blockposition = movingobjectpositionblock.getBlockPosition();
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(iprojectile, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
a(world, blockposition, entity instanceof EntityLiving ? (EntityLiving) entity : null);
|
||||
world.a(blockposition, false);
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/BlockTallPlant.java
|
||||
+++ b/net/minecraft/server/BlockTallPlant.java
|
||||
@@ -66,6 +66,11 @@
|
||||
}
|
||||
|
||||
protected static void b(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman) {
|
||||
+ // CraftBukkit start
|
||||
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPhysicsEvent(world, blockposition).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
BlockPropertyDoubleBlockHalf blockpropertydoubleblockhalf = (BlockPropertyDoubleBlockHalf) iblockdata.get(BlockTallPlant.HALF);
|
||||
|
||||
if (blockpropertydoubleblockhalf == BlockPropertyDoubleBlockHalf.UPPER) {
|
||||
@@ -0,0 +1,31 @@
|
||||
--- a/net/minecraft/server/BlockTrapdoor.java
|
||||
+++ b/net/minecraft/server/BlockTrapdoor.java
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockTrapdoor extends BlockFacingHorizontal implements IBlockWaterlogged {
|
||||
|
||||
public static final BlockStateBoolean OPEN = BlockProperties.u;
|
||||
@@ -88,6 +90,19 @@
|
||||
boolean flag1 = world.isBlockIndirectlyPowered(blockposition);
|
||||
|
||||
if (flag1 != (Boolean) iblockdata.get(BlockTrapdoor.c)) {
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.World bworld = world.getWorld();
|
||||
+ org.bukkit.block.Block bblock = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+
|
||||
+ int power = bblock.getBlockPower();
|
||||
+ int oldPower = (Boolean) iblockdata.get(OPEN) ? 15 : 0;
|
||||
+
|
||||
+ if (oldPower == 0 ^ power == 0 || block.getBlockData().isPowerSource()) {
|
||||
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bblock, oldPower, power);
|
||||
+ world.getServer().getPluginManager().callEvent(eventRedstone);
|
||||
+ flag1 = eventRedstone.getNewCurrent() > 0;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
if ((Boolean) iblockdata.get(BlockTrapdoor.OPEN) != flag1) {
|
||||
iblockdata = (IBlockData) iblockdata.set(BlockTrapdoor.OPEN, flag1);
|
||||
this.a((EntityHuman) null, world, blockposition, flag1);
|
||||
@@ -0,0 +1,52 @@
|
||||
--- a/net/minecraft/server/BlockTripwire.java
|
||||
+++ b/net/minecraft/server/BlockTripwire.java
|
||||
@@ -5,6 +5,8 @@
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockTripwire extends Block {
|
||||
|
||||
public static final BlockStateBoolean POWERED = BlockProperties.w;
|
||||
@@ -132,6 +134,40 @@
|
||||
}
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Call interact even when triggering connected tripwire
|
||||
+ if (flag != flag1 && flag1 && (Boolean)iblockdata.get(ATTACHED)) {
|
||||
+ org.bukkit.World bworld = world.getWorld();
|
||||
+ org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
|
||||
+ org.bukkit.block.Block block = bworld.getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+ boolean allowed = false;
|
||||
+
|
||||
+ // If all of the events are cancelled block the tripwire trigger, else allow
|
||||
+ for (Object object : list) {
|
||||
+ if (object != null) {
|
||||
+ org.bukkit.event.Cancellable cancellable;
|
||||
+
|
||||
+ if (object instanceof EntityHuman) {
|
||||
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) object, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
|
||||
+ } else if (object instanceof Entity) {
|
||||
+ cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
|
||||
+ manager.callEvent((EntityInteractEvent) cancellable);
|
||||
+ } else {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ if (!cancellable.isCancelled()) {
|
||||
+ allowed = true;
|
||||
+ break;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ if (!allowed) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (flag1 != flag) {
|
||||
iblockdata = (IBlockData) iblockdata.set(BlockTripwire.POWERED, flag1);
|
||||
world.setTypeAndData(blockposition, iblockdata, 3);
|
||||
@@ -0,0 +1,29 @@
|
||||
--- a/net/minecraft/server/BlockTripwireHook.java
|
||||
+++ b/net/minecraft/server/BlockTripwireHook.java
|
||||
@@ -4,6 +4,8 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||
+
|
||||
public class BlockTripwireHook extends Block {
|
||||
|
||||
public static final BlockStateDirection FACING = BlockFacingHorizontal.FACING;
|
||||
@@ -134,6 +136,17 @@
|
||||
this.a(world, blockposition1, flag4, flag5, flag2, flag3);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ());
|
||||
+
|
||||
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
|
||||
+ world.getServer().getPluginManager().callEvent(eventRedstone);
|
||||
+
|
||||
+ if (eventRedstone.getNewCurrent() > 0) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
this.a(world, blockposition, flag4, flag5, flag2, flag3);
|
||||
if (!flag) {
|
||||
world.setTypeAndData(blockposition, (IBlockData) iblockdata3.set(BlockTripwireHook.FACING, enumdirection), 3);
|
||||
@@ -0,0 +1,65 @@
|
||||
--- a/net/minecraft/server/BlockTurtleEgg.java
|
||||
+++ b/net/minecraft/server/BlockTurtleEgg.java
|
||||
@@ -3,6 +3,12 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.event.entity.EntityInteractEvent;
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockTurtleEgg extends Block {
|
||||
|
||||
private static final VoxelShape c = Block.a(3.0D, 0.0D, 3.0D, 12.0D, 7.0D, 12.0D);
|
||||
@@ -36,6 +42,19 @@
|
||||
IBlockData iblockdata = world.getType(blockposition);
|
||||
|
||||
if (iblockdata.a(Blocks.TURTLE_EGG)) {
|
||||
+ // CraftBukkit start - Step on eggs
|
||||
+ org.bukkit.event.Cancellable cancellable;
|
||||
+ if (entity instanceof EntityHuman) {
|
||||
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
|
||||
+ } else {
|
||||
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), CraftBlock.at(world, blockposition));
|
||||
+ world.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
|
||||
+ }
|
||||
+
|
||||
+ if (cancellable.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.a(world, blockposition, iblockdata);
|
||||
}
|
||||
}
|
||||
@@ -62,9 +81,19 @@
|
||||
int i = (Integer) iblockdata.get(BlockTurtleEgg.a);
|
||||
|
||||
if (i < 2) {
|
||||
+ // CraftBukkit start - Call BlockGrowEvent
|
||||
+ if (!CraftEventFactory.handleBlockGrowEvent(worldserver, blockposition, iblockdata.set(BlockTurtleEgg.a, i + 1), 2)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_EGG_CRACK, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
|
||||
- worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockTurtleEgg.a, i + 1), 2);
|
||||
+ // worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockTurtleEgg.a, i + 1), 2); // CraftBukkit - handled above
|
||||
} else {
|
||||
+ // CraftBukkit start - Call BlockFadeEvent
|
||||
+ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, Blocks.AIR.getBlockData()).isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
worldserver.playSound((EntityHuman) null, blockposition, SoundEffects.ENTITY_TURTLE_EGG_HATCH, SoundCategory.BLOCKS, 0.7F, 0.9F + random.nextFloat() * 0.2F);
|
||||
worldserver.a(blockposition, false);
|
||||
|
||||
@@ -75,7 +104,7 @@
|
||||
entityturtle.setAgeRaw(-24000);
|
||||
entityturtle.setHomePos(blockposition);
|
||||
entityturtle.setPositionRotation((double) blockposition.getX() + 0.3D + (double) j * 0.2D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.3D, 0.0F, 0.0F);
|
||||
- worldserver.addEntity(entityturtle);
|
||||
+ worldserver.addEntity(entityturtle, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
--- a/net/minecraft/server/BlockVine.java
|
||||
+++ b/net/minecraft/server/BlockVine.java
|
||||
@@ -8,6 +8,8 @@
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
|
||||
+
|
||||
public class BlockVine extends Block {
|
||||
|
||||
public static final BlockStateBoolean UP = BlockSprawling.e;
|
||||
@@ -175,20 +177,24 @@
|
||||
BlockPosition blockposition3 = blockposition2.shift(enumdirection1);
|
||||
BlockPosition blockposition4 = blockposition2.shift(enumdirection2);
|
||||
|
||||
+ // CraftBukkit start - Call BlockSpreadEvent
|
||||
+ BlockPosition source = blockposition;
|
||||
+
|
||||
if (flag && a((IBlockAccess) worldserver, blockposition3, enumdirection1)) {
|
||||
- worldserver.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), true), 2);
|
||||
+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection1), true), 2);
|
||||
} else if (flag1 && a((IBlockAccess) worldserver, blockposition4, enumdirection2)) {
|
||||
- worldserver.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), true), 2);
|
||||
+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.getBlockData().set(getDirection(enumdirection2), true), 2);
|
||||
} else {
|
||||
EnumDirection enumdirection3 = enumdirection.opposite();
|
||||
|
||||
if (flag && worldserver.isEmpty(blockposition3) && a((IBlockAccess) worldserver, blockposition.shift(enumdirection1), enumdirection3)) {
|
||||
- worldserver.setTypeAndData(blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2);
|
||||
+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition3, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2);
|
||||
} else if (flag1 && worldserver.isEmpty(blockposition4) && a((IBlockAccess) worldserver, blockposition.shift(enumdirection2), enumdirection3)) {
|
||||
- worldserver.setTypeAndData(blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2);
|
||||
+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition4, (IBlockData) this.getBlockData().set(getDirection(enumdirection3), true), 2);
|
||||
} else if ((double) worldserver.random.nextFloat() < 0.05D && a((IBlockAccess) worldserver, blockposition2.up(), EnumDirection.UP)) {
|
||||
- worldserver.setTypeAndData(blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, true), 2);
|
||||
+ CraftEventFactory.handleBlockSpreadEvent(worldserver, source, blockposition2, (IBlockData) this.getBlockData().set(BlockVine.UP, true), 2);
|
||||
}
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
} else if (a((IBlockAccess) worldserver, blockposition2, enumdirection)) {
|
||||
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(getDirection(enumdirection), true), 2);
|
||||
@@ -218,7 +224,7 @@
|
||||
}
|
||||
|
||||
if (this.canSpread(iblockdata2)) {
|
||||
- worldserver.setTypeAndData(blockposition1, iblockdata2, 2);
|
||||
+ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition1, iblockdata2, 2); // CraftBukkit
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -233,7 +239,7 @@
|
||||
IBlockData iblockdata4 = this.a(iblockdata, iblockdata3, random);
|
||||
|
||||
if (iblockdata3 != iblockdata4 && this.canSpread(iblockdata4)) {
|
||||
- worldserver.setTypeAndData(blockposition2, iblockdata4, 2);
|
||||
+ CraftEventFactory.handleBlockSpreadEvent(worldserver, blockposition, blockposition2, iblockdata4, 2); // CraftBukkit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/BlockWaterLily.java
|
||||
+++ b/net/minecraft/server/BlockWaterLily.java
|
||||
@@ -11,7 +11,7 @@
|
||||
@Override
|
||||
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Entity entity) {
|
||||
super.a(iblockdata, world, blockposition, entity);
|
||||
- if (world instanceof WorldServer && entity instanceof EntityBoat) {
|
||||
+ if (world instanceof WorldServer && entity instanceof EntityBoat && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.AIR.getBlockData()).isCancelled()) { // CraftBukkit
|
||||
world.a(new BlockPosition(blockposition), true, entity);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/server/BlockWitherRose.java
|
||||
+++ b/net/minecraft/server/BlockWitherRose.java
|
||||
@@ -18,7 +18,7 @@
|
||||
EntityLiving entityliving = (EntityLiving) entity;
|
||||
|
||||
if (!entityliving.isInvulnerable(DamageSource.WITHER)) {
|
||||
- entityliving.addEffect(new MobEffect(MobEffects.WITHER, 40));
|
||||
+ entityliving.addEffect(new MobEffect(MobEffects.WITHER, 40), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.WITHER_ROSE); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
--- a/net/minecraft/server/BlockWitherSkull.java
|
||||
+++ b/net/minecraft/server/BlockWitherSkull.java
|
||||
@@ -3,6 +3,11 @@
|
||||
import java.util.Iterator;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
|
||||
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class BlockWitherSkull extends BlockSkull {
|
||||
|
||||
@Nullable
|
||||
@@ -26,6 +31,7 @@
|
||||
}
|
||||
|
||||
public static void a(World world, BlockPosition blockposition, TileEntitySkull tileentityskull) {
|
||||
+ if (world.captureBlockStates) return; // CraftBukkit
|
||||
if (!world.isClientSide) {
|
||||
IBlockData iblockdata = tileentityskull.getBlock();
|
||||
boolean flag = iblockdata.a(Blocks.WITHER_SKELETON_SKULL) || iblockdata.a(Blocks.WITHER_SKELETON_WALL_SKULL);
|
||||
@@ -35,12 +41,14 @@
|
||||
ShapeDetector.ShapeDetectorCollection shapedetector_shapedetectorcollection = shapedetector.a(world, blockposition);
|
||||
|
||||
if (shapedetector_shapedetectorcollection != null) {
|
||||
+ // CraftBukkit start - Use BlockStateListPopulator
|
||||
+ BlockStateListPopulator blockList = new BlockStateListPopulator(world);
|
||||
for (int i = 0; i < shapedetector.c(); ++i) {
|
||||
for (int j = 0; j < shapedetector.b(); ++j) {
|
||||
ShapeDetectorBlock shapedetectorblock = shapedetector_shapedetectorcollection.a(i, j, 0);
|
||||
|
||||
- world.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2);
|
||||
- world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a()));
|
||||
+ blockList.setTypeAndData(shapedetectorblock.getPosition(), Blocks.AIR.getBlockData(), 2); // CraftBukkit
|
||||
+ // world.triggerEffect(2001, shapedetectorblock.getPosition(), Block.getCombinedId(shapedetectorblock.a())); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +58,15 @@
|
||||
entitywither.setPositionRotation((double) blockposition1.getX() + 0.5D, (double) blockposition1.getY() + 0.55D, (double) blockposition1.getZ() + 0.5D, shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F, 0.0F);
|
||||
entitywither.aA = shapedetector_shapedetectorcollection.getFacing().n() == EnumDirection.EnumAxis.X ? 0.0F : 90.0F;
|
||||
entitywither.beginSpawnSequence();
|
||||
+ // CraftBukkit start
|
||||
+ if (!world.addEntity(entitywither, SpawnReason.BUILD_WITHER)) {
|
||||
+ return;
|
||||
+ }
|
||||
+ for (BlockPosition pos : blockList.getBlocks()) {
|
||||
+ world.triggerEffect(2001, pos, Block.getCombinedId(world.getType(pos)));
|
||||
+ }
|
||||
+ blockList.updateList();
|
||||
+ // CraftBukkit end
|
||||
Iterator iterator = world.a(EntityPlayer.class, entitywither.getBoundingBox().g(50.0D)).iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -58,7 +75,7 @@
|
||||
CriterionTriggers.n.a(entityplayer, (Entity) entitywither);
|
||||
}
|
||||
|
||||
- world.addEntity(entitywither);
|
||||
+ // world.addEntity(entitywither); // CraftBukkit - moved up
|
||||
|
||||
for (int k = 0; k < shapedetector.c(); ++k) {
|
||||
for (int l = 0; l < shapedetector.b(); ++l) {
|
||||
@@ -0,0 +1,62 @@
|
||||
--- a/net/minecraft/server/TileEntity.java
|
||||
+++ b/net/minecraft/server/TileEntity.java
|
||||
@@ -5,8 +5,18 @@
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.util.Supplier;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
|
||||
+import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
|
||||
+import org.bukkit.inventory.InventoryHolder;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class TileEntity {
|
||||
|
||||
+ // CraftBukkit start - data containers
|
||||
+ private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
|
||||
+ public CraftPersistentDataContainer persistentDataContainer;
|
||||
+ // CraftBukkit end
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private final TileEntityTypes<?> tileType;
|
||||
@Nullable
|
||||
@@ -38,6 +48,14 @@
|
||||
|
||||
public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) {
|
||||
this.position = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
|
||||
+ // CraftBukkit start - read container
|
||||
+ this.persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
|
||||
+
|
||||
+ NBTBase persistentDataTag = nbttagcompound.get("PublicBukkitValues");
|
||||
+ if (persistentDataTag instanceof NBTTagCompound) {
|
||||
+ this.persistentDataContainer.putAll((NBTTagCompound) persistentDataTag);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||
@@ -54,6 +72,11 @@
|
||||
nbttagcompound.setInt("x", this.position.getX());
|
||||
nbttagcompound.setInt("y", this.position.getY());
|
||||
nbttagcompound.setInt("z", this.position.getZ());
|
||||
+ // CraftBukkit start - store container
|
||||
+ if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) {
|
||||
+ nbttagcompound.set("PublicBukkitValues", this.persistentDataContainer.toTagCompound());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
return nbttagcompound;
|
||||
}
|
||||
}
|
||||
@@ -169,4 +192,13 @@
|
||||
}, this::getPosition});
|
||||
}
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start - add method
|
||||
+ public InventoryHolder getOwner() {
|
||||
+ if (world == null) return null;
|
||||
+ org.bukkit.block.BlockState state = world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()).getState();
|
||||
+ if (state instanceof InventoryHolder) return (InventoryHolder) state;
|
||||
+ return null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
--- a/net/minecraft/server/TileEntityBanner.java
|
||||
+++ b/net/minecraft/server/TileEntityBanner.java
|
||||
@@ -70,6 +70,11 @@
|
||||
}
|
||||
|
||||
this.patterns = nbttagcompound.getList("Patterns", 10);
|
||||
+ // CraftBukkit start
|
||||
+ while (this.patterns.size() > 20) {
|
||||
+ this.patterns.remove(20);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.h = null;
|
||||
this.g = true;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
--- a/net/minecraft/server/TileEntityBarrel.java
|
||||
+++ b/net/minecraft/server/TileEntityBarrel.java
|
||||
@@ -1,7 +1,49 @@
|
||||
package net.minecraft.server;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.List;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TileEntityBarrel extends TileEntityLootable {
|
||||
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ public List<HumanEntity> transaction = new ArrayList<>();
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+ public boolean opened;
|
||||
+
|
||||
+ @Override
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return this.items;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setMaxStackSize(int i) {
|
||||
+ maxStack = i;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
private NonNullList<ItemStack> items;
|
||||
private int b;
|
||||
|
||||
@@ -100,7 +142,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
- boolean flag = (Boolean) iblockdata.get(BlockBarrel.OPEN);
|
||||
+ boolean flag = (Boolean) iblockdata.get(BlockBarrel.OPEN) && !opened; // CraftBukkit - only set flag if Barrel isn't set open by API.
|
||||
|
||||
if (flag) {
|
||||
this.playOpenSound(iblockdata, SoundEffects.BLOCK_BARREL_CLOSE);
|
||||
@@ -0,0 +1,133 @@
|
||||
--- a/net/minecraft/server/TileEntityBeacon.java
|
||||
+++ b/net/minecraft/server/TileEntityBeacon.java
|
||||
@@ -8,6 +8,11 @@
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.potion.CraftPotionUtil;
|
||||
+import org.bukkit.potion.PotionEffect;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TileEntityBeacon extends TileEntity implements ITileInventory, ITickable {
|
||||
|
||||
public static final MobEffectList[][] a = new MobEffectList[][]{{MobEffects.FASTER_MOVEMENT, MobEffects.FASTER_DIG}, {MobEffects.RESISTANCE, MobEffects.JUMP}, {MobEffects.INCREASE_DAMAGE}, {MobEffects.REGENERATION}};
|
||||
@@ -24,6 +29,15 @@
|
||||
public IChatBaseComponent customName;
|
||||
public ChestLock chestLock;
|
||||
private final IContainerProperties containerProperties;
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ public PotionEffect getPrimaryEffect() {
|
||||
+ return (this.primaryEffect != null) ? CraftPotionUtil.toBukkit(new MobEffect(this.primaryEffect, getLevel(), getAmplification(), true, true)) : null;
|
||||
+ }
|
||||
+
|
||||
+ public PotionEffect getSecondaryEffect() {
|
||||
+ return (hasSecondaryEffect()) ? CraftPotionUtil.toBukkit(new MobEffect(this.secondaryEffect, getLevel(), getAmplification(), true, true)) : null;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public TileEntityBeacon() {
|
||||
super(TileEntityTypes.BEACON);
|
||||
@@ -192,39 +206,78 @@
|
||||
super.al_();
|
||||
}
|
||||
|
||||
- private void applyEffects() {
|
||||
- if (!this.world.isClientSide && this.primaryEffect != null) {
|
||||
- double d0 = (double) (this.levels * 10 + 10);
|
||||
+ // CraftBukkit start - split into components
|
||||
+ private byte getAmplification() {
|
||||
+ {
|
||||
byte b0 = 0;
|
||||
|
||||
if (this.levels >= 4 && this.primaryEffect == this.secondaryEffect) {
|
||||
b0 = 1;
|
||||
}
|
||||
|
||||
+ return b0;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private int getLevel() {
|
||||
+ {
|
||||
int i = (9 + this.levels * 2) * 20;
|
||||
+ return i;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ public List getHumansInRange() {
|
||||
+ {
|
||||
+ double d0 = (double) (this.levels * 10 + 10);
|
||||
+
|
||||
AxisAlignedBB axisalignedbb = (new AxisAlignedBB(this.position)).g(d0).b(0.0D, (double) this.world.getBuildHeight(), 0.0D);
|
||||
List<EntityHuman> list = this.world.a(EntityHuman.class, axisalignedbb);
|
||||
+
|
||||
+ return list;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ private void applyEffect(List list, MobEffectList effects, int i, int b0) {
|
||||
+ {
|
||||
Iterator iterator = list.iterator();
|
||||
|
||||
EntityHuman entityhuman;
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
entityhuman = (EntityHuman) iterator.next();
|
||||
- entityhuman.addEffect(new MobEffect(this.primaryEffect, i, b0, true, true));
|
||||
+ entityhuman.addEffect(new MobEffect(effects, i, b0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.BEACON);
|
||||
}
|
||||
+ }
|
||||
+ }
|
||||
|
||||
+ private boolean hasSecondaryEffect() {
|
||||
+ {
|
||||
if (this.levels >= 4 && this.primaryEffect != this.secondaryEffect && this.secondaryEffect != null) {
|
||||
- iterator = list.iterator();
|
||||
-
|
||||
- while (iterator.hasNext()) {
|
||||
- entityhuman = (EntityHuman) iterator.next();
|
||||
- entityhuman.addEffect(new MobEffect(this.secondaryEffect, i, 0, true, true));
|
||||
- }
|
||||
+ return true;
|
||||
}
|
||||
|
||||
+ return false;
|
||||
}
|
||||
}
|
||||
|
||||
+ private void applyEffects() {
|
||||
+ if (!this.world.isClientSide && this.primaryEffect != null) {
|
||||
+ double d0 = (double) (this.levels * 10 + 10);
|
||||
+ byte b0 = getAmplification();
|
||||
+
|
||||
+ int i = getLevel();
|
||||
+ List list = getHumansInRange();
|
||||
+
|
||||
+ applyEffect(list, this.primaryEffect, i, b0);
|
||||
+
|
||||
+ if (hasSecondaryEffect()) {
|
||||
+ applyEffect(list, this.secondaryEffect, i, 0);
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public void a(SoundEffect soundeffect) {
|
||||
this.world.playSound((EntityHuman) null, this.position, soundeffect, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
}
|
||||
@@ -254,8 +307,11 @@
|
||||
@Override
|
||||
public void load(IBlockData iblockdata, NBTTagCompound nbttagcompound) {
|
||||
super.load(iblockdata, nbttagcompound);
|
||||
- this.primaryEffect = b(nbttagcompound.getInt("Primary"));
|
||||
- this.secondaryEffect = b(nbttagcompound.getInt("Secondary"));
|
||||
+ // CraftBukkit start - persist manually set non-default beacon effects (SPIGOT-3598)
|
||||
+ this.primaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Primary"));
|
||||
+ this.secondaryEffect = MobEffectList.fromId(nbttagcompound.getInt("Secondary"));
|
||||
+ this.levels = nbttagcompound.getInt("Levels"); // SPIGOT-5053, use where available
|
||||
+ // CraftBukkit end
|
||||
if (nbttagcompound.hasKeyOfType("CustomName", 8)) {
|
||||
this.customName = IChatBaseComponent.ChatSerializer.a(nbttagcompound.getString("CustomName"));
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
--- a/net/minecraft/server/TileEntityBeehive.java
|
||||
+++ b/net/minecraft/server/TileEntityBeehive.java
|
||||
@@ -10,6 +10,7 @@
|
||||
private final List<TileEntityBeehive.HiveBee> bees = Lists.newArrayList();
|
||||
@Nullable
|
||||
public BlockPosition flowerPos = null;
|
||||
+ public int maxBees = 3; // CraftBukkit - allow setting max amount of bees a hive can hold
|
||||
|
||||
public TileEntityBeehive() {
|
||||
super(TileEntityTypes.BEEHIVE);
|
||||
@@ -49,7 +50,7 @@
|
||||
}
|
||||
|
||||
public boolean isFull() {
|
||||
- return this.bees.size() == 3;
|
||||
+ return this.bees.size() == this.maxBees; // CraftBukkit
|
||||
}
|
||||
|
||||
public void a(@Nullable EntityHuman entityhuman, IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
|
||||
@@ -66,7 +67,7 @@
|
||||
|
||||
if (entityhuman.getPositionVector().distanceSquared(entity.getPositionVector()) <= 16.0D) {
|
||||
if (!this.isSedated()) {
|
||||
- entitybee.setGoalTarget(entityhuman);
|
||||
+ entitybee.setGoalTarget(entityhuman, org.bukkit.event.entity.EntityTargetEvent.TargetReason.CLOSEST_PLAYER, true); // CraftBukkit
|
||||
} else {
|
||||
entitybee.setCannotEnterHiveTicks(400);
|
||||
}
|
||||
@@ -78,10 +79,16 @@
|
||||
}
|
||||
|
||||
private List<Entity> releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
|
||||
+ // CraftBukkit start - This allows us to bypass the night/rain/emergency check
|
||||
+ return releaseBees(iblockdata, tileentitybeehive_releasestatus, false);
|
||||
+ }
|
||||
+
|
||||
+ public List<Entity> releaseBees(IBlockData iblockdata, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) {
|
||||
List<Entity> list = Lists.newArrayList();
|
||||
|
||||
this.bees.removeIf((tileentitybeehive_hivebee) -> {
|
||||
- return this.releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus);
|
||||
+ return this.releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, force);
|
||||
+ // CraftBukkit end
|
||||
});
|
||||
return list;
|
||||
}
|
||||
@@ -107,7 +114,19 @@
|
||||
}
|
||||
|
||||
public void a(Entity entity, boolean flag, int i) {
|
||||
- if (this.bees.size() < 3) {
|
||||
+ if (this.bees.size() < this.maxBees) { // CraftBukkit
|
||||
+ // CraftBukkit start
|
||||
+ if (this.world != null) {
|
||||
+ org.bukkit.event.entity.EntityEnterBlockEvent event = new org.bukkit.event.entity.EntityEnterBlockEvent(entity.getBukkitEntity(), org.bukkit.craftbukkit.block.CraftBlock.at(world, getPosition()));
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ if (entity instanceof EntityBee) {
|
||||
+ ((EntityBee) entity).setCannotEnterHiveTicks(400);
|
||||
+ }
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
entity.stopRiding();
|
||||
entity.ejectPassengers();
|
||||
NBTTagCompound nbttagcompound = new NBTTagCompound();
|
||||
@@ -133,7 +152,13 @@
|
||||
}
|
||||
|
||||
private boolean releaseBee(IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus) {
|
||||
- if ((this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
|
||||
+ // CraftBukkit start - This allows us to bypass the night/rain/emergency check
|
||||
+ return releaseBee(iblockdata, tileentitybeehive_hivebee, list, tileentitybeehive_releasestatus, false);
|
||||
+ }
|
||||
+
|
||||
+ private boolean releaseBee(IBlockData iblockdata, TileEntityBeehive.HiveBee tileentitybeehive_hivebee, @Nullable List<Entity> list, TileEntityBeehive.ReleaseStatus tileentitybeehive_releasestatus, boolean force) {
|
||||
+ if (!force && (this.world.isNight() || this.world.isRaining()) && tileentitybeehive_releasestatus != TileEntityBeehive.ReleaseStatus.EMERGENCY) {
|
||||
+ // CraftBukkit end
|
||||
return false;
|
||||
} else {
|
||||
BlockPosition blockposition = this.getPosition();
|
||||
@@ -157,6 +182,18 @@
|
||||
if (!entity.getEntityType().a((Tag) TagsEntity.BEEHIVE_INHABITORS)) {
|
||||
return false;
|
||||
} else {
|
||||
+ // CraftBukkit start
|
||||
+ if (entity instanceof EntityBee) {
|
||||
+ float f = entity.getWidth();
|
||||
+ double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F);
|
||||
+ double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getAdjacentX();
|
||||
+ double d2 = (double) blockposition.getY() + 0.5D - (double) (entity.getHeight() / 2.0F);
|
||||
+ double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ();
|
||||
+
|
||||
+ entity.setPositionRotation(d1, d2, d3, entity.yaw, entity.pitch);
|
||||
+ }
|
||||
+ if (!this.world.addEntity(entity, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BEEHIVE)) return false; // CraftBukkit - SpawnReason, moved from below
|
||||
+ // CraftBukkit end
|
||||
if (entity instanceof EntityBee) {
|
||||
EntityBee entitybee = (EntityBee) entity;
|
||||
|
||||
@@ -186,6 +223,7 @@
|
||||
list.add(entitybee);
|
||||
}
|
||||
|
||||
+ /* // CraftBukkit start
|
||||
float f = entity.getWidth();
|
||||
double d0 = flag ? 0.0D : 0.55D + (double) (f / 2.0F);
|
||||
double d1 = (double) blockposition.getX() + 0.5D + d0 * (double) enumdirection.getAdjacentX();
|
||||
@@ -193,10 +231,11 @@
|
||||
double d3 = (double) blockposition.getZ() + 0.5D + d0 * (double) enumdirection.getAdjacentZ();
|
||||
|
||||
entity.setPositionRotation(d1, d2, d3, entity.yaw, entity.pitch);
|
||||
+ */ // CraftBukkit end
|
||||
}
|
||||
|
||||
this.world.playSound((EntityHuman) null, blockposition, SoundEffects.BLOCK_BEEHIVE_EXIT, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
- return this.world.addEntity(entity);
|
||||
+ return true; // return this.world.addEntity(entity); // CraftBukkit - moved up
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
@@ -234,6 +273,10 @@
|
||||
|
||||
if (this.releaseBee(iblockdata, tileentitybeehive_hivebee, (List) null, tileentitybeehive_releasestatus)) {
|
||||
iterator.remove();
|
||||
+ // CraftBukkit start
|
||||
+ } else {
|
||||
+ tileentitybeehive_hivebee.ticksInHive = tileentitybeehive_hivebee.minOccupationTicks / 2; // Not strictly Vanilla behaviour in cases where bees cannot spawn but still reasonable
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -276,6 +319,11 @@
|
||||
this.flowerPos = GameProfileSerializer.b(nbttagcompound.getCompound("FlowerPos"));
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (nbttagcompound.hasKey("Bukkit.MaxEntities")) {
|
||||
+ this.maxBees = nbttagcompound.getInt("Bukkit.MaxEntities");
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -285,6 +333,7 @@
|
||||
if (this.x()) {
|
||||
nbttagcompound.set("FlowerPos", GameProfileSerializer.a(this.flowerPos));
|
||||
}
|
||||
+ nbttagcompound.setInt("Bukkit.MaxEntities", this.maxBees); // CraftBukkit
|
||||
|
||||
return nbttagcompound;
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
--- a/net/minecraft/server/TileEntityBrewingStand.java
|
||||
+++ b/net/minecraft/server/TileEntityBrewingStand.java
|
||||
@@ -4,6 +4,16 @@
|
||||
import java.util.Iterator;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.List;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.event.inventory.BrewEvent;
|
||||
+import org.bukkit.event.inventory.BrewingStandFuelEvent;
|
||||
+import org.bukkit.inventory.InventoryHolder;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TileEntityBrewingStand extends TileEntityContainer implements IWorldInventory, ITickable {
|
||||
|
||||
private static final int[] b = new int[]{3};
|
||||
@@ -15,6 +25,36 @@
|
||||
private Item k;
|
||||
public int fuelLevel;
|
||||
protected final IContainerProperties a;
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ private int lastTick = MinecraftServer.currentTick;
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+ private int maxStack = 64;
|
||||
+
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return this.items;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
public TileEntityBrewingStand() {
|
||||
super(TileEntityTypes.BREWING_STAND);
|
||||
@@ -83,8 +123,19 @@
|
||||
ItemStack itemstack = (ItemStack) this.items.get(4);
|
||||
|
||||
if (this.fuelLevel <= 0 && itemstack.getItem() == Items.BLAZE_POWDER) {
|
||||
- this.fuelLevel = 20;
|
||||
- itemstack.subtract(1);
|
||||
+ // CraftBukkit start
|
||||
+ BrewingStandFuelEvent event = new BrewingStandFuelEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), CraftItemStack.asCraftMirror(itemstack), 20);
|
||||
+ this.world.getServer().getPluginManager().callEvent(event);
|
||||
+
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ this.fuelLevel = event.getFuelPower();
|
||||
+ if (this.fuelLevel > 0 && event.isConsuming()) {
|
||||
+ itemstack.subtract(1);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.update();
|
||||
}
|
||||
|
||||
@@ -92,9 +143,14 @@
|
||||
boolean flag1 = this.brewTime > 0;
|
||||
ItemStack itemstack1 = (ItemStack) this.items.get(3);
|
||||
|
||||
+ // CraftBukkit start - Use wall time instead of ticks for brewing
|
||||
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
|
||||
+ this.lastTick = MinecraftServer.currentTick;
|
||||
+
|
||||
if (flag1) {
|
||||
- --this.brewTime;
|
||||
- boolean flag2 = this.brewTime == 0;
|
||||
+ this.brewTime -= elapsedTicks;
|
||||
+ boolean flag2 = this.brewTime <= 0; // == -> <=
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (flag2 && flag) {
|
||||
this.j();
|
||||
@@ -168,6 +224,16 @@
|
||||
|
||||
private void j() {
|
||||
ItemStack itemstack = (ItemStack) this.items.get(3);
|
||||
+ // CraftBukkit start
|
||||
+ InventoryHolder owner = this.getOwner();
|
||||
+ if (owner != null) {
|
||||
+ BrewEvent event = new BrewEvent(world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), (org.bukkit.inventory.BrewerInventory) owner.getInventory(), this.fuelLevel);
|
||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
this.items.set(i, PotionBrewer.d(itemstack, (ItemStack) this.items.get(i)));
|
||||
@@ -0,0 +1,36 @@
|
||||
--- a/net/minecraft/server/TileEntityCampfire.java
|
||||
+++ b/net/minecraft/server/TileEntityCampfire.java
|
||||
@@ -4,6 +4,12 @@
|
||||
import java.util.Random;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.event.block.BlockCookEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TileEntityCampfire extends TileEntity implements Clearable, ITickable {
|
||||
|
||||
private final NonNullList<ItemStack> items;
|
||||
@@ -55,6 +61,20 @@
|
||||
}).orElse(itemstack);
|
||||
BlockPosition blockposition = this.getPosition();
|
||||
|
||||
+ // CraftBukkit start - fire BlockCookEvent
|
||||
+ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
|
||||
+ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
|
||||
+
|
||||
+ BlockCookEvent blockCookEvent = new BlockCookEvent(CraftBlock.at(this.world, this.position), source, result);
|
||||
+ this.world.getServer().getPluginManager().callEvent(blockCookEvent);
|
||||
+
|
||||
+ if (blockCookEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ result = blockCookEvent.getResult();
|
||||
+ itemstack1 = CraftItemStack.asNMSCopy(result);
|
||||
+ // CraftBukkit end
|
||||
InventoryUtils.dropItem(this.world, (double) blockposition.getX(), (double) blockposition.getY(), (double) blockposition.getZ(), itemstack1);
|
||||
this.items.set(i, ItemStack.b);
|
||||
this.k();
|
||||
@@ -0,0 +1,127 @@
|
||||
--- a/net/minecraft/server/TileEntityChest.java
|
||||
+++ b/net/minecraft/server/TileEntityChest.java
|
||||
@@ -3,6 +3,11 @@
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TileEntityChest extends TileEntityLootable implements ITickable {
|
||||
|
||||
private NonNullList<ItemStack> items;
|
||||
@@ -11,6 +16,37 @@
|
||||
public int viewingCount;
|
||||
private int j;
|
||||
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+ public boolean opened;
|
||||
+
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return this.items;
|
||||
+ }
|
||||
+
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected TileEntityChest(TileEntityTypes<?> tileentitytypes) {
|
||||
super(tileentitytypes);
|
||||
this.items = NonNullList.a(27, ItemStack.b);
|
||||
@@ -61,6 +97,13 @@
|
||||
this.b = this.a;
|
||||
float f = 0.1F;
|
||||
|
||||
+ // CraftBukkit start - If chest is forced open by API, remove a viewer due to playBlockAction() call and don't tick to prevent sound effects.
|
||||
+ if (opened) {
|
||||
+ this.viewingCount--;
|
||||
+ return;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
if (this.viewingCount > 0 && this.a == 0.0F) {
|
||||
this.playOpenSound(SoundEffects.BLOCK_CHEST_OPEN);
|
||||
}
|
||||
@@ -155,8 +198,20 @@
|
||||
if (this.viewingCount < 0) {
|
||||
this.viewingCount = 0;
|
||||
}
|
||||
+ int oldPower = Math.max(0, Math.min(15, this.viewingCount)); // CraftBukkit - Get power before new viewer is added
|
||||
|
||||
++this.viewingCount;
|
||||
+ if (this.world == null) return; // CraftBukkit
|
||||
+
|
||||
+ // CraftBukkit start - Call redstone event
|
||||
+ if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) {
|
||||
+ int newPower = Math.max(0, Math.min(15, this.viewingCount));
|
||||
+
|
||||
+ if (oldPower != newPower) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.onOpen();
|
||||
}
|
||||
|
||||
@@ -165,7 +220,18 @@
|
||||
@Override
|
||||
public void closeContainer(EntityHuman entityhuman) {
|
||||
if (!entityhuman.isSpectator()) {
|
||||
+ int oldPower = Math.max(0, Math.min(15, this.viewingCount)); // CraftBukkit - Get power before new viewer is added
|
||||
--this.viewingCount;
|
||||
+
|
||||
+ // CraftBukkit start - Call redstone event
|
||||
+ if (this.getBlock().getBlock() == Blocks.TRAPPED_CHEST) {
|
||||
+ int newPower = Math.max(0, Math.min(15, this.viewingCount));
|
||||
+
|
||||
+ if (oldPower != newPower) {
|
||||
+ org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(world, position, oldPower, newPower);
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
this.onOpen();
|
||||
}
|
||||
|
||||
@@ -175,7 +241,7 @@
|
||||
Block block = this.getBlock().getBlock();
|
||||
|
||||
if (block instanceof BlockChest) {
|
||||
- this.world.playBlockAction(this.position, block, 1, this.viewingCount);
|
||||
+ if (!opened) this.world.playBlockAction(this.position, block, 1, this.viewingCount); // CraftBukkit
|
||||
this.world.applyPhysics(this.position, block);
|
||||
}
|
||||
|
||||
@@ -216,4 +282,11 @@
|
||||
protected Container createContainer(int i, PlayerInventory playerinventory) {
|
||||
return ContainerChest.a(i, playerinventory, this);
|
||||
}
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public boolean isFilteredNBT() {
|
||||
+ return true;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
--- a/net/minecraft/server/TileEntityCommand.java
|
||||
+++ b/net/minecraft/server/TileEntityCommand.java
|
||||
@@ -9,6 +9,13 @@
|
||||
private boolean c;
|
||||
private boolean g;
|
||||
private final CommandBlockListenerAbstract h = new CommandBlockListenerAbstract() {
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||||
+ return new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, TileEntityCommand.this);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
@Override
|
||||
public void setCommand(String s) {
|
||||
super.setCommand(s);
|
||||
@@ -0,0 +1,57 @@
|
||||
--- a/net/minecraft/server/TileEntityConduit.java
|
||||
+++ b/net/minecraft/server/TileEntityConduit.java
|
||||
@@ -7,6 +7,11 @@
|
||||
import java.util.UUID;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TileEntityConduit extends TileEntity implements ITickable {
|
||||
|
||||
private static final Block[] b = new Block[]{Blocks.PRISMARINE, Blocks.PRISMARINE_BRICKS, Blocks.SEA_LANTERN, Blocks.DARK_PRISMARINE};
|
||||
@@ -158,7 +163,7 @@
|
||||
EntityHuman entityhuman = (EntityHuman) iterator.next();
|
||||
|
||||
if (this.position.a((BaseBlockPosition) entityhuman.getChunkCoordinates(), (double) j) && entityhuman.isInWaterOrRain()) {
|
||||
- entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true));
|
||||
+ entityhuman.addEffect(new MobEffect(MobEffects.CONDUIT_POWER, 260, 0, true, true), org.bukkit.event.entity.EntityPotionEffectEvent.Cause.CONDUIT); // CraftBukkit
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +180,7 @@
|
||||
this.target = this.x();
|
||||
this.k = null;
|
||||
} else if (this.target == null) {
|
||||
- List<EntityLiving> list = this.world.a(EntityLiving.class, this.m(), (entityliving1) -> {
|
||||
+ List<EntityLiving> list = this.world.a(EntityLiving.class, this.m(), (java.util.function.Predicate<EntityLiving>) (entityliving1) -> { // CraftBukkit - decompile error
|
||||
return entityliving1 instanceof IMonster && entityliving1.isInWaterOrRain();
|
||||
});
|
||||
|
||||
@@ -187,8 +192,13 @@
|
||||
}
|
||||
|
||||
if (this.target != null) {
|
||||
- this.world.playSound((EntityHuman) null, this.target.locX(), this.target.locY(), this.target.locZ(), SoundEffects.BLOCK_CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
- this.target.damageEntity(DamageSource.MAGIC, 4.0F);
|
||||
+ // CraftBukkit start
|
||||
+ CraftEventFactory.blockDamage = CraftBlock.at(this.world, this.position);
|
||||
+ if (this.target.damageEntity(DamageSource.MAGIC, 4.0F)) {
|
||||
+ this.world.playSound((EntityHuman) null, this.target.locX(), this.target.locY(), this.target.locZ(), SoundEffects.BLOCK_CONDUIT_ATTACK_TARGET, SoundCategory.BLOCKS, 1.0F, 1.0F);
|
||||
+ }
|
||||
+ CraftEventFactory.blockDamage = null;
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
|
||||
if (entityliving != this.target) {
|
||||
@@ -221,7 +231,7 @@
|
||||
|
||||
@Nullable
|
||||
private EntityLiving x() {
|
||||
- List<EntityLiving> list = this.world.a(EntityLiving.class, this.m(), (entityliving) -> {
|
||||
+ List<EntityLiving> list = this.world.a(EntityLiving.class, this.m(), (java.util.function.Predicate<EntityLiving>) (entityliving) -> { // CraftBukkit - decompile error
|
||||
return entityliving.getUniqueID().equals(this.k);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
--- a/net/minecraft/server/TileEntityContainer.java
|
||||
+++ b/net/minecraft/server/TileEntityContainer.java
|
||||
@@ -76,4 +76,12 @@
|
||||
}
|
||||
|
||||
protected abstract Container createContainer(int i, PlayerInventory playerinventory);
|
||||
+
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public org.bukkit.Location getLocation() {
|
||||
+ if (world == null) return null;
|
||||
+ return new org.bukkit.Location(world.getWorld(), position.getX(), position.getY(), position.getZ());
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
--- a/net/minecraft/server/TileEntityDispenser.java
|
||||
+++ b/net/minecraft/server/TileEntityDispenser.java
|
||||
@@ -2,11 +2,48 @@
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import java.util.List;
|
||||
+
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TileEntityDispenser extends TileEntityLootable {
|
||||
|
||||
private static final Random a = new Random();
|
||||
private NonNullList<ItemStack> items;
|
||||
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return this.items;
|
||||
+ }
|
||||
+
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
protected TileEntityDispenser(TileEntityTypes<?> tileentitytypes) {
|
||||
super(tileentitytypes);
|
||||
this.items = NonNullList.a(9, ItemStack.b);
|
||||
@@ -0,0 +1,62 @@
|
||||
--- a/net/minecraft/server/TileEntityEndGateway.java
|
||||
+++ b/net/minecraft/server/TileEntityEndGateway.java
|
||||
@@ -7,6 +7,13 @@
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
+import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TileEntityEndGateway extends TileEntityEnderPortal implements ITickable {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
@@ -117,7 +124,7 @@
|
||||
public void b(Entity entity) {
|
||||
if (this.world instanceof WorldServer && !this.f()) {
|
||||
this.c = 100;
|
||||
- if (this.exitPortal == null && this.world.getDimensionKey() == World.THE_END) {
|
||||
+ if (this.exitPortal == null && this.world.getTypeKey() == DimensionManager.THE_END) { // CraftBukkit - work in alternate worlds
|
||||
this.a((WorldServer) this.world);
|
||||
}
|
||||
|
||||
@@ -142,6 +149,27 @@
|
||||
entity1 = entity.getRootVehicle();
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - Fire PlayerTeleportEvent
|
||||
+ if (entity1 instanceof EntityPlayer) {
|
||||
+ org.bukkit.craftbukkit.entity.CraftPlayer player = (CraftPlayer) entity1.getBukkitEntity();
|
||||
+ org.bukkit.Location location = new Location(world.getWorld(), (double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D);
|
||||
+ location.setPitch(player.getLocation().getPitch());
|
||||
+ location.setYaw(player.getLocation().getYaw());
|
||||
+
|
||||
+ PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.END_GATEWAY);
|
||||
+ Bukkit.getPluginManager().callEvent(teleEvent);
|
||||
+ if (teleEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ entity1.resetPortalCooldown();
|
||||
+ ((EntityPlayer) entity1).playerConnection.teleport(teleEvent.getTo());
|
||||
+ this.h(); // CraftBukkit - call at end of method
|
||||
+ return;
|
||||
+
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
entity1.resetPortalCooldown();
|
||||
entity1.enderTeleportAndLoad((double) blockposition.getX() + 0.5D, (double) blockposition.getY(), (double) blockposition.getZ() + 0.5D);
|
||||
}
|
||||
@@ -246,7 +274,7 @@
|
||||
}
|
||||
|
||||
private void a(WorldServer worldserver, BlockPosition blockposition) {
|
||||
- WorldGenerator.END_GATEWAY.b((WorldGenFeatureConfiguration) WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition);
|
||||
+ WorldGenerator.END_GATEWAY.b(WorldGenEndGatewayConfiguration.a(this.getPosition(), false)).a(worldserver, worldserver.getChunkProvider().getChunkGenerator(), new Random(), blockposition); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public void a(BlockPosition blockposition, boolean flag) {
|
||||
@@ -0,0 +1,187 @@
|
||||
--- a/net/minecraft/server/TileEntityFurnace.java
|
||||
+++ b/net/minecraft/server/TileEntityFurnace.java
|
||||
@@ -10,6 +10,17 @@
|
||||
import java.util.Map;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.block.CraftBlock;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.entity.Player;
|
||||
+import org.bukkit.event.inventory.FurnaceBurnEvent;
|
||||
+import org.bukkit.event.inventory.FurnaceExtractEvent;
|
||||
+import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public abstract class TileEntityFurnace extends TileEntityContainer implements IWorldInventory, RecipeHolder, AutoRecipeOutput, ITickable {
|
||||
|
||||
private static final int[] g = new int[]{0};
|
||||
@@ -137,6 +148,36 @@
|
||||
return map;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return this.items;
|
||||
+ }
|
||||
+
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
private static boolean b(Item item) {
|
||||
return TagsItem.NON_FLAMMABLE_WOOD.isTagged(item);
|
||||
}
|
||||
@@ -223,12 +264,23 @@
|
||||
this.cookTime = MathHelper.clamp(this.cookTime - 2, 0, this.cookTimeTotal);
|
||||
}
|
||||
} else {
|
||||
- IRecipe<?> irecipe = (IRecipe) this.world.getCraftingManager().craft(this.c, this, this.world).orElse((Object) null);
|
||||
+ IRecipe irecipe = this.world.getCraftingManager().craft((Recipes<RecipeCooking>) this.c, this, this.world).orElse(null); // Eclipse fail
|
||||
|
||||
if (!this.isBurning() && this.canBurn(irecipe)) {
|
||||
- this.burnTime = this.fuelTime(itemstack);
|
||||
+ // CraftBukkit start
|
||||
+ CraftItemStack fuel = CraftItemStack.asCraftMirror(itemstack);
|
||||
+
|
||||
+ FurnaceBurnEvent furnaceBurnEvent = new FurnaceBurnEvent(CraftBlock.at(this.world, this.position), fuel, fuelTime(itemstack));
|
||||
+ this.world.getServer().getPluginManager().callEvent(furnaceBurnEvent);
|
||||
+
|
||||
+ if (furnaceBurnEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ this.burnTime = furnaceBurnEvent.getBurnTime();
|
||||
this.ticksForCurrentFuel = this.burnTime;
|
||||
- if (this.isBurning()) {
|
||||
+ if (this.isBurning() && furnaceBurnEvent.isBurning()) {
|
||||
+ // CraftBukkit end
|
||||
flag1 = true;
|
||||
if (!itemstack.isEmpty()) {
|
||||
Item item = itemstack.getItem();
|
||||
@@ -290,11 +342,38 @@
|
||||
ItemStack itemstack1 = irecipe.getResult();
|
||||
ItemStack itemstack2 = (ItemStack) this.items.get(2);
|
||||
|
||||
+ // CraftBukkit start - fire FurnaceSmeltEvent
|
||||
+ CraftItemStack source = CraftItemStack.asCraftMirror(itemstack);
|
||||
+ org.bukkit.inventory.ItemStack result = CraftItemStack.asBukkitCopy(itemstack1);
|
||||
+
|
||||
+ FurnaceSmeltEvent furnaceSmeltEvent = new FurnaceSmeltEvent(this.world.getWorld().getBlockAt(position.getX(), position.getY(), position.getZ()), source, result);
|
||||
+ this.world.getServer().getPluginManager().callEvent(furnaceSmeltEvent);
|
||||
+
|
||||
+ if (furnaceSmeltEvent.isCancelled()) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ result = furnaceSmeltEvent.getResult();
|
||||
+ itemstack1 = CraftItemStack.asNMSCopy(result);
|
||||
+
|
||||
+ if (!itemstack1.isEmpty()) {
|
||||
+ if (itemstack2.isEmpty()) {
|
||||
+ this.items.set(2, itemstack1.cloneItemStack());
|
||||
+ } else if (CraftItemStack.asCraftMirror(itemstack2).isSimilar(result)) {
|
||||
+ itemstack2.add(itemstack1.getCount());
|
||||
+ } else {
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ /*
|
||||
if (itemstack2.isEmpty()) {
|
||||
this.items.set(2, itemstack1.cloneItemStack());
|
||||
} else if (itemstack2.getItem() == itemstack1.getItem()) {
|
||||
itemstack2.add(1);
|
||||
}
|
||||
+ */
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (!this.world.isClientSide) {
|
||||
this.a(irecipe);
|
||||
@@ -319,7 +398,7 @@
|
||||
}
|
||||
|
||||
protected int getRecipeCookingTime() {
|
||||
- return (Integer) this.world.getCraftingManager().craft(this.c, this, this.world).map(RecipeCooking::getCookingTime).orElse(200);
|
||||
+ return (this.hasWorld()) ? (Integer) this.world.getCraftingManager().craft((Recipes<RecipeCooking>) this.c, this, this.world).map(RecipeCooking::getCookingTime).orElse(200) : 200; // CraftBukkit - SPIGOT-4302 // Eclipse fail
|
||||
}
|
||||
|
||||
public static boolean isFuel(ItemStack itemstack) {
|
||||
@@ -446,14 +525,20 @@
|
||||
@Override
|
||||
public void b(EntityHuman entityhuman) {}
|
||||
|
||||
- public void d(EntityHuman entityhuman) {
|
||||
- List<IRecipe<?>> list = this.a(entityhuman.world, entityhuman.getPositionVector());
|
||||
+ public void d(EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit
|
||||
+ List<IRecipe<?>> list = this.a(entityhuman.world, entityhuman.getPositionVector(), entityhuman, itemstack, amount); // CraftBukkit
|
||||
|
||||
entityhuman.discoverRecipes(list);
|
||||
this.n.clear();
|
||||
}
|
||||
|
||||
public List<IRecipe<?>> a(World world, Vec3D vec3d) {
|
||||
+ // CraftBukkit start
|
||||
+ return this.a(world, vec3d, null, null, 0);
|
||||
+ }
|
||||
+
|
||||
+ public List<IRecipe<?>> a(World world, Vec3D vec3d, EntityHuman entityhuman, ItemStack itemstack, int amount) {
|
||||
+ // CraftBukkit end
|
||||
List<IRecipe<?>> list = Lists.newArrayList();
|
||||
ObjectIterator objectiterator = this.n.object2IntEntrySet().iterator();
|
||||
|
||||
@@ -462,14 +547,14 @@
|
||||
|
||||
world.getCraftingManager().getRecipe((MinecraftKey) entry.getKey()).ifPresent((irecipe) -> {
|
||||
list.add(irecipe);
|
||||
- a(world, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience());
|
||||
+ a(world, vec3d, entry.getIntValue(), ((RecipeCooking) irecipe).getExperience(), entityhuman, itemstack, amount); // CraftBukkit
|
||||
});
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
- private static void a(World world, Vec3D vec3d, int i, float f) {
|
||||
+ private void a(World world, Vec3D vec3d, int i, float f, EntityHuman entityhuman, ItemStack itemstack, int amount) { // CraftBukkit
|
||||
int j = MathHelper.d((float) i * f);
|
||||
float f1 = MathHelper.h((float) i * f);
|
||||
|
||||
@@ -477,6 +562,14 @@
|
||||
++j;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start - fire FurnaceExtractEvent
|
||||
+ if (amount != 0) {
|
||||
+ FurnaceExtractEvent event = new FurnaceExtractEvent((Player) entityhuman.getBukkitEntity(), CraftBlock.at(world, position), org.bukkit.craftbukkit.util.CraftMagicNumbers.getMaterial(itemstack.getItem()), amount, j);
|
||||
+ world.getServer().getPluginManager().callEvent(event);
|
||||
+ j = event.getExpToDrop();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
while (j > 0) {
|
||||
int k = EntityExperienceOrb.getOrbValue(j);
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
--- a/net/minecraft/server/TileEntityHopper.java
|
||||
+++ b/net/minecraft/server/TileEntityHopper.java
|
||||
@@ -7,12 +7,51 @@
|
||||
import java.util.stream.IntStream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
+import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
+import org.bukkit.inventory.Inventory;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TileEntityHopper extends TileEntityLootable implements IHopper, ITickable {
|
||||
|
||||
private NonNullList<ItemStack> items;
|
||||
private int j;
|
||||
private long k;
|
||||
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return this.items;
|
||||
+ }
|
||||
+
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public TileEntityHopper() {
|
||||
super(TileEntityTypes.HOPPER);
|
||||
this.items = NonNullList.a(5, ItemStack.b);
|
||||
@@ -138,7 +177,28 @@
|
||||
for (int i = 0; i < this.getSize(); ++i) {
|
||||
if (!this.getItem(i).isEmpty()) {
|
||||
ItemStack itemstack = this.getItem(i).cloneItemStack();
|
||||
- ItemStack itemstack1 = addItem(this, iinventory, this.splitStack(i, 1), enumdirection);
|
||||
+ // ItemStack itemstack1 = addItem(this, iinventory, this.splitStack(i, 1), enumdirection);
|
||||
+
|
||||
+ // CraftBukkit start - Call event when pushing items into other inventories
|
||||
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(this.splitStack(i, 1));
|
||||
+
|
||||
+ Inventory destinationInventory;
|
||||
+ // Have to special case large chests as they work oddly
|
||||
+ if (iinventory instanceof InventoryLargeChest) {
|
||||
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
|
||||
+ } else {
|
||||
+ destinationInventory = iinventory.getOwner().getInventory();
|
||||
+ }
|
||||
+
|
||||
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(this.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
|
||||
+ this.getWorld().getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ this.setItem(i, itemstack);
|
||||
+ this.setCooldown(8); // Delay hopper checks
|
||||
+ return false;
|
||||
+ }
|
||||
+ ItemStack itemstack1 = addItem(this, iinventory, CraftItemStack.asNMSCopy(event.getItem()), enumdirection);
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (itemstack1.isEmpty()) {
|
||||
iinventory.update();
|
||||
@@ -203,7 +263,34 @@
|
||||
|
||||
if (!itemstack.isEmpty() && b(iinventory, itemstack, i, enumdirection)) {
|
||||
ItemStack itemstack1 = itemstack.cloneItemStack();
|
||||
- ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null);
|
||||
+ // ItemStack itemstack2 = addItem(iinventory, ihopper, iinventory.splitStack(i, 1), (EnumDirection) null);
|
||||
+ // CraftBukkit start - Call event on collection of items from inventories into the hopper
|
||||
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(iinventory.splitStack(i, 1));
|
||||
+
|
||||
+ Inventory sourceInventory;
|
||||
+ // Have to special case large chests as they work oddly
|
||||
+ if (iinventory instanceof InventoryLargeChest) {
|
||||
+ sourceInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
|
||||
+ } else {
|
||||
+ sourceInventory = iinventory.getOwner().getInventory();
|
||||
+ }
|
||||
+
|
||||
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(sourceInventory, oitemstack.clone(), ihopper.getOwner().getInventory(), false);
|
||||
+
|
||||
+ ihopper.getWorld().getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ iinventory.setItem(i, itemstack1);
|
||||
+
|
||||
+ if (ihopper instanceof TileEntityHopper) {
|
||||
+ ((TileEntityHopper) ihopper).setCooldown(8); // Delay hopper checks
|
||||
+ } else if (ihopper instanceof EntityMinecartHopper) {
|
||||
+ ((EntityMinecartHopper) ihopper).setCooldown(4); // Delay hopper minecart checks
|
||||
+ }
|
||||
+
|
||||
+ return false;
|
||||
+ }
|
||||
+ ItemStack itemstack2 = addItem(iinventory, ihopper, CraftItemStack.asNMSCopy(event.getItem()), null);
|
||||
+ // CraftBukkit end
|
||||
|
||||
if (itemstack2.isEmpty()) {
|
||||
iinventory.update();
|
||||
@@ -218,6 +305,13 @@
|
||||
|
||||
public static boolean a(IInventory iinventory, EntityItem entityitem) {
|
||||
boolean flag = false;
|
||||
+ // CraftBukkit start
|
||||
+ InventoryPickupItemEvent event = new InventoryPickupItemEvent(iinventory.getOwner().getInventory(), (org.bukkit.entity.Item) entityitem.getBukkitEntity());
|
||||
+ entityitem.world.getServer().getPluginManager().callEvent(event);
|
||||
+ if (event.isCancelled()) {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
ItemStack itemstack = entityitem.getItemStack().cloneItemStack();
|
||||
ItemStack itemstack1 = addItem((IInventory) null, iinventory, itemstack, (EnumDirection) null);
|
||||
|
||||
@@ -0,0 +1,152 @@
|
||||
--- a/net/minecraft/server/TileEntityLectern.java
|
||||
+++ b/net/minecraft/server/TileEntityLectern.java
|
||||
@@ -2,9 +2,63 @@
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
-public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory {
|
||||
+// CraftBukkit start
|
||||
+import java.util.ArrayList;
|
||||
+import java.util.Arrays;
|
||||
+import java.util.List;
|
||||
+import java.util.UUID;
|
||||
+import org.bukkit.Location;
|
||||
+import org.bukkit.block.Lectern;
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+import org.bukkit.inventory.InventoryHolder;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
+public class TileEntityLectern extends TileEntity implements Clearable, ITileInventory, ICommandListener { // CraftBukkit - ICommandListener
|
||||
+
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ public final IInventory inventory = new LecternInventory();
|
||||
+ public class LecternInventory implements IInventory {
|
||||
+
|
||||
+ public List<HumanEntity> transaction = new ArrayList<>();
|
||||
+ private int maxStack = 1;
|
||||
+
|
||||
+ @Override
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return Arrays.asList(book);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public void setMaxStackSize(int i) {
|
||||
+ maxStack = i;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public Location getLocation() {
|
||||
+ return new Location(world.getWorld(), position.getX(), position.getY(), position.getZ());
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public InventoryHolder getOwner() {
|
||||
+ return (Lectern) TileEntityLectern.this.getOwner();
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
- public final IInventory inventory = new IInventory() {
|
||||
@Override
|
||||
public int getSize() {
|
||||
return 1;
|
||||
@@ -49,11 +103,20 @@
|
||||
}
|
||||
|
||||
@Override
|
||||
- public void setItem(int i, ItemStack itemstack) {}
|
||||
+ // CraftBukkit start
|
||||
+ public void setItem(int i, ItemStack itemstack) {
|
||||
+ if (i == 0) {
|
||||
+ TileEntityLectern.this.setBook(itemstack);
|
||||
+ if (TileEntityLectern.this.getWorld() != null) {
|
||||
+ BlockLectern.setHasBook(TileEntityLectern.this.getWorld(), TileEntityLectern.this.getPosition(), TileEntityLectern.this.getBlock(), TileEntityLectern.this.hasBook());
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
|
||||
@Override
|
||||
public int getMaxStackSize() {
|
||||
- return 1;
|
||||
+ return maxStack; // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -135,7 +198,7 @@
|
||||
if (j != this.page) {
|
||||
this.page = j;
|
||||
this.update();
|
||||
- BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock());
|
||||
+ if (this.world != null) BlockLectern.a(this.getWorld(), this.getPosition(), this.getBlock()); // CraftBukkit
|
||||
}
|
||||
|
||||
}
|
||||
@@ -158,6 +221,32 @@
|
||||
return itemstack;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid) {
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||||
+ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean shouldSendSuccess() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean shouldSendFailure() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean shouldBroadcastCommands() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ // CraftBukkit end
|
||||
private CommandListenerWrapper a(@Nullable EntityHuman entityhuman) {
|
||||
String s;
|
||||
Object object;
|
||||
@@ -172,7 +261,8 @@
|
||||
|
||||
Vec3D vec3d = Vec3D.a((BaseBlockPosition) this.position);
|
||||
|
||||
- return new CommandListenerWrapper(ICommandListener.DUMMY, vec3d, Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityhuman);
|
||||
+ // CraftBukkit - this
|
||||
+ return new CommandListenerWrapper(this, vec3d, Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityhuman);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -211,7 +301,7 @@
|
||||
|
||||
@Override
|
||||
public Container createMenu(int i, PlayerInventory playerinventory, EntityHuman entityhuman) {
|
||||
- return new ContainerLectern(i, this.inventory, this.containerProperties);
|
||||
+ return new ContainerLectern(i, this.inventory, this.containerProperties, playerinventory); // CraftBukkit
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -0,0 +1,68 @@
|
||||
--- a/net/minecraft/server/TileEntityShulkerBox.java
|
||||
+++ b/net/minecraft/server/TileEntityShulkerBox.java
|
||||
@@ -4,6 +4,11 @@
|
||||
import java.util.stream.IntStream;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
+// CraftBukkit start
|
||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||
+import org.bukkit.entity.HumanEntity;
|
||||
+// CraftBukkit end
|
||||
+
|
||||
public class TileEntityShulkerBox extends TileEntityLootable implements IWorldInventory, ITickable {
|
||||
|
||||
private static final int[] a = IntStream.range(0, 27).toArray();
|
||||
@@ -16,6 +21,37 @@
|
||||
private EnumColor l;
|
||||
private boolean m;
|
||||
|
||||
+ // CraftBukkit start - add fields and methods
|
||||
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
|
||||
+ private int maxStack = MAX_STACK;
|
||||
+ public boolean opened;
|
||||
+
|
||||
+ public List<ItemStack> getContents() {
|
||||
+ return this.contents;
|
||||
+ }
|
||||
+
|
||||
+ public void onOpen(CraftHumanEntity who) {
|
||||
+ transaction.add(who);
|
||||
+ }
|
||||
+
|
||||
+ public void onClose(CraftHumanEntity who) {
|
||||
+ transaction.remove(who);
|
||||
+ }
|
||||
+
|
||||
+ public List<HumanEntity> getViewers() {
|
||||
+ return transaction;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public int getMaxStackSize() {
|
||||
+ return maxStack;
|
||||
+ }
|
||||
+
|
||||
+ public void setMaxStackSize(int size) {
|
||||
+ maxStack = size;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public TileEntityShulkerBox(@Nullable EnumColor enumcolor) {
|
||||
super(TileEntityTypes.SHULKER_BOX);
|
||||
this.contents = NonNullList.a(27, ItemStack.b);
|
||||
@@ -178,6 +214,7 @@
|
||||
}
|
||||
|
||||
++this.viewingCount;
|
||||
+ if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call.
|
||||
this.world.playBlockAction(this.position, this.getBlock().getBlock(), 1, this.viewingCount);
|
||||
if (this.viewingCount == 1) {
|
||||
this.world.playSound((EntityHuman) null, this.position, SoundEffects.BLOCK_SHULKER_BOX_OPEN, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
||||
@@ -190,6 +227,7 @@
|
||||
public void closeContainer(EntityHuman entityhuman) {
|
||||
if (!entityhuman.isSpectator()) {
|
||||
--this.viewingCount;
|
||||
+ if (opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call.
|
||||
this.world.playBlockAction(this.position, this.getBlock().getBlock(), 1, this.viewingCount);
|
||||
if (this.viewingCount <= 0) {
|
||||
this.world.playSound((EntityHuman) null, this.position, SoundEffects.BLOCK_SHULKER_BOX_CLOSE, SoundCategory.BLOCKS, 0.5F, this.world.random.nextFloat() * 0.1F + 0.9F);
|
||||
@@ -0,0 +1,118 @@
|
||||
--- a/net/minecraft/server/TileEntitySign.java
|
||||
+++ b/net/minecraft/server/TileEntitySign.java
|
||||
@@ -3,7 +3,7 @@
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
-public class TileEntitySign extends TileEntity {
|
||||
+public class TileEntitySign extends TileEntity implements ICommandListener { // CraftBukkit - implements
|
||||
|
||||
public final IChatBaseComponent[] lines;
|
||||
public boolean isEditable;
|
||||
@@ -29,6 +29,12 @@
|
||||
nbttagcompound.setString("Text" + (i + 1), s);
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ if (Boolean.getBoolean("convertLegacySigns")) {
|
||||
+ nbttagcompound.setBoolean("Bukkit.isConverted", true);
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
nbttagcompound.setString("Color", this.color.c());
|
||||
return nbttagcompound;
|
||||
}
|
||||
@@ -39,18 +45,38 @@
|
||||
super.load(iblockdata, nbttagcompound);
|
||||
this.color = EnumColor.a(nbttagcompound.getString("Color"), EnumColor.BLACK);
|
||||
|
||||
+ // CraftBukkit start - Add an option to convert signs correctly
|
||||
+ // This is done with a flag instead of all the time because
|
||||
+ // we have no way to tell whether a sign is from 1.7.10 or 1.8
|
||||
+
|
||||
+ boolean oldSign = Boolean.getBoolean("convertLegacySigns") && !nbttagcompound.getBoolean("Bukkit.isConverted");
|
||||
+
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
String s = nbttagcompound.getString("Text" + (i + 1));
|
||||
- IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.ChatSerializer.a(s.isEmpty() ? "\"\"" : s);
|
||||
+ if (s != null && s.length() > 2048) {
|
||||
+ s = "\"\"";
|
||||
+ }
|
||||
+
|
||||
+ try {
|
||||
+ IChatMutableComponent ichatmutablecomponent = IChatBaseComponent.ChatSerializer.a(s.isEmpty() ? "\"\"" : s);
|
||||
|
||||
- if (this.world instanceof WorldServer) {
|
||||
- try {
|
||||
- this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatmutablecomponent, (Entity) null, 0);
|
||||
- } catch (CommandSyntaxException commandsyntaxexception) {
|
||||
+ if (oldSign) {
|
||||
+ lines[i] = org.bukkit.craftbukkit.util.CraftChatMessage.fromString(s)[0];
|
||||
+ continue;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
+ if (this.world instanceof WorldServer) {
|
||||
+ try {
|
||||
+ this.lines[i] = ChatComponentUtils.filterForDisplay(this.a((EntityPlayer) null), ichatmutablecomponent, (Entity) null, 0);
|
||||
+ } catch (CommandSyntaxException commandsyntaxexception) {
|
||||
+ this.lines[i] = ichatmutablecomponent;
|
||||
+ }
|
||||
+ } else {
|
||||
this.lines[i] = ichatmutablecomponent;
|
||||
}
|
||||
- } else {
|
||||
- this.lines[i] = ichatmutablecomponent;
|
||||
+ } catch (com.google.gson.JsonParseException jsonparseexception) {
|
||||
+ this.lines[i] = new ChatComponentText(s);
|
||||
}
|
||||
|
||||
this.g[i] = null;
|
||||
@@ -111,11 +137,37 @@
|
||||
return true;
|
||||
}
|
||||
|
||||
+ // CraftBukkit start
|
||||
+ @Override
|
||||
+ public void sendMessage(IChatBaseComponent ichatbasecomponent, java.util.UUID uuid) {}
|
||||
+
|
||||
+ @Override
|
||||
+ public org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper) {
|
||||
+ return wrapper.getEntity() != null ? wrapper.getEntity().getBukkitSender(wrapper) : new org.bukkit.craftbukkit.command.CraftBlockCommandSender(wrapper, this);
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean shouldSendSuccess() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean shouldSendFailure() {
|
||||
+ return false;
|
||||
+ }
|
||||
+
|
||||
+ @Override
|
||||
+ public boolean shouldBroadcastCommands() {
|
||||
+ return false;
|
||||
+ }
|
||||
+ // CraftBukkit end
|
||||
+
|
||||
public CommandListenerWrapper a(@Nullable EntityPlayer entityplayer) {
|
||||
String s = entityplayer == null ? "Sign" : entityplayer.getDisplayName().getString();
|
||||
Object object = entityplayer == null ? new ChatComponentText("Sign") : entityplayer.getScoreboardDisplayName();
|
||||
|
||||
- return new CommandListenerWrapper(ICommandListener.DUMMY, Vec3D.a((BaseBlockPosition) this.position), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer);
|
||||
+ // CraftBukkit - this
|
||||
+ return new CommandListenerWrapper(this, Vec3D.a((BaseBlockPosition) this.position), Vec2F.a, (WorldServer) this.world, 2, s, (IChatBaseComponent) object, this.world.getMinecraftServer(), entityplayer);
|
||||
}
|
||||
|
||||
public EnumColor getColor() {
|
||||
@@ -126,7 +178,7 @@
|
||||
if (enumcolor != this.getColor()) {
|
||||
this.color = enumcolor;
|
||||
this.update();
|
||||
- this.world.notify(this.getPosition(), this.getBlock(), this.getBlock(), 3);
|
||||
+ if (this.world != null) this.world.notify(this.getPosition(), this.getBlock(), this.getBlock(), 3); // CraftBukkit - skip notify if world is null (SPIGOT-5122)
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/server/WorldGenMegaTreeProvider.java
|
||||
+++ b/net/minecraft/server/WorldGenMegaTreeProvider.java
|
||||
@@ -30,6 +30,7 @@
|
||||
return false;
|
||||
} else {
|
||||
((WorldGenFeatureTreeConfiguration) worldgenfeatureconfigured.f).b();
|
||||
+ setTreeType(worldgenfeatureconfigured); // CraftBukkit
|
||||
IBlockData iblockdata1 = Blocks.AIR.getBlockData();
|
||||
|
||||
worldserver.setTypeAndData(blockposition.b(i, 0, j), iblockdata1, 4);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user