Skip to content

Commit b23f98a

Browse files
authored
Underwater collision explosion (APDevTeam#693)
* Remove ProtocolLib repo * Implement underwater collision explosion property
1 parent de8588b commit b23f98a

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Diff for: Movecraft/src/main/java/net/countercraft/movecraft/async/translation/TranslationTask.java

+7-5
Original file line numberDiff line numberDiff line change
@@ -368,15 +368,17 @@ else if (world.equals(craft.getWorld())
368368
//Prevents CollisionExplosion crafts from exploding inside the craft.
369369
break;
370370
}
371-
float explosionForce = craft.getType().getFloatProperty(CraftType.COLLISION_EXPLOSION);
371+
float explosionForce;
372+
if (location.getY() < craft.getWaterLine()) {
373+
explosionForce = craft.getType().getFloatProperty(CraftType.UNDERWATER_COLLISION_EXPLOSION);
374+
}
375+
else {
376+
explosionForce = craft.getType().getFloatProperty(CraftType.COLLISION_EXPLOSION);
377+
}
372378
boolean incendiary = craft.getType().getBoolProperty(CraftType.INCENDIARY_ON_CRASH);
373379
if (craft.getType().getBoolProperty(CraftType.FOCUSED_EXPLOSION)) {
374380
explosionForce *= Math.min(oldHitBox.size(), craft.getType().getIntProperty(CraftType.MAX_SIZE));
375381
}
376-
//TODO: Account for underwater explosions
377-
/*if (location.getY() < waterLine) { // underwater explosions require more force to do anything
378-
explosionForce += 25;//TODO: find the correct amount
379-
}*/
380382
Location oldLocation = location.translate(-dx, -dy, -dz).toBukkit(craft.getWorld());
381383
Location newLocation = location.toBukkit(world);
382384
if (!oldLocation.getBlock().getType().isAir()) {

Diff for: api/src/main/java/net/countercraft/movecraft/craft/type/CraftType.java

+2
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ final public class CraftType {
129129
public static final NamespacedKey EXPLODE_ON_CRASH = buildKey("explode_on_crash");
130130
public static final NamespacedKey INCENDIARY_ON_CRASH = buildKey("incendiary_on_crash");
131131
public static final NamespacedKey COLLISION_EXPLOSION = buildKey("collision_explosion");
132+
public static final NamespacedKey UNDERWATER_COLLISION_EXPLOSION = buildKey("underwater_collision_explosion");
132133
private static final NamespacedKey MIN_HEIGHT_LIMIT = buildKey("min_height_limit");
133134
// Private key used as default for PER_WORLD_MIN_HEIGHT_LIMIT
134135
public static final NamespacedKey PER_WORLD_MIN_HEIGHT_LIMIT = buildKey("per_world_min_height_limit");
@@ -454,6 +455,7 @@ public static void registerTypeValidator(Predicate<CraftType> validator, String
454455
registerProperty(new FloatProperty("explodeOnCrash", EXPLODE_ON_CRASH, type -> 0F));
455456
registerProperty(new BooleanProperty("incendiaryOnCrash", INCENDIARY_ON_CRASH, type -> false));
456457
registerProperty(new FloatProperty("collisionExplosion", COLLISION_EXPLOSION, type -> 0F));
458+
registerProperty(new FloatProperty("underwaterCollisionExplosion", UNDERWATER_COLLISION_EXPLOSION, type -> type.getFloatProperty(COLLISION_EXPLOSION)));
457459
registerProperty(new IntegerProperty("minHeightLimit", MIN_HEIGHT_LIMIT, type -> Integer.MIN_VALUE));
458460
registerProperty(new PerWorldProperty<>("perWorldMinHeightLimit", PER_WORLD_MIN_HEIGHT_LIMIT,
459461
(type, worldName) -> type.getIntProperty(MIN_HEIGHT_LIMIT)));

Diff for: buildSrc/src/main/kotlin/buildlogic.java-conventions.gradle.kts

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ repositories {
66
mavenLocal()
77
maven("https://repo.maven.apache.org/maven2/")
88
maven("https://oss.sonatype.org/content/repositories/snapshots/")
9-
maven("https://repo.dmulloy2.net/nexus/repository/public/")
109
maven("https://repo.papermc.io/repository/maven-public/")
1110
}
1211

0 commit comments

Comments
 (0)