2015-05-25 18:37:24 +08:00
|
|
|
--- a/net/minecraft/server/BlockRedstoneOre.java
|
|
|
|
+++ b/net/minecraft/server/BlockRedstoneOre.java
|
2016-11-17 09:41:03 +08:00
|
|
|
@@ -2,6 +2,11 @@
|
|
|
|
|
2014-11-26 05:32:16 +08:00
|
|
|
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 {
|
|
|
|
|
2018-07-15 08:00:00 +08:00
|
|
|
public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
|
|
|
|
@@ -16,23 +21,44 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
|
|
|
|
2018-07-15 08:00:00 +08:00
|
|
|
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);
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
|
|
|
|
2016-03-01 05:32:46 +08:00
|
|
|
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
|
2018-07-15 08:00:00 +08:00
|
|
|
- interact(world.getType(blockposition), world, blockposition);
|
2016-03-01 05:32:46 +08:00
|
|
|
- super.stepOn(world, blockposition, entity);
|
2014-11-26 05:32:16 +08:00
|
|
|
+ // CraftBukkit start
|
2018-07-15 08:00:00 +08:00
|
|
|
+ // interact(world.getType(blockposition), world, blockposition);
|
2016-03-01 05:32:46 +08:00
|
|
|
+ // super.stepOn(world, blockposition, entity);
|
2014-11-26 05:32:16 +08:00
|
|
|
+ if (entity instanceof EntityHuman) {
|
2016-03-04 12:24:51 +08:00
|
|
|
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityHuman) entity, org.bukkit.event.block.Action.PHYSICAL, blockposition, null, null, null);
|
2014-11-26 05:32:16 +08:00
|
|
|
+ if (!event.isCancelled()) {
|
2018-07-15 08:00:00 +08:00
|
|
|
+ interact(world.getType(blockposition), world, blockposition, entity); // add entity
|
2016-03-01 05:32:46 +08:00
|
|
|
+ super.stepOn(world, blockposition, entity);
|
2014-11-26 05:32:16 +08:00
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
|
|
|
+ world.getServer().getPluginManager().callEvent(event);
|
|
|
|
+ if (!event.isCancelled()) {
|
2018-07-15 08:00:00 +08:00
|
|
|
+ interact(world.getType(blockposition), world, blockposition, entity); // add entity
|
2016-03-01 05:32:46 +08:00
|
|
|
+ super.stepOn(world, blockposition, entity);
|
2014-11-26 05:32:16 +08:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2018-07-15 08:00:00 +08:00
|
|
|
public boolean interact(IBlockData iblockdata, World world, BlockPosition blockposition, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
|
|
|
|
- interact(iblockdata, world, blockposition);
|
|
|
|
+ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman
|
|
|
|
return super.interact(iblockdata, world, blockposition, entityhuman, enumhand, enumdirection, f, f1, f2);
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
|
|
|
|
2018-07-15 08:00:00 +08:00
|
|
|
- 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)).booleanValue()) {
|
2014-11-26 05:32:16 +08:00
|
|
|
+ // CraftBukkit start
|
2018-07-15 08:00:00 +08:00
|
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(true))).isCancelled()) {
|
2014-11-26 05:32:16 +08:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2018-07-15 08:00:00 +08:00
|
|
|
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(true)), 3);
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
|
|
|
|
2018-07-15 08:00:00 +08:00
|
|
|
@@ -40,6 +66,11 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
|
2018-07-15 08:00:00 +08:00
|
|
|
public void a(IBlockData iblockdata, World world, BlockPosition blockposition, Random random) {
|
|
|
|
if (((Boolean) iblockdata.get(BlockRedstoneOre.a)).booleanValue()) {
|
2014-11-26 05:32:16 +08:00
|
|
|
+ // CraftBukkit start
|
2018-07-15 08:00:00 +08:00
|
|
|
+ if (CraftEventFactory.callBlockFadeEvent(world, blockposition, iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(false))).isCancelled()) {
|
2014-11-26 05:32:16 +08:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2018-07-15 08:00:00 +08:00
|
|
|
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, Boolean.valueOf(false)), 3);
|
2014-11-26 05:32:16 +08:00
|
|
|
}
|
|
|
|
|
2018-07-15 08:00:00 +08:00
|
|
|
@@ -59,12 +90,25 @@
|
2014-11-26 05:32:16 +08:00
|
|
|
|
2018-07-15 08:00:00 +08:00
|
|
|
public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, float f, int i) {
|
|
|
|
super.dropNaturally(iblockdata, world, blockposition, f, i);
|
2014-11-26 05:32:16 +08:00
|
|
|
+ /* CraftBukkit start - Delegated to getExpDrop
|
2018-07-15 08:00:00 +08:00
|
|
|
if (this.getDropType(iblockdata, world, blockposition, i) != this) {
|
2014-11-26 05:32:16 +08:00
|
|
|
int j = 1 + world.random.nextInt(5);
|
|
|
|
|
|
|
|
this.dropExperience(world, blockposition, j);
|
|
|
|
}
|
|
|
|
+ // */
|
2016-05-10 19:47:39 +08:00
|
|
|
+
|
2014-11-26 05:32:16 +08:00
|
|
|
+ }
|
2018-07-15 08:00:00 +08:00
|
|
|
|
2014-11-26 05:32:16 +08:00
|
|
|
+ @Override
|
2018-07-15 08:00:00 +08:00
|
|
|
+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, int enchantmentLevel) {
|
|
|
|
+ if (this.getDropType(iblockdata, world, blockposition, enchantmentLevel) != this) {
|
2014-11-26 05:32:16 +08:00
|
|
|
+ int j = 1 + world.random.nextInt(5);
|
2018-07-15 08:00:00 +08:00
|
|
|
+
|
2014-11-26 05:32:16 +08:00
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2018-07-15 08:00:00 +08:00
|
|
|
private static void playEffect(World world, BlockPosition blockposition) {
|