Skip to content

Commit

Permalink
Also test MutableBlockPosition. It is pretty slow...
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Zangl committed Jan 12, 2016
1 parent 7119b08 commit e438d13
Showing 1 changed file with 55 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,38 @@
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.util.Vec3i;

@AICommand(helpText = "Some performance/... tests.", name = "minebot")
public class CommandTestMinectaft {
private static final int TEST_RUNS = 50;

public static final class MutableBlockPos extends BlockPos {
public int x;
public int y;
public int z;

private MutableBlockPos()
{
super(0, 0, 0);
}

public int getX()
{
return this.x;
}

public int getY()
{
return this.y;
}

public int getZ()
{
return this.z;
}
}

@AICommandInvocation()
public static AIStrategy run(
AIHelper helper,
Expand All @@ -39,6 +66,8 @@ protected void singleRun(AIHelper helper) {
accessBlocksAroundPlayer(helper.getWorld());
accessNativeBlocksAroundPlayerLoop(helper.getWorld(),
helper.getMinecraft().theWorld);
accessNativeBlocksAroundPlayerLoopMutableBP(helper.getWorld(),
helper.getMinecraft().theWorld);
accessBlocksAroundPlayerLoop(helper.getWorld());
accessBlockSetAroundPlayer(helper.getWorld());
accessBlockMetaSetAroundPlayer(helper.getWorld());
Expand Down Expand Up @@ -142,6 +171,32 @@ private static void accessNativeBlocksAroundPlayerLoop(WorldData world,
done("accessNativeBlocksAroundPlayerLoop", start);
}

private static void accessNativeBlocksAroundPlayerLoopMutableBP(WorldData world,
WorldClient theWorld) {
BlockCuboid area = blocksAroundPlayer(world);
int minX = area.getMin().getX();
int minY = area.getMin().getY();
int minZ = area.getMin().getZ();
int maxX = area.getMax().getX();
int maxY = area.getMax().getY();
int maxZ = area.getMax().getZ();
long start = start();
MutableBlockPos p = new MutableBlockPos();
for (int i = 0; i < TEST_RUNS; i++) {
for (int y = minY; y <= maxY; y++) {
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
p.x = x;
p.y = y;
p.z = z;
theWorld.getBlockState(p);
}
}
}
}
done("accessNativeBlocksAroundPlayerLoopMutableBP", start);
}

private static void accessBlockSetAroundPlayer(WorldData world) {
BlockArea area = blocksAroundPlayer(world);
final BlockSet set = BlockSets.SAFE_CEILING;
Expand Down

0 comments on commit e438d13

Please sign in to comment.