Skip to content

Commit 1eaf343

Browse files
authored
Merge pull request #94 from BentoBoxWorld/MC_1_21_3
MC 1.21.3 updates and codemc updates
2 parents 0513f71 + 449ff42 commit 1eaf343

File tree

7 files changed

+47
-119
lines changed

7 files changed

+47
-119
lines changed

pom.xml

+9-9
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,9 @@
3030
</issueManagement>
3131

3232
<distributionManagement>
33-
<snapshotRepository>
34-
<id>codemc-snapshots</id>
35-
<url>https://repo.codemc.org/repository/maven-snapshots</url>
36-
</snapshotRepository>
3733
<repository>
38-
<id>codemc-releases</id>
39-
<url>https://repo.codemc.org/repository/maven-releases</url>
34+
<id>bentoboxworld</id>
35+
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
4036
</repository>
4137
</distributionManagement>
4238

@@ -45,8 +41,8 @@
4541
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
4642
<java.version>17</java.version>
4743
<!-- More visible way how to change dependency versions -->
48-
<spigot.version>1.20.2-R0.1-SNAPSHOT</spigot.version>
49-
<bentobox.version>2.5.0-SNAPSHOT</bentobox.version>
44+
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
45+
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
5046
<!-- Revision variable removes warning about dynamic version -->
5147
<revision>${build.version}-SNAPSHOT</revision>
5248
<!-- This allows to change between versions and snapshots. -->
@@ -101,9 +97,13 @@
10197
<id>spigot-repo</id>
10298
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots</url>
10399
</repository>
100+
<repository>
101+
<id>bentoboxworld</id>
102+
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
103+
</repository>
104104
<repository>
105105
<id>codemc-repo</id>
106-
<url>https://repo.codemc.org/repository/maven-public</url>
106+
<url>https://repo.codemc.org/repository/maven-public/</url>
107107
</repository>
108108
</repositories>
109109

src/main/java/world/bentobox/caveblock/Settings.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
import org.bukkit.entity.EntityType;
1717
import org.eclipse.jdt.annotation.NonNull;
1818

19-
import com.google.common.base.Enums;
20-
2119
import world.bentobox.bentobox.BentoBox;
2220
import world.bentobox.bentobox.api.configuration.ConfigComment;
2321
import world.bentobox.bentobox.api.configuration.ConfigEntry;
@@ -147,7 +145,7 @@ public class Settings implements WorldSettings
147145

148146
@ConfigComment("The default biome for the overworld")
149147
@ConfigEntry(path = "world.default-biome")
150-
private Biome defaultBiome = Enums.getIfPresent(Biome.class, "DRIPSTONE_CAVES").or(Biome.THE_VOID);
148+
private Biome defaultBiome = Biome.DRIPSTONE_CAVES;
151149

152150
@ConfigComment("The maximum number of players a player can ban at any one time in this game mode.")
153151
@ConfigComment("The permission caveblock.ban.maxlimit.X where X is a number can also be used per player")
@@ -231,7 +229,7 @@ public class Settings implements WorldSettings
231229

232230
@ConfigComment("The default biome for the nether world (this may affect what mobs can spawn)")
233231
@ConfigEntry(path = "world.nether.biome", since = "1.14.0")
234-
private Biome defaultNetherBiome = Enums.getIfPresent(Biome.class, "NETHER_WASTES").or(Biome.THE_VOID);
232+
private Biome defaultNetherBiome = Biome.NETHER_WASTES;
235233

236234
@ConfigComment("Nether spawn protection radius - this is the distance around the nether spawn")
237235
@ConfigComment("that will be protected from player interaction (breaking blocks, pouring lava etc.)")
@@ -279,7 +277,7 @@ public class Settings implements WorldSettings
279277

280278
@ConfigComment("The default biome for the end world (this may affect what mobs can spawn)")
281279
@ConfigEntry(path = "world.end.biome", since = "1.14.0")
282-
private Biome defaultTheEndBiome = Enums.getIfPresent(Biome.class, "THE_END").or(Biome.THE_VOID);
280+
private Biome defaultTheEndBiome = Biome.THE_END;
283281

284282
@ConfigEntry(path = "world.end.dragon-spawn", experimental = true)
285283
private boolean dragonSpawn = false;

src/main/java/world/bentobox/caveblock/generators/ChunkGeneratorWorld.java

+13-13
Original file line numberDiff line numberDiff line change
@@ -56,27 +56,27 @@ public ChunkGeneratorWorld(CaveBlock addon, World.Environment environment) {
5656

5757
private Material getGroundRoofMaterial(World.Environment environment) {
5858
return switch (environment) {
59-
case NETHER -> this.settings.isNetherRoof() ? Material.BEDROCK : this.settings.getNetherMainBlock();
60-
case THE_END -> this.settings.isEndRoof() ? Material.BEDROCK : this.settings.getEndMainBlock();
61-
default -> this.settings.isNormalRoof() ? Material.BEDROCK : this.settings.getNormalMainBlock();
59+
case NETHER -> this.settings.isNetherRoof() ? Material.BEDROCK : this.settings.getNetherMainBlock();
60+
case THE_END -> this.settings.isEndRoof() ? Material.BEDROCK : this.settings.getEndMainBlock();
61+
default -> this.settings.isNormalRoof() ? Material.BEDROCK : this.settings.getNormalMainBlock();
6262
};
6363
}
6464

6565

6666
private Material getGroundFloorMaterial(World.Environment environment) {
6767
return switch (environment) {
68-
case NETHER -> this.settings.isNetherFloor() ? Material.BEDROCK : this.settings.getNetherMainBlock();
69-
case THE_END -> this.settings.isEndFloor() ? Material.BEDROCK : this.settings.getEndMainBlock();
70-
default -> this.settings.isNormalFloor() ? Material.BEDROCK : this.settings.getNormalMainBlock();
68+
case NETHER -> this.settings.isNetherFloor() ? Material.BEDROCK : this.settings.getNetherMainBlock();
69+
case THE_END -> this.settings.isEndFloor() ? Material.BEDROCK : this.settings.getEndMainBlock();
70+
default -> this.settings.isNormalFloor() ? Material.BEDROCK : this.settings.getNormalMainBlock();
7171
};
7272
}
7373

7474

7575
private Material getBaseMaterial(World.Environment environment) {
7676
return switch (environment) {
77-
case NETHER -> this.settings.getNetherMainBlock();
78-
case THE_END -> this.settings.getEndMainBlock();
79-
default -> this.settings.getNormalMainBlock();
77+
case NETHER -> this.settings.getNetherMainBlock();
78+
case THE_END -> this.settings.getEndMainBlock();
79+
default -> this.settings.getNormalMainBlock();
8080
};
8181
}
8282

@@ -117,10 +117,10 @@ public void generateNoise(WorldInfo worldInfo, Random random, int chunkX, int ch
117117
final World.Environment environment = worldInfo.getEnvironment();
118118
if (isNewGenerator) {
119119
switch (environment) {
120-
case NETHER:
121-
if (worldHeight + 1 > 34) {
122-
chunkData.setRegion(0, minHeight + 1, 0, 16, 34, 16, Material.SOUL_SAND);
123-
chunkData.setRegion(0, 34, 0, 16, worldHeight - 1, 16, Material.NETHERRACK);
120+
case NETHER:
121+
if (worldHeight + 1 > 34) {
122+
chunkData.setRegion(0, minHeight + 1, 0, 16, 34, 16, Material.SOUL_SAND);
123+
chunkData.setRegion(0, 34, 0, 16, worldHeight - 1, 16, Material.NETHERRACK);
124124
} else {
125125
chunkData.setRegion(0, minHeight + 1, 0, 16, worldHeight - 1, 16, Material.NETHERRACK);
126126
}

src/main/java/world/bentobox/caveblock/generators/populators/EntitiesPopulator.java

+18-89
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
package world.bentobox.caveblock.generators.populators;
22

33

4+
import java.util.Arrays;
5+
import java.util.EnumMap;
6+
import java.util.HashMap;
7+
import java.util.List;
8+
import java.util.Map;
9+
import java.util.Random;
10+
import java.util.stream.Collectors;
11+
412
import org.bukkit.Location;
513
import org.bukkit.Material;
614
import org.bukkit.World.Environment;
715
import org.bukkit.entity.Entity;
816
import org.bukkit.entity.EntityType;
917
import org.bukkit.entity.LivingEntity;
18+
import org.bukkit.entity.WaterMob;
1019
import org.bukkit.generator.BlockPopulator;
1120
import org.bukkit.generator.LimitedRegion;
1221
import org.bukkit.generator.WorldInfo;
@@ -17,9 +26,6 @@
1726
import world.bentobox.caveblock.CaveBlock;
1827
import world.bentobox.caveblock.Utils;
1928

20-
import java.util.*;
21-
import java.util.stream.Collectors;
22-
2329
/**
2430
* This class populates generated chunk with entities by random chance.
2531
*/
@@ -29,17 +35,6 @@ public class EntitiesPopulator extends BlockPopulator {
2935
// Section: Variables
3036
// ---------------------------------------------------------------------
3137

32-
/**
33-
* Water entities
34-
*/
35-
private static final List<EntityType> WATER_ENTITIES = Arrays.asList(EntityType.GUARDIAN,
36-
EntityType.SQUID,
37-
EntityType.COD,
38-
EntityType.SALMON,
39-
EntityType.PUFFERFISH,
40-
EntityType.TROPICAL_FISH,
41-
EntityType.DROWNED,
42-
EntityType.DOLPHIN);
4338
/**
4439
* CaveBlock addon.
4540
*/
@@ -170,12 +165,16 @@ private void tryToPlaceEntity(WorldInfo worldInfo, Location location, LimitedReg
170165
if (!limitedRegion.isInRegion(location)) return;
171166
if (!limitedRegion.getType(location).equals(originalMaterial)) return;
172167

173-
BoundingBox bb = this.getEntityBoundingBox(entityType, location);
168+
// Spawn the entity and then make space for it
169+
Entity entity = limitedRegion.spawnEntity(location, entityType);
170+
BoundingBox bb = entity.getBoundingBox();
174171

175172
for (int x = (int) Math.floor(bb.getMinX()); x < bb.getMaxX(); x++) {
176173
for (int z = (int) Math.floor(bb.getMinZ()); z < bb.getMaxZ(); z++) {
177174
int y = (int) Math.floor(bb.getMinY());
178175
if (!limitedRegion.isInRegion(x, y, z)) {
176+
// Only spawn if it's in the region
177+
entity.remove();
179178
return;
180179
}
181180

@@ -186,96 +185,26 @@ private void tryToPlaceEntity(WorldInfo worldInfo, Location location, LimitedReg
186185

187186
if (!limitedRegion.isInRegion(x, y, z) || !limitedRegion.getType(x, y, z).equals(originalMaterial)) {
188187
// Cannot place entity
188+
entity.remove();
189189
return;
190190
}
191-
limitedRegion.setType(x, y, z, WATER_ENTITIES.contains(entityType) ? Material.WATER : Material.AIR);
191+
limitedRegion.setType(x, y, z, entity instanceof WaterMob ? Material.WATER : Material.AIR);
192192
}
193193
// Add air block on top for all water entities (required for dolphin, okay for others)
194-
if (WATER_ENTITIES.contains(entityType) && limitedRegion.isInRegion(x, y, z) && limitedRegion.getType(x, y, z).equals(originalMaterial)) {
194+
if (entity instanceof WaterMob && limitedRegion.isInRegion(x, y, z)
195+
&& limitedRegion.getType(x, y, z).equals(originalMaterial)) {
195196
limitedRegion.setType(x, y, z, Material.CAVE_AIR);
196197
}
197198
}
198199
}
199200

200-
Entity entity = limitedRegion.spawnEntity(location, entityType);
201-
202201
if (entity instanceof LivingEntity livingEntity)
203202
{
204203
livingEntity.setAI(hasAI);
205204
livingEntity.setRemoveWhenFarAway(false);
206205
}
207206
}
208207

209-
210-
/**
211-
* This is manual bounding box calculation base on entity type.
212-
* @param entityType Entity type which bounding box should be created.
213-
* @param location Location of the bounding box.
214-
* @return Approximate bounding box of the entity type.
215-
*/
216-
private BoundingBox getEntityBoundingBox(EntityType entityType, Location location)
217-
{
218-
BoundingBox boundingBox = new BoundingBox();
219-
// Set bounding box to 1 for all entities
220-
boundingBox.expand(1);
221-
// Shift to correct location.
222-
boundingBox.shift(location);
223-
224-
switch (entityType)
225-
{
226-
// Turtles base size is 1.1
227-
case TURTLE -> boundingBox.expand(-0.05, 0, -0.05, 0.05, 0, 0.05);
228-
// Panda base size is 1.3 and height is 1.25
229-
case PANDA -> boundingBox.expand(-0.15, 0, -0.15, 0.15, 0.25, 0.15);
230-
// Sheep height is 1.3
231-
case SHEEP -> boundingBox.expand(0, 0, 0, 0, 0.3, 0);
232-
// Cow height is 1.4
233-
case COW, MUSHROOM_COW -> boundingBox.expand(0, 0, 0, 0, 0.4, 0);
234-
// Polar Bear base size is 1.3 and height is 1.4
235-
case POLAR_BEAR -> boundingBox.expand(-0.15, 0, -0.15, 0.15, 0.4, 0.15);
236-
// Horse base size is 1.3964
237-
case HORSE, ZOMBIE_HORSE, SKELETON_HORSE -> boundingBox.expand(-0.2, 0, -0.2, 0.2, 0.6, 0.2);
238-
// Llama height is 1.875
239-
case LLAMA -> boundingBox.expand(0, 0, 0, 0, 0.875, 0);
240-
// Ravager base size is 1.95 and height is 2.2
241-
case RAVAGER -> boundingBox.expand(-0.48, 0, -0.48, 0.48, 1.2, 0.48);
242-
// Spider base size is 1.4
243-
case SPIDER -> boundingBox.expand(-0.2, 0, -0.2, 0.2, 0, 0.2);
244-
// Creeper height 1.7
245-
case CREEPER -> boundingBox.expand(0, 0, 0, 0, 0.7, 0);
246-
// Blaze height 1.8
247-
case BLAZE -> boundingBox.expand(0, 0, 0, 0, 0.8, 0);
248-
// Zombie, evoker, villager, husk, witch, vindicator, illusioner, drowned, pigman, villager and pillager height is 1.95
249-
case ZOMBIE, EVOKER, VILLAGER, HUSK, WITCH, VINDICATOR, ILLUSIONER, DROWNED, PIGLIN, PIGLIN_BRUTE, ZOMBIFIED_PIGLIN, ZOMBIE_VILLAGER, PILLAGER, WANDERING_TRADER ->
250-
boundingBox.expand(0, 0, 0, 0, 0.95, 0);
251-
// Skeletons height is 1.99
252-
case SKELETON, STRAY -> boundingBox.expand(0, 0, 0, 0, 0.99, 0);
253-
// Elder Guardians base height is 2
254-
case ELDER_GUARDIAN -> boundingBox.expand(-0.5, 0, -0.5, 0.5, 1, 0.5);
255-
// Slimes are up to 2.04
256-
case SLIME -> boundingBox.expand(-0.5, 0, -0.5, 0.5, 1, 0.5);
257-
// Wither skeletons height is 2.4
258-
case WITHER_SKELETON -> boundingBox.expand(0, 0, 0, 0, 1.4, 0);
259-
// Wither height is 3.5
260-
case WITHER -> boundingBox.expand(0, 0, 0, 0, 2.5, 0);
261-
// Enderman height is 2.9
262-
case ENDERMAN -> boundingBox.expand(0, 0, 0, 0, 1.9, 0);
263-
// Ghast base size is 4
264-
case GHAST -> boundingBox.expand(-2, 0, -2, 2, 3, 2);
265-
// Iron Golem base size is 1.4 and height is 2.7
266-
case IRON_GOLEM -> boundingBox.expand(-0.2, 0, -0.2, 0.2, 1.7, 0.2);
267-
// Snowman height is 1.9
268-
case SNOWMAN -> boundingBox.expand(0, 0, 0, 0, 0.9, 0);
269-
// Hoglin base size is 1.4 and height is 1.3965
270-
case HOGLIN, ZOGLIN -> boundingBox.expand(-0.2, 0, -0.2, 0.2, 0.4, 0.2);
271-
// Warden height is 2.9
272-
case WARDEN -> boundingBox.expand(0, 0, 0, 0, 1.9, 0);
273-
}
274-
275-
return boundingBox;
276-
}
277-
278-
279208
// ---------------------------------------------------------------------
280209
// Section: Private Classes
281210
// ---------------------------------------------------------------------

src/main/resources/addon.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: CaveBlock
22
main: world.bentobox.caveblock.CaveBlock
33
version: ${version}${build.number}
4-
api-version: 2.5.0
4+
api-version: 2.7.1
55
metrics: true
66
repository: "BentoBoxWorld/CaveBlock"
77
icon: "STONE_PICKAXE"

src/main/resources/config.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ world:
150150
- MATERIAL:GRANITE:40:10
151151
- MATERIAL:ANDESITE:20:10
152152
- MATERIAL:DIORITE:30:8
153+
- MATERIAL:LAVA:15:4
153154
- ENTITY:ZOMBIE:10:1
154155
- ENTITY:ENDERMAN:10:1
155156
- ENTITY:SKELETON:10:1
@@ -200,7 +201,7 @@ world:
200201
- MATERIAL:MAGMA_BLOCK:10:3
201202
- MATERIAL:GLOWSTONE:20:8
202203
- MATERIAL:NETHER_BRICKS:10:5
203-
- MATERIAL:LAVA:10:1
204+
- MATERIAL:LAVA:30:10
204205
- ENTITY:MAGMA_CUBE:0.5:1
205206
- ENTITY:GHAST:0.1:1
206207
- ENTITY:WITHER_SKELETON:0.1:1

src/main/resources/plugin.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: BentoBox-CaveBlock
22
main: world.bentobox.caveblock.CaveBlockPladdon
33
version: ${project.version}${build.number}
4-
api-version: "1.19"
4+
api-version: "1.21"
55

66
authors: [tastybento, BONNe]
77
contributors: ["The BentoBoxWorld Community"]

0 commit comments

Comments
 (0)