Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,6 @@ public class CustomProjectileDefinition implements ProjectilePhysics {
private final @Nullable Integer customModelData;

private final @NotNull Map<String, @NotNull Double> attributes;

private final @NotNull Map<String, @NotNull Double> entityDisplayData;
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,22 @@ private static void loadEntry(YamlConfiguration cfg, String node) {
.charged(section.getBoolean("charged"))
.critical(section.getBoolean("critical"))
.material(Key.from(section.getString("material", "SNOWBALL")))
.customModelData(section.getObject("customModelData", Integer.class, null));
.customModelData(section.getObject("customModelData", Integer.class, null))
.attributes(getStringDoubleHashMap(section, "attributes"))
.entityDisplayData(getStringDoubleHashMap(section, "entityDisplayData"));

var attributeSection = section.getConfigurationSection("attributes");
Registries.CUSTOM_PROJECTILE_DEFINITION.register(builder.build());
}

private static @NotNull HashMap<String, @NotNull Double> getStringDoubleHashMap(ConfigurationSection section, String key) {
var attributeSection = section.getConfigurationSection(key);
HashMap<String, @NotNull Double> attributeMap = new HashMap<>();
if (attributeSection != null) {
for (var attrName : attributeSection.getKeys(false)) {
var value = attributeSection.getDouble(attrName);
attributeMap.put(attrName, value);
}
}

builder = builder.attributes(attributeMap);
Registries.CUSTOM_PROJECTILE_DEFINITION.register(builder.build());
return attributeMap;
}
}
14 changes: 14 additions & 0 deletions cannons-bukkit/src/main/resources/projectile_definitions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@
# attributes:
# scale: 2.0
#
# # available for all entities that are Display, mainly for ItemDisplay
# entityDisplayData:
# # initial rotations
# rotationX: 5.0
# rotationY: -5.0
# rotationZ: 0.0
#
# # change in rotation in degrees x tick
# rotationSpeedX: -5.0
# rotationSpeedY: 2.0
# rotationSpeedZ: 0.0
#
# size: 4.0
#
# # this stuff is for throwable projectiles, such as snowballs, and item displays
# material: SNOWBALL # you can set any material https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html
# customModelData: 123 # must be an integer, texturepack magic number goes here
Expand Down