Jump to content

weckar

Forge Modder
  • Posts

    62
  • Joined

  • Last visited

Everything posted by weckar

  1. Thanks guys, really helpful. I'm sure I am not the only one who actually does still look at this code, so can we please make room for one of those rare few? It was in the title, so I really get the feeling you only clicked this thread to... say nothing of use.
  2. I'm aware 1.7.10 is well out of date from being supported, but here goes. I am implementing a custom NEI TemplateRecipeHandler. Literally everything works (NEI picks it up just fine, recipes are loaded and render, etc.), except that the transferRects are either not picking up my clicks or not handling them properly, and I cannot figure out why. I've looked at several implementations and do not see what I am doing differently. The tooltip for the TransferRects IS being displayed properly, however. @Override public void loadTransferRects() { transferRects.add(new RecipeTransferRect( new Rectangle(xOff + 75, yOff + 29, 25, 18), this.getOverlayIdentifier())); } Any tips would be greatly appreciated, because it is severely bugging me.
  3. Yeah, you're right. Turns out I was fighting the fog color the whole time with odd sky color values. Setting them to the same color vector circumvents the whole issue. Thanks!
  4. I've been working on my own dimension with custom sky rendering, and I have come across an odd bug where increasing the render distance will make the sky (much) brighter, while lowering it makes it much darker. I would not even know what to look for causing this, but I am happy to take any pointers...
  5. After a lot more testing and trying, I've come up with a few more facts of the case: My assessment that it had to do with looking at the 0,0,0 point has been proved false. It depends on the world, it seems. The problem is limited to this method, and even then only when it is called in render pass 0. However, rendering in pass 1 instead seems to invert both the internal and external drawing order among the Tile Entities. The inside is drawn outside causing weird overlaps and a very Escherian feeling... I feel like I'm getting closer, but there is still a few things that elude me here... [EDIT] Felt it was time for another screenshot of the current situation. This shape is made up of 5 cuboids, just for testing purposes. It is currently being drawn in render pass 1.
  6. Yeah, got that bit covered. See the [EDIT]. Thanks anyway though, now I know a technical term for it! [EDIT] So now I am getting the blocks to render properly (the order of some of the vertices was wrong before), but now the oddest thing happens: If I am not looking in a limited cone of directions (on all axis), none of the blocks render at all. They all disappear at once, not one at a time. It is therefore not to do with the Render Bounding Box.. [EDIT2] After a little more experimenting, it seems to only draw if I WOULD be able to see coordinates 0,0,0 in my crosshairs. Am I messing up translation or something? None of my other drawing commands are showing this behaviour so I think I may be using the Tesselator wrong...
  7. [Please see latest post for a new screenshot of the current condition.] Sooo I've been working on my TESR, and am trying to just draw a dang block Apparently, harder than expected. So I made a method to do it for me. And it DOES draw the block with the proper texturing! Unfortunately, it also makes the block flicker black randomly across the surface as I move around it. I THINK I may have messed up the UV mapping, but I'm not sure... protected void drawBlock(float x, float y, float z, float w, float h, float l, Block block, int meta){ IIcon[] icons = new IIcon[6]; for(int i = 0; i<6; i++){ icons[i] = block.getIcon(i,meta); } GL11.glPushMatrix(); GL11.glTranslatef(x, y, z); tess.startDrawingQuads(); //top tess.setNormal(0.0F, 0.0F, 1.0F); tess.addVertexWithUV(w,h,l,icons[1].getMaxU(),icons[1].getMaxV()); tess.addVertexWithUV(w,0,l,icons[1].getMaxU(),icons[1].getMinV()); tess.addVertexWithUV(0,0,l,icons[1].getMinU(),icons[1].getMinV()); tess.addVertexWithUV(0,h,l,icons[1].getMinU(),icons[1].getMaxV()); //bottom tess.setNormal(0.0F, 0.0F,-1.0F); tess.addVertexWithUV(w,h,0,icons[0].getMaxU(),icons[0].getMaxV()); tess.addVertexWithUV(w,0,0,icons[0].getMaxU(),icons[0].getMinV()); tess.addVertexWithUV(0,0,0,icons[0].getMinU(),icons[0].getMinV()); tess.addVertexWithUV(0,h,0,icons[0].getMinU(),icons[0].getMaxV()); //south tess.setNormal(0.0F, 1.0F, 0.0F); tess.addVertexWithUV(w,h,l,icons[2].getMaxU(),icons[2].getMaxV()); tess.addVertexWithUV(w,h,0,icons[2].getMaxU(),icons[2].getMinV()); tess.addVertexWithUV(0,h,0,icons[2].getMinU(),icons[2].getMinV()); tess.addVertexWithUV(0,h,l,icons[2].getMinU(),icons[2].getMaxV()); //north tess.setNormal(0.0F, -1.0F, 0.0F); tess.addVertexWithUV(w,0,l,icons[3].getMaxU(),icons[3].getMaxV()); tess.addVertexWithUV(w,0,0,icons[3].getMaxU(),icons[3].getMinV()); tess.addVertexWithUV(0,0,0,icons[3].getMinU(),icons[3].getMinV()); tess.addVertexWithUV(0,0,l,icons[3].getMinU(),icons[3].getMaxV()); //east tess.setNormal(1.0F, 0.0F, 0.0F); tess.addVertexWithUV(w,h,l,icons[5].getMaxU(),icons[5].getMaxV()); tess.addVertexWithUV(w,h,0,icons[5].getMaxU(),icons[5].getMinV()); tess.addVertexWithUV(w,0,0,icons[5].getMinU(),icons[5].getMinV()); tess.addVertexWithUV(w,0,l,icons[5].getMinU(),icons[5].getMaxV()); //west tess.setNormal(-1.0F, 0.0F, 0.0F); tess.addVertexWithUV(0,h,l,icons[4].getMaxU(),icons[4].getMaxV()); tess.addVertexWithUV(0,h,0,icons[4].getMaxU(),icons[4].getMinV()); tess.addVertexWithUV(0,0,0,icons[4].getMinU(),icons[4].getMinV()); tess.addVertexWithUV(0,0,l,icons[4].getMinU(),icons[4].getMaxV()); tess.draw(); GL11.glPopMatrix(); } Maybe some pointers would be nice, as none of the TESR tutorials I found specifically deal with drawing cuboids... [EDIT] So, apparently I forgot the turn off the actual block's rendering, but in the process I learned this method is messed up in many ways regardless. Maybe I should restart it from scratch? I'd still appreciate any and all advice.
  8. Interesting topic indeed. Mind if I borrow some code on the water removal?
  9. Thanks much. Seems I'll need to interrupt the chunk provider when it is building my custom biome so that small lakes, lava lakes, ravines and such do not appear. Or can I use a custom chunk provider just for one biome...?
  10. So, after my disastrous last idea (which was still very educational, thank you all for that!) I've decided to turn my attention to biomes and world generation. Adding worldgen is easy enough, it seems, but I have yet to find a way to disable default world generation for custom biomes: Ores, ravines... that sort of thing. Ideally I'd do it selectively, but... I also cannot find the place in vanilla code where these things are called as I am using cpw's interface. A few pointers (or a big shove in the right direction) are as always appreciated.
  11. I see what you're saying, but I am already capable of removing duplicate items from the world, and am also canceling the crafting of any possible duplicates. The real problem comes in, as mentioned, when they get somehow destroyed anyway - at which point I want to make it possible to obtain a new one. But the point has been made abundantly clear that such cannot be done. It's a pity. Thank you all anyway.
  12. Hitting the nail on the head there, Ernio. In the end, I am accepting of the fact that I can't catch ALL cases of destruction and prevent them, but I would like to achieve a way in which even if they are destroyed somehow I can free up their 'slot' in the world again. For the record, though: an Item's onUpdate will only happen if it is in the inventory of a living Entity, yes? No way to get a similar thing to happen if it is in a chest or the like? Because if I could I could have it send regular information pulses to a central controller who would assume a cease of existance if it has missed 3 pulses in a row or something... Although that does carry the problem with it of chunks unloading...
  13. So, here's the thing. I have a list of ItemStacks. I need to somehow figure out for every one of these whether it is a) Currently stored in an EntityItem b) In the inventory of an Entity c) In the inventory of a TileEntity I don't need to know which, I just need to basically know whether the ItemStack still has a physical representation SOMEWHERE in the world. Luckily, I have already managed to limit the ways this representation could be removed from the world, as it is immune to fire, despawning, damage, the void and explosions. The only things that could still destroy it that I am aware of are Creative Mode stuff, crafting, and certain mods that hard-remove items from inventories. So having an event trigger for any of these would work for me as well.... Thus far, I've had little luck finding any existing mechanics that track ItemStacks or that hard-delete them, because it seems minecraft is happy to just let them sit there unmanaged and unedited until the garbage collector gets to them. Unfortunately, because I do have them listed that will never happen. So, I need to know when it is safe to de-list them - hence the above question.
  14. Soooo a block that has growth metadata that drops fruit when right-clicked at max metadata and at that point also resets itself to 0? Only at all tricky part would be incrementing said data, I'd think.
  15. hate to say I can't really help you, as I've only worked on deconstructing trees before - but I felt the need to drop in and say how much I love this mod idea. We could all use a spicier life.
  16. You have to consider the fact that some of the mods you mention include worldgen aspects that won't work if you turn off the mod entirely, and won't just retroactively kick in. You may be better off looking into disabling and enabling recipes instead, which several mods have done before.
  17. OKay, so I am getting closer. It's reading and writing the NBT when appropriate. Unfortunately, my logging tells me that the NBT data isn't actually being STORED when it is written... @Override public void readFromNBT(NBTTagCompound nbt) { itemUnique = new ArrayList<Item>(); NBTTagList list = nbt.getTagList("Items", 10); for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound stackTag = list.getCompoundTagAt(i); itemUnique.add(ItemStack.loadItemStackFromNBT(stackTag).getItem()); } } @Override public void writeToNBT(NBTTagCompound nbt) { NBTTagList list = new NBTTagList(); for (int i = 0; i < itemUnique.size(); ++i) { NBTTagCompound stackTag = new NBTTagCompound(); new ItemStack(itemUnique.get(i),1).writeToNBT(stackTag); list.appendTag(stackTag); } nbt.setTag("UniqueItems", list); } I've been trying to simplify my code as I go. EDIT: I DID IT!!! Re-reading your code as you post really seems to help in a weird way. Let's just say UniqueItems and Items.... aren't the same tag...
  18. For reference, are you talking about something similar to the Twilight Forest Naga?
  19. I see how that would retrieve the data, but how exactly does that force the storage again? Or is the Dirty declaration enough for that? getPerWorldStorage() also doesn't seem to exist for World... EDIT: So, I got the code working a little better, to the point where loading a new world will clear the data from the old world. It still tries to create a new perWorldStorage data tag every time, though. ...I'm also noticing that the data it is TRYING to save is being saved per dimension.... ugh... But I guess there's no harm in just loading the data at world load, therefore always getting all the data from the first world loaded (presumably the overworld)... public class WorldDataHandler extends WorldSavedData { public List<Item> itemUnique = new ArrayList<Item>(); private static WorldDataHandler INSTANCE; public WorldDataHandler(String string) { super(string); } @Override public void readFromNBT(NBTTagCompound nbt) { itemUnique = new ArrayList<Item>(); NBTTagList list = nbt.getTagList("Items", 10); for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound stackTag = list.getCompoundTagAt(i); int slot = stackTag.getByte("Slot") & 255; itemUnique.add(ItemStack.loadItemStackFromNBT(stackTag).getItem()); } } @Override public void writeToNBT(NBTTagCompound nbt) { NBTTagList list = new NBTTagList(); for (int i = 0; i < itemUnique.size(); ++i) { NBTTagCompound stackTag = new NBTTagCompound(); stackTag.setByte("Slot", (byte) i); new ItemStack(itemUnique.get(i),1).writeToNBT(stackTag); list.appendTag(stackTag); } nbt.setTag("UniqueItems", list); } public boolean checkUnique(Item item, boolean doAdd){ if (itemUnique.contains(item)) return false; if (doAdd) itemUnique.add(item); markDirty(); return true; } public static WorldDataHandler getInstance() { return INSTANCE; } public static void setInstance(World world) { String tagname = "MEUNIQUE"; MapStorage storage = world.perWorldStorage; LogHelper.info(world.perWorldStorage.toString()); WorldDataHandler result = (WorldDataHandler)storage.loadData(WorldDataHandler.class, tagname); if (result == null) { result = new WorldDataHandler(tagname); storage.setData(tagname, result); } INSTANCE = result; } public static void resetInstance() { INSTANCE = null; } } setInstance() and resetInstance() are called by the first triggered world load and unload events respectively.
  20. After ALOT of trying to find implementations of WorldSavedData extensions and coming up empty, I turn back to this topic. Mostly because I'm very sure I'm using it very wrongly. import java.util.ArrayList; import java.util.List; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagList; import net.minecraft.world.WorldSavedData; public class WorldDataHandler extends WorldSavedData { public List<Item> itemUnique = new ArrayList<Item>(); private static final WorldDataHandler INSTANCE = new WorldDataHandler(""); private WorldDataHandler(String string) { super(string); } @Override public void readFromNBT(NBTTagCompound nbt) { itemUnique = new ArrayList<Item>(); NBTTagList list = nbt.getTagList("Items", 10); for (int i = 0; i < list.tagCount(); ++i) { NBTTagCompound stackTag = list.getCompoundTagAt(i); int slot = stackTag.getByte("Slot") & 255; itemUnique.add(ItemStack.loadItemStackFromNBT(stackTag).getItem()); } } @Override public void writeToNBT(NBTTagCompound nbt) { NBTTagList list = new NBTTagList(); for (int i = 0; i < itemUnique.size(); ++i) { NBTTagCompound stackTag = new NBTTagCompound(); stackTag.setByte("Slot", (byte) i); new ItemStack(itemUnique.get(i),1).writeToNBT(stackTag); list.appendTag(stackTag); } nbt.setTag("UniqueItems", list); } public boolean checkUnique(Item item, boolean doAdd){ if (itemUnique.contains(item)) return false; if (doAdd) itemUnique.add(item); markDirty(); return true; } public static WorldDataHandler getInstance(){ return INSTANCE; } } It works - within a session. That is, the data is stored and retrieved properly, but the NBT data is never accessed. Don't quite know how to trigger that. Also, switching between saves of course doesn't clear that list. In other words: I'm doing something majorly wrong and probably shouldn't even be attempting this. But I am anyway.
  21. Really? I strongly recall trying that before... Let me try it again? EDIT: Of course, things just magically start working once you start asking. Obvious answers are indeed obvious.
  22. I see no reason why it wouldn't work if you set up your conditionals right?
  23. So, I come to you with a question from an organisational perspective. By default, the only place minecraft will look for block and item textures are those respective resource folders. I'm wanting to organise these a bit, because they are getting... bloated. I've heard of people using subfolders to these main folders, but thus far I've had no luck in finding a way to make that work short of throwing the existing resource handling mechanisms out together, or de-foldering it all at compile time anyway. So the question is: How WOULD I do this?
  24. I'm not creating Item instances on the fly. Just making sure only one ItemStack can exist of each at any time. I want these items to be craftable, and the way I do it right now simply makes the recipe fail if an ItemStack (or EntityItem) of such already exists. Because they are (virtually) indestructible, I figured this was a very easy way to do it.
  25. Hi there! In the mod I am working on there is a class (lowercase c) of items deemed 'legendary'. In practice, this means they are utterly indestructible once created, and only one of them can ever exist in the game. I've got this working to a degree - whenever an itemstack is created it checks whether it already exists by referring to a hashset in a serverside singleton. If not, it is created and puts itself in. If it is, it cancels its own creation. Problem comes in when restarting the game: All data is gone (of course) because the singleton got recreated. That leads me to my question: How can I write the hashset to permanent world data, and load it as well? Or is there a better way entirely to do what I am trying?
×
×
  • Create New...

Important Information

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