render improvements
This commit is contained in:
parent
4caf6a8265
commit
2cbf8fff9b
@ -134,9 +134,11 @@ public class PathingBehavior extends Behavior {
|
|||||||
//System.out.println("Render passing");
|
//System.out.println("Render passing");
|
||||||
//System.out.println(event.getPartialTicks());
|
//System.out.println(event.getPartialTicks());
|
||||||
float partialTicks = event.getPartialTicks();
|
float partialTicks = event.getPartialTicks();
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
// Render the current path, if there is one
|
// Render the current path, if there is one
|
||||||
getPath().ifPresent(path -> drawPath(path, player(), partialTicks, Color.RED));
|
getPath().ifPresent(path -> drawPath(path, player(), partialTicks, Color.RED));
|
||||||
|
long split = System.currentTimeMillis();
|
||||||
getPath().ifPresent(path -> {
|
getPath().ifPresent(path -> {
|
||||||
for (BlockPos pos : path.getBlocksToBreak()) {
|
for (BlockPos pos : path.getBlocksToBreak()) {
|
||||||
drawSelectionBox(player(), pos, partialTicks, Color.RED);
|
drawSelectionBox(player(), pos, partialTicks, Color.RED);
|
||||||
@ -156,6 +158,9 @@ public class PathingBehavior extends Behavior {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
long end = System.currentTimeMillis();
|
||||||
|
if (end - start > 0)
|
||||||
|
System.out.println("Frame took " + (split - start) + " " + (end - split));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawPath(IPath path, EntityPlayerSP player, float partialTicks, Color color) {
|
public void drawPath(IPath path, EntityPlayerSP player, float partialTicks, Color color) {
|
||||||
|
@ -187,23 +187,34 @@ public abstract class Movement implements Helper, MovementHelper {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<BlockPos> toBreakCached = null;
|
||||||
|
public ArrayList<BlockPos> toPlaceCached = null;
|
||||||
|
|
||||||
public ArrayList<BlockPos> toBreak() {
|
public ArrayList<BlockPos> toBreak() {
|
||||||
|
if (toBreakCached != null) {
|
||||||
|
return toBreakCached;
|
||||||
|
}
|
||||||
ArrayList<BlockPos> result = new ArrayList<>();
|
ArrayList<BlockPos> result = new ArrayList<>();
|
||||||
for (BlockPos positionsToBreak1 : positionsToBreak) {
|
for (BlockPos positionsToBreak1 : positionsToBreak) {
|
||||||
if (!MovementHelper.canWalkThrough(positionsToBreak1, BlockStateInterface.get(positionsToBreak1))) {
|
if (!MovementHelper.canWalkThrough(positionsToBreak1, BlockStateInterface.get(positionsToBreak1))) {
|
||||||
result.add(positionsToBreak1);
|
result.add(positionsToBreak1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
toBreakCached = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<BlockPos> toPlace() {
|
public ArrayList<BlockPos> toPlace() {
|
||||||
|
if (toPlaceCached != null) {
|
||||||
|
return toPlaceCached;
|
||||||
|
}
|
||||||
ArrayList<BlockPos> result = new ArrayList<>();
|
ArrayList<BlockPos> result = new ArrayList<>();
|
||||||
for (BlockPos positionsToPlace1 : positionsToPlace) {
|
for (BlockPos positionsToPlace1 : positionsToPlace) {
|
||||||
if (!MovementHelper.canWalkOn(positionsToPlace1)) {
|
if (!MovementHelper.canWalkOn(positionsToPlace1)) {
|
||||||
result.add(positionsToPlace1);
|
result.add(positionsToPlace1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
toPlaceCached = result;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class PathExecutor extends Behavior {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTick(TickEvent event) {
|
public void onTick(TickEvent event) {
|
||||||
if(event.getType() == TickEvent.Type.OUT) {
|
if (event.getType() == TickEvent.Type.OUT) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (pathPosition >= path.length()) {
|
if (pathPosition >= path.length()) {
|
||||||
@ -48,6 +48,7 @@ public class PathExecutor extends Behavior {
|
|||||||
BlockPos whereAmI = playerFeet();
|
BlockPos whereAmI = playerFeet();
|
||||||
if (pathPosition == path.length() - 1) {
|
if (pathPosition == path.length() - 1) {
|
||||||
System.out.println("On last path position -- done!");
|
System.out.println("On last path position -- done!");
|
||||||
|
pathPosition++;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!whereShouldIBe.equals(whereAmI)) {
|
if (!whereShouldIBe.equals(whereAmI)) {
|
||||||
@ -116,6 +117,12 @@ public class PathExecutor extends Behavior {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
|
for (int i = pathPosition - 10; i < pathPosition + 10; i++) {
|
||||||
|
if (i >= 0 && i < path.movements().size()) {
|
||||||
|
path.movements().get(i).toBreakCached = null;
|
||||||
|
path.movements().get(i).toPlaceCached = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
Movement movement = path.movements().get(pathPosition);
|
Movement movement = path.movements().get(pathPosition);
|
||||||
if (movement.recalculateCost() >= ActionCosts.COST_INF) {
|
if (movement.recalculateCost() >= ActionCosts.COST_INF) {
|
||||||
System.out.println("Something has changed in the world and this movement has become impossible. Cancelling.");
|
System.out.println("Something has changed in the world and this movement has become impossible. Cancelling.");
|
||||||
|
Loading…
Reference in New Issue
Block a user