Skip to content

Commit

Permalink
EliteMobs 7.3.12-SNAPSHOT-12
Browse files Browse the repository at this point in the history
- [New] Rewrote the core of wormholes.
    - [Fix] Fixes the massive FPS drops from runaway armor stand generation issues
    - [Fix] Fixes rare doubling up of particles
    - [Tweak] Increases the performance of Wormholes
- [New] Added the isocahedron portal type, looks like a tabletop 20-sided die. Use of a scale of about 2 is recommended for better visuals.
- [New] Moved the default wormhole locations to new spot in the Adventurer's Map, a dedicated building for dungeons
- [New] Added sizeMultiplier config field to the wormholes config, allows admins to set the multiplier for the size of the portal. Automatically adjusts all relevant values.
- [Tweak] Increased the scan frequency of wormholes
- [Tweak] Reduced the distance at which wormholes detect player presence.

Signed-off-by: MagmaGuy <tiagoarnaut@gmail.com>
  • Loading branch information
MagmaGuy committed Jan 12, 2022
1 parent e4c7c2f commit 64919c4
Show file tree
Hide file tree
Showing 27 changed files with 434 additions and 294 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ compileJava.options.encoding = "UTF-8"
compileTestJava.options.encoding = "UTF-8"

group 'com.magmaguy'
version '7.3.12-SNAPSHOT-10'
version '7.3.12-SNAPSHOT-11'

repositories {
maven {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/magmaguy/elitemobs/EventsRegistrer.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import wormhole.WormholeEntry;

public class EventsRegistrer {

Expand Down Expand Up @@ -141,6 +142,9 @@ public static void registerEvents() {
pluginManager.registerEvents(new EliteMobDamagedByPlayerEvent.EliteMobDamagedByPlayerEventFilter(), plugin);
pluginManager.registerEvents(new EliteExplosionEvent.EliteExplosionEvents(), plugin);

//Wormholes
pluginManager.registerEvents(new WormholeEntry.WormholeEntryEvent(), plugin);


/*
While these powers could be registered in a more automated way, I realized that it's also a bad way of getting
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ public AdminCommands(PaperCommandManager<CommandSender> manager, Command.Builder
commandContext.getSender().sendMessage(ChatColorConverter.convert("&8[EliteMobs] &aAttempted to send a message to Discord!"));
}));

// /em unbind
// /em forceunbind
manager.command(builder.literal("forceunbind")
.senderType(Player.class)
.permission("elitemobs.*")
Expand Down Expand Up @@ -647,15 +647,15 @@ public AdminCommands(PaperCommandManager<CommandSender> manager, Command.Builder
.handler(commandContext -> TransitiveBlockCommand.processCommand((Player) commandContext.getSender(),
commandContext.get("regionalBoss"), commandContext.get("blockTransitionPhase"), false, true)));

// /em registerblocksarea <regional_boss_file.yml> <on_spawn/on_remove>
// /em registerblocksareaedit <regional_boss_file.yml> <on_spawn/on_remove>
manager.command(builder.literal("registerblocksareaedit")
.senderType(Player.class)
.argument(StringArgument.<CommandSender>newBuilder("regionalBoss").withSuggestionsProvider(((objectCommandContext, s) -> customBosses)),
ArgumentDescription.of("Regional Boss configuration file name"))
.argument(StringArgument.<CommandSender>newBuilder("blockTransitionPhase").withSuggestionsProvider(((objectCommandContext, s) -> blockTransitionPhases)),
ArgumentDescription.of("Block transition phase"))
.permission("elitemobs.*")
.meta(CommandMeta.DESCRIPTION, "Registers large transitive blocks areas for use by regional bosses.")
.meta(CommandMeta.DESCRIPTION, "Edits large transitive blocks areas for use by regional bosses.")
.handler(commandContext -> TransitiveBlockCommand.processCommand((Player) commandContext.getSender(),
commandContext.get("regionalBoss"), commandContext.get("blockTransitionPhase"), true, true)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public UserCommands(PaperCommandManager<CommandSender> manager, Command.Builder<
}
}));

// /em smelt
// /em scrap
manager.command(builder.literal("scrap")
.meta(CommandMeta.DESCRIPTION, "Opens the custom item shop or teleports the player to the Adventurer's Guild Hub")
.senderType(Player.class)
Expand Down Expand Up @@ -255,7 +255,7 @@ public UserCommands(PaperCommandManager<CommandSender> manager, Command.Builder<

// /em menu
manager.command(builder.literal("menu")
.meta(CommandMeta.DESCRIPTION, "Opens the EliteMobs rank menu.")
.meta(CommandMeta.DESCRIPTION, "Opens the EliteMobs status screen.")
.senderType(Player.class)
.handler(commandContext -> new PlayerStatusScreen((Player) commandContext.getSender())));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ public void processConfigFields() {
for (String string : uniqueLootList)
if (SpecialLoot.isSpecialLootEntry(string))
specialLoot.put(string, new SpecialLoot(string));
// minecraft:type=ITEM_TYPE:amount=AMOUNT
// minecraft:type=ITEM_TYPE:amount=AMOUNT:chance=CHANCE
for (String string : uniqueLootList)
if (string.contains("minecraft:")) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ public class WormholeConfigFields extends CustomConfigFields implements CustomCo
@Getter
@Setter
private boolean blindPlayer;
@Getter
@Setter
private double sizeMultiplier = 1D;

public WormholeConfigFields(String filename,
boolean isEnabled,
Expand Down Expand Up @@ -63,6 +66,7 @@ public void processConfigFields() {
this.style = processEnum("style", style, Wormhole.WormholeStyle.CUBE, Wormhole.WormholeStyle.class, false);
this.particleColor = processInt("particleColor", particleColor, 0x800080, false);
this.blindPlayer = processBoolean("blindPlayer", blindPlayer, false, false);
this.sizeMultiplier = processDouble("sizeMultiplier", sizeMultiplier, 1D, false);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGAirshipWormholeConfig extends WormholeConfigFields {
public AGAirshipWormholeConfig() {
super("ag_airship_wormhole",
true,
"em_adventurers_guild,279.5,77,225.5,-135,0",
"em_adventurers_guild,284.5,101,296.5,0,0",
"airship_minidungeon.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGBinderOfWorldsLairWormholeConfig extends WormholeConfigFields {
public AGBinderOfWorldsLairWormholeConfig() {
super("ag_binder_of_worlds_wormhole",
true,
"em_adventurers_guild,292.5,62,219.5,90,0",
"em_adventurers_guild,290.5,123,302.5,90,0",
"binder_of_worlds_lair.yml",
Wormhole.WormholeStyle.CRYSTAL);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGCatacombsWormholeConfig extends WormholeConfigFields {
public AGCatacombsWormholeConfig() {
super("ag_catacombs_wormhole",
true,
"em_adventurers_guild,291.5,77,225.5,-135,0",
"em_adventurers_guild,296.5,98,296.5,98,0",
"catacombs_lair.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGColosseumWormholeConfig extends WormholeConfigFields {
public AGColosseumWormholeConfig() {
super("ag_colosseum_wormhole",
true,
"em_adventurers_guild,278.5,72,219.5,-90,0",
"em_adventurers_guild,296.5,103,308.5,-175,0",
"colosseum_lair.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGDarkCathedralWormholeConfig extends WormholeConfigFields {
public AGDarkCathedralWormholeConfig() {
super("ag_dark_cathedral_wormhole",
true,
"em_adventurers_guild,285.5,72,212.5,0,0",
"em_adventurers_guild,290.5,103.5,311.5,-135,0",
"colosseum_lair.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGDarkSpireWormholeConfig extends WormholeConfigFields {
public AGDarkSpireWormholeConfig() {
super("ag_dark_spire_wormhole",
true,
"em_adventurers_guild,285.5,67,212.5,0,0",
"em_adventurers_guild,284.5,105,296.5,0,0",
"dark_spire_minidungeon.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGFireworksWormholeConfig extends WormholeConfigFields {
public AGFireworksWormholeConfig() {
super("ag_fireworks_wormhole",
true,
"em_adventurers_guild,278.5,77,219.5,-90,0",
"em_adventurers_guild,296.5,102,296.5,-90,0",
"fireworks_lair.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGHallosseumWormholeConfig extends WormholeConfigFields {
public AGHallosseumWormholeConfig() {
super("ag_hallosseum_wormhole",
true,
"em_adventurers_guild,278.5,77,222.5,-110,0",
"em_adventurers_guild,290.5,101.5,293.5,-40,0",
"hallosseum_lair.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGInvasionWormholeConfig extends WormholeConfigFields {
public AGInvasionWormholeConfig() {
super("ag_invasion_wormhole",
true,
"em_adventurers_guild,282.5,77,226.5,-156,0",
"em_adventurers_guild,281.5,100.5,302.5,-46,0",
"invasion_minidungeon.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGNorthPoleWormholeConfig extends WormholeConfigFields {
public AGNorthPoleWormholeConfig() {
super("ag_north_pole_wormhole",
true,
"em_adventurers_guild,279.5,72,213.5,-45,0",
"em_adventurers_guild,284.5,104,308.5,-90,0",
"north_pole_minidungeon.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGOasisWormholeConfig extends WormholeConfigFields {
public AGOasisWormholeConfig() {
super("ag_oasis_wormhole",
true,
"em_adventurers_guild,292.5,77,222.5,112,0",
"em_adventurers_guild,290.5,97.5,293.5,54,0",
"oasis_adventure.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGPirateShipWormholeConfig extends WormholeConfigFields {
public AGPirateShipWormholeConfig() {
super("ag_pirate_ship_wormhole",
true,
"em_adventurers_guild,288.5,77,226.5,-157,0",
"em_adventurers_guild,296.5,99,308.5,-174,0",
"pirate_ship_minidungeon.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ public class AGPrimisWormholeConfig extends WormholeConfigFields {
public AGPrimisWormholeConfig() {
super("ag_primis_wormhole",
true,
"em_adventurers_guild,292.5,77,219.5,90,0",
"em_adventurers_guild,290.5,97,302.5,109,0",
"primis_adventure.yml",
Wormhole.WormholeStyle.CUBE);
Wormhole.WormholeStyle.ICOSAHEDRON);
setBlindPlayer(true);
setLocation1Text("&2『Primis Adventure』 &aLvls 0-15");
setParticleColor(0x008000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGRuinsWormholeConfig extends WormholeConfigFields {
public AGRuinsWormholeConfig() {
super("ag_ruins_wormhole",
true,
"em_adventurers_guild,291.5,67,213.5,45,0",
"em_adventurers_guild,290.5,107.5,311.5,-135,0",
"the_ruins.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGSewersWormholeConfig extends WormholeConfigFields {
public AGSewersWormholeConfig() {
super("ag_sewers_wormhole",
true,
"em_adventurers_guild,285.5,77,226.5,-180,0",
"em_adventurers_guild,299.5,98.5,302.5,133,0",
"sewers_minidungeon.yml",
Wormhole.WormholeStyle.CUBE);
setBlindPlayer(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class AGVampireManorWormholeConfig extends WormholeConfigFields {
public AGVampireManorWormholeConfig() {
super("ag_vampire_manor_wormhole",
true,
"em_adventurers_guild,292.5,62,222.5,113,0",
"em_adventurers_guild,290.5,105.5,293.5,45,0",
"vampire_manor.yml",
Wormhole.WormholeStyle.CRYSTAL);
setBlindPlayer(true);
Expand Down
151 changes: 151 additions & 0 deletions src/main/java/wormhole/VisualEffects.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
package wormhole;

import com.magmaguy.elitemobs.config.wormholes.WormholeConfigFields;
import com.magmaguy.elitemobs.utils.WarningMessage;
import lombok.Getter;
import org.bukkit.util.Vector;

import java.util.ArrayList;
import java.util.List;

public class VisualEffects {
private final WormholeConfigFields wormholeConfigFields;
private final List<Vector> cachedLocations = new ArrayList<>();
@Getter
private final List<List<Vector>> cachedRotations = new ArrayList<List<Vector>>();

public VisualEffects(WormholeConfigFields wormholeConfigFields) {
this.wormholeConfigFields = wormholeConfigFields;
initializeVisualEffect();
}

private void initializeVisualEffect() {
switch (wormholeConfigFields.getStyle()) {
case CUBE:
generateCube();
break;
case CRYSTAL:
generateCrystal();
break;
case ICOSAHEDRON:
generateIcosahedron();
break;
default:
new WarningMessage("Missing wormhole style for " + wormholeConfigFields.getStyle());
}
}

private void generateCrystal() {
//top
Vector top = new Vector(0, 1, 0).multiply(wormholeConfigFields.getSizeMultiplier());
cachedLocations.add(top);
//bottom
Vector bottom = new Vector(0, -1, 0).multiply(wormholeConfigFields.getSizeMultiplier());
cachedLocations.add(bottom);
//front
Vector front = new Vector(.5, 0, 0).multiply(wormholeConfigFields.getSizeMultiplier());
cachedLocations.add(front);
//side
Vector side = new Vector(0, 0, .5).multiply(wormholeConfigFields.getSizeMultiplier());
cachedLocations.add(side);

finishCuboidInitialization(top, bottom, front, side);

}

private void generateCube() {
//top
Vector top = new Vector(0, 1, 0).multiply(wormholeConfigFields.getSizeMultiplier());
cachedLocations.add(top);
//bottom
Vector bottom = new Vector(0, -1, 0).multiply(wormholeConfigFields.getSizeMultiplier());
cachedLocations.add(bottom);
//front
Vector front = new Vector(1, 0, 0).multiply(wormholeConfigFields.getSizeMultiplier());
cachedLocations.add(front);
//side
Vector side = new Vector(0, 0, 1).multiply(wormholeConfigFields.getSizeMultiplier());
cachedLocations.add(side);

finishCuboidInitialization(top, bottom, front, side);

}

private void generateIcosahedron() {
Vector top = new Vector(0, 1, 0).multiply(wormholeConfigFields.getSizeMultiplier());
cachedLocations.add(top);
Vector offsetTopPoint = new Vector(1, .5, 0).multiply(wormholeConfigFields.getSizeMultiplier());
List<Vector> topPentagon = getPentagonVectors(top, offsetTopPoint);

Vector bottom = new Vector(0, -1, 0).multiply(wormholeConfigFields.getSizeMultiplier());
Vector offsetBottomPoint = new Vector(1, -.5, 0).multiply(wormholeConfigFields.getSizeMultiplier());
offsetBottomPoint.rotateAroundY(2 * Math.PI / 5D / 2D);
List<Vector> bottomPentagon = getPentagonVectors(bottom, offsetBottomPoint);

for (int i = 0; i < topPentagon.size(); i++) {
trace(topPentagon.get(i), bottomPentagon.get(i));
if (i + 1 < topPentagon.size() - 1)
trace(topPentagon.get(i + 1), bottomPentagon.get(i));
}
trace(topPentagon.get(0), bottomPentagon.get(4));
cacheRotations();
}

private List<Vector> getPentagonVectors(Vector centerPosition, Vector offsetPosition) {
List<Vector> pentagonVectors = new ArrayList<>();
for (int i = 0; i < 6; i++) {
Vector rotatedVector = offsetPosition.clone().rotateAroundY(2 * Math.PI / 5D * i).clone();
if (i > 0)
trace(pentagonVectors.get(i - 1), rotatedVector);
trace(centerPosition, rotatedVector);
pentagonVectors.add(rotatedVector);
}
trace(pentagonVectors.get(0), pentagonVectors.get(pentagonVectors.size() - 1));
return pentagonVectors;
}

private void finishCuboidInitialization(Vector top, Vector bottom, Vector front, Vector side) {
trace(top, front);
trace(bottom, front);
trace(front, side);

List<Vector> otherSidesList = new ArrayList<>();

for (int i = 1; i < 4; i++) {
double rotation = Math.PI / 2 * i;
for (Vector vector : cachedLocations) {
Vector rotatedVector = vector.clone().rotateAroundY(rotation);
if (rotatedVector.getX() != vector.getX() || rotatedVector.getZ() != vector.getZ())
otherSidesList.add(rotatedVector);
}
}

cachedLocations.addAll(otherSidesList);

cacheRotations();
}

private void cacheRotations() {
double rotationPointCount = 100;
for (int i = 0; i < rotationPointCount; i++) {
double rotation = (Math.PI * 2) / rotationPointCount * i;
List<Vector> vectors = new ArrayList<>();
for (Vector vector : cachedLocations) {
vectors.add(vector.clone().rotateAroundY(rotation));
}
cachedRotations.add(vectors);
}
}

private void trace(Vector source, Vector target) {
Vector ray = target.clone().subtract(source).normalize().multiply(.2);
Vector clonedSource = source.clone();
int counter = 0;
while (clonedSource.distance(target) > 0.1 && counter < 20) {
clonedSource = clonedSource.add(ray);
cachedLocations.add(clonedSource.clone());
counter++;
}
}

}
Loading

0 comments on commit 64919c4

Please sign in to comment.