mirror of
https://github.com/Flowsqy/ShopChest.git
synced 2024-12-01 01:53:22 +01:00
Add base structure for Component in nms implementation
This commit is contained in:
parent
365034c08c
commit
39ee2eeafe
@ -0,0 +1,7 @@
|
||||
package de.epiceric.shopchest.nms.v1_19_R2.component;
|
||||
|
||||
public class ComponentExtractor {
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package de.epiceric.shopchest.nms.v1_19_R2.component;
|
||||
|
||||
import de.epiceric.shopchest.nms.v1_19_R2.item.NMSItemStack;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.nbt.Tag;
|
||||
|
||||
public class ItemTagExtractor {
|
||||
|
||||
public String extractItemTag(NMSItemStack itemStack) {
|
||||
final Tag tag = itemStack.getNmsItemStack().save(new CompoundTag()).get("tag");
|
||||
return tag == null ? null : tag.getAsString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package de.epiceric.shopchest.nms.v1_19_R2.component;
|
||||
|
||||
import de.epiceric.shopchest.nms.v1_19_R2.item.NMSItemStack;
|
||||
import net.minecraft.network.chat.Component;
|
||||
|
||||
public class TranslatableItemNameExtractor {
|
||||
|
||||
public String extractTranslatableItemName(NMSItemStack nmsItemStack) {
|
||||
final net.minecraft.world.item.ItemStack nStack = nmsItemStack.getNmsItemStack();
|
||||
final Component component = nStack.getItem().getName(nStack);
|
||||
return Component.Serializer.toJson(component);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package de.epiceric.shopchest.nms.v1_19_R2.item;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_19_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class NMSItemStack {
|
||||
|
||||
private final ItemStack bukkitItemStack;
|
||||
private final net.minecraft.world.item.ItemStack nmsItemStack;
|
||||
|
||||
public NMSItemStack(ItemStack bukkitItemStack) {
|
||||
this.bukkitItemStack = bukkitItemStack;
|
||||
nmsItemStack = CraftItemStack.asNMSCopy(bukkitItemStack);
|
||||
}
|
||||
|
||||
public net.minecraft.world.item.ItemStack getNmsItemStack() {
|
||||
return nmsItemStack;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user