Jump to content

TheEpicTekkit

Members
  • Posts

    361
  • Joined

  • Last visited

Everything posted by TheEpicTekkit

  1. That looks really cool! In my opinion, I think it would look better if you left it black, instead of making it bright green. But, your mod, so your decision.
  2. When you say "with this code" do you mean when I suggested GL11.glColor4f(1, 1, 1, 1); or when I said to set the 1 to a 0, or when I said to set the zeros to a 1?
  3. I am no expert, but maybe, try using GL11.glColor4f(1, 1, 1, 1); this will enable red, green, blue, and alpha (transparency) I saw you had GL11.glColor3f(0, 1, 0); I have never used this one, but I'm logically assuming that is red, green and blue. so this is only enabling green. But weirdly, you said green is the only one not working. Maybe it is somehow inverted? try setting that 1 to a 0, or all of them to 1.
  4. Okay thanks. You were right. I had accidentally imported Scala.util.Random instead of Java.util.Random. Just a silly mistake... oops.
  5. Hello everyone. I have something quite strange here. I am trying to make a block drop an item when broken. Should be as simple as getItemDropped like so: public Item getItemDropped(int par1, Random rand, int par2) { return ItemHandler.gemSapphire; } right? Well, wrong... somehow this isn't working. This method has even been copied directly Block.class yet somehow it still doesn't override it, and when my block is broken, it just drops the block. Now this is strange, because it is trying to override it, I think, but for some reason can't. When I pressed control, and clicked open super implementation, eclipse crashed, and this tells me that this isn't a problem with my code. I have even put an @Override annotation above the method and it gives me an error saying "The method getItemDropped(int, Random, int) of type SapphireOre must override or implement a supertype method" What can I do? I know that I have got the method right, no spelling mistakes etc. but it still doesn't work. Thanks.
  6. Okay, thanks. I don't think I explained the bobbing very well, I think you have misunderstood what I meant. It is hard to explain, but when an items damage is charging (not just for my item), it bobs up and down. e.g. I can't remember what the mod is called, It may just be "chargepads" but, there is a mod that adds charge pads, and when you stand on one, it charges things like IC2 armour or electric items in the players inventory like batteries, and when you hold an electric item while it is charging, it does the same thing, it bobs up and down. I think this is a vanilla thing. maybe it is because it thinks for each damage value change, you have changed item or something. But thanks anyway. If I can make it display a damage bar for a value that isn't the actual items damage, then it shouldn't bob up and down.
  7. Hello everyone. So, I am creating an item that can be charged with energy (my own custom energy), and when it is on (switched on by holding control and clicking), this energy is constantly drained, at a rate of 1 per tick (it stores 9600, so that is enough for 6 minutes of use.) I have been using things like stackTagCompound to store data like this in the item. Now, the way I am decreasing the energy, is with stack.setItemDamage(stack.getItemDamage - 1); But there are two problems with this, one of which is quite strange. one: the item is constantly bobbing up and down in the players hand when the damage is changing, I would like to stop this from happening, or have an alternative way to decrease the stored energy. Is there a method I can override to stop this? two: (quite strange) the damage bar is reversed... so when it is empty, the damage bar shows full, and when it is full, the damage bar shows empty, and as it is filling, the damage bar goes down, and visa versa. So, how do I fix these two things? preferably, I wouldn't like to use item damage, I would like to use a stored value in stackTagCompound, and have a damage bar displayed for this. But is that the best way to do it? I'm not sure. thanks.
  8. Well, if it isn't rendering, you either haven't bound the texture properly, or it is out of the players FOV, if you go into third person mode, can you see it? if not, the texture is not done properly, if so, you just need to use GL11 to translate it into the players view, and from there, you need to figure out the rotations and translations as no two models have the same translations/rotations.
  9. And just for future preference too, you can do the same for the player too if needed. Minecraft.getMinecraft().thePlayer; This returns an instance of the player (I think, on the server. It returns an EntityClientPlayerMP, I think. I haven't got eclipse here to check as I am on a school pc.)
  10. Okay, for that crash, there is a NullPointerException on line 19 of your model class. always make sure something is not null if there is the possibility for it to be. Unfortunately, I can't look at the code you put on bitbucket, I am on a school pc, and that website is blocked due to a security error. May you put the code in "code" and "/code" (with square brackets [ ]) annotations? that way I can see what you have changed. As I said though, you don't need a model class, put it in the ItemRenderer.
  11. To load an obj model you need an IModelCustom, and a ResourceLocation. You don't need a model class, that just over complicates things. You just put these in the ItemRenderer. You only need a model class if you are using techne, and also, not needed, but if you are using tessellators too. public final ResourceLocation modelResource = new ResourceLocation("modid:yourModelLocation/yourModel.obj"); public final ResourceLocation texture = new ResourceLocation("modid:yourTextureLocation/yourTexture.png"); public IModelCustom model = AdvancedModelLoader.loadModel(modelResource); public void renderItem(ItemRenderType type, ItemStack stack, Object... data) { GL11.glPushMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(this.texture); //Not 100% sure if I got this right, but you bing the texture here. //Do all your GL11 rotations, scales, and translaters here... this.model.renderAll(); //Finally render the model GL11.glPopMatrix(); } Hope this helped! Also please note that your model HAS to be triangulated. If your model isn't triangulated, you will get a crash saying ModelFormatException.
  12. Okay, I figured it out. I simply did the following: public Minecraft mc = Minecraft.getMinecraft(); //Get an instance of minecraft //Then in renderItem method //...Irrelevant code here... float pitch = this.mc.thePlayer.rotationPitch; GL11.glRotatef(rotationPitch, 1, 0, 0); //...Then just the rest of the rendering code here Now obviously there is more to this, like GL11.glPush/PopMatrix(); and model.renderAll() (if using obj) and whatever other rotation values there are, but this is the general idea that I had, get an instance of the player from Minecraft.getMinecraft().
  13. Hello everyone. I would like to know how I can change the rotation angle of my custom rendered item depending on the players rotationPitch (up / down angle) I would kind of like to do what the map does, but I can't find the code that allows the map to do this anywhere. So, my question really is; how do I get the players rotationPitch from the item renderer? there is no EntityPlayer parameter in any of the methods in IItemRenderer, and I can't find a way to get the player that is holding the current item from the ItemStack parameters. If I could do either of these two things, I would be fine from there to achieve the rest. Thanks.
  14. I think you need a break at the end of each switch statement. Also try putting a default statement in too (with a break at the end) and make it do something there. If it is doing whatever you made it do in the default statement (I'd just make it print something like "Can't find model, report as a bug!" and leave it in), then it isn't getting the metadata, or it can't find it, and in that case, it would be -1. If not, put a println at the top of the renderItem method to see if it is actually getting called. Edit: I have just noticed that you have two renderItem methods. Why? I think that in this case, your problem is the renderItem method with the @Override annotation and the "//TODO Auto-generated method stub" is the one that is getting called, and it has nothing in it at all. The one that has your render code in it has two ItemStack parameters, it shouldn't. @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { // TODO Auto-generated method stub //This method shouldn't be empty. This is why you can't see the model now, it isn't getting rendered at all. } Hope this helped.
  15. Okay, I'm really confused why this isn't working. If you cant even get it working in a new simple test mod, I'd reinstall mcp and forge and see if that fixes it. (Again, it is very unlikely that there is a bug in your installation of mcp and forge, but not impossible)
  16. Solved it. TGG, you mentioned the console, so I loaded up the game and watched the console, and it did say missing texture. Now, my textures were in modid:textures\models\cables\texture.png and I imediatly knew the problem when I saw the console saying "Unable to load texture: modid:textures\blocks\textures\models\cables\texture.png" It was thinking the resource was in the blocks textures. So I have moved my textures and changed the resource location slightly, and it is fixed. Thanks for the help guys.
  17. Okay, so that "System.out.println(icon[meta]);" is printing out the resource location for the icons. Strangely, it only does this when I hit the block (probably because that is when it is getting called) and it is only printing out the resource for meta[0], but nevertheless, it is still a resourcelocation, and so should be working.
  18. Okay, this is weird. I see no reason why the block bounds aren't working. As TGG said, maybe try drawing your own bounding boxes. If that doesn't work, I'd reinstall mcp, very unlikely, but maybe you have a glitch with mcp / forge. One question though; did getCollisionBoundingBoxFromPool work for the collision box, so were you able to walk simi-inside the blockspace? (unfortunately, the full one block bounds may be overriding this as they aren't working properly) because that is what that should have done, again, I am not sure if it should actually render the bounds, but I know it sets the collision bounds. If so, then drawing your own bounding box would be the best option, if not, then you may have smaller bounds, but the collision box is still one full block. Also, I have a question of my own (not hijacking this post, just a quick question) based from what TGG said; I didn't know about the drawSelectionBox() method, but would this allow me to draw multiple bounds in one block? like what buildcraft pipes do, they have a bounding box cube in the centre, and have a separate bounding box rendered for each connection. If so, then would this further allow me to make the block do something when a certain bounding box is activated?
  19. The render type is -1. I'm not sure, but maybe having renderAsNormalBlock and isOpaqueCube as false might be causing problems? My textures are 16x16 well, four of them are, and even they still don't work, they have that aspect ratio and the size is always a power of 2, so the same as vanilla texture rules, e.g some are 128x128 but I don't see that being a problem, it still isn't working though. Do I need to create a new texture sheet specifically for the particles then?
  20. Not Forge 1.8, MC 1.8 (I don't know what version of Forge is the earliest for 1.
  21. Post the rest of your blocks code, we might be able to identify the problem from there.
  22. You can only have one renderer per item/block. In the ClientProxy, only register one renderer for this item, giving one item more than one renderer will cause problems. Now, in the renderer, for each model, have a different ResourceLocation, and the same for each texture, now, you would make it select the appropriate resource location depending on the metadata. This could be done in many ways. I personally prefer to use a switch statement. I have not done this for an item before, but recently I did something very similar to this for a block. It can't be much different, in the block, I used the tileEntity parameter in renderTileEntityAt to get the metadata "int meta = tileEntity.getBlockMetadata()", but in the item renderer, you can use the itemStack parameter in the renderItem method (I might have got that methods name wrong) to get the metadata with "int meta = itemStack.getItemDamage()" Now with this, you can do something like: int meta = itemStack.getItemDamage(); switch (meta) { case 0: { //Get the correct model //Bind the texture from the appropriate resource //Do the rest of the rendering stuff here } case 1: { //Get the correct model //Bind the texture from the appropriate resource } }
  23. I don't know if you already have this, and I'm not sure if it is the same in 1.8, but it works for me in 1.7, try: public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } Ignore this if you already have this. I am just trying to help .
  24. So, how would I fix this then? I know that it isn't impossible, I have seen it done before. I am assuming that these are the two methods required, am I wright?
  25. Hello everyone. I have several models in my mod, and I have been ignoring this for a while now, but I would like to know how I can fix the hit effects and destroy effects for my models. Currently, they are just the purple and black broken textures. I do know about the addDestroyEffects and addHitEffects methods, but don't know how to use them properly. I couldn't find any tutorials, so I have looked at the source code for Buildcraft on github, and figured it out to an extent, but it still isn't working. This is my texture and hit/break effects code so far: public IIcon[] icon = new IIcon[8]; //I have 8 metadata subtypes for my block, so 8 icons, and this was the neatest way to save them. //...Irrelevant code here... //Only registering icons for the particle effect when hit or broken, the actual block texture is in the renderer class. public IIcon getIcon(int side, int meta) { System.out.println(icon[meta]); if (icon[meta] != null) return icon[meta]; else return blockIcon; } @Override @SideOnly(Side.CLIENT) public void registerBlockIcons(IIconRegister icon) { //These resource locations are the exact same textures that the renderer uses this.blockIcon = icon.registerIcon(modid + ":" + ""); this.icon[0] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_LV"); this.icon[1] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_LV_Uninsulated"); this.icon[2] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_MV"); this.icon[3] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_MV_Uninsulated"); this.icon[4] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_HV"); this.icon[5] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_HV_Uninsulated"); this.icon[6] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_UV"); this.icon[7] = icon.registerIcon(modid + ":" + "textures/models/cables/Cable_UV_Uninsulated"); } //... More irrelevant code here... @Override @SideOnly(Side.CLIENT) public boolean addHitEffects(World world, MovingObjectPosition pos, EffectRenderer renderer) { int x = pos.blockX, y = pos.blockY, z = pos.blockZ; int meta = world.getBlockMetadata(x, y, z); Block block = world.getBlock(x, y, z); if (block == null) { return false; } int side = pos.sideHit; float i = 0.1F; double posX = x + rand.nextDouble() * (block.getBlockBoundsMaxX() - block.getBlockBoundsMinX() - (i * 2.0F)) + i + block.getBlockBoundsMinX(); double posY = y + rand.nextDouble() * (block.getBlockBoundsMaxY() - block.getBlockBoundsMinY() - (i * 2.0F)) + i + block.getBlockBoundsMinY(); double posZ = z + rand.nextDouble() * (block.getBlockBoundsMaxZ() - block.getBlockBoundsMinZ() - (i * 2.0F)) + i + block.getBlockBoundsMinZ(); if (side == 4) posX = x + block.getBlockBoundsMinX() - i; if (side == 5) posX = x + block.getBlockBoundsMaxX() + i; if (side == 0) posY = y + block.getBlockBoundsMinY() - i; if (side == 1) posY = y + block.getBlockBoundsMaxY() + i; if (side == 2) posZ = z + block.getBlockBoundsMinZ() - i; if (side == 3) posZ = z + block.getBlockBoundsMaxZ() + i; EntityDiggingFX digFX = new EntityDiggingFX(world, posX, posY, posZ, 0.0D, 0.0D, 0.0D, block, side, world.getBlockMetadata(x, y, z)); digFX.setParticleIcon(icon[meta]); renderer.addEffect(digFX.applyColourMultiplier(x, y, z).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); return true; } @Override @SideOnly(Side.CLIENT) public boolean addDestroyEffects(World world, int x, int y, int z, int meta, EffectRenderer renderer) { Block block = world.getBlock(x, y, z); if (block == null) { return false; } byte b0 = 4; for (int i = 0; i < b0; ++i) { for (int j = 0; j < b0; ++j) { for (int k = 0; k < b0; ++k) { double px = x + (i + 0.5D) / b0; double py = y + (j + 0.5D) / b0; double pz = z + (k + 0.5D) / b0; int random = rand.nextInt(6); EntityDiggingFX fx = new EntityDiggingFX(world, px, py, pz, px - x - 0.5D, py - y - 0.5D, pz - z - 0.5D, this, random, meta); fx.setParticleIcon(icon[meta]); renderer.addEffect(fx.applyColourMultiplier(x, y, z)); } } } return true; } Thanks.
×
×
  • Create New...

Important Information

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