2021-03-15 23:00:00 +01:00
|
|
|
--- a/net/minecraft/world/level/block/BlockRedstoneOre.java
|
|
|
|
+++ b/net/minecraft/world/level/block/BlockRedstoneOre.java
|
|
|
|
@@ -21,6 +21,11 @@
|
|
|
|
import net.minecraft.world.level.block.state.properties.BlockStateBoolean;
|
|
|
|
import net.minecraft.world.phys.MovingObjectPositionBlock;
|
2014-11-25 22:32:16 +01:00
|
|
|
|
|
|
|
+// CraftBukkit start
|
|
|
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
|
|
+import org.bukkit.event.entity.EntityInteractEvent;
|
|
|
|
+// CraftBukkit end
|
|
|
|
+
|
|
|
|
public class BlockRedstoneOre extends Block {
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
public static final BlockStateBoolean LIT = BlockRedstoneTorch.LIT;
|
2022-06-07 18:00:00 +02:00
|
|
|
@@ -32,14 +37,27 @@
|
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
|
2021-06-11 07:00:00 +02:00
|
|
|
public void stepOn(World world, BlockPosition blockposition, IBlockData iblockdata, Entity entity) {
|
2022-06-07 18:00:00 +02:00
|
|
|
if (!entity.isSteppingCarefully()) {
|
|
|
|
- interact(iblockdata, world, blockposition);
|
|
|
|
+ // CraftBukkit start
|
|
|
|
+ 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.getBlockState(blockposition), world, blockposition, entity); // add entity
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ EntityInteractEvent event = new EntityInteractEvent(entity.getBukkitEntity(), world.getWorld().getBlockAt(blockposition.getX(), blockposition.getY(), blockposition.getZ()));
|
|
|
|
+ world.getCraftServer().getPluginManager().callEvent(event);
|
|
|
|
+ if (!event.isCancelled()) {
|
|
|
|
+ interact(world.getBlockState(blockposition), world, blockposition, entity); // add entity
|
|
|
|
+ }
|
2014-11-25 22:32:16 +01:00
|
|
|
+ }
|
2022-06-07 18:00:00 +02:00
|
|
|
+ // CraftBukkit end
|
|
|
|
}
|
2014-11-25 22:32:16 +01:00
|
|
|
|
2022-06-07 18:00:00 +02:00
|
|
|
super.stepOn(world, blockposition, iblockdata, entity);
|
|
|
|
@@ -50,7 +68,7 @@
|
2020-06-25 02:00:00 +02:00
|
|
|
if (world.isClientSide) {
|
2021-11-21 23:00:00 +01:00
|
|
|
spawnParticles(world, blockposition);
|
2019-12-10 23:00:00 +01:00
|
|
|
} else {
|
|
|
|
- interact(iblockdata, world, blockposition);
|
|
|
|
+ interact(iblockdata, world, blockposition, entityhuman); // CraftBukkit - add entityhuman
|
|
|
|
}
|
2020-06-25 02:00:00 +02:00
|
|
|
|
2021-11-21 23:00:00 +01:00
|
|
|
ItemStack itemstack = entityhuman.getItemInHand(enumhand);
|
2022-06-07 18:00:00 +02:00
|
|
|
@@ -58,9 +76,14 @@
|
2021-11-21 23:00:00 +01:00
|
|
|
return itemstack.getItem() instanceof ItemBlock && (new BlockActionContext(entityhuman, enumhand, itemstack, movingobjectpositionblock)).canPlace() ? 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
|
2021-11-21 23:00:00 +01:00
|
|
|
spawnParticles(world, blockposition);
|
|
|
|
if (!(Boolean) iblockdata.getValue(BlockRedstoneOre.LIT)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2021-11-21 23:00:00 +01:00
|
|
|
+ if (CraftEventFactory.callEntityChangeBlockEvent(entity, blockposition, iblockdata.setValue(BlockRedstoneOre.LIT, true)).isCancelled()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
world.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneOre.LIT, true), 3);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2022-06-07 18:00:00 +02:00
|
|
|
@@ -74,6 +97,11 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2022-06-07 18:00:00 +02:00
|
|
|
public void randomTick(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, RandomSource randomsource) {
|
2021-11-21 23:00:00 +01:00
|
|
|
if ((Boolean) iblockdata.getValue(BlockRedstoneOre.LIT)) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ // CraftBukkit start
|
2021-11-21 23:00:00 +01:00
|
|
|
+ if (CraftEventFactory.callBlockFadeEvent(worldserver, blockposition, iblockdata.setValue(BlockRedstoneOre.LIT, false)).isCancelled()) {
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // CraftBukkit end
|
2021-11-21 23:00:00 +01:00
|
|
|
worldserver.setBlock(blockposition, (IBlockData) iblockdata.setValue(BlockRedstoneOre.LIT, false), 3);
|
2014-11-25 22:32:16 +01:00
|
|
|
}
|
|
|
|
|
2022-06-07 18:00:00 +02:00
|
|
|
@@ -82,12 +110,20 @@
|
2019-04-23 04:00:00 +02:00
|
|
|
@Override
|
2022-06-07 18:00:00 +02:00
|
|
|
public void spawnAfterBreak(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) {
|
|
|
|
super.spawnAfterBreak(iblockdata, worldserver, blockposition, itemstack, flag);
|
2021-11-21 23:00:00 +01:00
|
|
|
+ // CraftBukkit start - Delegated to getExpDrop
|
2019-12-10 23:00:00 +01:00
|
|
|
+ }
|
2021-11-21 23:00:00 +01:00
|
|
|
+
|
2014-11-25 22:32:16 +01:00
|
|
|
+ @Override
|
2022-06-07 18:00:00 +02:00
|
|
|
+ public int getExpDrop(IBlockData iblockdata, WorldServer worldserver, BlockPosition blockposition, ItemStack itemstack, boolean flag) {
|
|
|
|
if (flag && EnchantmentManager.getItemEnchantmentLevel(Enchantments.SILK_TOUCH, itemstack) == 0) {
|
2021-11-21 23:00:00 +01:00
|
|
|
int i = 1 + worldserver.random.nextInt(5);
|
|
|
|
|
|
|
|
- this.popExperience(worldserver, blockposition, i);
|
|
|
|
+ // this.popExperience(worldserver, blockposition, i);
|
2019-04-23 04:00:00 +02:00
|
|
|
+ return i;
|
2021-11-21 23:00:00 +01:00
|
|
|
}
|
|
|
|
|
2014-11-25 22:32:16 +01:00
|
|
|
+ return 0;
|
|
|
|
+ // CraftBukkit end
|
2019-12-10 23:00:00 +01:00
|
|
|
}
|
|
|
|
|
2021-06-11 07:00:00 +02:00
|
|
|
@Override
|