Skip to content

Commit fa3f459

Browse files
committed
refactor: replace ItemArmorBaseComponent with ItemWearableComponent across API and server code
1 parent 6e8ba06 commit fa3f459

33 files changed

+246
-175
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Unless otherwise specified, any version comparison below is the comparison of th
1717
- (API) Added camera shake API (`Player.shakeCamera()`, `Player.stopCameraShake()`) and implemented `/camerashake` command.
1818
- (API) Added fog API (`Player.pushFog()`, `Player.popFog()`, `Player.removeFog()`, `Player.removeAllFogs()`, `Player.getFogs()`) with `FogIds` constants, and implemented `/fog` command.
1919
- (API) Added `BiomeTags` constants interface with code-generated biome tag definitions.
20+
- (API) Added `ItemWearableComponent` as the shared wearable contract for armor, elytra, carved pumpkins, and heads.
2021
- Added custom biome support. Plugins can register custom biomes via `new AllayBiomeType(Identifier, BiomeData)` with auto-allocated persistent IDs (starting from 30000, saved to `biome_ids.yml`).
2122
- Added `AllayBlockType.Builder.customizeItemType(Consumer<AllayItemType.Builder>)` to customize automatically generated block item types for custom blocks.
2223
- Added `BlockStateDefinition.MaterialInstance.alphaTestToOpaque(String)`, `alphaTestSingleSidedToOpaque(String)`, and `blendToOpaque(String)` convenience factories for custom block material instances.

api/src/main/java/org/allaymc/api/item/component/ItemArmorBaseComponent.java renamed to api/src/main/java/org/allaymc/api/item/component/ItemWearableComponent.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import org.allaymc.api.item.data.ArmorType;
44

55
/**
6+
* Component for wearable items.
7+
*
68
* @author daoge_cmd
79
*/
8-
public interface ItemArmorBaseComponent extends ItemBaseComponent {
9-
10+
public interface ItemWearableComponent extends ItemComponent {
1011
/**
11-
* Returns the armor type of the item.
12+
* Returns the armor type of this item.
1213
*
1314
* @return The armor type
1415
*/

api/src/main/java/org/allaymc/api/item/enchantment/ApplicableType.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.allaymc.api.item.enchantment;
22

33
import org.allaymc.api.item.ItemHelper;
4-
import org.allaymc.api.item.component.ItemArmorBaseComponent;
4+
import org.allaymc.api.item.component.ItemWearableComponent;
55
import org.allaymc.api.item.data.ArmorType;
66
import org.allaymc.api.item.type.ItemType;
77
import org.allaymc.api.item.type.ItemTypes;
@@ -45,7 +45,7 @@ public boolean canBeAppliedTo(ItemType<?> itemType) {
4545
HELMET {
4646
@Override
4747
public boolean canBeAppliedTo(ItemType<?> itemType) {
48-
if (itemType.createItemStack() instanceof ItemArmorBaseComponent armor) {
48+
if (ItemHelper.isArmor(itemType) && itemType.createItemStack() instanceof ItemWearableComponent armor) {
4949
return armor.getArmorType() == ArmorType.HELMET;
5050
}
5151

@@ -58,7 +58,7 @@ public boolean canBeAppliedTo(ItemType<?> itemType) {
5858
CHESTPLATE {
5959
@Override
6060
public boolean canBeAppliedTo(ItemType<?> itemType) {
61-
if (itemType.createItemStack() instanceof ItemArmorBaseComponent armor) {
61+
if (ItemHelper.isArmor(itemType) && itemType.createItemStack() instanceof ItemWearableComponent armor) {
6262
return armor.getArmorType() == ArmorType.CHESTPLATE;
6363
}
6464

@@ -71,7 +71,7 @@ public boolean canBeAppliedTo(ItemType<?> itemType) {
7171
LEGGINGS {
7272
@Override
7373
public boolean canBeAppliedTo(ItemType<?> itemType) {
74-
if (itemType.createItemStack() instanceof ItemArmorBaseComponent armor) {
74+
if (ItemHelper.isArmor(itemType) && itemType.createItemStack() instanceof ItemWearableComponent armor) {
7575
return armor.getArmorType() == ArmorType.LEGGINGS;
7676
}
7777

@@ -84,7 +84,7 @@ public boolean canBeAppliedTo(ItemType<?> itemType) {
8484
BOOTS {
8585
@Override
8686
public boolean canBeAppliedTo(ItemType<?> itemType) {
87-
if (itemType.createItemStack() instanceof ItemArmorBaseComponent armor) {
87+
if (ItemHelper.isArmor(itemType) && itemType.createItemStack() instanceof ItemWearableComponent armor) {
8888
return armor.getArmorType() == ArmorType.BOOTS;
8989
}
9090

@@ -160,7 +160,7 @@ public boolean canBeAppliedTo(ItemType<?> itemType) {
160160
WEARABLE {
161161
@Override
162162
public boolean canBeAppliedTo(ItemType<?> itemType) {
163-
return ItemHelper.isArmor(itemType) || itemType == ItemTypes.CARVED_PUMPKIN || ItemHelper.isHead(itemType);
163+
return itemType.createItemStack() instanceof ItemWearableComponent;
164164
}
165165
},
166166
/**
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.allaymc.api.item.interfaces;
22

33
import org.allaymc.api.item.ItemStack;
4-
import org.allaymc.api.item.component.ItemArmorBaseComponent;
54
import org.allaymc.api.item.component.ItemTrimmableComponent;
5+
import org.allaymc.api.item.component.ItemWearableComponent;
66

7-
public interface ItemBootsStack extends ItemStack, ItemArmorBaseComponent, ItemTrimmableComponent {
7+
public interface ItemBootsStack extends ItemStack, ItemWearableComponent, ItemTrimmableComponent {
88
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.allaymc.api.item.interfaces;
22

33
import org.allaymc.api.item.ItemStack;
4+
import org.allaymc.api.item.component.ItemWearableComponent;
45

5-
public interface ItemCarvedPumpkinStack extends ItemStack {
6+
public interface ItemCarvedPumpkinStack extends ItemStack, ItemWearableComponent {
67
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package org.allaymc.api.item.interfaces;
22

33
import org.allaymc.api.item.ItemStack;
4-
import org.allaymc.api.item.component.ItemArmorBaseComponent;
54
import org.allaymc.api.item.component.ItemRepairableComponent;
65
import org.allaymc.api.item.component.ItemTrimmableComponent;
6+
import org.allaymc.api.item.component.ItemWearableComponent;
77

8-
public interface ItemChestplateStack extends ItemStack, ItemArmorBaseComponent, ItemTrimmableComponent, ItemRepairableComponent {
8+
public interface ItemChestplateStack extends ItemStack, ItemWearableComponent, ItemTrimmableComponent, ItemRepairableComponent {
99
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.allaymc.api.item.interfaces;
22

33
import org.allaymc.api.item.ItemStack;
4-
import org.allaymc.api.item.component.ItemArmorBaseComponent;
54
import org.allaymc.api.item.component.ItemRepairableComponent;
5+
import org.allaymc.api.item.component.ItemWearableComponent;
66

7-
public interface ItemElytraStack extends ItemStack, ItemArmorBaseComponent, ItemRepairableComponent {
7+
public interface ItemElytraStack extends ItemStack, ItemWearableComponent, ItemRepairableComponent {
88
}
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.allaymc.api.item.interfaces;
22

33
import org.allaymc.api.item.ItemStack;
4+
import org.allaymc.api.item.component.ItemWearableComponent;
45

5-
public interface ItemHeadStack extends ItemStack {
6+
public interface ItemHeadStack extends ItemStack, ItemWearableComponent {
67
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package org.allaymc.api.item.interfaces;
22

33
import org.allaymc.api.item.ItemStack;
4-
import org.allaymc.api.item.component.ItemArmorBaseComponent;
54
import org.allaymc.api.item.component.ItemRepairableComponent;
65
import org.allaymc.api.item.component.ItemTrimmableComponent;
6+
import org.allaymc.api.item.component.ItemWearableComponent;
77

8-
public interface ItemHelmetStack extends ItemStack, ItemArmorBaseComponent, ItemTrimmableComponent, ItemRepairableComponent {
8+
public interface ItemHelmetStack extends ItemStack, ItemWearableComponent, ItemTrimmableComponent, ItemRepairableComponent {
99
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package org.allaymc.api.item.interfaces;
22

33
import org.allaymc.api.item.ItemStack;
4-
import org.allaymc.api.item.component.ItemArmorBaseComponent;
54
import org.allaymc.api.item.component.ItemTrimmableComponent;
5+
import org.allaymc.api.item.component.ItemWearableComponent;
66

7-
public interface ItemLeggingsStack extends ItemStack, ItemArmorBaseComponent, ItemTrimmableComponent {
7+
public interface ItemLeggingsStack extends ItemStack, ItemWearableComponent, ItemTrimmableComponent {
88
}

0 commit comments

Comments
 (0)