Created
November 28, 2010 00:04
-
-
Save grum/718409 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void a(fz paramfz) { | |
// hMod: Is admin? | |
boolean bool = this.d.e.B = (this.d.f.g(getPlayer().getName()) || getPlayer().isAdmin()); | |
if (paramfz.e == 255) { | |
hl localhl1 = paramfz.a >= 0 ? new hl(paramfz.a) : null; | |
this.e.c.a(this.e, this.d.e, localhl1); | |
} else { | |
// hMod: what are we doing here if we can't build! | |
if (!getPlayer().canBuild()) { | |
this.d.e.B = false; | |
return; | |
} | |
int m = paramfz.b; | |
int n = paramfz.c; | |
int i1 = paramfz.d; | |
int i2 = paramfz.e; | |
int i3 = (int) hf.e(m - this.d.e.m); | |
int i4 = (int) hf.e(i1 - this.d.e.o); | |
if (i3 > i4) { | |
i4 = i3; | |
} | |
// hMod: Block creation hook (also finds what block was clicked on) | |
// If we were building inside spawn, bail! (unless ops/admin) | |
if ((i4 > etc.getInstance().getSpawnProtectionSize()) || (bool)) { | |
hl localhl = paramfz.a >= 0 ? new hl(paramfz.a) : null; | |
// Data we have are of the block which face we clicked. | |
int targetBlockId = etc.getServer().getBlockIdAt(m, n, i1); | |
Block blockClicked = new Block(targetBlockId, m, n, i1); | |
// Static face for snow, as `bt.class` does. | |
blockClicked.setFaceClicked(Block.Face.fromId( targetBlockId == 78 ? 0 : paramfz.e)); | |
// Calculate the block placed as `bt.class` does. | |
Block blockPlaced = new Block(localhl != null ? localhl.c : paramfz.a, m, n, i1); | |
if (targetBlockId != 78) { // Only if not snow layer | |
if (paramfz.e == 0) { | |
blockPlaced.setY(blockPlaced.getY() - 1); | |
} else if (paramfz.e == 1) { | |
blockPlaced.setY(blockPlaced.getY() + 1); | |
} else if (paramfz.e == 2) { | |
blockPlaced.setZ(blockPlaced.getZ() - 1); | |
} else if (paramfz.e == 3) { | |
blockPlaced.setZ(blockPlaced.getZ() + 1); | |
} else if (paramfz.e == 4) { | |
blockPlaced.setX(blockPlaced.getX() - 1); | |
} else if (paramfz.e == 5) { | |
blockPlaced.setX(blockPlaced.getX() + 1); | |
} | |
} | |
// Store this externally, someone might think to be smart and change blockPlaced. | |
int oldX = blockPlaced.getX(); | |
int oldY = blockPlaced.getY(); | |
int oldZ = blockPlaced.getZ(); | |
int oldBlockMaterial = etc.getServer().getBlockIdAt( oldX, oldY, oldZ ); | |
// This logic has to be inversed because we have no way to know | |
// if the server will allow the placement of the block until we | |
// actually have done it >.> | |
Boolean placed = this.e.c.a(this.e, this.d.e, localhl, m, n, i1, i2); | |
if (placed && (Boolean) etc.getLoader().callHook(PluginLoader.Hook.BLOCK_CREATED, new Object[]{e, blockPlaced, blockClicked, paramfz.a})) { | |
// Undo! -- this is the 'hardcore version' -- do not bother checking for physics. | |
// do NOT use etc.getServer().setBlockAt(blockType, oldX, oldY, oldZ); | |
etc.getMCServer().e.d(oldX, oldY, oldZ, oldBlockMaterial ); | |
} | |
} else { | |
// hMod: No point sending the client to update the blocks, you weren't allowed to place! | |
this.d.e.B = false; | |
return; | |
} | |
// hMod: these are the 'block changed' packets for the client. | |
this.e.a.b(new fl(m, n, i1, this.d.e)); | |
if (i2 == 0) { | |
n--; | |
} | |
if (i2 == 1) { | |
n++; | |
} | |
if (i2 == 2) { | |
i1--; | |
} | |
if (i2 == 3) { | |
i1++; | |
} | |
if (i2 == 4) { | |
m--; | |
} | |
if (i2 == 5) { | |
m++; | |
} | |
this.e.a.b(new fl(m, n, i1, this.d.e)); | |
} | |
this.d.e.B = false; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment