Skip to content

Bridge egg#1686

Open
eliminate123 wants to merge 2 commits into
PGMDev:devfrom
Javggg:bridge-egg
Open

Bridge egg#1686
eliminate123 wants to merge 2 commits into
PGMDev:devfrom
Javggg:bridge-egg

Conversation

@eliminate123

Copy link
Copy Markdown
Contributor
2026-06-11 14-23-40 (online-video-cutter com)(1)

This PR adds new attributes for <projectile>:

bridge-egg="true/false"
bridge-range="integer" (Distance bridge continues before stopping)
bridge-material="filter" (Blocks used for bridge. If >1 block type, randomizes placement)
team-color="true/false" (Dyes dyeable blocks)
silent="true/false" (Mutes bridge noises)

<projectiles>
    <projectile id="bridge" projectile="Egg" click="right" bridge-egg="true" bridge-range="30" bridge-material="bridge-block-filter" team-color="true" velocity="2"/>
</projectiles>
<filters>
    <any id="bridge-block-filter">
        <material>stone</material>
        <material>dirt</material>
        <material>diamond block</material>
        <material>wool</material>
    </any>
</filters>

If a player leaves/obs/switches teams with an active bridge egg, its killed. If a bridge egg hits any region where building isnt enabled the bridge egg is killed. If the bridge egg hits vanilla height limit/ it gets killed. If a bridge egg hits the void it gets killed.

Signed-off-by: Eliminate123 <96848330+eliminate123@users.noreply.github.com>
@technodono

Copy link
Copy Markdown
Contributor

Oh golly do I already have a map that could use this 😈

Comment thread core/src/main/java/tc/oc/pgm/projectile/ActiveBridgeEgg.java Outdated
Comment thread core/src/main/java/tc/oc/pgm/projectile/ProjectileModule.java Outdated
Comment on lines +81 to +82
boolean bridgeEgg =
XMLUtils.parseBoolean(projectileElement.getAttribute("bridge-egg"), false);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of bridge-egg="true" i'd expect projectile="bridge-egg", which goes in line with what i mentioned about supporting other projectile types that aren't vanilla entities but rather more expansive concepts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it so it now uses projectile="bridge-egg"

Comment on lines +106 to +138
if (bridgeRange < MIN_BRIDGE_RANGE) {
throw new InvalidXMLException(
"'bridge-range' must be at least " + MIN_BRIDGE_RANGE, projectileElement);
}
if (bridgeRange > MAX_BRIDGE_RANGE) {
bridgeRange = MAX_BRIDGE_RANGE;
}

if (bridgeMaterials.isEmpty()) {
throw new InvalidXMLException(
"'bridge-material' has not been defined", projectileElement);
}
if (power != null) {
throw new InvalidXMLException(
"'bridge-egg' and 'power' cannot both be defined", projectileElement);
}
if (potionKit != null && !potionKit.isEmpty()) {
throw new InvalidXMLException(
"'bridge-egg' and 'effect' cannot both be defined", projectileElement);
}
if (destroyFilter != null) {
throw new InvalidXMLException(
"'bridge-egg' and 'destroy-filter' cannot both be defined", projectileElement);
}
} else {
if (bridgeRange != 0) {
throw new InvalidXMLException(
"'bridge-range' is only supported for 'bridge-egg'", projectileElement);
}
if (!bridgeMaterials.isEmpty()) {
throw new InvalidXMLException(
"'bridge-material' is only supported for 'bridge-egg'", projectileElement);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is pain copypaste slop of mutually exclusive tags, many of them aren't even necessarily mutually exclusive they're just unused depending on what is being parsed. So bridge eggs just shouldn't be reading stuff like power, and non-bridge eggs shouldn't be reading stuff like bridge-range.

PGM will report them as unused nodes and that's all you really need here.

Signed-off-by: Eliminate123 <96848330+eliminate123@users.noreply.github.com>
@eliminate123 eliminate123 requested a review from Pablete1234 June 13, 2026 16:45
Comment on lines 19 to +29
protected Class<? extends Entity> projectile;
protected List<PotionEffect> potion;
protected Filter destroyFilter;
protected Duration coolDown;
protected boolean throwable;
protected boolean precise;
protected BlockMaterialData blockMaterial;
protected final int bridgeRange;
protected List<Material> bridgeMaterial;
protected boolean teamColor;
protected boolean silent;

@Pablete1234 Pablete1234 Jun 13, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe i didn't make a clear enough comment in the first review, but what i mean is that the definition shouldn't have stuff not relevant to it, so i'd expect this to instead work more like:

Suggested change
protected boolean silent;
protected PgmProjectile projectile;
protected List<PotionEffect> potion;
protected Filter destroyFilter;
protected Duration coolDown;
protected boolean throwable;
protected boolean precise;
protected BlockMaterialData blockMaterial;

where that PgmProjectile can be a direct entity can be something along the lines of:

interface PgmProjectile {

  public void spawn(...);

  public void despawn(...);

}

and you can have differing implementations like:
record EntityProjectile(Class<? extends Entity> projectile) implements PgmProjectile {...} (current behavior)
record BridgeEggProjectile(int range, List<Material> material, boolean teamColor, boolean silent) implements PgmProjectile { ... }

That means that attributes that are specific to one type are only parsed by that type, so in the parsing code you can have something like:

PgmProjectile projectile = switch (projType) {
  case "bridge-egg" -> new BridgeEggProjectile(
      parser.parseInt(el, "bridge-range"),
      parser.parseMaterial(...),
      parser.parseBool(el, "bridge-team-color"),
      parser.parseBool(el, "bridge-silent"));
  default -> new EntityProjectile(...);
}

This way the attributes that are specific to bridge-eggs only get parsed if bridge egg is relevant, and are passed along with it.

You can see a big portion of this same idea implemented in #1502 (https://github.com/PGMDev/PGM/pull/1502/changes#diff-079be93d9cad6596ef0f505dad1789ed6b2f93ac49776622e21b4e82f3df6ae5R19)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants