Skip to content

Commit

Permalink
Prepare 1.17 release (#88)
Browse files Browse the repository at this point in the history
* Fixes a 1.18 world generator bug where it generated dirt-grass layers.

Expose 3 world generator options for overworld:
- natural-surface - generates surface that is natural(-ish). Currently, it may be just grass and dirt layers.
- natural-caves - generates caves inside world.
- natural-bedrock - generates natural looking bedrock pattern.

This also fixes a bug with floor and roof config option not working properly.

Fixes BentoBoxWorld/Level#258

* Fixes issue when ores were not generated in correct form. #77

* Init 1.17.0 version

* Translate de.yml via GitLocalize (#84)

Co-authored-by: Patrick <patrick.wassmuth@gmx.de>

* Translate ru.yml via GitLocalize (#85)

Co-authored-by: Marmur2020 <marmur2020@gmail.com>

* Rework entity populator.

The new world populator on some engines are multi-threaded, however, minecraft does not allow to remove entities outside main-thread. As entity populator spawned entity and then removed when there were no spot for it, servers crashed.

The issue should be fixed now as I add custom entity bounding box calculator before it is spawned to check if there is place for entity.

Fixes #86

* Caveblock TR locale (#87)

* Translate tr.yml via GitLocalize

* Translate tr.yml via GitLocalize

* Translate tr.yml via GitLocalize

Co-authored-by: Wolerus <yakup1907.sen@gmail.com>
Co-authored-by: Over_Brave <soncesurlar@gmail.com>
Co-authored-by: mt-gitlocalize <mt@gitlocalize.com>

Co-authored-by: gitlocalize-app[bot] <55277160+gitlocalize-app[bot]@users.noreply.github.com>
Co-authored-by: Patrick <patrick.wassmuth@gmx.de>
Co-authored-by: Marmur2020 <marmur2020@gmail.com>
Co-authored-by: Wolerus <yakup1907.sen@gmail.com>
Co-authored-by: Over_Brave <soncesurlar@gmail.com>
Co-authored-by: mt-gitlocalize <mt@gitlocalize.com>
  • Loading branch information
7 people authored Jan 5, 2023
1 parent 0cbb775 commit 3070abe
Show file tree
Hide file tree
Showing 5 changed files with 409 additions and 30 deletions.
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>16</java.version>
<java.version>17</java.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.18.1-R0.1-SNAPSHOT</spigot.version>
<spigot.version>1.19.2-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>1.19.0</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- This allows to change between versions and snapshots. -->
<build.version>1.16.0</build.version>
<build.version>1.17.0</build.version>
<build.number>-LOCAL</build.number>
<sonar.organization>bentobox-world</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.bukkit.generator.LimitedRegion;
import org.bukkit.generator.WorldInfo;
import org.bukkit.util.BoundingBox;
import org.eclipse.jdt.annotation.NonNull;

import world.bentobox.bentobox.util.Pair;
import world.bentobox.caveblock.CaveBlock;
import world.bentobox.caveblock.Utils;
Expand Down Expand Up @@ -95,7 +97,7 @@ private void loadSettings() {
* @param limitedRegion Region where population operates.
*/
@Override
public void populate(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, LimitedRegion limitedRegion) {
public void populate(WorldInfo worldInfo, @NonNull Random random, int chunkX, int chunkZ, @NonNull LimitedRegion limitedRegion) {
int minHeight = worldInfo.getMinHeight();
int height = Math.min(worldInfo.getMaxHeight(), worldHeight) - 1;

Expand Down Expand Up @@ -168,29 +170,22 @@ private void tryToPlaceEntity(WorldInfo worldInfo, Location location, LimitedReg
if (!limitedRegion.isInRegion(location)) return;
if (!limitedRegion.getType(location).equals(originalMaterial)) return;

Entity entity = limitedRegion.spawnEntity(location, entityType);
if (entity instanceof LivingEntity livingEntity) {
livingEntity.setAI(hasAI);
livingEntity.setRemoveWhenFarAway(false);
}
BoundingBox bb = this.getEntityBoundingBox(entityType, location);

BoundingBox bb = entity.getBoundingBox();
for (int x = (int) Math.floor(bb.getMinX()); x < bb.getMaxX(); x++) {
for (int z = (int) Math.floor(bb.getMinZ()); z < bb.getMaxZ(); z++) {
int y = (int) Math.floor(bb.getMinY());
if (!limitedRegion.isInRegion(x, y, z)) {
entity.remove();
return;
}

for (; y <= bb.getMaxY(); y++) {
if (addon.getSettings().isDebug()) {
addon.log("DEBUG: Entity spawn: " + worldInfo.getName() + " " + x + " " + y + " " + z + " " + entity.getType());
addon.log("DEBUG: Entity spawn: " + worldInfo.getName() + " " + x + " " + y + " " + z + " " + entityType);
}

if (!limitedRegion.isInRegion(x, y, z) || !limitedRegion.getType(x, y, z).equals(originalMaterial)) {
// Cannot place entity
entity.remove();
return;
}
limitedRegion.setType(x, y, z, WATER_ENTITIES.contains(entityType) ? Material.WATER : Material.AIR);
Expand All @@ -201,8 +196,86 @@ private void tryToPlaceEntity(WorldInfo worldInfo, Location location, LimitedReg
}
}
}

Entity entity = limitedRegion.spawnEntity(location, entityType);

if (entity instanceof LivingEntity livingEntity)
{
livingEntity.setAI(hasAI);
livingEntity.setRemoveWhenFarAway(false);
}
}


/**
* This is manual bounding box calculation base on entity type.
* @param entityType Entity type which bounding box should be created.
* @param location Location of the bounding box.
* @return Approximate bounding box of the entity type.
*/
private BoundingBox getEntityBoundingBox(EntityType entityType, Location location)
{
BoundingBox boundingBox = new BoundingBox();
// Set bounding box to 1 for all entities
boundingBox.expand(1);
// Shift to correct location.
boundingBox.shift(location);

switch (entityType)
{
// Turtles base size is 1.1
case TURTLE -> boundingBox.expand(-0.05, 0, -0.05, 0.05, 0, 0.05);
// Panda base size is 1.3 and height is 1.25
case PANDA -> boundingBox.expand(-0.15, 0, -0.15, 0.15, 0.25, 0.15);
// Sheep height is 1.3
case SHEEP -> boundingBox.expand(0, 0, 0, 0, 0.3, 0);
// Cow height is 1.4
case COW, MUSHROOM_COW -> boundingBox.expand(0, 0, 0, 0, 0.4, 0);
// Polar Bear base size is 1.3 and height is 1.4
case POLAR_BEAR -> boundingBox.expand(-0.15, 0, -0.15, 0.15, 0.4, 0.15);
// Horse base size is 1.3964
case HORSE, ZOMBIE_HORSE, SKELETON_HORSE -> boundingBox.expand(-0.2, 0, -0.2, 0.2, 0.6, 0.2);
// Llama height is 1.875
case LLAMA -> boundingBox.expand(0, 0, 0, 0, 0.875, 0);
// Ravager base size is 1.95 and height is 2.2
case RAVAGER -> boundingBox.expand(-0.48, 0, -0.48, 0.48, 1.2, 0.48);
// Spider base size is 1.4
case SPIDER -> boundingBox.expand(-0.2, 0, -0.2, 0.2, 0, 0.2);
// Creeper height 1.7
case CREEPER -> boundingBox.expand(0, 0, 0, 0, 0.7, 0);
// Blaze height 1.8
case BLAZE -> boundingBox.expand(0, 0, 0, 0, 0.8, 0);
// Zombie, evoker, villager, husk, witch, vindicator, illusioner, drowned, pigman, villager and pillager height is 1.95
case ZOMBIE, EVOKER, VILLAGER, HUSK, WITCH, VINDICATOR, ILLUSIONER, DROWNED, PIGLIN, PIGLIN_BRUTE, ZOMBIFIED_PIGLIN, ZOMBIE_VILLAGER, PILLAGER, WANDERING_TRADER ->
boundingBox.expand(0, 0, 0, 0, 0.95, 0);
// Skeletons height is 1.99
case SKELETON, STRAY -> boundingBox.expand(0, 0, 0, 0, 0.99, 0);
// Elder Guardians base height is 2
case ELDER_GUARDIAN -> boundingBox.expand(-0.5, 0, -0.5, 0.5, 1, 0.5);
// Slimes are up to 2.04
case SLIME -> boundingBox.expand(-0.5, 0, -0.5, 0.5, 1, 0.5);
// Wither skeletons height is 2.4
case WITHER_SKELETON -> boundingBox.expand(0, 0, 0, 0, 1.4, 0);
// Wither height is 3.5
case WITHER -> boundingBox.expand(0, 0, 0, 0, 2.5, 0);
// Enderman height is 2.9
case ENDERMAN -> boundingBox.expand(0, 0, 0, 0, 1.9, 0);
// Ghast base size is 4
case GHAST -> boundingBox.expand(-2, 0, -2, 2, 3, 2);
// Iron Golem base size is 1.4 and height is 2.7
case IRON_GOLEM -> boundingBox.expand(-0.2, 0, -0.2, 0.2, 1.7, 0.2);
// Snowman height is 1.9
case SNOWMAN -> boundingBox.expand(0, 0, 0, 0, 0.9, 0);
// Hoglin base size is 1.4 and height is 1.3965
case HOGLIN, ZOGLIN -> boundingBox.expand(-0.2, 0, -0.2, 0.2, 0.4, 0.2);
// Warden height is 2.9
case WARDEN -> boundingBox.expand(0, 0, 0, 0, 1.9, 0);
}

return boundingBox;
}


// ---------------------------------------------------------------------
// Section: Private Classes
// ---------------------------------------------------------------------
Expand Down
36 changes: 19 additions & 17 deletions src/main/resources/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ caveblock:
no-safe-location-found: "&cKann keinen sicheren Ort finden, an den du dich in
der Höhle teleportieren kannst."
not-owner: "&cDu bist nicht der Besitzer deiner Höhle!"
cave-limit-reached: "&c Du hast die Spitze deiner Höhle erreicht. Höher geht
nicht!"
commands:
admin:
team:
Expand Down Expand Up @@ -81,7 +83,7 @@ caveblock:
Höhlen im Müll
setrange:
description: Stellen Sie die Reichweite der Spielerhöhle ein
range-updated: Höhlenbereich auf [Nummer] aktualisiert
range-updated: Höhlenbereich auf [number] aktualisiert
tp:
description: teleportiere zur Höhle eines Spielers
getrank:
Expand Down Expand Up @@ -141,15 +143,15 @@ caveblock:
description: Lass einen Spieler in deiner Höhle ranken
uncoop:
you-are-no-longer-a-coop-member: "&cSie sind kein Coop-Mitglied mehr in
der Höhle von [Name]"
der Höhle von [name]"
all-members-logged-off: "& cAlle Höhlenmitglieder haben sich abgemeldet,
sodass Sie nicht länger ein Coop-Mitglied der Höhle von [Name] sind"
sodass Sie nicht länger ein Coop-Mitglied der Höhle von [name] sind "
trust:
description: Gib einem Spieler einen vertrauenswürdigen Rang in deiner Höhle
invite:
description: Lade einen Spieler ein, sich deiner Höhle anzuschließen
name-has-invited-you: "& a [Name] hat dich eingeladen, dich ihrer Höhle
anzuschließen."
name-has-invited-you: "& a [name] hat dich eingeladen, dich ihrer Höhle
anzuschließen. "
you-will-lose-your-island: "& WARNUNG! Sie werden Ihre Höhle verlieren,
wenn Sie akzeptieren!"
errors:
Expand All @@ -164,16 +166,16 @@ caveblock:
reject:
you-rejected-invite: "& aSie lehnten die Einladung ab, sich einer Höhle
anzuschließen."
name-rejected-your-invite: "& c [Name] hat deine Höhleneinladung abgelehnt!"
name-rejected-your-invite: "& c [name] hat deine Höhleneinladung abgelehnt!"
cancel:
description: storniere die ausstehende Einladung, dich deiner Höhle anzuschließen
leave:
description: Verlasse deine Höhle
left-your-island: "& c [Name] & spalte deine Höhle"
left-your-island: "& c [name] & spalte deine Höhle"
kick:
description: Entferne ein Mitglied aus deiner Höhle
owner-kicked: "& cDer Besitzer hat dich aus der Höhle geworfen!"
success: "& b [Name] & wurde aus deiner Höhle geworfen."
success: "& b [name] & wurde aus deiner Höhle geworfen."
demote:
description: Herabstufen eines Spielers in Ihrer Höhle um einen Rang
promote:
Expand All @@ -182,27 +184,27 @@ caveblock:
description: Übertragen Sie Ihren Höhlenbesitz auf ein Mitglied
errors:
target-is-not-member: "& cDieser Spieler ist nicht Teil Ihres Höhlenteams!"
name-is-the-owner: "& a [Name] ist jetzt der Höhlenbesitzer!"
name-is-the-owner: "& a [name] ist jetzt der Höhlenbesitzer!"
you-are-the-owner: "& aSie sind jetzt der Höhlenbesitzer!"
ban:
description: verbanne einen Spieler aus deiner Höhle
cannot-ban-more-players: "& cSie haben das Sperrlimit erreicht, können Sie
keine Spieler mehr aus Ihrer Höhle verbannen."
player-banned: "& b [Name] & c ist jetzt aus deiner Höhle verbannt."
owner-banned-you: "& b [Name] & c hat dich aus ihrer Höhle verbannt!"
player-banned: "& b [name] & c ist jetzt aus deiner Höhle verbannt."
owner-banned-you: "& b [name] & c hat dich aus ihrer Höhle verbannt!"
you-are-banned: "& bSie sind aus dieser Höhle verbannt!"
unban:
description: Entbinde einen Spieler aus deiner Höhle
player-unbanned: "& b [Name] & a ist jetzt nicht mehr in deiner Höhle verboten."
you-are-unbanned: "& b [Name] & a verbannt dich aus ihrer Höhle!"
player-unbanned: "& b [name] & a ist jetzt nicht mehr in deiner Höhle verboten."
you-are-unbanned: "& b [name] & a verbannt dich aus ihrer Höhle!"
banlist:
noone: "& aKeine Höhle ist in dieser Höhle verboten."
settings:
description: Höhleneinstellungen anzeigen
expel:
description: Vertreibe einen Spieler aus deiner Höhle
not-on-island: "& cDieser Spieler ist nicht in deiner Höhle!"
player-expelled-you: "& b [Name] & c hat dich aus der Höhle vertrieben!"
player-expelled-you: "& b [name] & c hat dich aus der Höhle vertrieben!"
ranks:
owner: Zwergenkönig
sub-owner: Zwergenritter
Expand All @@ -219,7 +221,7 @@ caveblock:
& Ablocks aus Höhlen
name: Enderman trauert
ENTER_EXIT_MESSAGES:
island: "[Name] Höhle"
island: "[name] Höhle"
GEO_LIMIT_MOBS:
description: |-
& aEntferne Mobs, die gehen
Expand Down Expand Up @@ -287,8 +289,8 @@ caveblock:
hint: "& cSie können sich nicht in Ihre Höhle zurück teleportieren, während
Sie fallen."
locked: "& cDiese Höhle ist verschlossen!"
protected: "& cCave protected: [Beschreibung]"
spawn-protected: "& cSpawn protected: [Beschreibung]"
protected: "& cCave protected: [description]"
spawn-protected: "& cSpawn protected: [description]"
panel:
PROTECTION:
description: |-
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ caveblock:
no-safe-location-found: "&cНе удалось найти безопасное место для телепортации
в пещеру."
not-owner: "&cВы не владелец этой пещеры!"
cave-limit-reached: "&c Вы достигли вершины своей пещеры. Вы не можете стать
выше!"
commands:
admin:
team:
Expand Down
Loading

0 comments on commit 3070abe

Please sign in to comment.