Jump to content

Nuchaz

Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by Nuchaz

  1. I should also mention I am loading an OBJ model so I am pretty sure it is using the OBJBakedModel class when rendering. After further investigation, the OBJBakedModel class implements IPerspectiveAwareModel and it calls the handlePerspective method like this: @Override public Pair<? extends IBakedModel, Matrix4f> handlePerspective(TransformType cameraTransformType) { return IPerspectiveAwareModel.MapWrapper.handlePerspective(this, state, cameraTransformType); } So it looks like it is calling the static, state sensitive method of handlePerspective for IPerspectiveAwareModel instead of the method with just the TransformType, which is the one I need to get called in my custom OBJ model that extends IPerspectiveAwareModel. In debug mode in Eclipse I can see that the state sensitive version of handlePerspective is indeed running on IPerspectiveAwareModel, but the handlePerspective on my custom model never gets called. This is starting to maybe look like a bug in forge, but I'd like a second opinion. Should I create an issue on the forge github for this? I am still wondering too if maybe there is just something new I have to do that wasn't in 1.8.9 that I am unaware of.
  2. I am updating my mod, BiblioCraft, from 1.8.9 to 1.9.4 / 1.10.2 (tried both, same issue) and I have some custom models that implement IPerspectiveAwareModel. The interface adds the handlePerspective method to my custom model and in 1.8.9 would run every tick on item models. Now in 1.9.4 / 1.10.2 it doesn't get called at all and my models transforms are unaffected by anything that happens in this method. What changed here? Is there something new I need to do to make the handlePerspective method fire in 1.9.4 / 1.10.2?
  3. Greetings. I am thinking you need to register your textures. Everything else looks good as far as I can tell. In 1.8.9 we need to @SubscribeEvent the client side event: "TextureStitchEvent" and then you can register your textures in that. For example: event.map.registerSprite(new ResourceLocation("bibliocraft:models/bookcase_books")); Hope that helps.
  4. Greetings, I am working on rendering a compass item using a custom OBJ model. I have a model class that implements ISmartItemModel and I am creating an IBakedModel in the handleItemState method. I create my OBJModel.OBJState using my List<String> of the parts I want to show and then I can create TRSRTransformation with whatever I need and then use that stuff to bake the IBakedModel that gets rendered. I can't seem to figure out a way to apply the transform to individual parts, using this method the transform is applied to the entire model. My model only has 2 parts, the base and the compass needle. I want to rotate the compass needle on a single axis based on a float value that is saved in NBT to the ItemStack. So my question, is there is a way to apply transforms to individual parts of a custom model? Thanks.
  5. I haven't quite figured out vanilla json models yet so I can try loading the cube_all model. I'm still going through the learning curve on much of the 1.8 stuff. I plan to keep experimenting with that. But I did learn that I can just edit or remove the "textures" portion of my json file and it doesn't seem to make any difference. The textures are being loading from the .mtl file that goes with the .obj file. So maybe there is something else I need to do since I am using an obj model.
  6. I just tried the breakpoint and it turns out that yeah, it is null. My property isn't getting initialized before createBlockState() is being called. I checked and it looks like the constructor in my block doesn't seem to get called before the createBlockState() method either. That seems pretty odd, so I tried removing the final from the property and initalizing my WOOD_TYPE inside the createBlockState() method and it worked! Thanks, at least I understand the problem better and have a work around. I don't understand why my WOOD_TYPE isn't getting initialized as a final static type though. With the metablocks working, the textures on the models still aren't changing. I have my 7 blocks, but the textures are all the same. The only place I've done anything to read the metadata / "woodtype" is in the json file I shared in the OP. Is there something else that must be done? Like is there something I have to put into my .mtl file to allow me to override the default texture or does something have to change in my json file? Thanks.
  7. Hello everyone, I ran into another problem that I am stuck on. For the life of my I can't seem to get blockstates working in such a way that it simulates metadata. I basically have a block and I want 7 variants. Each variant should have a different texture. That is the only difference. I am using custom OBJ models and I have my block working fine. I've read over several "metadata" and blockstates tutorials and have tried everything I can think of over the last 3 days with the same results all the time. I get a crash on the createBlockState method in my block if I try to add any IProperty to the blockstate. The crash happens on game load, before I even get to the menu and while the forge splash screen shows I am on the "constructing mods" phase. So, for example, I can do this with no problems: @Override protected BlockState createBlockState() { return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[]{OBJModel.OBJProperty.instance}); } But if I try adding this to my block class I crash: public static final PropertyInteger WOOD_TYPE = PropertyInteger.create("woodtype", 0,6); @Override protected BlockState createBlockState() { System.out.println("test"); return new ExtendedBlockState(this, new IProperty[]{WOOD_TYPE}, new IUnlistedProperty[]{OBJModel.OBJProperty.instance}); } @Override public IBlockState getStateFromMeta(int meta) { return this.getDefaultState().withProperty(WOOD_TYPE, meta); } @Override public int getMetaFromState(IBlockState state) { return state.getValue(WOOD_TYPE); } I've tried creating my own Enum and using the PropertyEnum class and I've tried creating an IUnlistedProperty and using the Properties.toUnlisted and adding either one to the IUnlistedProperties all the time with a similar crash. I've tried returning just a BlockState with the same results too. I've tried commenting out my getExtendedState method to make sure that wasn't interfereing and I got the same result. The code above I think is the simplest methods to get some meta data values. However, I get the NPE crash. Here is my crash: http://pastebin.com/cMmjDCsB It comes down to this: Caused by: java.lang.NullPointerException at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:213) Which I am totally at a loss for. I've tried everything I can think of and I keep getting this error if I try to add an IProperty. I've even copy pasted the three methods from BlockColored and I got the same exact result. I think I added the relevant data to my .json file, but I am not totally confident on that. Here is my .json: { "forge_marker": 1, "defaults": { "textures": { "wood": "bibliocraft:texture", "books": "bibliocraft:texture" }, "custom": { "flip-v": true }, "model": "bibliocraft:bookcase.obj" }, "variants": { "normal": [{}], "inventory": [{ "transform": "forge:default-block" }], "woodtype": { 0: { "textures": { "wood": "minecraft:blocks/planks_oak" } }, 1: { "textures": { "wood": "minecraft:blocks/planks_spruce" } }, 2: { "textures": { "wood": "minecraft:blocks/planks_birch" } }, 3: { "textures": { "wood": "minecraft:blocks/planks_jungle" } }, 4: { "textures": { "wood": "minecraft:blocks/planks_acacia" } }, 5: { "textures": { "wood": "minecraft:blocks/planks_darkoak" } }, 6: { "textures": { "wood": "bibliocraft:blocks/frame" } } } } } For further reference, my custom models are loaded in the preInit on the client side like this: OBJLoader.instance.addDomain("bibliocraft"); Item item = Item.getItemFromBlock(BlockBookcase.instance); ModelResourceLocation loc = new ModelResourceLocation("bibliocraft:" + BlockBookcase.name, "inventory"); ModelLoader.setCustomModelResourceLocation(item, 0, loc); Does anyone have any idea what is happening or what I can do to fix this? Is there something I am missing perhaps? I just want some simple block variants. I think I posted all the relevant code, but let me know if there is something else.
  8. It may be that your texture is mirrored. I had this issue with my obj models. My UVs were being mirrored both vertically and horizontally. To fix this, I had to add a line to my json file. In the "defaults" section of the json add "custom": { "flip-v": true }
  9. Thanks! That looks like exactly what I am looking for. I'll have a play around with it later. I didn't know I could share an .mtl between obj models and I wasn't sure how to stitch textures. That was something I wanted to know at some point. So huge thanks for the extra tips too!
  10. Hello everyone, I am working on updating BiblioCraft to v1.8.8 and am still working my way through all the new features trying to understand how to use them. I think I am going to really like the new systems once I get a feel for them. So far I think I have an understanding of how to render OBJ models, show/hide parts of the models, and apply transforms using the getExtendedState within my block classes. Now I am trying to understand how to dynamically update the texture of my blocks. I've looked over the retexture method in the OBJModel class so I sure there must be a way to do this. What I am doing is basically saving a string to NBT on the TileEntity (for ex: "minecraft:blocks/planks_oak") which I can pass on to easily work with either the retexture method in the OBJModel class or I can easily use it to get a TextureAtlasSprite. This only really needs to happen on block placement (the string will be saved to the ItemStack and passed to the Tile on placment) and when the blocks initially load. I also want to pull the string from NBT on the ItemStack, get the texture and apply it to the ItemStack model as well. That NBT tag can changed in game so the texture on the ItemStack model can change any number of times. I've been looking at this example on the forge github of the ModelBakeEventDebug class trying to understand how I might approach this retexture problem. https://github.com/MinecraftForge/MinecraftForge/blob/master/src/test/java/net/minecraftforge/debug/ModelBakeEventDebug.java From what I've learned from that I am guessing I may have to create a custom model class and implement several interfaces and use the handleBlockState and handleItemState methods. But I am not sure how to approach that using an OBJ model because there is already a OBJModel class and an OBJBakedModel class that already does all the things including the implementation of the retexture method from the IRetexturableModel interface. I thought about just extending the OBJBakedModel class and overrideing the handleBlockState method but the current OBJBakedModel handleBlockState method is doing some things that access private variables when dealing with the visibility groups. I am just not sure how to proceed. I am wondering if I have to do something in my model json file too. Can anyone give me some tips on how to dynamically change the texture on an OBJ model? Or possibly is there any working examples out there I can read over that allow retexturing an OBJ model? Thanks!
  11. Yup, my logic was flawed. There was a hole in my logic I didn't realize until someone found a way to exploit it. I have fixed it. I was just hoping for extra layers of security, it just seemed like a good idea.
  12. I'm aware of all that, and I agree with you (except the nothing will happen part). All my logic is server side. I've even fixed the problem. I just want extra security to know that someone can't hack my packets. Stuff CAN happen when packets get hacked, they can trigger server logic that shouldn't be triggered unless under certain circumstance. The circumstance is irrelevant though, since it is a straightforward question. The question still stands, can I get the ModID from a custom packet?
  13. I am trying to secure my custom packets better because I found out you can just send packets to any mod if you know the channel id of that packet and some folks are using this to cheat. There is a mod out there that will send a packet to my mod from a hacked client on a server and can be used to spawn anything. I've already taken steps to fix it. I've even doubled up on security for the issue, but I wouldn't mind adding a 3rd layer. In my server packet handler, where I receive my event.packet, I would like to get the ModID of the mod that sent the packet, than I can just compare with my own ModID and return anyone using a different mod. So, is there a way to get the ModID from a custom packet? Thanks.
  14. I noticed some of the bindTexture stuff has moved around a little. In places where I used ForgeHooksClient.binTexture(String, int) for 1.4.7, I now use: FMLClientHandler.instance().getClient().renderEngine.bindTexture(String) for 1.5.x (no more int variable required). I am not sure if there is a simpler way, but this seems to work. Though I haven't tried it with EntityFX, it works great on my item renderers that implement IItemRenderer. Hope that helps.
  15. Hello, I am trying to write a method that can scan and ultimately return an array of texture names from the /armor/ directory. I know this directory exists inside of minecraft.jar and inside a bunch of files inside the /mods/ folder, but when loaded up minecraft sees them all as being in /armor/. At first I was thinking I could use some file operations with File and/or JarFile and loading minecraft.jar and returning what I need. But then I realized that probably won't get me the armor textures inside of all the mod files. It seems a little overkill to have to write methods to scan though all the .zip's and .jar's in /mods/ folder manually just to find these textures. Is there an easier way through forge to list of all .png's that can be found in /armor/ plus its sub-directories?
  16. I was messing with this the other day because I wanted a small candle flame for a block. I was able to create new particle effects and use them without too much trouble. First I created a new class that extends EntityFX. See something like EntityFlameFX for example. To get my particle to spawn I used the displayRandomTick method on the block and used something similar to this: EntityFX candleFlame = new EntityCandleFX(world, x, y, z, 0.0D, 0.0D, 0.0D); Minecraft.getMinecraft().effectRenderer.addEffect(candleFlame) My x, y, z values are setup with a switch case that depends on 1 of 4 angles that takes the x, y, z, sent to the randomDisplayTick method and adds those with my desired offsets for each angle. Hopefully that is helpful. Good luck.
  17. Is there a way to lock a sprite graphic in place so it doesn't always face the player? I have some items that I want to render in a fixed position. In fancy graphics this is not a problem, the items render in my TileEntitySpecialRenderer just fine, but in fast graphics mode they turn to sprites and always face the player. I just want to lock them so they cannot rotate. Thanks
  18. ok, so it seems I just didn't do enough testing with ForgeHooksClient.getArmorTexture(itemStack, defaultString) and I have learned that any armor item that implements the interface IArmorTextureProvider does actually return the texture path I am looking for. I had tested with vanilla and IC2 and both of them would only return the defaultString. Mods like thaumcraft, twilight forest, railcraft, minechem, and foresty setup the IArmorTextureProvider interface( I assume) and return the correct texture path I am looking for. I think I was closer to my solution than I thought this whole time. It seems like it would be easy enough to test for vanilla armor and IC2 armor and just hardcode in the IC2 armor texture locations so I think that is the route I am going to take.
  19. Okay, so I am still trying to figure this one out. I've got it setup now so that if a piece of armor is present is one of the 4 slots on my armor stand then that piece of armor renders. Basically I am using the vanilla code to get the armor texture path from the vanilla armor then just rendering that texture onto a custom ModelBiped class that I extended. It works fine for vanilla armor, though it doesn't display enchanted armor (or at least the enchantment/glowing effect). I'm using this to get my string for the texture path. Item helmItem = helmStack.getItem(); ItemArmor armorHelm = (ItemArmor)helmItem; int aType = armorHelm.armorType; String helmTexture = ForgeHooksClient.getArmorTexture(helmStack, "/armor/" + armorFilenamePrefix[armorHelm.renderIndex] + "_" + (aType != 2 ? 1 : 2) + ".png"); Then I just use ForgeHooksClient.bindTexture to place the texture on my model. But of course this only works for vanilla textures and trying to put mod stuff on there in many cases caused crashes (not that I expected this to work, but I had to try, for science.) I pretty much just need some way to get the texture path for the armor from an ItemStack. I know there must be code in vanilla somewhere that does this for rendering the armor on the player, but I can't seem to find where this code could be. I am also wondering about the enchantment effect and how I might apply that. If anyone has any tips that might help me get this texture path I would really appreciate it. Thanks.
  20. Hello, I am working on a mod that is adding several new types of custom and visually attractive storage options. One such block I am working on is an armor stand. I have no trouble rending a custom model w/ custom texture, setting up a TileEntity with a TileEntitySpecialRenderer than passing along my ItemStack of my armor pieces to my renderer, but then I am not sure how exactly to get the armor to render. I am thinking I need to bring in the ModelBiped and initilize a new ModelBiped(); then get the armor texture from my itemstack(s) and use ForgeHooksClient.bindTexture to apply the texture. Am I correct in my approach to this problem? The main issue I am having with this approach is I am not sure how to properly get the texture from the itemstack. I tried using String helmTexture = ForgeHooksClient.getArmorTexture(helmStack, armorHelm.getTextureFile()); but I only seem to get back the item texture and not the actual armor texture I can apply to a ModelBiped. I pulled the itemstack for my helmStack from the TileEntity and did a ItemArmor armorHelm = (ItemArmor)helmItem;. I've made it render just the item by doing a EntityItem helmItem = new EntityItem(null, i, j, k, helmStack); and then a itemRenderer.doRenderItem(helmItem, 0, 0, 0, 0, 0); but that is not exactly what I want. I had a good look at the RenderPlayer class, but I haven't had any success in accomplishing my goal. I would really like it if I could make this armor stand work with most / any mod that adds armor's which I think is making this a little more difficult to pull the texture. Any help / suggestions would be most appreciated. Thanks!
×
×
  • Create New...

Important Information

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