Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
85527f7004
Commit
7f7081adfe
@ -26,7 +26,7 @@ import org.bukkit.util.VoxelShape;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class AxisMovementLimiter {
|
public class AxisMovementLimiter19 {
|
||||||
|
|
||||||
private double x;
|
private double x;
|
||||||
private double y;
|
private double y;
|
||||||
@ -41,7 +41,7 @@ public class AxisMovementLimiter {
|
|||||||
private double minZ;
|
private double minZ;
|
||||||
private double maxZ;
|
private double maxZ;
|
||||||
|
|
||||||
public AxisMovementLimiter(double x, double y, double z, Axis axis, double movement) {
|
public AxisMovementLimiter19(double x, double y, double z, Axis axis, double movement) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
@ -84,19 +84,19 @@ public class AxisMovementLimiter {
|
|||||||
// System.out.println(axis + " " + minX + " -> " + maxX + " " + minY + " -> " + maxY + " " + minZ + " -> " + maxZ);
|
// System.out.println(axis + " " + minX + " -> " + maxX + " " + minY + " -> " + maxY + " " + minZ + " -> " + maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Pos> possibleCollisions() {
|
private List<Pos19> possibleCollisions() {
|
||||||
int minX = TNT.floor(this.minX);
|
int minX = TNT19.floor(this.minX);
|
||||||
int maxX = TNT.floor(this.maxX);
|
int maxX = TNT19.floor(this.maxX);
|
||||||
int minY = TNT.floor(this.minY) - 1;
|
int minY = TNT19.floor(this.minY) - 1;
|
||||||
int maxY = TNT.floor(this.maxY);
|
int maxY = TNT19.floor(this.maxY);
|
||||||
int minZ = TNT.floor(this.minZ);
|
int minZ = TNT19.floor(this.minZ);
|
||||||
int maxZ = TNT.floor(this.maxZ);
|
int maxZ = TNT19.floor(this.maxZ);
|
||||||
|
|
||||||
List<Pos> poss = new ArrayList<>();
|
List<Pos19> poss = new ArrayList<>();
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; x++) {
|
||||||
for (int y = minY; y <= maxY; y++) {
|
for (int y = minY; y <= maxY; y++) {
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
poss.add(new Pos(x, y, z));
|
poss.add(new Pos19(x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,14 +104,14 @@ public class AxisMovementLimiter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: This can be optimized by optimizing the x,y,z loop layout
|
// TODO: This can be optimized by optimizing the x,y,z loop layout
|
||||||
public double run(SimulatorData simulatorData) {
|
public double run(SimulatorData19 simulatorData) {
|
||||||
if (movement == 0.0) return 0.0;
|
if (movement == 0.0) return 0.0;
|
||||||
|
|
||||||
BoundingBox movementBoundingBox = new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
BoundingBox movementBoundingBox = new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
List<Pos> poss = possibleCollisions();
|
List<Pos19> poss = possibleCollisions();
|
||||||
|
|
||||||
Double collision = null;
|
Double collision = null;
|
||||||
for (Pos pos : poss) {
|
for (Pos19 pos : poss) {
|
||||||
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
||||||
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
||||||
boundingBox = boundingBox.clone().shift(pos.x, pos.y, pos.z);
|
boundingBox = boundingBox.clone().shift(pos.x, pos.y, pos.z);
|
@ -24,7 +24,7 @@ import org.bukkit.block.data.Waterlogged;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class Explosion {
|
public class Explosion19 {
|
||||||
|
|
||||||
private static final double[] FACE_BLOCKS = new double[(16 * 16 * 2 + 14 * 16 * 2 + 14 * 14 * 2) * 3];
|
private static final double[] FACE_BLOCKS = new double[(16 * 16 * 2 + 14 * 16 * 2 + 14 * 14 * 2) * 3];
|
||||||
|
|
||||||
@ -60,21 +60,21 @@ public class Explosion {
|
|||||||
private static final Random RANDOM = new Random();
|
private static final Random RANDOM = new Random();
|
||||||
private static final float POWER = 4.0F;
|
private static final float POWER = 4.0F;
|
||||||
|
|
||||||
private final TNT tnt;
|
private final TNT19 tnt;
|
||||||
private final double x;
|
private final double x;
|
||||||
private final double y;
|
private final double y;
|
||||||
private final double z;
|
private final double z;
|
||||||
|
|
||||||
|
|
||||||
public Explosion(TNT tnt, double x, double y, double z) {
|
public Explosion19(TNT19 tnt, double x, double y, double z) {
|
||||||
this.tnt = tnt;
|
this.tnt = tnt;
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void calculate(SimulatorData simulatorData) {
|
public void calculate(SimulatorData19 simulatorData) {
|
||||||
Set<Pos> affectedBlocks = new HashSet<>();
|
Set<Pos19> affectedBlocks = new HashSet<>();
|
||||||
for (int i = 0; i < FACE_BLOCKS.length; i += 3) {
|
for (int i = 0; i < FACE_BLOCKS.length; i += 3) {
|
||||||
double d = FACE_BLOCKS[i + 0];
|
double d = FACE_BLOCKS[i + 0];
|
||||||
double e = FACE_BLOCKS[i + 1];
|
double e = FACE_BLOCKS[i + 1];
|
||||||
@ -86,9 +86,9 @@ public class Explosion {
|
|||||||
double o = z;
|
double o = z;
|
||||||
|
|
||||||
for (; h > 0.0F; h -= 0.22500001F) {
|
for (; h > 0.0F; h -= 0.22500001F) {
|
||||||
int x = TNT.floor(m);
|
int x = TNT19.floor(m);
|
||||||
int y = TNT.floor(n);
|
int y = TNT19.floor(n);
|
||||||
int z = TNT.floor(o);
|
int z = TNT19.floor(o);
|
||||||
|
|
||||||
Material material = simulatorData.getBlockType(x, y, z);
|
Material material = simulatorData.getBlockType(x, y, z);
|
||||||
if (!material.isAir()) {
|
if (!material.isAir()) {
|
||||||
@ -102,7 +102,7 @@ public class Explosion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (h > 0.0F) {
|
if (h > 0.0F) {
|
||||||
affectedBlocks.add(new Pos(x, y, z));
|
affectedBlocks.add(new Pos19(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
m += d * 0.30000001192092896;
|
m += d * 0.30000001192092896;
|
||||||
@ -120,7 +120,7 @@ public class Explosion {
|
|||||||
int t = floor(z - q - 1.0D);
|
int t = floor(z - q - 1.0D);
|
||||||
int u = floor(z + q + 1.0D);
|
int u = floor(z + q + 1.0D);
|
||||||
|
|
||||||
for (TNT currentTNT : simulatorData.tntList) {
|
for (TNT19 currentTNT : simulatorData.tntList) {
|
||||||
if (currentTNT == tnt) continue;
|
if (currentTNT == tnt) continue;
|
||||||
if (!(currentTNT.getX() >= k && currentTNT.getY() >= r && currentTNT.getZ() >= t && currentTNT.getX() <= l && currentTNT.getY() <= s && currentTNT.getZ() <= u)) {
|
if (!(currentTNT.getX() >= k && currentTNT.getY() >= r && currentTNT.getZ() >= t && currentTNT.getX() <= l && currentTNT.getY() <= s && currentTNT.getZ() <= u)) {
|
||||||
continue;
|
continue;
|
||||||
@ -160,7 +160,7 @@ public class Explosion {
|
|||||||
private static final double EXPOSURE_CONSTANT_1 = 1.0 / (SIZE * 2 + 1.0);
|
private static final double EXPOSURE_CONSTANT_1 = 1.0 / (SIZE * 2 + 1.0);
|
||||||
private static final double EXPOSURE_CONSTANT_2 = (1.0 - Math.floor(1.0 / EXPOSURE_CONSTANT_1) * EXPOSURE_CONSTANT_1) / 2.0;
|
private static final double EXPOSURE_CONSTANT_2 = (1.0 - Math.floor(1.0 / EXPOSURE_CONSTANT_1) * EXPOSURE_CONSTANT_1) / 2.0;
|
||||||
|
|
||||||
private static float getExposure(SimulatorData simulatorData, double x, double y, double z) {
|
private static float getExposure(SimulatorData19 simulatorData, double x, double y, double z) {
|
||||||
float blockMisses = 0;
|
float blockMisses = 0;
|
||||||
float blockTotal = 0;
|
float blockTotal = 0;
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ public class Explosion {
|
|||||||
return start + delta * (end - start);
|
return start + delta * (end - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean rayTrace(SimulatorData simulatorData, double sX, double sY, double sZ, double dX, double dY, double dZ) {
|
public static boolean rayTrace(SimulatorData19 simulatorData, double sX, double sY, double sZ, double dX, double dY, double dZ) {
|
||||||
double x = sX;
|
double x = sX;
|
||||||
double y = sY;
|
double y = sY;
|
||||||
double z = sZ;
|
double z = sZ;
|
@ -23,7 +23,7 @@ import org.bukkit.Axis;
|
|||||||
import org.bukkit.util.BoundingBox;
|
import org.bukkit.util.BoundingBox;
|
||||||
import org.bukkit.util.VoxelShape;
|
import org.bukkit.util.VoxelShape;
|
||||||
|
|
||||||
public class OptimizedAxisMovementLimiter {
|
public class OptimizedAxisMovementLimiter19 {
|
||||||
|
|
||||||
private Axis axis;
|
private Axis axis;
|
||||||
private double movement;
|
private double movement;
|
||||||
@ -44,7 +44,7 @@ public class OptimizedAxisMovementLimiter {
|
|||||||
|
|
||||||
private BoundingBox movementBoundingBox;
|
private BoundingBox movementBoundingBox;
|
||||||
|
|
||||||
public OptimizedAxisMovementLimiter(double x, double y, double z, Axis axis, double movement) {
|
public OptimizedAxisMovementLimiter19(double x, double y, double z, Axis axis, double movement) {
|
||||||
this.axis = axis;
|
this.axis = axis;
|
||||||
this.movement = movement;
|
this.movement = movement;
|
||||||
|
|
||||||
@ -82,17 +82,17 @@ public class OptimizedAxisMovementLimiter {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
minIX = TNT.floor(minX);
|
minIX = TNT19.floor(minX);
|
||||||
maxIX = TNT.floor(maxX);
|
maxIX = TNT19.floor(maxX);
|
||||||
minIY = TNT.floor(minY) - 1;
|
minIY = TNT19.floor(minY) - 1;
|
||||||
maxIY = TNT.floor(maxY);
|
maxIY = TNT19.floor(maxY);
|
||||||
minIZ = TNT.floor(minZ);
|
minIZ = TNT19.floor(minZ);
|
||||||
maxIZ = TNT.floor(maxZ);
|
maxIZ = TNT19.floor(maxZ);
|
||||||
|
|
||||||
movementBoundingBox = new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
movementBoundingBox = new BoundingBox(minX, minY, minZ, maxX, maxY, maxZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double run(SimulatorData simulatorData) {
|
public double run(SimulatorData19 simulatorData) {
|
||||||
if (movement == 0.0) return 0.0;
|
if (movement == 0.0) return 0.0;
|
||||||
switch (axis) {
|
switch (axis) {
|
||||||
case X:
|
case X:
|
||||||
@ -117,12 +117,12 @@ public class OptimizedAxisMovementLimiter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private double runNX(SimulatorData simulatorData) {
|
private double runNX(SimulatorData19 simulatorData) {
|
||||||
Double collision = null;
|
Double collision = null;
|
||||||
for (int x = maxIX - 1; x >= minIX; x--) {
|
for (int x = maxIX - 1; x >= minIX; x--) {
|
||||||
for (int y = minIY; y < maxIY; y++) {
|
for (int y = minIY; y < maxIY; y++) {
|
||||||
for (int z = minIZ; z < maxIZ; z++) {
|
for (int z = minIZ; z < maxIZ; z++) {
|
||||||
Pos pos = new Pos(x, y, z);
|
Pos19 pos = new Pos19(x, y, z);
|
||||||
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
||||||
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
||||||
boundingBox = boundingBox.clone().shift(x, y, z);
|
boundingBox = boundingBox.clone().shift(x, y, z);
|
||||||
@ -147,12 +147,12 @@ public class OptimizedAxisMovementLimiter {
|
|||||||
return movement + (collision - minX);
|
return movement + (collision - minX);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double runPX(SimulatorData simulatorData) {
|
private double runPX(SimulatorData19 simulatorData) {
|
||||||
Double collision = null;
|
Double collision = null;
|
||||||
for (int x = minIX; x < maxIX; x++) {
|
for (int x = minIX; x < maxIX; x++) {
|
||||||
for (int y = minIY; y < maxIY; y++) {
|
for (int y = minIY; y < maxIY; y++) {
|
||||||
for (int z = minIZ; z < maxIZ; z++) {
|
for (int z = minIZ; z < maxIZ; z++) {
|
||||||
Pos pos = new Pos(x, y, z);
|
Pos19 pos = new Pos19(x, y, z);
|
||||||
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
||||||
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
||||||
boundingBox = boundingBox.clone().shift(x, y, z);
|
boundingBox = boundingBox.clone().shift(x, y, z);
|
||||||
@ -177,12 +177,12 @@ public class OptimizedAxisMovementLimiter {
|
|||||||
return movement + (collision - minX);
|
return movement + (collision - minX);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double runNY(SimulatorData simulatorData) {
|
private double runNY(SimulatorData19 simulatorData) {
|
||||||
Double collision = null;
|
Double collision = null;
|
||||||
for (int y = maxIY - 1; y >= minIY; y--) {
|
for (int y = maxIY - 1; y >= minIY; y--) {
|
||||||
for (int x = minIX; x < maxIX; x++) {
|
for (int x = minIX; x < maxIX; x++) {
|
||||||
for (int z = minIZ; z < maxIZ; z++) {
|
for (int z = minIZ; z < maxIZ; z++) {
|
||||||
Pos pos = new Pos(x, y, z);
|
Pos19 pos = new Pos19(x, y, z);
|
||||||
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
||||||
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
||||||
boundingBox = boundingBox.clone().shift(x, y, z);
|
boundingBox = boundingBox.clone().shift(x, y, z);
|
||||||
@ -207,12 +207,12 @@ public class OptimizedAxisMovementLimiter {
|
|||||||
return movement + (collision - minY);
|
return movement + (collision - minY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double runPY(SimulatorData simulatorData) {
|
private double runPY(SimulatorData19 simulatorData) {
|
||||||
Double collision = null;
|
Double collision = null;
|
||||||
for (int y = minIY; y < maxIY; y++) {
|
for (int y = minIY; y < maxIY; y++) {
|
||||||
for (int x = minIX; x < maxIX; x++) {
|
for (int x = minIX; x < maxIX; x++) {
|
||||||
for (int z = minIZ; z < maxIZ; z++) {
|
for (int z = minIZ; z < maxIZ; z++) {
|
||||||
Pos pos = new Pos(x, y, z);
|
Pos19 pos = new Pos19(x, y, z);
|
||||||
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
||||||
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
||||||
boundingBox = boundingBox.clone().shift(x, y, z);
|
boundingBox = boundingBox.clone().shift(x, y, z);
|
||||||
@ -237,12 +237,12 @@ public class OptimizedAxisMovementLimiter {
|
|||||||
return movement + (collision - minY);
|
return movement + (collision - minY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double runNZ(SimulatorData simulatorData) {
|
private double runNZ(SimulatorData19 simulatorData) {
|
||||||
Double collision = null;
|
Double collision = null;
|
||||||
for (int z = maxIZ - 1; z >= minIZ; z--) {
|
for (int z = maxIZ - 1; z >= minIZ; z--) {
|
||||||
for (int x = minIX; x < maxIX; x++) {
|
for (int x = minIX; x < maxIX; x++) {
|
||||||
for (int y = minIY; y < maxIY; y++) {
|
for (int y = minIY; y < maxIY; y++) {
|
||||||
Pos pos = new Pos(x, y, z);
|
Pos19 pos = new Pos19(x, y, z);
|
||||||
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
||||||
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
||||||
boundingBox = boundingBox.clone().shift(x, y, z);
|
boundingBox = boundingBox.clone().shift(x, y, z);
|
||||||
@ -267,12 +267,12 @@ public class OptimizedAxisMovementLimiter {
|
|||||||
return movement + (collision - minZ);
|
return movement + (collision - minZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
private double runPZ(SimulatorData simulatorData) {
|
private double runPZ(SimulatorData19 simulatorData) {
|
||||||
Double collision = null;
|
Double collision = null;
|
||||||
for (int z = minIZ; z < maxIZ; z++) {
|
for (int z = minIZ; z < maxIZ; z++) {
|
||||||
for (int x = minIX; x < maxIX; x++) {
|
for (int x = minIX; x < maxIX; x++) {
|
||||||
for (int y = minIY; y < maxIY; y++) {
|
for (int y = minIY; y < maxIY; y++) {
|
||||||
Pos pos = new Pos(x, y, z);
|
Pos19 pos = new Pos19(x, y, z);
|
||||||
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
VoxelShape voxelShape = simulatorData.getVoxelShape(pos);
|
||||||
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
for (BoundingBox boundingBox : voxelShape.getBoundingBoxes()) {
|
||||||
boundingBox = boundingBox.clone().shift(x, y, z);
|
boundingBox = boundingBox.clone().shift(x, y, z);
|
@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.simulator.preview;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class Pos {
|
public class Pos19 {
|
||||||
public final int x;
|
public final int x;
|
||||||
public final int y;
|
public final int y;
|
||||||
public final int z;
|
public final int z;
|
@ -42,10 +42,10 @@ public class Simulator19 implements Simulator {
|
|||||||
if (toCalculate == null) return null;
|
if (toCalculate == null) return null;
|
||||||
|
|
||||||
BukkitRunnable bukkitRunnable = new BukkitRunnable() {
|
BukkitRunnable bukkitRunnable = new BukkitRunnable() {
|
||||||
private SimulatorData simulatorData = new SimulatorData();
|
private SimulatorData19 simulatorData = new SimulatorData19();
|
||||||
private PreviewRecord previewRecord = new PreviewRecord();
|
private PreviewRecord previewRecord = new PreviewRecord();
|
||||||
private int currentTick = 0;
|
private int currentTick = 0;
|
||||||
private Map<TNT, Record.TNTRecord> recordMap = new IdentityHashMap<>();
|
private Map<TNT19, Record.TNTRecord> recordMap = new IdentityHashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -63,7 +63,7 @@ public class Simulator19 implements Simulator {
|
|||||||
pairs.forEach(pair -> {
|
pairs.forEach(pair -> {
|
||||||
if (pair.getValue() > 0) {
|
if (pair.getValue() > 0) {
|
||||||
hasSomeLeft.set(true);
|
hasSomeLeft.set(true);
|
||||||
TNT tnt = new TNT(pair.getKey().location.getX(), pair.getKey().location.getY(), pair.getKey().location.getZ());
|
TNT19 tnt = new TNT19(pair.getKey().location.getX(), pair.getKey().location.getY(), pair.getKey().location.getZ());
|
||||||
if (!pair.getKey().xVelocity) tnt.setVx(0.0);
|
if (!pair.getKey().xVelocity) tnt.setVx(0.0);
|
||||||
if (!pair.getKey().yVelocity) tnt.setVy(0.0);
|
if (!pair.getKey().yVelocity) tnt.setVy(0.0);
|
||||||
if (!pair.getKey().zVelocity) tnt.setVz(0.0);
|
if (!pair.getKey().zVelocity) tnt.setVz(0.0);
|
||||||
@ -80,8 +80,8 @@ public class Simulator19 implements Simulator {
|
|||||||
}
|
}
|
||||||
currentTick++;
|
currentTick++;
|
||||||
|
|
||||||
List<TNT> remove = new ArrayList<>();
|
List<TNT19> remove = new ArrayList<>();
|
||||||
for (TNT tnt : simulatorData.tntList) {
|
for (TNT19 tnt : simulatorData.tntList) {
|
||||||
// System.out.println("CALC: " + simulatorData.blockTypesMap.size() + "/" + simulatorData.blockDataMap.size() + "/" + simulatorData.collisionDataMap.size() + "/" + simulatorData.airBlocks.size() + " " + recordMap.size());
|
// System.out.println("CALC: " + simulatorData.blockTypesMap.size() + "/" + simulatorData.blockDataMap.size() + "/" + simulatorData.collisionDataMap.size() + "/" + simulatorData.airBlocks.size() + " " + recordMap.size());
|
||||||
if (tnt.tick(simulatorData)) {
|
if (tnt.tick(simulatorData)) {
|
||||||
remove.add(tnt);
|
remove.add(tnt);
|
||||||
|
@ -29,7 +29,7 @@ import java.util.*;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class SimulatorData {
|
public class SimulatorData19 {
|
||||||
|
|
||||||
private static final BlockData AIR_BLOCK_DATA = Material.AIR.createBlockData();
|
private static final BlockData AIR_BLOCK_DATA = Material.AIR.createBlockData();
|
||||||
private static final VoxelShape AIR_VOXEL_SHAPE = new VoxelShape() {
|
private static final VoxelShape AIR_VOXEL_SHAPE = new VoxelShape() {
|
||||||
@ -47,15 +47,15 @@ public class SimulatorData {
|
|||||||
long accessed = 0;
|
long accessed = 0;
|
||||||
long cacheMisses = 0;
|
long cacheMisses = 0;
|
||||||
long aired = 0;
|
long aired = 0;
|
||||||
final List<TNT> tntList = new ArrayList<>();
|
final List<TNT19> tntList = new ArrayList<>();
|
||||||
final Set<Pos> airBlocks = new HashSet<>();
|
final Set<Pos19> airBlocks = new HashSet<>();
|
||||||
final Map<Pos, Material> blockTypesMap = new HashMap<>();
|
final Map<Pos19, Material> blockTypesMap = new HashMap<>();
|
||||||
final Map<Pos, BlockData> blockDataMap = new HashMap<>();
|
final Map<Pos19, BlockData> blockDataMap = new HashMap<>();
|
||||||
final Map<Pos, VoxelShape> collisionDataMap = new HashMap<>();
|
final Map<Pos19, VoxelShape> collisionDataMap = new HashMap<>();
|
||||||
|
|
||||||
public Material getBlockType(int x, int y, int z) { // Get BlockType of Chunk Data array?
|
public Material getBlockType(int x, int y, int z) { // Get BlockType of Chunk Data array?
|
||||||
accessed++;
|
accessed++;
|
||||||
Pos pos = new Pos(x, y, z);
|
Pos19 pos = new Pos19(x, y, z);
|
||||||
if (airBlocks.contains(pos)) {
|
if (airBlocks.contains(pos)) {
|
||||||
return Material.AIR;
|
return Material.AIR;
|
||||||
}
|
}
|
||||||
@ -67,7 +67,7 @@ public class SimulatorData {
|
|||||||
|
|
||||||
public BlockData getBlockData(int x, int y, int z) {
|
public BlockData getBlockData(int x, int y, int z) {
|
||||||
accessed++;
|
accessed++;
|
||||||
Pos pos = new Pos(x, y, z);
|
Pos19 pos = new Pos19(x, y, z);
|
||||||
if (airBlocks.contains(pos)) {
|
if (airBlocks.contains(pos)) {
|
||||||
return AIR_BLOCK_DATA;
|
return AIR_BLOCK_DATA;
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ public class SimulatorData {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public VoxelShape getVoxelShape(Pos pos) {
|
public VoxelShape getVoxelShape(Pos19 pos) {
|
||||||
accessed++;
|
accessed++;
|
||||||
if (airBlocks.contains(pos)) {
|
if (airBlocks.contains(pos)) {
|
||||||
return AIR_VOXEL_SHAPE;
|
return AIR_VOXEL_SHAPE;
|
||||||
@ -88,7 +88,7 @@ public class SimulatorData {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearBlock(Pos pos) {
|
public void clearBlock(Pos19 pos) {
|
||||||
aired++;
|
aired++;
|
||||||
airBlocks.add(pos);
|
airBlocks.add(pos);
|
||||||
blockTypesMap.remove(pos);
|
blockTypesMap.remove(pos);
|
||||||
@ -96,7 +96,7 @@ public class SimulatorData {
|
|||||||
collisionDataMap.remove(pos);
|
collisionDataMap.remove(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearBlocks(Set<Pos> poss) {
|
public void clearBlocks(Set<Pos19> poss) {
|
||||||
poss.forEach(this::clearBlock);
|
poss.forEach(this::clearBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ public class SimulatorData {
|
|||||||
|
|
||||||
public Predicate<Vector> accessedBlocks() {
|
public Predicate<Vector> accessedBlocks() {
|
||||||
return vector -> {
|
return vector -> {
|
||||||
Pos pos = new Pos(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
Pos19 pos = new Pos19(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ());
|
||||||
return airBlocks.contains(pos) || blockTypesMap.containsKey(pos) || blockDataMap.containsKey(pos) || collisionDataMap.containsKey(pos);
|
return airBlocks.contains(pos) || blockTypesMap.containsKey(pos) || blockDataMap.containsKey(pos) || collisionDataMap.containsKey(pos);
|
||||||
};
|
};
|
||||||
}
|
}
|
@ -31,12 +31,11 @@ import org.bukkit.block.data.type.*;
|
|||||||
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
import org.bukkit.craftbukkit.v1_19_R2.CraftWorld;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class TNT {
|
public class TNT19 {
|
||||||
|
|
||||||
private static final Random R = new Random();
|
private static final Random R = new Random();
|
||||||
|
|
||||||
@ -58,7 +57,7 @@ public class TNT {
|
|||||||
private boolean verticalCollision = false;
|
private boolean verticalCollision = false;
|
||||||
private Vector movementMultiplier = new Vector(0, 0, 0);
|
private Vector movementMultiplier = new Vector(0, 0, 0);
|
||||||
|
|
||||||
public TNT(double x, double y, double z) {
|
public TNT19(double x, double y, double z) {
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
@ -71,7 +70,7 @@ public class TNT {
|
|||||||
this.fuse = 80;
|
this.fuse = 80;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean tick(SimulatorData simulatorData) {
|
public boolean tick(SimulatorData19 simulatorData) {
|
||||||
this.vy -= 0.04;
|
this.vy -= 0.04;
|
||||||
|
|
||||||
move(simulatorData, new Vector(this.vx, this.vy, this.vz));
|
move(simulatorData, new Vector(this.vx, this.vy, this.vz));
|
||||||
@ -82,14 +81,16 @@ public class TNT {
|
|||||||
|
|
||||||
this.fuse--;
|
this.fuse--;
|
||||||
if (this.fuse <= 0) {
|
if (this.fuse <= 0) {
|
||||||
Explosion explosion = new Explosion(this, x, y + 0.98 * 0.0625, z);
|
Explosion19 explosion = new Explosion19(this, x, y + 0.98 * 0.0625, z);
|
||||||
explosion.calculate(simulatorData);
|
explosion.calculate(simulatorData);
|
||||||
return true;
|
return true;
|
||||||
|
} else {
|
||||||
|
// TODO: Update Water and Lava Flowing
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void move(SimulatorData simulatorData, Vector movement) {
|
private void move(SimulatorData19 simulatorData, Vector movement) {
|
||||||
if (movementMultiplier.lengthSquared() > 1.0E-7) {
|
if (movementMultiplier.lengthSquared() > 1.0E-7) {
|
||||||
movement.multiply(movementMultiplier);
|
movement.multiply(movementMultiplier);
|
||||||
movementMultiplier = new Vector(0, 0, 0);
|
movementMultiplier = new Vector(0, 0, 0);
|
||||||
@ -160,21 +161,21 @@ public class TNT {
|
|||||||
this.vz *= j;
|
this.vz *= j;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector adjustMovementForCollisions(SimulatorData simulatorData, Vector movement) {
|
private Vector adjustMovementForCollisions(SimulatorData19 simulatorData, Vector movement) {
|
||||||
if (movement.lengthSquared() == 0.0) {
|
if (movement.lengthSquared() == 0.0) {
|
||||||
return movement;
|
return movement;
|
||||||
}
|
}
|
||||||
|
|
||||||
double mY = new AxisMovementLimiter(x, y, z, Axis.Y, movement.getY()).run(simulatorData);
|
double mY = new AxisMovementLimiter19(x, y, z, Axis.Y, movement.getY()).run(simulatorData);
|
||||||
|
|
||||||
boolean bl = Math.abs(movement.getX()) < Math.abs(movement.getZ());
|
boolean bl = Math.abs(movement.getX()) < Math.abs(movement.getZ());
|
||||||
if (bl) {
|
if (bl) {
|
||||||
double mZ = new AxisMovementLimiter(x, y + mY, z, Axis.Z, movement.getZ()).run(simulatorData);
|
double mZ = new AxisMovementLimiter19(x, y + mY, z, Axis.Z, movement.getZ()).run(simulatorData);
|
||||||
double mX = new AxisMovementLimiter(x, y + mY, z + mZ, Axis.X, movement.getX()).run(simulatorData);
|
double mX = new AxisMovementLimiter19(x, y + mY, z + mZ, Axis.X, movement.getX()).run(simulatorData);
|
||||||
return new Vector(mX, mY, mZ);
|
return new Vector(mX, mY, mZ);
|
||||||
} else {
|
} else {
|
||||||
double mX = new AxisMovementLimiter(x, y + mY, z, Axis.X, movement.getX()).run(simulatorData);
|
double mX = new AxisMovementLimiter19(x, y + mY, z, Axis.X, movement.getX()).run(simulatorData);
|
||||||
double mZ = new AxisMovementLimiter(x + mX, y + mY, z, Axis.Z, movement.getZ()).run(simulatorData);
|
double mZ = new AxisMovementLimiter19(x + mX, y + mY, z, Axis.Z, movement.getZ()).run(simulatorData);
|
||||||
return new Vector(mX, mY, mZ);
|
return new Vector(mX, mY, mZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -188,7 +189,7 @@ public class TNT {
|
|||||||
return value < (double)i ? i - 1 : i;
|
return value < (double)i ? i - 1 : i;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Vector getLandingPos(SimulatorData simulatorData) {
|
private Vector getLandingPos(SimulatorData19 simulatorData) {
|
||||||
int x = floor(this.x);
|
int x = floor(this.x);
|
||||||
int y = floor(this.y - 0.2F);
|
int y = floor(this.y - 0.2F);
|
||||||
int z = floor(this.z);
|
int z = floor(this.z);
|
||||||
@ -210,7 +211,7 @@ public class TNT {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkBlockCollision(SimulatorData simulatorData) {
|
private void checkBlockCollision(SimulatorData19 simulatorData) {
|
||||||
int x1 = floor(x + 1.0E-7);
|
int x1 = floor(x + 1.0E-7);
|
||||||
int y1 = floor(y + 1.0E-7);
|
int y1 = floor(y + 1.0E-7);
|
||||||
int z1 = floor(z + 1.0E-7);
|
int z1 = floor(z + 1.0E-7);
|
||||||
@ -278,7 +279,7 @@ public class TNT {
|
|||||||
return d + 1.0E-7 > f || e + 1.0E-7 > f;
|
return d + 1.0E-7 > f || e + 1.0E-7 > f;
|
||||||
}
|
}
|
||||||
|
|
||||||
private float getVelocityMultiplier(SimulatorData simulatorData) {
|
private float getVelocityMultiplier(SimulatorData19 simulatorData) {
|
||||||
Material material = simulatorData.getBlockType(floor(x), floor(y), floor(z));
|
Material material = simulatorData.getBlockType(floor(x), floor(y), floor(z));
|
||||||
float f = 1F;
|
float f = 1F;
|
||||||
if (material == Material.SOUL_SAND) {
|
if (material == Material.SOUL_SAND) {
|
@ -149,7 +149,10 @@ public class TNTSimulator {
|
|||||||
if (!force && previewRecord == null) {
|
if (!force && previewRecord == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (currentlyCalculating != null) currentlyCalculating.cancel();
|
if (currentlyCalculating != null) {
|
||||||
|
System.out.println("Cancelled");
|
||||||
|
currentlyCalculating.cancel();
|
||||||
|
}
|
||||||
currentlyCalculating = Simulator.impl.run(locations(true), newRecord -> {
|
currentlyCalculating = Simulator.impl.run(locations(true), newRecord -> {
|
||||||
currentlyCalculating = null;
|
currentlyCalculating = null;
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren