fixed flowers generational stacking on server start
This commit is contained in:
parent
03c26bc2f9
commit
46782b97c8
@ -21,36 +21,34 @@ public class PixelBlockHitbox {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void spawn() {
|
public void spawn() {
|
||||||
Location pixelBlockLocation = this.parentBlock.getPixelBlockLocation();
|
Location absoluteLocation = this.parentBlock.getPixelBlockLocation();
|
||||||
List<PixelBlockWorld.PixelData> pixels = this.parentBlock.getPixelData();
|
List<PixelBlockWorld.PixelData> pixels = this.parentBlock.getPixelData();
|
||||||
double scale = pixels.getFirst().scale();
|
|
||||||
|
|
||||||
float offset = (float) Main.configuration().hitboxOffset();
|
float offset = (float) Main.configuration().hitboxOffset();
|
||||||
int pixelsPerBlock = Main.configuration().pixelsPerBlock();
|
int pixelsPerBlock = Main.configuration().pixelsPerBlock();
|
||||||
|
|
||||||
Interaction interaction;
|
Interaction interaction;
|
||||||
if(true) {
|
if (pixels.size() <= 5 || true) {
|
||||||
interaction = (Interaction) pixelBlockLocation.getWorld().spawnEntity(
|
interaction = (Interaction) absoluteLocation.getWorld().spawnEntity(
|
||||||
pixelBlockLocation.clone().add(0.5, -offset, 0.5),
|
absoluteLocation.clone().add(0.5, -offset, 0.5),
|
||||||
EntityType.INTERACTION
|
EntityType.INTERACTION
|
||||||
);
|
);
|
||||||
interaction.setInteractionHeight(1 + 2 * offset);
|
interaction.setInteractionHeight(1 + 2 * offset);
|
||||||
interaction.setInteractionWidth(1 + 2 * offset);
|
interaction.setInteractionWidth(1 + 2 * offset);
|
||||||
} else {
|
} else {
|
||||||
// double startingX = this.parentBlock.getPixelBlockLocation().x() + MinMaxUtil.getMinProperty(pixels, pixel -> pixel.relativeLocation().getX()) * scale;
|
// double startingX = absoluteLocation.x() + MinMaxUtil.getMinProperty(pixels, pixel -> pixel.relativeLocation().getX());
|
||||||
// double startingY = this.parentBlock.getPixelBlockLocation().y() + MinMaxUtil.getMinProperty(pixels, pixel -> pixel.relativeLocation().getY()) * scale;
|
// double startingY = absoluteLocation.y() + MinMaxUtil.getMinProperty(pixels, pixel -> pixel.relativeLocation().getY());
|
||||||
// double startingZ = this.parentBlock.getPixelBlockLocation().z() + MinMaxUtil.getMinProperty(pixels, pixel -> pixel.relativeLocation().getZ()) * scale;
|
// double startingZ = absoluteLocation.z() + MinMaxUtil.getMinProperty(pixels, pixel -> pixel.relativeLocation().getZ());
|
||||||
//
|
//
|
||||||
// double endingX = this.parentBlock.getPixelBlockLocation().x() + MinMaxUtil.getMaxProperty(pixels, pixel -> pixel.relativeLocation().getX()) * scale;
|
// double endingX = absoluteLocation.x() + MinMaxUtil.getMaxProperty(pixels, pixel -> pixel.relativeLocation().getX());
|
||||||
// double endingY = this.parentBlock.getPixelBlockLocation().y() + MinMaxUtil.getMaxProperty(pixels, pixel -> pixel.relativeLocation().getY()) * scale;
|
// double endingY = absoluteLocation.y() + MinMaxUtil.getMaxProperty(pixels, pixel -> pixel.relativeLocation().getY());
|
||||||
// double endingZ = this.parentBlock.getPixelBlockLocation().z() + MinMaxUtil.getMaxProperty(pixels, pixel -> pixel.relativeLocation().getZ()) * scale;
|
// double endingZ = absoluteLocation.z() + MinMaxUtil.getMaxProperty(pixels, pixel -> pixel.relativeLocation().getZ());
|
||||||
//
|
//
|
||||||
// Location spawnLocation = pixelBlockLocation.clone().add(
|
// Location spawnLocation = absoluteLocation.clone().add(
|
||||||
// ((startingX+endingX+1)/2)/pixelsPerBlock,
|
// ((startingX+endingX+1)/2)/pixelsPerBlock,
|
||||||
// (startingY/pixelsPerBlock)-offset,
|
// ((startingY+endingY+1)/2)/pixelsPerBlock,
|
||||||
// ((startingZ+endingZ+1)/2)/pixelsPerBlock
|
// ((startingZ+endingZ+1)/2)/pixelsPerBlock
|
||||||
// );
|
// );
|
||||||
//
|
|
||||||
// float height = (float) (endingY-startingY+1)/pixelsPerBlock + 2*offset;
|
// float height = (float) (endingY-startingY+1)/pixelsPerBlock + 2*offset;
|
||||||
//
|
//
|
||||||
// float width;
|
// float width;
|
||||||
@ -73,20 +71,21 @@ public class PixelBlockHitbox {
|
|||||||
// if(spawnLocation.getZ()-width/2 < pixelBlockLocation.getZ()) {
|
// if(spawnLocation.getZ()-width/2 < pixelBlockLocation.getZ()) {
|
||||||
// spawnLocation.add(0, 0, pixelBlockLocation.getZ()-(spawnLocation.getZ()-width/2));
|
// spawnLocation.add(0, 0, pixelBlockLocation.getZ()-(spawnLocation.getZ()-width/2));
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// interaction = (Interaction) pixelBlockLocation.getWorld().spawnEntity(
|
// interaction = (Interaction) absoluteLocation.getWorld().spawnEntity(
|
||||||
// spawnLocation,
|
// spawnLocation,
|
||||||
// EntityType.INTERACTION
|
// EntityType.INTERACTION
|
||||||
// );
|
// );
|
||||||
//
|
//
|
||||||
// interaction.setInteractionHeight(height);
|
// interaction.setInteractionHeight(0.5f);
|
||||||
// interaction.setInteractionWidth(width);
|
// interaction.setInteractionWidth(0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
interaction.getPersistentDataContainer()
|
interaction.getPersistentDataContainer()
|
||||||
.set(hitboxOfTag, PersistentDataType.STRING, this.parentBlock.getBlockUUID().toString());
|
.set(hitboxOfTag, PersistentDataType.STRING, this.parentBlock.getBlockUUID().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
this.parentBlock.getPixelBlockLocation().getNearbyEntitiesByType(Interaction.class, 1)
|
this.parentBlock.getPixelBlockLocation().getNearbyEntitiesByType(Interaction.class, 1)
|
||||||
.stream()
|
.stream()
|
||||||
@ -95,9 +94,6 @@ public class PixelBlockHitbox {
|
|||||||
interaction.getPersistentDataContainer().get(hitboxOfTag, PersistentDataType.STRING),
|
interaction.getPersistentDataContainer().get(hitboxOfTag, PersistentDataType.STRING),
|
||||||
parentBlock.getBlockUUID().toString()
|
parentBlock.getBlockUUID().toString()
|
||||||
))
|
))
|
||||||
.reduce((a, b) -> {
|
.forEach(Entity::remove);
|
||||||
throw new IllegalStateException(String.format("Mehrere hitboxen für PixelBlock '%s' gefunden!", parentBlock.getBlockUUID()));
|
|
||||||
})
|
|
||||||
.ifPresent(Entity::remove);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -179,23 +179,26 @@ public class PixelBlockWorld {
|
|||||||
LocationUtil.iterateBlocks(getPlatformOrigin().add(1, 1, 1), getPlatformOriginEnd().add(0, 1, 0), location -> {
|
LocationUtil.iterateBlocks(getPlatformOrigin().add(1, 1, 1), getPlatformOriginEnd().add(0, 1, 0), location -> {
|
||||||
if(allowPlacements(location)) return;
|
if(allowPlacements(location)) return;
|
||||||
if(!location.clone().subtract(0, 1, 0).getBlock().getType().equals(Material.GRASS_BLOCK)) return;
|
if(!location.clone().subtract(0, 1, 0).getBlock().getType().equals(Material.GRASS_BLOCK)) return;
|
||||||
|
|
||||||
|
List<Material> flowers = List.of(
|
||||||
|
Material.DANDELION,
|
||||||
|
Material.POPPY,
|
||||||
|
Material.BLUE_ORCHID,
|
||||||
|
Material.ALLIUM,
|
||||||
|
Material.AZURE_BLUET,
|
||||||
|
Material.RED_TULIP,
|
||||||
|
Material.ORANGE_TULIP,
|
||||||
|
Material.WHITE_TULIP,
|
||||||
|
Material.CORNFLOWER,
|
||||||
|
Material.LILY_OF_THE_VALLEY,
|
||||||
|
Material.SHORT_GRASS,
|
||||||
|
Material.TALL_GRASS
|
||||||
|
);
|
||||||
|
if(flowers.contains(location.getBlock().getType())) location.getBlock().setType(Material.AIR);
|
||||||
if(!location.getBlock().getType().equals(Material.AIR)) return;
|
if(!location.getBlock().getType().equals(Material.AIR)) return;
|
||||||
|
|
||||||
if(random.nextInt(10) == 0) {
|
if(random.nextInt(30) == 0) {
|
||||||
Material[] flowers = {
|
Material randomFlower = flowers.get(random.nextInt(flowers.size()));
|
||||||
Material.DANDELION,
|
|
||||||
Material.POPPY,
|
|
||||||
Material.BLUE_ORCHID,
|
|
||||||
Material.ALLIUM,
|
|
||||||
Material.AZURE_BLUET,
|
|
||||||
Material.RED_TULIP,
|
|
||||||
Material.ORANGE_TULIP,
|
|
||||||
Material.WHITE_TULIP,
|
|
||||||
Material.CORNFLOWER,
|
|
||||||
Material.LILY_OF_THE_VALLEY,
|
|
||||||
};
|
|
||||||
|
|
||||||
Material randomFlower = flowers[random.nextInt(flowers.length)];
|
|
||||||
location.getBlock().setType(randomFlower);
|
location.getBlock().setType(randomFlower);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user