Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add splash potions entity to Spawner module #1002

Merged
merged 23 commits into from
May 22, 2022

Conversation

CoWinkKeyDinkInc
Copy link
Contributor

This PR adds falling potions (splash potions) as a droppable entity that can be configured with the XML spawner. These are automatically used when using <effect> <effects> <potion> <potions>. Some work needs to be done on it first, like fixing the positions that the potions spawn, flame effects, potion colour and so on.

<spawners>
    <!-- drops a slowness splash potion -->
    <spawner spawn-region="gold-apple" player-region="gold-apple" delay="5s">
        <effect duration="10" amplifier="1">slowness</effect>
    </spawner>
    <!-- drops a splash potion that contains both speed and jumpboost -->
    <spawner spawn-region="arrows" player-region="arrows" delay="5s">
        <effect duration="10" amplifier="3">speed</effect>
        <effect duration="10" amplifier="6">jump_boost</effect>
    </spawner>
</spawners>

@CoWinkKeyDinkInc
Copy link
Contributor Author

The potion effects are now nested inside <potion> and can inherit attributes from a higher element, which follows XML conventions seen in other modules. Thanks to @Pablete1234 for the suggestion.

<spawners>
    <spawner spawn-region="gold-apple" player-region="gold-apple" delay="5s">
        <potion duration="10">
            <effect amplifier="1">slowness</effect>
        </potion>
    </spawner>
    <spawner spawn-region="arrows" player-region="arrows" delay="5s">
        <potion duration="10" amplifier="3">
            <effect>speed</effect>
            <effect>jump_boost</effect>
        </potion>
    </spawner>
</spawners>

core/src/main/java/tc/oc/pgm/spawner/SpawnerModule.java Outdated Show resolved Hide resolved
core/src/main/java/tc/oc/pgm/spawner/SpawnerModule.java Outdated Show resolved Hide resolved
core/src/main/java/tc/oc/pgm/spawner/SpawnerModule.java Outdated Show resolved Hide resolved
core/src/main/java/tc/oc/pgm/spawner/SpawnerModule.java Outdated Show resolved Hide resolved
core/src/main/java/tc/oc/pgm/spawner/SpawnerModule.java Outdated Show resolved Hide resolved
core/src/main/java/tc/oc/pgm/spawner/SpawnerModule.java Outdated Show resolved Hide resolved
core/src/main/java/tc/oc/pgm/spawner/SpawnerModule.java Outdated Show resolved Hide resolved
@CoWinkKeyDinkInc
Copy link
Contributor Author

CoWinkKeyDinkInc commented May 9, 2022

The ThrownPotion entity now appears correctly by using NMS hacks, since its appearance can't be changed after spawning. The potion particles appear off centre (should be in centre of red wool) as you can see in the screenshot, but this is pretty minor. Currently the metadata isn't set to the splash potion entity, but other than that it's complete imo.

2022-05-09_02 18 31

@CoWinkKeyDinkInc CoWinkKeyDinkInc marked this pull request as ready for review May 9, 2022 08:33
@KingOfSquares
Copy link
Contributor

Does the NMS hack work on Spigot as well?

@CoWinkKeyDinkInc
Copy link
Contributor Author

Does the NMS hack work on Spigot as well?

The entity does not spawn using Spigot 1.8.8. It returns this error:

[20:04:31 ERROR]: [MatchImpl] Could not tick tc.oc.pgm.spawner.Spawner@5713494e
java.lang.NoClassDefFoundError: org/bukkit/attribute/AttributeModifier
        at java.lang.Class.getDeclaringClass0(Native Method) ~[?:1.8.0_332]
        at java.lang.Class.getDeclaringClass(Class.java:1235) ~[?:1.8.0_332]
        at java.lang.Class.getEnclosingClass(Class.java:1277) ~[?:1.8.0_332]
        at java.lang.Class.getSimpleBinaryName(Class.java:1443) ~[?:1.8.0_332]
        at java.lang.Class.getSimpleName(Class.java:1309) ~[?:1.8.0_332]
        at org.bukkit.craftbukkit.v1_8_R3.SpigotTimings.getEntityTimings(SpigotTimings.java:91) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.Entity.<init>(Entity.java:120) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.EntityProjectile.<init>(EntityProjectile.java:45) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.EntityPotion.<init>(EntityPotion.java:31) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at tc.oc.pgm.util.nms.NMSHacks$EntityPotion.<init>(NMSHacks.java:1332) ~[PGM.jar:?]
        at tc.oc.pgm.spawner.objects.SpawnablePotion.spawn(SpawnablePotion.java:32) ~[PGM.jar:?]
        at tc.oc.pgm.spawner.Spawner.tick(Spawner.java:52) ~[PGM.jar:?]
        at tc.oc.pgm.match.MatchImpl$TickableTask.run(MatchImpl.java:721) [PGM.jar:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_332]
        at tc.oc.pgm.util.concurrent.TaskExecutorService$Task.run(TaskExecutorService.java:228) [PGM.jar:?]
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:723) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at java.lang.Thread.run(Thread.java:750) [?:1.8.0_332]

@KingOfSquares

@KingOfSquares
Copy link
Contributor

Does the NMS hack work on Spigot as well?

The entity does not spawn using Spigot 1.8.8. It returns this error:

[20:04:31 ERROR]: [MatchImpl] Could not tick tc.oc.pgm.spawner.Spawner@5713494e
java.lang.NoClassDefFoundError: org/bukkit/attribute/AttributeModifier
        at java.lang.Class.getDeclaringClass0(Native Method) ~[?:1.8.0_332]
        at java.lang.Class.getDeclaringClass(Class.java:1235) ~[?:1.8.0_332]
        at java.lang.Class.getEnclosingClass(Class.java:1277) ~[?:1.8.0_332]
        at java.lang.Class.getSimpleBinaryName(Class.java:1443) ~[?:1.8.0_332]
        at java.lang.Class.getSimpleName(Class.java:1309) ~[?:1.8.0_332]
        at org.bukkit.craftbukkit.v1_8_R3.SpigotTimings.getEntityTimings(SpigotTimings.java:91) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.Entity.<init>(Entity.java:120) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.EntityProjectile.<init>(EntityProjectile.java:45) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.EntityPotion.<init>(EntityPotion.java:31) ~[spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at tc.oc.pgm.util.nms.NMSHacks$EntityPotion.<init>(NMSHacks.java:1332) ~[PGM.jar:?]
        at tc.oc.pgm.spawner.objects.SpawnablePotion.spawn(SpawnablePotion.java:32) ~[PGM.jar:?]
        at tc.oc.pgm.spawner.Spawner.tick(Spawner.java:52) ~[PGM.jar:?]
        at tc.oc.pgm.match.MatchImpl$TickableTask.run(MatchImpl.java:721) [PGM.jar:?]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_332]
        at tc.oc.pgm.util.concurrent.TaskExecutorService$Task.run(TaskExecutorService.java:228) [PGM.jar:?]
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:723) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot-1.8.8.jar:git-Spigot-21fe707-741a1bd]
        at java.lang.Thread.run(Thread.java:750) [?:1.8.0_332]

@KingOfSquares

Then you should adjust the NMSHack using the SportPaper check so it uses a Spigot compatible method. Not a real worry since its only potion colors right?

@CoWinkKeyDinkInc
Copy link
Contributor Author

Luckily it looks like it was just a building error on my end, using the PGM compiled by the GitHub Builds shows it spawning the potion properly without any errors in Spigot.

Copy link
Member

@Pablete1234 Pablete1234 left a comment

Choose a reason for hiding this comment

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

Looking pretty good in general, just a few more tweaks

@Electroid Electroid merged commit 6003eff into PGMDev:dev May 22, 2022
Electroid added a commit that referenced this pull request May 22, 2022
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.

5 participants