mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-27 13:06:02 +01:00
Fire events for tripwire and hooks.
This commit is contained in:
parent
982efb8c24
commit
e1a4273957
@ -3,6 +3,11 @@ package net.minecraft.server;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||||
|
import org.bukkit.event.entity.EntityInteractEvent;
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
public class BlockTripwire extends Block {
|
public class BlockTripwire extends Block {
|
||||||
|
|
||||||
public BlockTripwire(int i) {
|
public BlockTripwire(int i) {
|
||||||
@ -135,6 +140,39 @@ public class BlockTripwire extends Block {
|
|||||||
flag1 = true;
|
flag1 = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
org.bukkit.World bworld = world.getWorld();
|
||||||
|
org.bukkit.plugin.PluginManager manager = world.getServer().getPluginManager();
|
||||||
|
|
||||||
|
if (flag != flag1) {
|
||||||
|
if (flag1) {
|
||||||
|
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, i, j, k, -1, null);
|
||||||
|
} else if (object instanceof Entity) {
|
||||||
|
cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), bworld.getBlockAt(i, j, k));
|
||||||
|
manager.callEvent((EntityInteractEvent) cancellable);
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cancellable.isCancelled()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bworld.getBlockAt(i, j, k), flag ? 1 : 0, flag1 ? 1 : 0);
|
||||||
|
manager.callEvent(eventRedstone);
|
||||||
|
|
||||||
|
flag1 = eventRedstone.getNewCurrent() > 0;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
if (flag1 && !flag) {
|
if (flag1 && !flag) {
|
||||||
l |= 1;
|
l |= 1;
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package net.minecraft.server;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
|
||||||
|
|
||||||
public class BlockTripwireHook extends Block {
|
public class BlockTripwireHook extends Block {
|
||||||
|
|
||||||
public BlockTripwireHook(int i) {
|
public BlockTripwireHook(int i) {
|
||||||
@ -153,6 +155,17 @@ public class BlockTripwireHook extends Block {
|
|||||||
this.a(world, l2, j, k3, flag3, flag4, flag1, flag2);
|
this.a(world, l2, j, k3, flag3, flag4, flag1, flag2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CraftBukkit start
|
||||||
|
org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
|
||||||
|
|
||||||
|
BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 1, 0);
|
||||||
|
world.getServer().getPluginManager().callEvent(eventRedstone);
|
||||||
|
|
||||||
|
if (eventRedstone.getNewCurrent() > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
|
||||||
this.a(world, i, j, k, flag3, flag4, flag1, flag2);
|
this.a(world, i, j, k, flag3, flag4, flag1, flag2);
|
||||||
if (l > 0) {
|
if (l > 0) {
|
||||||
world.setData(i, j, k, i1);
|
world.setData(i, j, k, i1);
|
||||||
|
Loading…
Reference in New Issue
Block a user