2015-05-25 12:37:24 +02:00
|
|
|
--- a/net/minecraft/server/BlockRedstoneOre.java
|
|
|
|
+++ b/net/minecraft/server/BlockRedstoneOre.java
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -2,6 +2,11 @@
|
|
|
|
|
2014-11-25 22:32:16 +01: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 {
|
|
|
|
|
|
|
|
private final boolean a;
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -20,23 +25,45 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void attack(World world, BlockPosition blockposition, EntityHuman entityhuman) {
|
2016-02-29 22:32:46 +01:00
|
|
|
- this.interact(world, blockposition);
|
|
|
|
+ this.interact(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
|
2014-11-25 22:32:16 +01:00
|
|
|
super.attack(world, blockposition, entityhuman);
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
|
|
|
|
- this.interact(world, blockposition);
|
|
|
|
- super.stepOn(world, blockposition, entity);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // this.interact(world, blockposition);
|
|
|
|
+ // super.stepOn(world, blockposition, entity);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ if (entity instanceof EntityHuman) {
|
2016-03-04 05:24:51 +01: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-25 22:32:16 +01:00
|
|
|
+ if (!event.isCancelled()) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.interact(world, blockposition, entity); // add entity
|
|
|
|
+ super.stepOn(world, blockposition, entity);
|
2014-11-25 22:32:16 +01: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()) {
|
2016-02-29 22:32:46 +01:00
|
|
|
+ this.interact(world, blockposition, entity); // add entity
|
|
|
|
+ super.stepOn(world, blockposition, entity);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
+
|
2016-11-17 02:41:03 +01:00
|
|
|
public boolean interact(World world, BlockPosition blockposition, IBlockData iblockdata, EntityHuman entityhuman, EnumHand enumhand, EnumDirection enumdirection, float f, float f1, float f2) {
|
2016-02-29 22:32:46 +01:00
|
|
|
- this.interact(world, blockposition);
|
|
|
|
+ this.interact(world, blockposition, entityhuman); // CraftBukkit - add entityhuman
|
2016-11-17 02:41:03 +01:00
|
|
|
return super.interact(world, blockposition, iblockdata, entityhuman, enumhand, enumdirection, f, f1, f2);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
- private void interact(World world, BlockPosition blockposition) {
|
|
|
|
+ private void interact(World world, BlockPosition blockposition, Entity entity) { // CraftBukkit - add Entity
|
|
|
|
this.playEffect(world, blockposition);
|
2014-11-25 22:32:16 +01:00
|
|
|
if (this == Blocks.REDSTONE_ORE) {
|
|
|
|
+ // CraftBukkit start
|
2016-07-08 03:12:40 +02:00
|
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, Blocks.LIT_REDSTONE_ORE, 0).isCancelled()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
world.setTypeUpdate(blockposition, Blocks.LIT_REDSTONE_ORE.getBlockData());
|
|
|
|
}
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -44,6 +71,11 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void b(World world, BlockPosition blockposition, IBlockData iblockdata, Random random) {
|
|
|
|
if (this == Blocks.LIT_REDSTONE_ORE) {
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ if (CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()), Blocks.REDSTONE_ORE).isCancelled()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
world.setTypeUpdate(blockposition, Blocks.REDSTONE_ORE.getBlockData());
|
|
|
|
}
|
|
|
|
|
2016-11-17 02:41:03 +01:00
|
|
|
@@ -63,12 +95,25 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
public void dropNaturally(World world, BlockPosition blockposition, IBlockData iblockdata, float f, int i) {
|
|
|
|
super.dropNaturally(world, blockposition, iblockdata, f, i);
|
|
|
|
+ /* CraftBukkit start - Delegated to getExpDrop
|
|
|
|
if (this.getDropType(iblockdata, world.random, i) != Item.getItemOf(this)) {
|
|
|
|
int j = 1 + world.random.nextInt(5);
|
|
|
|
|
|
|
|
this.dropExperience(world, blockposition, j);
|
|
|
|
}
|
|
|
|
+ // */
|
2016-05-10 13:47:39 +02:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2016-05-10 13:47:39 +02:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ @Override
|
|
|
|
+ public int getExpDrop(World world, IBlockData data, int i) {
|
|
|
|
+ if (this.getDropType(data, world.random, i) != Item.getItemOf(this)) {
|
|
|
|
+ int j = 1 + world.random.nextInt(5);
|
2016-05-10 13:47:39 +02:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2016-02-29 22:32:46 +01:00
|
|
|
private void playEffect(World world, BlockPosition blockposition) {
|