Jump to content

0pteron

Members
  • Posts

    2
  • Joined

  • Last visited

Converted

  • Gender
    Undisclosed
  • Personal Text
    I am new!

0pteron's Achievements

Tree Puncher

Tree Puncher (2/8)

0

Reputation

  1. As I understand it, Feed the Beast mods do have fakeplayers they create but because the lack of a BreakBlockEvent in Forge they never trigger any event at all before they destroy the block. Perhaps it could be possible to convince/mod these mods to trigger a PlayerInteractEvent and then check if a plugin (Chunk Protection or any grief prevention) has cancelled that event, and then the machine will not break the the block. This is how ComputerCraft in Tekkit works by using Bukkits BreakBlockEvent. Here is the code from the dig function (this is where blocks get broken): Player fakePlayer = FakePlayer.getBukkitEntity(this.world, getTurtleName()); if (fakePlayer != null) { CraftWorld craftWorld = ((WorldServer)this.world).getWorld(); CraftServer craftServer = ((WorldServer)this.world).getServer(); BlockBreakEvent event = new BlockBreakEvent(craftWorld.getBlockAt(j, k, l), fakePlayer); craftServer.getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } } .. etc .. Block block = Block.byId[i1]; this.world.triggerEffect(2001, j, k, l, block.id + (this.world.getData(j, k, l) << 12)); this.world.setTypeId(j, k, l, 0); Note that it sends a BlockBreakEvent with the fakePlayer and then if that event is cancelled the dig fuctions returns before breaking the block. The actual "breaking" of the block is setting the block type id to 0, as done with "this.world.setTypeId(j, k, l, 0);" ------------------------------ Now lets look at similar code in the FTB computercraft: if (!canBreakBlock(worldObj, newX, newY, newZ)) { return false; } ..etc.. int blockID = worldObj.a(newX, newY, newZ); worldObj.f(2001, newX, newY, newZ, blockID + worldObj.h(newX, newY, newZ) * 4096); worldObj.e(newX, newY, newZ, 0); Here is the canBreakBlock function: protected boolean canBreakBlock(yc world, int x, int y, int z) { int bid = world.a(x, y, z); amq block = amq.p[bid]; if ((bid == 0) || (bid == amq.C.cm) || (block.m(world, x, y, z) <= -1.0F)) { return false; } return true; } ----------------- So you can see all the FTB computer craft does is check if the block is breakable, exists, and whatever amq.C.cm is. Never is there an event thrown where a third party plugin (such as any grief detection) can intercept and cancel and return the function before the breaking of the block, in this case I think the function "e" is some type of obfuscated name for "setTypeId" I have not investigated how IC2 and other mods do it, but I suspect the same. In order to get these mods to stop griefing they have to throw an event for a thirdparty to cancel. Three things can happen for this to work: 1.) Forge needs to make a BlockBreakEvent event and all the mods need to trigger this BlockBreakEvent with their fakePlayer (or owner's name), and prevent the breaking of a block if that event is cancelled in any way (such as by a anti-griefing plugin). 2.) The mods must trigger a PlayerInteractEvent (As I understand it, an alternative to bukkit's BlockBreakEvent but perhaps not as good?) with their fakePlayer (or owner's name), and prevent the breaking of a block if that event is cancelled in any way (such as by a anti-griefing plugin). 3) Each forge mod must be modified to check if bukkit support exists (via MCPC+ or the like) and if so, use Bukkit's BlockBreakEvent similar in the way it's done in Tekkit. (see tekkit CC code above).
  2. As I understand it, Feed the Beast mods do have fakeplayers they create but because the lack of a BreakBlockEvent in Forge they never trigger any event at all before they destroy the block. Perhaps it could be possible to convince/mod these mods to trigger a PlayerInteractEvent and then check if a plugin (Chunk Protection or any grief prevention) has cancelled that event, and then the machine will not break the the block. This is how ComputerCraft in Tekkit works by using Bukkits BreakBlockEvent. Here is the code from the dig function (this is where blocks get broken): Player fakePlayer = FakePlayer.getBukkitEntity(this.world, getTurtleName()); if (fakePlayer != null) { CraftWorld craftWorld = ((WorldServer)this.world).getWorld(); CraftServer craftServer = ((WorldServer)this.world).getServer(); BlockBreakEvent event = new BlockBreakEvent(craftWorld.getBlockAt(j, k, l), fakePlayer); craftServer.getPluginManager().callEvent(event); if (event.isCancelled()) { return false; } } .. etc .. Block block = Block.byId[i1]; this.world.triggerEffect(2001, j, k, l, block.id + (this.world.getData(j, k, l) << 12)); this.world.setTypeId(j, k, l, 0); Note that it sends a BlockBreakEvent with the fakePlayer and then if that event is cancelled the dig fuctions returns before breaking the block. The actual "breaking" of the block is setting the block type id to 0, as done with "this.world.setTypeId(j, k, l, 0);" ------------------------------ Now lets look at similar code in the FTB computercraft: if (!canBreakBlock(worldObj, newX, newY, newZ)) { return false; } ..etc.. int blockID = worldObj.a(newX, newY, newZ); worldObj.f(2001, newX, newY, newZ, blockID + worldObj.h(newX, newY, newZ) * 4096); worldObj.e(newX, newY, newZ, 0); Here is the canBreakBlock function: protected boolean canBreakBlock(yc world, int x, int y, int z) { int bid = world.a(x, y, z); amq block = amq.p[bid]; if ((bid == 0) || (bid == amq.C.cm) || (block.m(world, x, y, z) <= -1.0F)) { return false; } return true; } ----------------- So you can see all the FTB computer craft does is check if the block is breakable, exists, and whatever amq.C.cm is. Never is there an event thrown where a third party plugin (such as any grief detection) can intercept and cancel and return the function before the breaking of the block, in this case I think the function "e" is some type of obfuscated name for "setTypeId" I have not investigated how IC2 and other mods do it, but I suspect the same. In order to get these mods to stop griefing they have to throw an event for a thirdparty to cancel. Three things can happen for this to work: 1.) Forge needs to make a BlockBreakEvent event and all the mods need to trigger this BlockBreakEvent with their fakePlayer (or owner's name), and prevent the breaking of a block if that event is cancelled in any way (such as by a anti-griefing plugin). 2.) The mods must trigger a PlayerInteractEvent (As I understand it, an alternative to bukkit's BlockBreakEvent but perhaps not as good?) with their fakePlayer (or owner's name), and prevent the breaking of a block if that event is cancelled in any way (such as by a anti-griefing plugin). 3) Each forge mod must be modified to check if bukkit support exists (via MCPC+ or the like) and if so, use Bukkit's BlockBreakEvent similar in the way it's done in Tekkit. (see tekkit CC code above).
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.