-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
07f7d37
commit 27387a5
Showing
16 changed files
with
135 additions
and
146 deletions.
There are no files selected for viewing
14 changes: 3 additions & 11 deletions
14
src/main/java/de/dafuqs/spectrum/api/item/ActivatableItem.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,16 @@ | ||
package de.dafuqs.spectrum.api.item; | ||
|
||
import de.dafuqs.spectrum.registries.*; | ||
import net.minecraft.item.*; | ||
import net.minecraft.nbt.*; | ||
|
||
public interface ActivatableItem { | ||
|
||
String NBT_STRING = "activated"; | ||
|
||
static void setActivated(ItemStack stack, boolean activated) { | ||
NbtCompound compound = stack.getOrCreateNbt(); | ||
compound.putBoolean(NBT_STRING, activated); | ||
stack.setNbt(compound); | ||
stack.set(SpectrumDataComponentTypes.ACTIVATED, activated); | ||
} | ||
|
||
static boolean isActivated(ItemStack stack) { | ||
NbtCompound compound = stack.getNbt(); | ||
if (compound != null && compound.contains(NBT_STRING)) { | ||
return compound.getBoolean(NBT_STRING); | ||
} | ||
return false; | ||
return stack.getOrDefault(SpectrumDataComponentTypes.ACTIVATED, false); | ||
} | ||
|
||
} |
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
Oops, something went wrong.