use of net.minecraft.nbt.NBTTagString in project SecurityCraft by Geforce132.
the class ItemSCManual method onUpdate.
@Override
public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5) {
if (par1ItemStack.getTagCompound() == null) {
NBTTagList bookPages = new NBTTagList();
par1ItemStack.setTagInfo("pages", bookPages);
par1ItemStack.setTagInfo("author", new NBTTagString("Geforce"));
par1ItemStack.setTagInfo("title", new NBTTagString("SecurityCraft"));
}
}
use of net.minecraft.nbt.NBTTagString in project SpongeCommon by SpongePowered.
the class NbtTranslator method setInternal.
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void setInternal(NBTBase base, byte type, DataView view, String key) {
checkNotNull(base);
checkNotNull(view);
checkNotNull(key);
checkArgument(!key.isEmpty());
checkArgument(type > NbtDataUtil.TAG_END && type <= NbtDataUtil.TAG_INT_ARRAY);
switch(type) {
case NbtDataUtil.TAG_BYTE:
if (key.contains(BOOLEAN_IDENTIFER)) {
view.set(of(key.replace(BOOLEAN_IDENTIFER, "")), (((NBTTagByte) base).getByte() != 0));
} else {
view.set(of(key), ((NBTTagByte) base).getByte());
}
break;
case NbtDataUtil.TAG_SHORT:
view.set(of(key), ((NBTTagShort) base).getShort());
break;
case NbtDataUtil.TAG_INT:
view.set(of(key), ((NBTTagInt) base).getInt());
break;
case NbtDataUtil.TAG_LONG:
view.set(of(key), ((NBTTagLong) base).getLong());
break;
case NbtDataUtil.TAG_FLOAT:
view.set(of(key), ((NBTTagFloat) base).getFloat());
break;
case NbtDataUtil.TAG_DOUBLE:
view.set(of(key), ((NBTTagDouble) base).getDouble());
break;
case NbtDataUtil.TAG_BYTE_ARRAY:
view.set(of(key), ((NBTTagByteArray) base).getByteArray());
break;
case NbtDataUtil.TAG_STRING:
view.set(of(key), ((NBTTagString) base).getString());
break;
case NbtDataUtil.TAG_LIST:
NBTTagList list = (NBTTagList) base;
byte listType = (byte) list.getTagType();
int count = list.tagCount();
List objectList = Lists.newArrayListWithCapacity(count);
for (int i = 0; i < count; i++) {
objectList.add(fromTagBase(list.get(i), listType));
}
view.set(of(key), objectList);
break;
case NbtDataUtil.TAG_COMPOUND:
DataView internalView = view.createView(of(key));
NBTTagCompound compound = (NBTTagCompound) base;
for (String internalKey : compound.getKeySet()) {
NBTBase internalBase = compound.getTag(internalKey);
byte internalType = internalBase.getId();
// Basically.... more recursion.
// Reasoning: This avoids creating a new DataContainer which would
// then be copied in to the owning DataView anyways. We can internally
// set the actual data directly to the child view instead.
setInternal(internalBase, internalType, internalView, internalKey);
}
break;
case NbtDataUtil.TAG_INT_ARRAY:
view.set(of(key), ((NBTTagIntArray) base).getIntArray());
break;
default:
throw new IllegalArgumentException("Unknown NBT type " + type);
}
}
use of net.minecraft.nbt.NBTTagString in project Charset by CharsetMC.
the class ProjectorHandlerBook method render.
@Override
@SideOnly(Side.CLIENT)
public void render(ItemStack stack, IProjector projector, IProjectorSurface surface) {
// oh boy! text!
if (stack.hasTagCompound()) {
GlStateManager.pushMatrix();
GlStateManager.translate(((surface.getCornerStart().x + surface.getCornerEnd().x) / 2) + surface.getScreenFacing().getFrontOffsetX() * 0.001f, ((surface.getCornerStart().y + surface.getCornerEnd().y) / 2) + surface.getScreenFacing().getFrontOffsetY() * 0.001f, ((surface.getCornerStart().z + surface.getCornerEnd().z) / 2) + surface.getScreenFacing().getFrontOffsetZ() * 0.001f);
Orientation orientation = ProjectorHelper.INSTANCE.getOrientation(surface);
Quaternion.fromOrientation(orientation).glRotate();
GlStateManager.rotate(270.0f, 0, 0, 1);
GlStateManager.rotate(270.0f, 0, 1, 0);
GlStateManager.translate(0, 0, -ProjectorHelper.OFFSET);
float scaleVal = 2f * surface.getWidth() / 146f;
GlStateManager.scale(scaleVal, scaleVal, scaleVal);
FontRenderer renderer = Minecraft.getMinecraft().fontRenderer;
NBTTagList pages = stack.getTagCompound().getTagList("pages", Constants.NBT.TAG_STRING);
if (pages.tagCount() > projector.getPage()) {
String pageCount = I18n.format("book.pageIndicator", projector.getPage() + 1, pages.tagCount());
renderer.drawString(pageCount, -73 + 129 - renderer.getStringWidth(pageCount), -90 + 15, 0xFF000000);
String page = ((NBTTagString) pages.get(projector.getPage())).getString();
ITextComponent fullComponent = ITextComponent.Serializer.jsonToComponent(page);
if (fullComponent != null) {
List<ITextComponent> components = GuiUtilRenderComponents.splitText(fullComponent, 116, renderer, true, true);
for (int i = 0; i < components.size(); i++) {
renderer.drawString(components.get(i).getUnformattedText(), -73 + 16, -90 + 30 + i * renderer.FONT_HEIGHT, 0xFF000000);
}
}
}
GlStateManager.popMatrix();
surface.restoreGLColor();
}
Minecraft.getMinecraft().getTextureManager().bindTexture(new ResourceLocation("textures/gui/book.png"));
ProjectorHelper.INSTANCE.renderTexture(surface, 20, 20 + 146, 1, 1 + 180);
}
use of net.minecraft.nbt.NBTTagString in project Charset by CharsetMC.
the class TileEntityDayBarrel method makeBarrel.
public static ItemStack makeBarrel(Set<BarrelUpgrade> upgrades, ItemMaterial log, ItemMaterial slab) {
ItemStack stack = new ItemStack(CharsetStorageBarrels.barrelItem);
NBTTagCompound compound = ItemUtils.getTagCompound(stack, true);
compound.setString("log", log.getId());
compound.setString("slab", slab.getId());
if (upgrades.size() > 0) {
NBTTagList list = new NBTTagList();
for (BarrelUpgrade u : upgrades) list.appendTag(new NBTTagString(u.name()));
compound.setTag("upgrades", list);
}
return stack;
}
use of net.minecraft.nbt.NBTTagString in project TechReborn by TechReborn.
the class StackWIPHandler method addHead.
private void addHead(String name) {
ItemStack head = new ItemStack(Items.SKULL, 1, 3);
head.setTagCompound(new NBTTagCompound());
head.getTagCompound().setTag("SkullOwner", new NBTTagString(name));
devHeads.add(head);
}
Aggregations