Skip to content

Instantly share code, notes, and snippets.

@bspkrs
Created September 5, 2013 16:23
Show Gist options
  • Save bspkrs/6452521 to your computer and use it in GitHub Desktop.
Save bspkrs/6452521 to your computer and use it in GitHub Desktop.
Luna timber code...
@Override
public void onBlockHarvested(World world, int x, int y, int z, int metadata, EntityPlayer player) {
if (!world.isRemote && !player.isSneaking() && (!player.capabilities.isCreativeMode || this.settings.enableCreative) && player.getCurrentEquippedItem() != null) {
int type = 0x00;
if (this.settings.axes.contains(player.getCurrentEquippedItem().itemID)) {
type = 0x01;
} else if (this.settings.shears.contains(player.getCurrentEquippedItem().itemID)) {
type = 0x02;
} else {
return;
}
Vector3i topLog = new Vector3i(x, y, z);
while (world.getBlockId(topLog.x, topLog.y + 1, topLog.z) == this.blockID) {
++topLog.y;
}
if (areLeavesAround(world, topLog, 2)) {
List<Vector3i> listFinal = new ArrayList<Vector3i>();
List<Vector3i> logs = getLogs(world, new Vector3i(x, y, z));
getLogsAbove(world, new Vector3i(x, y, z), listFinal);
destroyBlocksWithChance(world, logs, type);
for (Vector3i pos : listFinal) {
List<Vector3i> leavez = getLeaves(world, pos);
removeLeavesWithLogsAround(world, leavez);
destroyBlocksWithChance(world, leavez, type);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment