problems with entities not loading correctly
This commit is contained in:
@@ -18,7 +18,7 @@ import java.util.*;
|
||||
import static eu.mhsl.minecraft.pixelblocks.PixelBlocks.*;
|
||||
|
||||
public class PixelBlock {
|
||||
public static List<PixelBlock> placedBlocks = new ArrayList<>();
|
||||
public static List<PixelBlock> placedPixelBlocks = new ArrayList<>();
|
||||
public static float hitboxOffset = 0.005F;
|
||||
public static int worldGrassBorderWidth = 5;
|
||||
public static int pixelsPerBlock = 16;
|
||||
@@ -34,7 +34,6 @@ public class PixelBlock {
|
||||
public UUID uuid;
|
||||
|
||||
public PixelBlock(Location originLocation, UUID ownerUID, UUID blockUUID) {
|
||||
PixelBlock.placedBlocks.add(this);
|
||||
this.uuid = blockUUID;
|
||||
|
||||
this.pixelBlockLocation = originLocation.toBlockLocation();
|
||||
@@ -47,7 +46,7 @@ public class PixelBlock {
|
||||
|
||||
public static PixelBlock getPixelBlockFromWorld(World world) {
|
||||
String blockUUID = Arrays.stream(world.getName().split(pathSeparator)).toList().getLast();
|
||||
List<PixelBlock> pixelBlocks = placedBlocks.stream().filter(block -> block.uuid.toString().equals(blockUUID)).toList();
|
||||
List<PixelBlock> pixelBlocks = placedPixelBlocks.stream().filter(block -> block.uuid.toString().equals(blockUUID)).toList();
|
||||
|
||||
if(!pixelBlocks.isEmpty()) {
|
||||
return pixelBlocks.getFirst();
|
||||
@@ -61,7 +60,7 @@ public class PixelBlock {
|
||||
loc.setPitch(0);
|
||||
loc.setYaw(0);
|
||||
|
||||
List<PixelBlock> pixelBlocks = placedBlocks.stream()
|
||||
List<PixelBlock> pixelBlocks = placedPixelBlocks.stream()
|
||||
.filter(block -> block.pixelBlockLocation.equals(loc))
|
||||
.toList();
|
||||
|
||||
@@ -289,7 +288,7 @@ public class PixelBlock {
|
||||
|
||||
public void update() {
|
||||
Bukkit.getScheduler().runTask(plugin, () -> {
|
||||
clearEntities();
|
||||
this.clearEntities();
|
||||
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int y = 0; y < 16; y++) {
|
||||
@@ -336,17 +335,22 @@ public class PixelBlock {
|
||||
}
|
||||
|
||||
public void clearEntities() {
|
||||
System.out.println("Clear Entities");
|
||||
|
||||
if(!pixels.isEmpty()) {
|
||||
System.out.println("Clear Pixels");
|
||||
this.pixels.forEach(Pixel::remove);
|
||||
pixels.clear();
|
||||
this.pixels.clear();
|
||||
}
|
||||
|
||||
if(hitbox != null) {
|
||||
hitbox.remove();
|
||||
hitbox = null;
|
||||
System.out.println("Clear Hitbox");
|
||||
this.hitbox.remove();
|
||||
this.hitbox = null;
|
||||
}
|
||||
|
||||
if(barrier != null) {
|
||||
System.out.println("Clear Barrier");
|
||||
this.barrier.remove();
|
||||
this.barrier = null;
|
||||
}
|
||||
@@ -361,6 +365,7 @@ public class PixelBlock {
|
||||
this.pixelBlockLocation = newLocation;
|
||||
update();
|
||||
dataBase.savePixelBlock(this);
|
||||
placedPixelBlocks.add(this);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -370,7 +375,7 @@ public class PixelBlock {
|
||||
dataBase.removePixelBlock(this);
|
||||
|
||||
clearEntities();
|
||||
placedBlocks.remove(this);
|
||||
placedPixelBlocks.remove(this);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
|
||||
Reference in New Issue
Block a user