-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add config for the border and the knockback, cleanup
- Loading branch information
Showing
26 changed files
with
797 additions
and
361 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 20 additions & 7 deletions
27
eternalcombat-plugin/src/main/java/com/eternalcode/combat/border/BorderSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,32 @@ | ||
package com.eternalcode.combat.border; | ||
|
||
import com.eternalcode.combat.border.animation.block.BlockSettings; | ||
import com.eternalcode.combat.border.animation.particle.ParticleSettings; | ||
import eu.okaeri.configs.OkaeriConfig; | ||
import eu.okaeri.configs.annotation.Comment; | ||
import java.time.Duration; | ||
import org.jetbrains.annotations.ApiStatus; | ||
|
||
public interface BorderSettings { | ||
public class BorderSettings extends OkaeriConfig { | ||
|
||
@ApiStatus.Internal | ||
default Duration indexRefreshDelay() { | ||
@Comment("# Border view distance") | ||
public double distance = 6.5; | ||
|
||
@Comment("# Border block animation settings") | ||
public BlockSettings block = new BlockSettings(); | ||
|
||
@Comment("# Border particle animation settings") | ||
public ParticleSettings particle = new ParticleSettings(); | ||
|
||
public Duration indexRefreshDelay() { | ||
return Duration.ofSeconds(1); | ||
} | ||
|
||
double distance(); | ||
public int distanceRounded() { | ||
return (int) Math.ceil(this.distance); | ||
} | ||
|
||
default int distanceRounded() { | ||
return (int) Math.ceil(this.distance()); | ||
public boolean isEnabled() { | ||
return this.block.enabled || this.particle.enabled; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...lcombat-plugin/src/main/java/com/eternalcode/combat/border/animation/BorderColorUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.eternalcode.combat.border.animation; | ||
|
||
import java.awt.Color; | ||
|
||
public final class BorderColorUtil { | ||
|
||
private BorderColorUtil() { | ||
} | ||
|
||
public static Color xyzToRainbow(int x, int y, int z) { | ||
float hue = (float) (((Math.sin(x * 0.05) + Math.cos(z * 0.05)) * 0.5 + 0.5) % 1.0); | ||
float saturation = 1.0f; | ||
float brightness = 0.8f + 0.2f * Math.max(0.0f, Math.min(1.0f, (float) y / 255)); | ||
|
||
return Color.getHSBColor(hue, saturation, brightness); | ||
} | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
...bat-plugin/src/main/java/com/eternalcode/combat/border/animation/block/BlockSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.eternalcode.combat.border.animation.block; | ||
|
||
import eu.okaeri.configs.OkaeriConfig; | ||
import eu.okaeri.configs.annotation.Comment; | ||
import java.time.Duration; | ||
|
||
public class BlockSettings extends OkaeriConfig { | ||
|
||
@Comment("# Enable block animation?") | ||
public boolean enabled = true; | ||
|
||
@Comment({ | ||
"# Block type used for rendering the border", | ||
"# Custom: RAINBOW_GLASS, RAINBOW_WOOL, RAINBOW_TERRACOTTA, RAINBOW_CONCRETE", | ||
"# Vanilla: https://javadocs.packetevents.com/com/github/retrooper/packetevents/protocol/world/states/type/StateTypes.html" | ||
}) | ||
public BlockType type = BlockType.RAINBOW_GLASS; | ||
|
||
@Comment({ | ||
"# Delay between each async animation update", | ||
"# Lower values will decrease performance but will make the animation smoother", | ||
"# Higher values will increase performance" | ||
}) | ||
public Duration updateDelay = Duration.ofMillis(250); | ||
|
||
@Comment({ | ||
"# Delay between each chunk cache update", | ||
"# Lower values will decrease performance", | ||
"# Higher values will increase performance but may cause overlapping existing blocks (this does not modify the world)" | ||
}) | ||
public Duration chunkCacheDelay = Duration.ofMillis(300); | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
...lcombat-plugin/src/main/java/com/eternalcode/combat/border/animation/block/BlockType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.eternalcode.combat.border.animation.block; | ||
|
||
import com.eternalcode.combat.border.BorderPoint; | ||
import static com.eternalcode.combat.border.animation.block.BorderBlockRainbowUtil.xyzToConcrete; | ||
import static com.eternalcode.combat.border.animation.block.BorderBlockRainbowUtil.xyzToGlass; | ||
import static com.eternalcode.combat.border.animation.block.BorderBlockRainbowUtil.xyzToTerracotta; | ||
import static com.eternalcode.combat.border.animation.block.BorderBlockRainbowUtil.xyzToWool; | ||
import com.github.retrooper.packetevents.protocol.world.states.type.StateType; | ||
import com.github.retrooper.packetevents.protocol.world.states.type.StateTypes; | ||
import java.util.Locale; | ||
|
||
public class BlockType { | ||
|
||
public static final BlockType RAINBOW_GLASS = new BlockType("RAINBOW_GLASS", point -> xyzToGlass(point)); | ||
public static final BlockType RAINBOW_TERRACOTTA = new BlockType("RAINBOW_TERRACOTTA", point -> xyzToTerracotta(point)); | ||
public static final BlockType RAINBOW_WOOL = new BlockType("RAINBOW_WOOL", point -> xyzToWool(point)); | ||
public static final BlockType RAINBOW_CONCRETE = new BlockType("RAINBOW_CONCRETE", point -> xyzToConcrete(point)); | ||
|
||
private final String name; | ||
private final TypeProvider type; | ||
|
||
private BlockType(String name, TypeProvider type) { | ||
this.name = name; | ||
this.type = type; | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public StateType getStateType(BorderPoint point) { | ||
return type.provide(point); | ||
} | ||
|
||
public static BlockType fromName(String name) { | ||
return switch (name) { | ||
case "RAINBOW_GLASS" -> RAINBOW_GLASS; | ||
case "RAINBOW_WOOL" -> RAINBOW_WOOL; | ||
case "RAINBOW_TERRACOTTA" -> RAINBOW_TERRACOTTA; | ||
case "RAINBOW_CONCRETE" -> RAINBOW_CONCRETE; | ||
default -> new BlockType(name, point -> StateTypes.getByName(name.toLowerCase(Locale.ROOT))); | ||
}; | ||
} | ||
|
||
private interface TypeProvider { | ||
StateType provide(BorderPoint point); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...gin/src/main/java/com/eternalcode/combat/border/animation/block/BlockTypeTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package com.eternalcode.combat.border.animation.block; | ||
|
||
import eu.okaeri.configs.schema.GenericsPair; | ||
import eu.okaeri.configs.serdes.BidirectionalTransformer; | ||
import eu.okaeri.configs.serdes.SerdesContext; | ||
import java.util.Locale; | ||
|
||
public class BlockTypeTransformer extends BidirectionalTransformer<String, BlockType> { | ||
|
||
@Override | ||
public GenericsPair<String, BlockType> getPair() { | ||
return this.genericsPair(String.class, BlockType.class); | ||
} | ||
|
||
@Override | ||
public BlockType leftToRight(String data, SerdesContext serdesContext) { | ||
BlockType blockType = BlockType.fromName(data); | ||
if (blockType == null) { | ||
throw new IllegalArgumentException("Unknown block type: " + data); | ||
} | ||
|
||
return blockType; | ||
} | ||
|
||
@Override | ||
public String rightToLeft(BlockType data, SerdesContext serdesContext) { | ||
return data.getName().toUpperCase(Locale.ROOT); | ||
} | ||
|
||
} |
Oops, something went wrong.