-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added equipment and handle attributes
- Loading branch information
Showing
30 changed files
with
668 additions
and
375 deletions.
There are no files selected for viewing
20 changes: 19 additions & 1 deletion
20
api/src/main/java/io/github/sculkpowered/server/attribute/Attribute.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,7 +1,25 @@ | ||
package io.github.sculkpowered.server.attribute; | ||
|
||
import io.github.sculkpowered.server.registry.Registry.Entry; | ||
import net.kyori.adventure.key.Key; | ||
import net.kyori.adventure.nbt.CompoundBinaryTag; | ||
import org.intellij.lang.annotations.Subst; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public record Attribute(@NotNull String key, int id, float def, float max) { | ||
public record Attribute( | ||
@NotNull Key key, | ||
int id, | ||
float def, | ||
float min, | ||
float max | ||
) implements Entry { | ||
|
||
public Attribute(@Subst("value") String key, int id, float def, float min, float max) { | ||
this(Key.key(Key.MINECRAFT_NAMESPACE, key), id, def, min, max); | ||
} | ||
|
||
@Override | ||
public @NotNull CompoundBinaryTag asNBT() { | ||
return CompoundBinaryTag.empty(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,7 @@ | |
|
||
public enum AttributeOperation { | ||
|
||
ADD, | ||
ADD_VALUE, | ||
MULTIPLY_BASE, | ||
MULTIPLY | ||
|
||
} |
36 changes: 26 additions & 10 deletions
36
api/src/main/java/io/github/sculkpowered/server/attribute/AttributeSlot.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,24 +1,40 @@ | ||
package io.github.sculkpowered.server.attribute; | ||
|
||
import io.github.sculkpowered.server.container.equipment.EquipmentSlot; | ||
|
||
public enum AttributeSlot { | ||
|
||
ANY("any"), | ||
MAIN_HAND("mainhand"), | ||
OFF_HAND("offhand"), | ||
FEET("feet"), | ||
LEGS("legs"), | ||
CHEST("chest"), | ||
HEAD("head"), | ||
ARMOR("armor"), | ||
BODY("body"); | ||
ANY("any", null), | ||
MAIN_HAND("mainhand", EquipmentSlot.MAIN_HAND), | ||
OFF_HAND("offhand", EquipmentSlot.OFF_HAND), | ||
HAND("hand", null), | ||
FEET("feet", EquipmentSlot.FEET), | ||
LEGS("legs", EquipmentSlot.LEGS), | ||
CHEST("chest", EquipmentSlot.CHEST), | ||
HEAD("head", null), | ||
ARMOR("armor", null), | ||
BODY("body", null); | ||
|
||
private final String key; | ||
private final EquipmentSlot equipmentSlot; | ||
|
||
AttributeSlot(final String key) { | ||
AttributeSlot(final String key, final EquipmentSlot equipmentSlot) { | ||
this.key = key; | ||
this.equipmentSlot = equipmentSlot; | ||
} | ||
|
||
public String key() { | ||
return this.key; | ||
} | ||
|
||
public EquipmentSlot equipmentSlot() { | ||
return this.equipmentSlot; | ||
} | ||
|
||
public boolean is(final EquipmentSlot slot) { | ||
return (this == AttributeSlot.ANY || | ||
(this == AttributeSlot.ARMOR && slot.isArmor()) || | ||
(this == AttributeSlot.HAND && slot.isHand()) || | ||
this.equipmentSlot() == slot); | ||
} | ||
} |
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
65 changes: 2 additions & 63 deletions
65
api/src/main/java/io/github/sculkpowered/server/container/Inventory.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
118 changes: 118 additions & 0 deletions
118
api/src/main/java/io/github/sculkpowered/server/container/equipment/EntityEquipment.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,118 @@ | ||
package io.github.sculkpowered.server.container.equipment; | ||
|
||
import io.github.sculkpowered.server.container.item.ItemStack; | ||
import java.util.Map; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Represents the equipment of an entity. | ||
*/ | ||
public interface EntityEquipment { | ||
|
||
/** | ||
* Gets the equipment at the specified equipment slot. | ||
* @param slot the slot | ||
* @return the item at the specified equipment slot | ||
* @since 1.0.0 | ||
*/ | ||
@NotNull ItemStack get(@NotNull EquipmentSlot slot); | ||
|
||
/** | ||
* Sets the equipment at the specified equipment slot. | ||
* @param slot the slot | ||
* @param equipment the item to set | ||
* @return the previous item | ||
* @since 1.0.0 | ||
*/ | ||
@NotNull ItemStack set(@NotNull EquipmentSlot slot, @NotNull ItemStack equipment); | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default @NotNull ItemStack itemInMainHand() { | ||
return this.get(EquipmentSlot.MAIN_HAND); | ||
} | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default void itemInMainHand(@NotNull ItemStack item) { | ||
this.set(EquipmentSlot.MAIN_HAND, item); | ||
} | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default @NotNull ItemStack itemInOffHand() { | ||
return this.get(EquipmentSlot.OFF_HAND); | ||
} | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default void itemInOffHand(@NotNull ItemStack item) { | ||
this.set(EquipmentSlot.OFF_HAND, item); | ||
} | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default @NotNull ItemStack helmet() { | ||
return this.get(EquipmentSlot.HEAD); | ||
} | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default void helmet(@NotNull ItemStack item) { | ||
this.set(EquipmentSlot.HEAD, item); | ||
} | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default @NotNull ItemStack chestplate() { | ||
return this.get(EquipmentSlot.CHEST); | ||
} | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default void chestplate(@NotNull ItemStack item) { | ||
this.set(EquipmentSlot.CHEST, item); | ||
} | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default @NotNull ItemStack leggings() { | ||
return this.get(EquipmentSlot.LEGS); | ||
} | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default void leggings(@NotNull ItemStack item) { | ||
this.set(EquipmentSlot.LEGS, item); | ||
} | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default @NotNull ItemStack boots() { | ||
return this.get(EquipmentSlot.FEET); | ||
} | ||
|
||
/** | ||
* @since 1.0.0 | ||
*/ | ||
default void boots(@NotNull ItemStack item) { | ||
this.set(EquipmentSlot.FEET, item); | ||
} | ||
|
||
/** | ||
* Gets the equipment as a map. | ||
* @return a map that contains the equipment, empty stacks are not stored | ||
*/ | ||
Map<EquipmentSlot, ItemStack> asMap(); | ||
} |
Oops, something went wrong.