Jump to content

1.9.4 [solved] texture issue updating pre-written book from 1.7.10.


salvestrom

Recommended Posts

 

 

        public static ItemStack eastScale;

public static ItemStack westScale;

 

public bookScale()

    {

super();

    this.setUnlocalizedName("bookScale");

    this.setContainerItem(this);

    this.setCreativeTab(w2theJungle.JungleModTab);

    this.setHasSubtypes(true);

 

{

{

eastScale = new ItemStack(Items.WRITTEN_BOOK);

eastScale.setItemDamage(367);

       

    NBTTagCompound tag = new NBTTagCompound();

    eastScale.setTagCompound(tag);

   

tag.setString("author", ("Salvestrom"));

tag.setString("title", ("The Books of Scale: The Bringer"));//Lord of the Living"));

NBTTagList bookPages = new NBTTagList();

tag.setTag("pages", bookPages);

    bookPages.appendTag(new NBTTagString

    ("\"Who really knows\n"

    + " and who can swear\n"

    + " How minecraft came,\n"

    + " when or where!\n"

    + "\n"

    + "Even gods came\n"

    + " after building day,\n"

    + " Who really knows,\n"

    + " who can truly say\n"

    + "\n"

    + "When and how\n"

    + " did generation start?\n"

    + " Did He do it?\n"

    + " Was it Notch?\""));

            }

   

{

westScale = new ItemStack(Items.WRITTEN_BOOK);

NBTTagCompound wtag = new NBTTagCompound();

westScale.setTagCompound(wtag);

    westScale.setItemDamage(368);

 

    NBTTagList westPages = new NBTTagList();

    wtag.setTag("pages", westPages);

wtag.setString("author", ("Salvestrom"));

wtag.setString("title", ("The Books of Scale: The Taker"));//Lord of the Damned"));

westPages.appendTag(new NBTTagString

    ("\"The first sheet "

    + "in this compilation is "

    + "an image of the moon, "

    + "divided into unequal "

    + "sections, each "

    + "depicting a "

    + "terrible punishment. "

    + "It seems the Saur-"

    + "ohn equated the "

    + "celestial body with "

    + "some sort of "

    + "Netherworld. The ruler "

    + "of this Selenic realm "

    + "is referred to only by\""));

    }}

 

@SuppressWarnings({"rawtypes", "unchecked"})

        @Override

@SideOnly(Side.CLIENT)

public void getSubItems(Item i, CreativeTabs c, List list) {

list.add(bookScale.eastScale);

list.add(bookScale.westScale);

list.add(bookScale.northScale);

list.add(bookScale.southScale);

}

 

 

 

 

nb: there are 4 books total, with over 30 pages between them. this is just the first page of two. to show how it all is setup.

 

The only actual issue i have with the code is I can't get them textured ingame. under 1.7.10 the sub items simply took the appearance of the written_books without my needing to do anything. My attempt to register separate renders for them did nothing.  (i think because the renderer needs an item, which is just a written book, so im effectively registering a render for the vanilla item, not my prewritten book)

 

I found this code over 18 months ago and have never been entirely happy with it even though it worked fine, barring one oddity only encountered if taking books from the creative inventory after acquiring a book in a normal way, which was wierd, but non-game breaking and rare. In any case, swapping it for an enumerator seemed like a good idea at this point. this went fine, allowing textures to apply, but I've no idea how to apply the nbt data to the variants which arent itemstacks.

 

I'm fine with whichevers best or easiest to resolve.

Link to comment
Share on other sites

So a funny thing happened on the way to the forums...

 

While compiling the information you asked for I saw I had made a mistake during my prior attempt to create individual renders for the books: i was passing the meta as 0, not the set item damage. doing so, and tweaking the item passed resolved the issue.

 

/hug disen

 

here's what you asked for, anyway:

 

 

 

public class JungleItems
{
public static ItemWrittenBook bookScales;

public static void init()
{
	//items
	bookScales = new bookScale();
                registerItems();
        }

public static void registerItems()
{
	registerItem(bookScales, "bookScale");
        }

public static void registerRenderers()
{
	registerRender(bookScales);
        }

public static void registerItem(Item item, String string)
{
	item.setRegistryName(string);
	GameRegistry.register(item);
}

public static void registerRender(Item item)
{
                ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(item.getRegistryName(), "inventory"));
}

 

 

 

the corrected renders:

 

registerRenderWithMeta("east_scale", bookScale.eastScale.getMetadata(), bookScale.eastScale.getItem());
	registerRenderWithMeta("west_scale", bookScale.westScale.getMetadata(), bookScale.westScale.getItem());
	registerRenderWithMeta("north_scale", bookScale.northScale.getMetadata(), bookScale.northScale.getItem());
	registerRenderWithMeta("south_scale", bookScale.southScale.getMetadata(), bookScale.southScale.getItem());

public static void registerRenderWithMeta(String string, int i, Item item)
{
        ModelLoader.setCustomModelResourceLocation(item, i, new ModelResourceLocation(References.MODID + ":" + string, "inventory"));
}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.