Skip to content

Commit

Permalink
feat: move all attributes into Attributes class
Browse files Browse the repository at this point in the history
  • Loading branch information
RealBauHD committed Nov 1, 2024
1 parent 9242803 commit c4adf41
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 50 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package eu.sculkpowered.server.attribute;

public final class GenericAttribute {
public final class Attributes {

public static final Attribute ARMOR =
new Attribute("generic.armor", 0, 0F, 0F, 30F);
Expand All @@ -12,10 +12,16 @@ public final class GenericAttribute {
new Attribute("generic.attack_knockback", 3, 0F, 0F, 5F);
public static final Attribute ATTACK_SPEED =
new Attribute("generic.attack_speed", 4, 4F, 0F, 1024F);
public static final Attribute BLOCK_BREAK_SPEED =
new Attribute("player.block_break_speed", 5, 1F, 0F, 1024F);
public static final Attribute BLOCK_INTERACTION_RANGE =
new Attribute("player.block_interaction_range", 6, 4.5F, 0F, 64F);
public static final Attribute BURNING_TIME =
new Attribute("generic.burning_time", 7, 0F, 0F, 1024F);
public static final Attribute EXPLOSION_KNOCKBACK_RESISTANCE =
new Attribute("generic.explosion_knockback_resistance", 8, 0F, 0F, 1F);
public static final Attribute ENTITY_INTERACTION_RANGE =
new Attribute("player.entity_interaction_range", 9, 3F, 0F, 64F);
public static final Attribute FALL_DAMAGE_MULTIPLIER =
new Attribute("generic.fall_damage_multiplier", 10, 1F, 0F, 100F);
public static final Attribute FLYING_SPEED =
Expand All @@ -34,6 +40,8 @@ public final class GenericAttribute {
new Attribute("generic.max_health", 17, 0F, 0F, 2048F);
public static final Attribute MAX_HEALTH =
new Attribute("generic.max_health", 18, 20F, 1F, 1024F);
public static final Attribute MINING_EFFICIENCY =
new Attribute("player.mining_efficiency", 19, 0F, 0F, 1024F);
public static final Attribute MOVEMENT_EFFICIENCY =
new Attribute("generic.movement_efficiency", 20, 0F, 0F, 1F);
public static final Attribute MOVEMENT_SPEED =
Expand All @@ -44,6 +52,10 @@ public final class GenericAttribute {
new Attribute("generic.safe_fall_distance", 23, 3F, -1024F, 1024F);
public static final Attribute SCALE =
new Attribute("generic.scale", 24, 1F, 0.0625F, 16F);
public static final Attribute SNEAKING_SPEED =
new Attribute("player.sneaking_speed", 25, 0.3F, 0F, 1F);
public static final Attribute SPAWN_REINFORCEMENTS =
new Attribute("zombie.spawn_reinforcements", 26, 0F, 0F, 1F);
public static final Attribute STEP_HEIGHT =
new Attribute("generic.step_height", 27, 0.6F, 0F, 10F);
public static final Attribute SUBMERGED_MINING_SPEED =
Expand Down
4 changes: 0 additions & 4 deletions api/src/main/java/eu/sculkpowered/server/entity/Zombie.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
package eu.sculkpowered.server.entity;

import eu.sculkpowered.server.attribute.Attribute;

/**
* Represents a zombie entity.
*/
public interface Zombie extends Mob, Ageable {

Attribute SPAWN_REINFORCEMENTS =
new Attribute("zombie.spawn_reinforcements", 26, 0F, 0F, 1F);
}
12 changes: 0 additions & 12 deletions api/src/main/java/eu/sculkpowered/server/entity/player/Player.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package eu.sculkpowered.server.entity.player;

import eu.sculkpowered.server.attribute.Attribute;
import eu.sculkpowered.server.command.CommandSource;
import eu.sculkpowered.server.connection.Connection;
import eu.sculkpowered.server.container.Container;
Expand All @@ -18,17 +17,6 @@
public interface Player extends LivingEntity, CommandSource, PlayerInfoEntry, Connection,
BossBarViewer {

Attribute BLOCK_BREAK_SPEED =
new Attribute("player.block_break_speed", 5, 1F, 0F, 1024F);
Attribute BLOCK_INTERACTION_RANGE =
new Attribute("player.block_interaction_range", 6, 4.5F, 0F, 64F);
Attribute ENTITY_INTERACTION_RANGE =
new Attribute("player.entity_interaction_range", 9, 3F, 0F, 64F);
Attribute MINING_EFFICIENCY =
new Attribute("player.mining_efficiency", 19, 0F, 0F, 1024F);
Attribute SNEAKING_SPEED =
new Attribute("player.sneaking_speed", 25, 0.3F, 0F, 1F);

/**
* Gets the name of the player.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,45 +1,43 @@
package eu.sculkpowered.server.attribute;

import eu.sculkpowered.server.entity.Zombie;
import eu.sculkpowered.server.entity.player.Player;
import eu.sculkpowered.server.registry.Registry;
import eu.sculkpowered.server.registry.SimpleRegistry;

public final class AttributeRegistry {

public static Registry<Attribute> get() {
final var registry = new SimpleRegistry<>("minecraft:attribute",
GenericAttribute.ARMOR);
registry.register(GenericAttribute.ARMOR_TOUGHNESS);
registry.register(GenericAttribute.ATTACK_DAMAGE);
registry.register(GenericAttribute.ATTACK_KNOCKBACK);
registry.register(GenericAttribute.ATTACK_SPEED);
registry.register(Player.BLOCK_BREAK_SPEED);
registry.register(Player.BLOCK_INTERACTION_RANGE);
registry.register(GenericAttribute.BURNING_TIME);
registry.register(GenericAttribute.EXPLOSION_KNOCKBACK_RESISTANCE);
registry.register(Player.ENTITY_INTERACTION_RANGE);
registry.register(GenericAttribute.FALL_DAMAGE_MULTIPLIER);
registry.register(GenericAttribute.FLYING_SPEED);
registry.register(GenericAttribute.FOLLOW_RANGE);
registry.register(GenericAttribute.GRAVITY);
registry.register(GenericAttribute.JUMP_STRENGTH);
registry.register(GenericAttribute.KNOCKBACK_RESISTANCE);
registry.register(GenericAttribute.LUCK);
registry.register(GenericAttribute.MAX_ABSORPTION);
registry.register(GenericAttribute.MAX_HEALTH);
registry.register(Player.MINING_EFFICIENCY);
registry.register(GenericAttribute.MOVEMENT_EFFICIENCY);
registry.register(GenericAttribute.MOVEMENT_SPEED);
registry.register(GenericAttribute.OXYGEN_BONUS);
registry.register(GenericAttribute.SAFE_FALL_DISTANCE);
registry.register(GenericAttribute.SCALE);
registry.register(Player.SNEAKING_SPEED);
registry.register(Zombie.SPAWN_REINFORCEMENTS);
registry.register(GenericAttribute.STEP_HEIGHT);
registry.register(GenericAttribute.SUBMERGED_MINING_SPEED);
registry.register(GenericAttribute.SWEEPING_DAMAGE_RATIO);
registry.register(GenericAttribute.WATER_MOVEMENT_EFFICIENCY);
Attributes.ARMOR);
registry.register(Attributes.ARMOR_TOUGHNESS);
registry.register(Attributes.ATTACK_DAMAGE);
registry.register(Attributes.ATTACK_KNOCKBACK);
registry.register(Attributes.ATTACK_SPEED);
registry.register(Attributes.BLOCK_BREAK_SPEED);
registry.register(Attributes.BLOCK_INTERACTION_RANGE);
registry.register(Attributes.BURNING_TIME);
registry.register(Attributes.EXPLOSION_KNOCKBACK_RESISTANCE);
registry.register(Attributes.ENTITY_INTERACTION_RANGE);
registry.register(Attributes.FALL_DAMAGE_MULTIPLIER);
registry.register(Attributes.FLYING_SPEED);
registry.register(Attributes.FOLLOW_RANGE);
registry.register(Attributes.GRAVITY);
registry.register(Attributes.JUMP_STRENGTH);
registry.register(Attributes.KNOCKBACK_RESISTANCE);
registry.register(Attributes.LUCK);
registry.register(Attributes.MAX_ABSORPTION);
registry.register(Attributes.MAX_HEALTH);
registry.register(Attributes.MINING_EFFICIENCY);
registry.register(Attributes.MOVEMENT_EFFICIENCY);
registry.register(Attributes.MOVEMENT_SPEED);
registry.register(Attributes.OXYGEN_BONUS);
registry.register(Attributes.SAFE_FALL_DISTANCE);
registry.register(Attributes.SCALE);
registry.register(Attributes.SNEAKING_SPEED);
registry.register(Attributes.SPAWN_REINFORCEMENTS);
registry.register(Attributes.STEP_HEIGHT);
registry.register(Attributes.SUBMERGED_MINING_SPEED);
registry.register(Attributes.SWEEPING_DAMAGE_RATIO);
registry.register(Attributes.WATER_MOVEMENT_EFFICIENCY);
return registry;
}
}

0 comments on commit c4adf41

Please sign in to comment.