Skip to content

Commit

Permalink
Multipart Balloon Sine Wave Configurations (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Tapply authored Jun 18, 2024
1 parent f1d1f9d commit b21d78a
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/main/java/net/jeqo/bloons/balloon/BalloonCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public BalloonCore(JavaPlugin plugin) {
public void initialize() {
ConfigurationSection multipartBalloonsSection = Bloons.getInstance().getConfig().getConfigurationSection("multipart-balloons");

this.getBalloons().clear();

if (multipartBalloonsSection == null) {
return;
}
Expand All @@ -68,6 +70,9 @@ public void initialize() {
keySection.getDouble("max-node-joint-angle"),
keySection.getDouble("y-axis-interpolation"),
keySection.getDouble("turning-spline-interpolation"),
keySection.getDouble("passive-sine-wave-speed"),
keySection.getDouble("passive-sine-wave-amplitude"),
keySection.getDouble("passive-nose-sine-wave-amplitude"),
new MultipartBalloonModel(BalloonModelType.HEAD, keySection.getString("head.material"), keySection.getString("head.color"), keySection.getInt("head.custom-model-data")),
new MultipartBalloonModel(BalloonModelType.BODY, keySection.getString("body.material"), keySection.getString("body.color"), keySection.getInt("body.custom-model-data")),
new MultipartBalloonModel(BalloonModelType.TAIL, keySection.getString("tail.material"), keySection.getString("tail.color"), keySection.getInt("tail.custom-model-data")));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,73 @@ public class MultipartBalloonType {
private double maxNodeJointAngle = 35.0;
private double yAxisInterpolation = 0.35;
private double turningSplineInterpolation = 0.35;
private double passiveSineWaveSpeed = 0.05;
private double passiveSineWaveAmplitude = 0.5;
private double passiveNoseSineWaveAmplitude = 0.5;
private MultipartBalloonModel headModel;
private MultipartBalloonModel bodyModel;
private MultipartBalloonModel tailModel;

public MultipartBalloonType(String id, String permission, String name, String[] lore, int nodeCount, double distanceBetweenNodes, double headNodeOffset, double bodyNodeOffset, double tailNodeOffset, double maxNodeJointAngle, double yAxisInterpolation, double turningSplineInterpolation, double passiveSineWaveSpeed, double passiveSineWaveAmplitude, double passiveNoseSineWaveAmplitude, MultipartBalloonModel headModel, MultipartBalloonModel bodyModel, MultipartBalloonModel tailModel) {
this.setId(id);
this.setPermission(permission);
this.setName(name);
this.setLore(lore);
this.setNodeCount(nodeCount);
this.setDistanceBetweenNodes(distanceBetweenNodes);
this.setHeadNodeOffset(headNodeOffset);
this.setBodyNodeOffset(bodyNodeOffset);
this.setTailNodeOffset(tailNodeOffset);
this.setMaxNodeJointAngle(maxNodeJointAngle);
this.setYAxisInterpolation(yAxisInterpolation);
this.setTurningSplineInterpolation(turningSplineInterpolation);
this.setPassiveSineWaveSpeed(passiveSineWaveSpeed);
this.setPassiveSineWaveAmplitude(passiveSineWaveAmplitude);
this.setPassiveNoseSineWaveAmplitude(passiveNoseSineWaveAmplitude);
this.setHeadModel(headModel);
this.setBodyModel(bodyModel);
this.setTailModel(tailModel);
}

public MultipartBalloonType(String id, String permission, String name, String[] lore, int nodeCount, double distanceBetweenNodes, double headNodeOffset, double bodyNodeOffset, double tailNodeOffset, double maxNodeJointAngle, double yAxisInterpolation, double turningSplineInterpolation, double passiveSineWaveSpeed, double passiveSineWaveAmplitude, MultipartBalloonModel headModel, MultipartBalloonModel bodyModel, MultipartBalloonModel tailModel) {
this.setId(id);
this.setPermission(permission);
this.setName(name);
this.setLore(lore);
this.setNodeCount(nodeCount);
this.setDistanceBetweenNodes(distanceBetweenNodes);
this.setHeadNodeOffset(headNodeOffset);
this.setBodyNodeOffset(bodyNodeOffset);
this.setTailNodeOffset(tailNodeOffset);
this.setMaxNodeJointAngle(maxNodeJointAngle);
this.setYAxisInterpolation(yAxisInterpolation);
this.setTurningSplineInterpolation(turningSplineInterpolation);
this.setPassiveSineWaveSpeed(passiveSineWaveSpeed);
this.setPassiveSineWaveAmplitude(passiveSineWaveAmplitude);
this.setHeadModel(headModel);
this.setBodyModel(bodyModel);
this.setTailModel(tailModel);
}

public MultipartBalloonType(String id, String permission, String name, String[] lore, int nodeCount, double distanceBetweenNodes, double headNodeOffset, double bodyNodeOffset, double tailNodeOffset, double maxNodeJointAngle, double yAxisInterpolation, double turningSplineInterpolation, double passiveSineWaveSpeed, MultipartBalloonModel headModel, MultipartBalloonModel bodyModel, MultipartBalloonModel tailModel) {
this.setId(id);
this.setPermission(permission);
this.setName(name);
this.setLore(lore);
this.setNodeCount(nodeCount);
this.setDistanceBetweenNodes(distanceBetweenNodes);
this.setHeadNodeOffset(headNodeOffset);
this.setBodyNodeOffset(bodyNodeOffset);
this.setTailNodeOffset(tailNodeOffset);
this.setMaxNodeJointAngle(maxNodeJointAngle);
this.setYAxisInterpolation(yAxisInterpolation);
this.setTurningSplineInterpolation(turningSplineInterpolation);
this.setPassiveSineWaveSpeed(passiveSineWaveSpeed);
this.setHeadModel(headModel);
this.setBodyModel(bodyModel);
this.setTailModel(tailModel);
}

public MultipartBalloonType(String id, String permission, String name, String[] lore, int nodeCount, double distanceBetweenNodes, double headNodeOffset, double bodyNodeOffset, double tailNodeOffset, double maxNodeJointAngle, double yAxisInterpolation, double turningSplineInterpolation, MultipartBalloonModel headModel, MultipartBalloonModel bodyModel, MultipartBalloonModel tailModel) {
this.setId(id);
this.setPermission(permission);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ public void run() {
}

long timeInTicks = 1;
double speed = 0.05; // Adjust the speed of the sine wave
double amplitude = 0.5; // Adjust the amplitude of the sine wave
double noseAmplitude = 0.5; // Adjust how much the nose of the first node goes up and down
double speed = this.getBalloonType().getPassiveSineWaveSpeed(); // Adjust the speed of the sine wave
double amplitude = this.getBalloonType().getPassiveSineWaveAmplitude(); // Adjust the amplitude of the sine wave
double noseAmplitude = this.getBalloonType().getPassiveNoseSineWaveAmplitude(); // Adjust how much the nose of the first node goes up and down

this.setRunnable(new BukkitRunnable() {
double yOffset = 0; // Initial offset for the sine curve
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/net/jeqo/bloons/commands/CommandReload.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ public boolean execute(CommandSender sender, String[] args) {
Bloons.getInstance().getConfig().options().copyDefaults();
Bloons.getInstance().saveDefaultConfig();

Bloons.getBalloonCore().initialize(); // Refresh balloons and their configurations

Component configReloadedMessage = messageTranslations.getSerializedString(messageTranslations.getMessage("prefix"), messageTranslations.getMessage("config-reloaded"));
sender.sendMessage(configReloadedMessage);

Expand Down
3 changes: 3 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ multipart-balloons:
max-joint-angle: 35.0 # The max angle in degrees of freedom for each joint between nodes
y-axis-interpolation: 0.2 # The amount of interpolation between nodes on the Y axis (must be between 0.0 and 1.0)
turning-spline-interpolation: 0.5 # The amount of interpolation for the spline when turning
passive-sine-wave-speed: 0.05
passive-sine-wave-amplitude: 0.5
passive-nose-sine-wave-amplitude: 0.5
head: # Head must be supplied for a balloon of this kind
material: LEATHER_HORSE_ARMOR # The material of the head
color: '#FF0000' # The color of the head item, this is optional
Expand Down

0 comments on commit b21d78a

Please sign in to comment.