Skip to content

Commit

Permalink
Underwater collision explosion (#693)
Browse files Browse the repository at this point in the history
* Remove ProtocolLib repo

* Implement underwater collision explosion property
  • Loading branch information
TylerS1066 authored Aug 16, 2024
1 parent de8588b commit b23f98a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -368,15 +368,17 @@ else if (world.equals(craft.getWorld())
//Prevents CollisionExplosion crafts from exploding inside the craft.
break;
}
float explosionForce = craft.getType().getFloatProperty(CraftType.COLLISION_EXPLOSION);
float explosionForce;
if (location.getY() < craft.getWaterLine()) {
explosionForce = craft.getType().getFloatProperty(CraftType.UNDERWATER_COLLISION_EXPLOSION);
}
else {
explosionForce = craft.getType().getFloatProperty(CraftType.COLLISION_EXPLOSION);
}
boolean incendiary = craft.getType().getBoolProperty(CraftType.INCENDIARY_ON_CRASH);
if (craft.getType().getBoolProperty(CraftType.FOCUSED_EXPLOSION)) {
explosionForce *= Math.min(oldHitBox.size(), craft.getType().getIntProperty(CraftType.MAX_SIZE));
}
//TODO: Account for underwater explosions
/*if (location.getY() < waterLine) { // underwater explosions require more force to do anything
explosionForce += 25;//TODO: find the correct amount
}*/
Location oldLocation = location.translate(-dx, -dy, -dz).toBukkit(craft.getWorld());
Location newLocation = location.toBukkit(world);
if (!oldLocation.getBlock().getType().isAir()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ final public class CraftType {
public static final NamespacedKey EXPLODE_ON_CRASH = buildKey("explode_on_crash");
public static final NamespacedKey INCENDIARY_ON_CRASH = buildKey("incendiary_on_crash");
public static final NamespacedKey COLLISION_EXPLOSION = buildKey("collision_explosion");
public static final NamespacedKey UNDERWATER_COLLISION_EXPLOSION = buildKey("underwater_collision_explosion");
private static final NamespacedKey MIN_HEIGHT_LIMIT = buildKey("min_height_limit");
// Private key used as default for PER_WORLD_MIN_HEIGHT_LIMIT
public static final NamespacedKey PER_WORLD_MIN_HEIGHT_LIMIT = buildKey("per_world_min_height_limit");
Expand Down Expand Up @@ -454,6 +455,7 @@ public static void registerTypeValidator(Predicate<CraftType> validator, String
registerProperty(new FloatProperty("explodeOnCrash", EXPLODE_ON_CRASH, type -> 0F));
registerProperty(new BooleanProperty("incendiaryOnCrash", INCENDIARY_ON_CRASH, type -> false));
registerProperty(new FloatProperty("collisionExplosion", COLLISION_EXPLOSION, type -> 0F));
registerProperty(new FloatProperty("underwaterCollisionExplosion", UNDERWATER_COLLISION_EXPLOSION, type -> type.getFloatProperty(COLLISION_EXPLOSION)));
registerProperty(new IntegerProperty("minHeightLimit", MIN_HEIGHT_LIMIT, type -> Integer.MIN_VALUE));
registerProperty(new PerWorldProperty<>("perWorldMinHeightLimit", PER_WORLD_MIN_HEIGHT_LIMIT,
(type, worldName) -> type.getIntProperty(MIN_HEIGHT_LIMIT)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ repositories {
mavenLocal()
maven("https://repo.maven.apache.org/maven2/")
maven("https://oss.sonatype.org/content/repositories/snapshots/")
maven("https://repo.dmulloy2.net/nexus/repository/public/")
maven("https://repo.papermc.io/repository/maven-public/")
}

Expand Down

0 comments on commit b23f98a

Please sign in to comment.