-
Posts
16559 -
Joined
-
Last visited
-
Days Won
156
Everything posted by Draco18s
-
[1.6.2]Changing a Specific Block's (x,y,z) Texture
Draco18s replied to Vemahk20's topic in Modder Support
You are forgetting that the block class is a singleton and that "instances" of it in the world are not actually instances, but simply a numbered reference. This thread, only a little ways down the first page on this very forum, will provide insight. -
If it's a TileEntity you can pass XYZ coordinates, then use world.getBlockTileEntity(...)
-
As opposed to say, making an item that extends ItemMapBase (so isMap -> true) which should be utilized in all ways by other objects in the same way as a vanilla map. (isMap is called in one place in the entire Minecraft codebase, which boggles my mind)
-
remove "final" modifier on getIconIndex(ItemStack)
Draco18s replied to AnonymousProductions's topic in Suggestions
It's a final method which calls a non-final method. The "final" in this case appears to be completely arbitrary. -
Probably because you're doing it client side. This is the code I pasted if(data != null && par2World.isRemote) { This line checks to make sure that the client is running it because... //oddly this function runs on the server, but directly altering the player entity has no effect. //so instead we end up using packets
-
@Override public void onUpdate(ItemStack stack, World world, Entity entity, int n, boolean b) { if (stack.getItemDamage() >= stack.getMaxDamage()) stack.stackSize -= 1; //if this is reduced to 0, it is automatically "destroyed" }
-
I noticed that item frames still don't use the handy isMap() method to render maps.
-
Its called by renderItemIntoGUI in RenderItem. There is one other function with the same name that also calls this funciton, passing an extra parameter doRenderItem also calls this function. renderItemIntoGUI also handles mutliple-pass rendering which calls the other function, so while there is a way to render the NBT data driven icon through the multiple-pass renderer, it should not be needed. It's a single icon that needs to be rendered once.
-
Solution was to render in pass 2 (which is not obvious, but anyway). I want the item icon when it appears in inventories. The only place an ItemStack gets its icon is the quoted function, which calls back to the finalized function in Item.java. I checked out all the other variants of getIcon in the Item class, as I'd said, but two of them don't take the item stack, two of them only cause the item to render in 3D with the indicated icon (the first passing its params to the second), and the last method is final. There aren't any others. So I'm not sure what you're question is.
-
That does work. Thanks. Already had that function overriden (getIcon) but I didn't think to set multiple render passes (and actually, you want that second function to return a 2: //default public int getRenderPasses(int metadata) { return requiresMultipleRenderPasses() ? 2 : 1; }
-
AFAICT, this is the only spot where an ItemStack is passed to the Item class in order to get an icon for drawing inventory sprites (as opposed to 3D world sprites). Unfortunately it's final and cannot be overriden (base class editing out the final gets me what I need). All it does is call getIconFromDamage(int par1) , which doesn't have enough info left to get at stack NBT data. public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) (which calls public Icon getIcon(ItemStack stack, int pass) , am already overriding) won't work, as that's the 3D render usage (apparently). The only other function available is public Icon getIconFromDamageForRenderPass(int par1, int par2) which also lacks the ItemStack. Lex has indicated that this must be possible as other mods are doing it, but my guess is that they've written a custom item renderer to handle it (which seems...excessive, as the necessary function is already there, but not modifiable).
-
public Icon getIcon(ItemStack stack, int renderPass, EntityPlayer player, ItemStack usingItem, int useRemaining) (which calls public Icon getIcon(ItemStack stack, int pass) and am currently overriding) doesn't work. The only other functions available are public Icon getIconFromDamageForRenderPass(int par1, int par2) and getIconFromDamage(int par1). which lacks the ItemStack. Oh look: //ItemStack.java public Icon getIconIndex() { return this.getItem().getIconIndex(this); } That calls the function I'm asking about. That's the only method on ItemStack that returns an Icon. I'd hazard a guess that those other mods wrote a custom renderer for their item, which would be unnecessary if the Item class didn't have this function as final.
-
Currently Item.getIconIndex(ItemStack par1ItemStack) is final and calls another function (which is not) with a lower-typed parameter: getIconFromDamage(int par1). This means that I can't use NBT data to override the inventory icon, only the held model icon.
-
I know how to use it, I just managed to not-see it.
-
Huh, I managed to miss that somehow. o..O I mean, I litterally trawled the Item class for every function I would possibly need and managed to grab the wrong canHarvestBlock one. Well damn.
-
Cough, look at vanilla chests, cough.
-
public boolean canHarvestBlock(Block par1Block); If this function determines if blocks drop their resource when mined. However, it isn't passed the ItemStack the player is using to mine the block (thus block-droppage is determined at the Item class level, requiring new Item-IDs to differentiate "tools" from "non tools"). Is there any way around this? My first thought was returning false (no drops) and then fixing it with the onBlockDestroyed() method to cause a drop if there should be one (based on the NBTdata) but this prevents getStrVsBlock() from being called, which means that NBTdata is not used to determine block breaking speed.
-
Point. However, that's how you make a bounding box.
-
Why gee, you could open up where this.boundingBox is defined and check: this.boundingBox = AxisAlignedBB.getBoundingBox(0.0D, 0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
-
Right, of course. And just because I did it right and forgot the null check when posting the first time doesn't mean I don't know. It just means that you shouldn't be blindingly copy-pasting.
-
Javadoc: I happen to be using the "or 0" effect in my current mod: public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { NBTTagCompound data = par1ItemStack.getTagCompound(); int effectID = 0; //oddly this function runs on the server, but directly altering the player entity has no effect. //so instead we end up using packets if(data != null && par2World.isRemote) { effectID = data.getInteger("onItemRightClick"); if(effectID != 0) { //do stuff } } return par1ItemStack; }
-
Ah. Yes. Of course, what's funny is when I tried it, an enchanted weapon told me the string was "Weapon damage" and my code didn't work. (Turned out the line I was missing at the time was nnbt.setString("AttributeName", att.getName()); "AttributeName" being what the end-result looks for, but I never found it being set anywhere, though I did find "Name" used in several places). Like I said, pain in the ass to figure out from just the code.
-
Its the same as getBlockTexture, but rather than looping through the directions (up,down,left,right,forward,backward) it is passed the direction to look at. This prevents blockA -> blockB -> blockA -> infinite loop texture requests. And yes, it doesn't work well for grass. Grass is such a pain in the ass to fake, due to using three textures, only one of which (the top) needs to get colored, but the getBlockColor() method takes no parameters! getRenderColor() is slightly better, but passes only a single integer (side?), not enough to know if the block that is being rendered is a supposed to be mimicking grass or not. colorMultiplier() is better still, but doesn't distinguish by side.