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 {
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
public static final BlockStateBoolean a = BlockRedstoneTorch.LIT;
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -13,14 +18,30 @@
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2018-07-15 02:00:00 +02: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-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2016-02-29 22:32:46 +01:00
|
|
|
public void stepOn(World world, BlockPosition blockposition, Entity entity) {
|
2018-07-15 02:00:00 +02:00
|
|
|
- interact(world.getType(blockposition), world, blockposition);
|
2016-02-29 22:32:46 +01:00
|
|
|
- super.stepOn(world, blockposition, entity);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2018-07-15 02:00:00 +02:00
|
|
|
+ // interact(world.getType(blockposition), world, blockposition);
|
2016-02-29 22:32:46 +01:00
|
|
|
+ // 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()) {
|
2018-07-15 02:00:00 +02:00
|
|
|
+ interact(world.getType(blockposition), world, blockposition, entity); // add entity
|
2016-02-29 22:32:46 +01:00
|
|
|
+ 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()) {
|
2018-07-15 02:00:00 +02:00
|
|
|
+ interact(world.getType(blockposition), world, blockposition, entity); // add entity
|
2016-02-29 22:32:46 +01:00
|
|
|
+ super.stepOn(world, blockposition, entity);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -28,7 +49,7 @@
|
|
|
|
if (world.isClientSide) {
|
2019-12-10 23:00:00 +01:00
|
|
|
playEffect(world, blockposition);
|
|
|
|
} else {
|
|
|
|
- interact(iblockdata, world, blockposition);
|
|
|
|
+ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman
|
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
|
|
|
|
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;
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2018-07-15 02:00:00 +02: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);
|
2018-12-06 00:00:00 +01:00
|
|
|
if (!(Boolean) iblockdata.get(BlockRedstoneOre.a)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2018-12-06 00:00:00 +01:00
|
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.set(BlockRedstoneOre.a, true)).isCancelled()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2018-12-06 00:00:00 +01:00
|
|
|
world.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, true), 3);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -52,6 +78,11 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2019-12-10 23:00:00 +01:00
|
|
|
public void tick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, Random random) {
|
2018-12-06 00:00:00 +01:00
|
|
|
if ((Boolean) iblockdata.get(BlockRedstoneOre.a)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2019-12-10 23:00:00 +01:00
|
|
|
+ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, iblockdata.set(BlockRedstoneOre.a, false)).isCancelled()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2019-12-10 23:00:00 +01:00
|
|
|
worldserver.setTypeAndData(blockposition, (IBlockData) iblockdata.set(BlockRedstoneOre.a, false), 3);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2020-06-25 02:00:00 +02:00
|
|
|
@@ -60,12 +91,25 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
|
|
|
public void dropNaturally(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) {
|
|
|
|
super.dropNaturally(iblockdata, world, blockposition, itemstack);
|
2014-11-25 22:32:16 +01:00
|
|
|
+ /* CraftBukkit start - Delegated to getExpDrop
|
2019-04-23 04:00:00 +02:00
|
|
|
if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
|
|
|
|
int i = 1 + world.random.nextInt(5);
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2019-04-23 04:00:00 +02:00
|
|
|
this.dropExperience(world, blockposition, i);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
+ // */
|
2019-12-10 23:00:00 +01:00
|
|
|
+
|
|
|
|
+ }
|
2018-07-15 02:00:00 +02:00
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ @Override
|
2019-04-23 04:00:00 +02:00
|
|
|
+ public int getExpDrop(IBlockData iblockdata, World world, BlockPosition blockposition, ItemStack itemstack) {
|
|
|
|
+ if (EnchantmentManager.getEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
|
|
|
|
+ int i = 1 + world.random.nextInt(5);
|
2018-07-15 02:00:00 +02:00
|
|
|
+
|
2019-04-23 04:00:00 +02:00
|
|
|
+ return i;
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
|
|
|
+ return 0;
|
|
|
|
+ // CraftBukkit end
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
|
|
|
|
2018-07-15 02:00:00 +02:00
|
|
|
private static void playEffect(World world, BlockPosition blockposition) {
|