-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tool): add switchable functionality to blaze tools
- Implement ISwitchable interface for blaze tools - Add switchMode method to toggle tool activation - Update tool usage to check and switch activation state - Refactor IBlazeTool to ISwitchable interface
- Loading branch information
Showing
8 changed files
with
76 additions
and
139 deletions.
There are no files selected for viewing
10 changes: 0 additions & 10 deletions
10
src/main/java/committee/nova/mods/avaritia/api/iface/IBlazeTool.java
This file was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
src/main/java/committee/nova/mods/avaritia/api/iface/ISwitchable.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,31 @@ | ||
package committee.nova.mods.avaritia.api.iface; | ||
|
||
import net.minecraft.nbt.CompoundTag; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.server.level.ServerPlayer; | ||
import net.minecraft.world.InteractionHand; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.item.ItemStack; | ||
import net.minecraft.world.level.Level; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* @Project: Avaritia | ||
* @Author: cnlimiter | ||
* @CreateTime: 2024/11/4 00:16 | ||
* @Description: | ||
*/ | ||
public interface ISwitchable { | ||
default boolean isActive(ItemStack stack) { | ||
if (!stack.getOrCreateTag().contains("active")) return false; | ||
return stack.getOrCreateTag().getBoolean("active"); | ||
} | ||
|
||
default void switchMode(@NotNull Level world, Player player, @NotNull InteractionHand hand) { | ||
ItemStack stack = player.getItemInHand(hand); | ||
CompoundTag tags = stack.getOrCreateTag(); | ||
tags.putBoolean("active", !tags.getBoolean("active")); | ||
if(!world.isClientSide && player instanceof ServerPlayer serverPlayer) serverPlayer.sendSystemMessage(Component.translatable("tooltip.tool.active"), true); | ||
player.swing(hand); | ||
} | ||
} |
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
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