use of net.minecraft.nbt.StringNBT in project Enigmatic-Legacy by Aizistral-Studios.
the class OblivionStoneCombineRecipe method matches.
@Override
public boolean matches(CraftingInventory inv, World world) {
List<ItemStack> stackList = new ArrayList<ItemStack>();
ItemStack voidStone = null;
for (int i = 0; i < inv.getSizeInventory(); i++) {
ItemStack checkedItemStack = inv.getStackInSlot(i);
if (!checkedItemStack.isEmpty()) {
if (checkedItemStack.getItem() == EnigmaticLegacy.oblivionStone) {
if (voidStone == null)
voidStone = checkedItemStack;
else
return false;
} else {
stackList.add(checkedItemStack);
}
}
}
if (voidStone != null & stackList.size() == 1) {
ItemStack savedStack = stackList.get(0).copy();
CompoundNBT nbt = voidStone.getOrCreateTag();
ListNBT arr = nbt.getList("SupersolidID", 8);
int counter = 0;
if (arr.size() >= ConfigHandler.OBLIVION_STONE_HARDCAP.getValue())
return false;
for (INBT s_uncast : arr) {
counter++;
String s = ((StringNBT) s_uncast).getString();
if (s.equals(ForgeRegistries.ITEMS.getKey(savedStack.getItem()).toString()))
return false;
}
return true;
} else if (voidStone != null & stackList.size() == 0) {
return true;
} else
return false;
}
use of net.minecraft.nbt.StringNBT in project Enigmatic-Legacy by Aizistral-Studios.
the class ItemLoreHelper method setLoreString.
public static ItemStack setLoreString(ItemStack stack, String string, int index) {
CompoundNBT nbt = stack.getOrCreateChildTag("display");
ListNBT loreList = nbt.getList("Lore", 8);
if (loreList.size() - 1 >= index)
loreList.set(index, new StringNBT(ITextComponent.Serializer.toJson(new StringTextComponent(string))));
else
loreList.add(new StringNBT(ITextComponent.Serializer.toJson(new StringTextComponent(string))));
nbt.put("Lore", loreList);
return stack;
}
use of net.minecraft.nbt.StringNBT in project Enigmatic-Legacy by Aizistral-Studios.
the class ItemLoreHelper method addLoreString.
public static ItemStack addLoreString(ItemStack stack, String string) {
CompoundNBT nbt = stack.getOrCreateChildTag("display");
ListNBT loreList = nbt.getList("Lore", 8);
loreList.add(new StringNBT(ITextComponent.Serializer.toJson(new StringTextComponent(string))));
nbt.put("Lore", loreList);
return stack;
}
use of net.minecraft.nbt.StringNBT in project ChocolateQuestRepoured by TeamChocoQuest.
the class ItemDungeonPlacer method getSubItems.
@Override
public void getSubItems(ItemGroup tab, NonNullList<ItemStack> items) {
if (this.isInCreativeTab(tab)) {
for (ClientDungeon fakeDungeon : CLIENT_DUNGEON_LIST) {
int iconID = fakeDungeon.getIconID() <= HIGHEST_ICON_NUMBER ? fakeDungeon.getIconID() : 0;
if (iconID == this.iconID) {
ItemStack stack = new ItemStack(this);
CompoundNBT compound = new CompoundNBT();
compound.setString("dungeonName", fakeDungeon.getDungeonName());
compound.setInteger("iconID", iconID);
ListNBT dependencies = new ListNBT();
for (String dependency : fakeDungeon.getDependencies()) {
dependencies.appendTag(new StringNBT(dependency));
}
compound.setTag("dependencies", dependencies);
stack.setTagCompound(compound);
items.add(stack);
}
}
}
}
use of net.minecraft.nbt.StringNBT in project ChocolateQuestRepoured by TeamChocoQuest.
the class NBTHelper method getVersionOfStructureFile.
public static String getVersionOfStructureFile(File file) {
try (DataInputStream input = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(file))))) {
if (input.readByte() != Constants.NBT.TAG_COMPOUND) {
return null;
}
input.readUTF();
byte id;
while ((id = input.readByte()) != 0) {
String key = input.readUTF();
INBT nbtbase = CompoundNBT.readNBT(id, key, input, 0, NBTSizeTracker.UNLIMITED);
if (key.equals("cqr_file_version")) {
return nbtbase instanceof StringNBT ? ((StringNBT) nbtbase).getAsString() : null;
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations