-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: durability support for tool items
- Loading branch information
Showing
34 changed files
with
437 additions
and
23 deletions.
There are no files selected for viewing
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
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
9 changes: 9 additions & 0 deletions
9
Allay-API/src/main/java/org/allaymc/api/item/component/tool/ItemAxeComponent.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,9 @@ | ||
package org.allaymc.api.item.component.tool; | ||
|
||
/** | ||
* Allay Project 2024/6/23 | ||
* | ||
* @author daoge_cmd | ||
*/ | ||
public interface ItemAxeComponent extends ItemToolComponent { | ||
} |
9 changes: 9 additions & 0 deletions
9
Allay-API/src/main/java/org/allaymc/api/item/component/tool/ItemHoeComponent.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,9 @@ | ||
package org.allaymc.api.item.component.tool; | ||
|
||
/** | ||
* Allay Project 2024/6/23 | ||
* | ||
* @author daoge_cmd | ||
*/ | ||
public interface ItemHoeComponent extends ItemToolComponent { | ||
} |
9 changes: 9 additions & 0 deletions
9
Allay-API/src/main/java/org/allaymc/api/item/component/tool/ItemPickaxeComponent.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,9 @@ | ||
package org.allaymc.api.item.component.tool; | ||
|
||
/** | ||
* Allay Project 2024/6/23 | ||
* | ||
* @author daoge_cmd | ||
*/ | ||
public interface ItemPickaxeComponent extends ItemToolComponent { | ||
} |
9 changes: 9 additions & 0 deletions
9
Allay-API/src/main/java/org/allaymc/api/item/component/tool/ItemShovelComponent.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,9 @@ | ||
package org.allaymc.api.item.component.tool; | ||
|
||
/** | ||
* Allay Project 2024/6/23 | ||
* | ||
* @author daoge_cmd | ||
*/ | ||
public interface ItemShovelComponent extends ItemToolComponent { | ||
} |
9 changes: 9 additions & 0 deletions
9
Allay-API/src/main/java/org/allaymc/api/item/component/tool/ItemSwordComponent.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,9 @@ | ||
package org.allaymc.api.item.component.tool; | ||
|
||
/** | ||
* Allay Project 2024/6/23 | ||
* | ||
* @author daoge_cmd | ||
*/ | ||
public interface ItemSwordComponent extends ItemToolComponent { | ||
} |
11 changes: 11 additions & 0 deletions
11
Allay-API/src/main/java/org/allaymc/api/item/component/tool/ItemToolComponent.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,11 @@ | ||
package org.allaymc.api.item.component.tool; | ||
|
||
import org.allaymc.api.item.component.ItemComponent; | ||
|
||
/** | ||
* Allay Project 2024/6/23 | ||
* | ||
* @author daoge_cmd | ||
*/ | ||
public interface ItemToolComponent extends ItemComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
Allay-API/src/main/java/org/allaymc/api/item/interfaces/pickaxe/ItemDiamondPickaxeStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.pickaxe; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemPickaxeComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemDiamondPickaxeStack extends ItemStack { | ||
public interface ItemDiamondPickaxeStack extends ItemStack, ItemPickaxeComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
Allay-API/src/main/java/org/allaymc/api/item/interfaces/pickaxe/ItemGoldenPickaxeStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.pickaxe; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemPickaxeComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemGoldenPickaxeStack extends ItemStack { | ||
public interface ItemGoldenPickaxeStack extends ItemStack, ItemPickaxeComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
Allay-API/src/main/java/org/allaymc/api/item/interfaces/pickaxe/ItemIronPickaxeStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.pickaxe; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemPickaxeComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemIronPickaxeStack extends ItemStack { | ||
public interface ItemIronPickaxeStack extends ItemStack, ItemPickaxeComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
...-API/src/main/java/org/allaymc/api/item/interfaces/pickaxe/ItemNetheritePickaxeStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.pickaxe; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemPickaxeComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemNetheritePickaxeStack extends ItemStack { | ||
public interface ItemNetheritePickaxeStack extends ItemStack, ItemPickaxeComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
Allay-API/src/main/java/org/allaymc/api/item/interfaces/pickaxe/ItemStonePickaxeStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.pickaxe; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemPickaxeComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemStonePickaxeStack extends ItemStack { | ||
public interface ItemStonePickaxeStack extends ItemStack, ItemPickaxeComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
Allay-API/src/main/java/org/allaymc/api/item/interfaces/pickaxe/ItemWoodenPickaxeStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.pickaxe; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemPickaxeComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemWoodenPickaxeStack extends ItemStack { | ||
public interface ItemWoodenPickaxeStack extends ItemStack, ItemPickaxeComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
Allay-API/src/main/java/org/allaymc/api/item/interfaces/sword/ItemDiamondSwordStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.sword; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemSwordComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemDiamondSwordStack extends ItemStack { | ||
public interface ItemDiamondSwordStack extends ItemStack, ItemSwordComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
Allay-API/src/main/java/org/allaymc/api/item/interfaces/sword/ItemGoldenSwordStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.sword; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemSwordComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemGoldenSwordStack extends ItemStack { | ||
public interface ItemGoldenSwordStack extends ItemStack, ItemSwordComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
Allay-API/src/main/java/org/allaymc/api/item/interfaces/sword/ItemIronSwordStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.sword; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemSwordComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemIronSwordStack extends ItemStack { | ||
public interface ItemIronSwordStack extends ItemStack, ItemSwordComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
Allay-API/src/main/java/org/allaymc/api/item/interfaces/sword/ItemNetheriteSwordStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.sword; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemSwordComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemNetheriteSwordStack extends ItemStack { | ||
public interface ItemNetheriteSwordStack extends ItemStack, ItemSwordComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
Allay-API/src/main/java/org/allaymc/api/item/interfaces/sword/ItemStoneSwordStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.sword; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemSwordComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemStoneSwordStack extends ItemStack { | ||
public interface ItemStoneSwordStack extends ItemStack, ItemSwordComponent { | ||
} |
3 changes: 2 additions & 1 deletion
3
Allay-API/src/main/java/org/allaymc/api/item/interfaces/sword/ItemWoodenSwordStack.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,10 +1,11 @@ | ||
package org.allaymc.api.item.interfaces.sword; | ||
|
||
import org.allaymc.api.item.ItemStack; | ||
import org.allaymc.api.item.component.tool.ItemSwordComponent; | ||
|
||
/** | ||
* @author daoge_cmd <br> | ||
* Allay Project <br> | ||
*/ | ||
public interface ItemWoodenSwordStack extends ItemStack { | ||
public interface ItemWoodenSwordStack extends ItemStack, ItemSwordComponent { | ||
} |
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
11 changes: 11 additions & 0 deletions
11
Allay-Server/src/main/java/org/allaymc/server/item/component/tool/ItemAxeComponentImpl.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,11 @@ | ||
package org.allaymc.server.item.component.tool; | ||
|
||
import org.allaymc.api.item.component.tool.ItemAxeComponent; | ||
|
||
/** | ||
* Allay Project 2024/6/23 | ||
* | ||
* @author daoge_cmd | ||
*/ | ||
public class ItemAxeComponentImpl extends ItemBlockBreakingToolComponent implements ItemAxeComponent { | ||
} |
36 changes: 36 additions & 0 deletions
36
.../src/main/java/org/allaymc/server/item/component/tool/ItemBlockBreakingToolComponent.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,36 @@ | ||
package org.allaymc.server.item.component.tool; | ||
|
||
import org.allaymc.api.component.annotation.Dependency; | ||
import org.allaymc.api.entity.interfaces.EntityPlayer; | ||
import org.allaymc.api.eventbus.EventHandler; | ||
import org.allaymc.api.item.component.common.ItemBaseComponent; | ||
import org.allaymc.api.item.component.event.ItemAttackEntityEvent; | ||
import org.allaymc.api.item.component.event.ItemBreakBlockEvent; | ||
import org.allaymc.api.item.component.tool.ItemToolComponent; | ||
import org.cloudburstmc.protocol.bedrock.data.GameType; | ||
|
||
/** | ||
* Allay Project 2024/6/23 | ||
* | ||
* @author daoge_cmd | ||
*/ | ||
public abstract class ItemBlockBreakingToolComponent implements ItemToolComponent { | ||
@Dependency | ||
protected ItemBaseComponent baseComponent; | ||
|
||
@EventHandler | ||
protected void onBreakBlock(ItemBreakBlockEvent event) { | ||
var entity = event.getBreaker(); | ||
if (entity instanceof EntityPlayer player && player.getGameType() == GameType.CREATIVE) return; | ||
var hardness = event.getBlock().getBlockAttributes().hardness(); | ||
if (hardness == 0) return; | ||
if (!baseComponent.willDamageItem()) return; | ||
baseComponent.increaseDurability(1); | ||
} | ||
|
||
@EventHandler | ||
protected void onAttackEntity(ItemAttackEntityEvent event) { | ||
if (!baseComponent.willDamageItem()) return; | ||
baseComponent.increaseDurability(2); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Allay-Server/src/main/java/org/allaymc/server/item/component/tool/ItemHoeComponentImpl.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,12 @@ | ||
package org.allaymc.server.item.component.tool; | ||
|
||
import org.allaymc.api.item.component.tool.ItemHoeComponent; | ||
|
||
/** | ||
* Allay Project 2024/6/23 | ||
* | ||
* @author daoge_cmd | ||
*/ | ||
public class ItemHoeComponentImpl extends ItemBlockBreakingToolComponent implements ItemHoeComponent { | ||
|
||
} |
Oops, something went wrong.