Jump to content

KGS

Members
  • Posts

    33
  • Joined

  • Last visited

Everything posted by KGS

  1. I extend vanilla stairs with my own class. I create a few instances of it. The problem is that the lighting is wrong on nearby blocks. Vanilla stairs: My stairs: As you can see, the light level is completely wrong. public class BaseStairs extends BlockStairs { public BaseStairs(Block block, int someInt) { super(block, someInt); } @Override public boolean isOpaqueCube() { return false; } @Override public boolean renderAsNormalBlock() { return false; } } Someone on the #minecraftforge channel suggested I override getAmbientOcclusionLightLevel and return 0.0f, but that made no difference.
  2. Are you trying to be deliberately unhelpful?
  3. The versions of forge which use gradle include minecraft source as a library rather than as sourcecode. This means it cannot be changed.
  4. Are there tutorials or documentation for IRecipe? I wouldn't really use something as undocumented as the IRecipe unless I really had to, and now I do. I want a recipe that accepts any of my custom types of wood, but the output of the recipe depends on the type of wood put into it (i have several variants). Normally I could make a recipe for each type of wood, but that would not be feasible in the long run for practical reason. I have subtypes of wood, and these must be preserved.
  5. I don't understand what you mean. You can store anything you like in a TileEntity. You write the NBT serialisation code yourself and can put whatever you need into it. TileEntities are specifically designed for exactly what it sounds like you're trying to do. Oh that's interesting. I haven't actually dealt with tile entities yet but now that I think about it's obvious they can store anything, seeing that they store inventory data for containers and such. I will look into using tile entities. Fair enough :-) Actually this is probably pretty easy since you only need to prevent spawning on the server, which is also the place you record your block placements. So the client doesn't need to know about your hash table at all. Yes that's what I was thinking too. My worry was that I would have to do some kind of syncing manually between clients, but I guess minecraft automatically synchs clients with whatever is on the server. The reverse, though, to make sure the server is updated when some local changes are made on clients is when you need to be careful... (?) Yeah. I'm not going to write my own hash tables. THAT would be reinventing the wheel Why haven't you been able to test it? (i.e. what's stopping you?) Well I guess I could run a server locally and test with myself only...
  6. Thanks for the replies people. I think you'll find the real issues are memory and speed. How long does it take to generate a hash ? How long does it take to retrieve a set of values (from the hash table) for a single block ? How many blocks in world ? How much memory total for the number of blocks ? Even if you have a single one of your blocks visible, you need to have the data for all of them in memory. Also where do you plan to store the data itself ? Using a TileEntity is a much simpler method, especially if you need to add extra values for each block. Afaik hashing 4 ints should be trivial. I expect at most 30-40 blocks of special metadata. Maybe 100 in extreme situations. I do not want to use a TileEntity because I might want to store more than just bits. Also the problem in general is interesting. I am aware of using multiple blocks to store metadata. It, however, is not as interesting as what I'm trying to get at here. This also relates to another problem I'm working on for my mod. I have a block that when it is placed in a chunk makes sure that no mobs can spawn in that chunk. It does so by adding a listener to events which checks if a spawned living event is triggered from inside a chunk with this particular block. Blocks are stored in a hash table which is a WorldSavedData using x, y, z, w tuples as keys and integers as values (the integer representing the number of these blocks in a particular chunk). What i want to know is how the server/client aspect might interfere with this. This works fine in single player, but I don't actually know if it works in multiplayer as I have been unable to test it.
  7. I'm planning on implementing some new features into my mod and for that I need more metadata per block. Only about a byte per block but I might end up using more than that for other things later. I figured out a way to do it which some people would probably consider extremely hacky. I'm pretty certain it will work in singleplayer, but I don't know much about the multiplayer aspects of MC modding so I come here to ask the question... Would this work? I have a hash table where the value is an int or byte, and the key is a tuple of 4 elements. Block coordinates x, y, z and dimension id. When I want to insert metadata at some location I create a tuple and put the relevant value at that location in the hash table. When I want to read it I can do the same. I save this hash table using the NBT. Known issues: *If a block using this metadata scheme is destroyed I must remember to erase the metadata (though this is not an important issue as only my own blocks will read from here) *If a block is placed in some other dimension such as one created by another mod like Dimensional Doors, then when that dimension is "destroyed" I need to have the hash table erase all entries with data that is keyed to that world. Is there some way to detect when that happens and deal with it easily? *How would this behave in practice in multiplayer? If there are any problems, how would I remedy them?
  8. My custom doors will need to drop items given certain metadata conditions, meaning that I need to implement the getItemDropped method. The problem with that method is that it needs to return an item, and when you create ItemBlocks they have no accesible instance. (you pass the class name to the register method which invokes the constructor internally). Edit: Solved. I found this: Item.getItemFromBlock(KGBlocks.blockArtDecoDoor1)
  9. http://i6.photobucket.com/albums/y207/KGanryuS/2013-12-31_023648_zps0a0d02f3.png~original[/img] This is an aesthetics mod. It features new doors, a particular utility block to be explained further down, and stuff that will be implemented later in development. Fear the darkness no more! With the mobstopper, your darkest and most foreboding castles (or any other constructions, really) will be safe from mobs. What you see is a few of the doors currently implemented in this mod. 4 doors from the Art Deco set, and 2 doors from the Fancy Door set. Note that the door in the middle of the bottom row is not in the mod any longer. It will be reworked. More doors will be added as development proceeds. The block in the foreground is the Mobstopper. Place a mobstopper in a chunk, and mobs will no longer spawn in that chunk. This is useful because of torches. Torches are ugly. Darkness is beautiful. Don't fear the darkness. Embrace it! With the mobstopper! (mobs can still enter chunks with mobstoppers inside them, but they cannot spawn directly within them) Miscellaneous Recipes: Art Deco Door Recipes: Fancy Door Recipes: The mod has been tested but only on my machine and bug reports are welcome (if you find any that is). There is a known rendering issue with the doors facing two particular angles which will be fixed next update (in a week). DOWNLOAD!
  10. Check if the library is still there. Do this by opening the "referenced libraries" folder in eclipse and check if you see a file named something like forgesrc at the top. Another thing you should make sure is that you ran the setupDecompWorkspace command with gradle. This command give you the source included. There's another command that does not give you the source files.
  11. I removed all the set texture code and I made sure only the Block was registered with a creative tab. Still does not show up... I can get normal blocks to show up, and items to show up, but not itemblocks...
  12. I have this block that does not appear in the game (in creative tabs). I will not post all code here, but only that which is relevant... I know some code (texture, most likely) will not work because I'm in the process of porting this from 1.6.4 to 1.7.2 (and these classes are still in development, hence some weird constructor stuff). Any idea what might be wrong? Edit: The block did show up in 1.6.4 before I made some change to support 1.7.2. This is the Item which extends a base item. public class ItemDoorArtDeco1 extends ItemBaseDoor { public ItemDoorArtDeco1(Block block) { super("kgblocks:itemartdecodoor1", block); } } This is the parent item. I will only paste constructor. public class ItemBaseDoor extends ItemBlock { public ItemBaseDoor(String textureName, Block blk) { super(blk); this.maxStackSize = 1; setTextureName(textureName); setCreativeTab(CreativeTabs.tabMisc); this.block = blk; } This is the relevant block. public class BlockArtDecoDoor1 extends BaseDoor { public BlockArtDecoDoor1() { super("kgblocks:blockartdecodoor1"); } } This is the parent block. Again I will ommit all non-constructor code. public abstract class BaseDoor extends Block { public BaseDoor(String textureName) { super(Material.wood); setBlockTextureName(textureName); setHardness(0.5F); float f = 0.5F; float f1 = 1.0F; setBlockBounds(0.5F - f, 0.0F, 0.5F - f, 0.5F + f, f1, 0.5F + f); } Now this code below is from the main mod class. I create the block and pass it to a method called registerBlockWithItemBlock. blockArtDecoDoor1 = new BlockArtDecoDoor1(); registerBlockWithItemBlock(blockArtDecoDoor1, ItemDoorArtDeco1.class, "blockArtDecoDoor"); And here's the method in question: public void registerBlockWithItemBlock(Block block, Class<? extends ItemBlock> itemclass, String name){ block.setBlockName(name); GameRegistry.registerBlock(block, itemclass, name); }
  13. I'm porting a mod to 1.7.2 from 1.6.4. There's some odd problems with the NBT, though. For some reason it seems to fail to read from it properly. I have a class called a Tracker which extends WorldSavedEvent. It contains a hash table that is read and saved to the NBT. Certain things in the game modify the hash table and it is supposed to be persistent between game sessions, but it isn't. The readFromNBT is executed, but does not actually reach the for loop. @Override public void readFromNBT(NBTTagCompound nbt) { NBTTagList tagList = nbt.getTagList("tracker", Constants.NBT.TAG_INT_ARRAY); // Read arrays from tag list and use the arrays as positions to insert blocks into table for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound)tagList.getCompoundTagAt(i); int[] arr = tag.getIntArray("position"); addBlock(arr[0], arr[1], arr[2], arr[3]); System.out.println("Reading Block at index: " + i + " - " + arr[0] + " " + arr[1] + " " + arr[2] + " " + arr[3]); } } @Override public void writeToNBT(NBTTagCompound nbt) { NBTTagList itemList = new NBTTagList(); int counter = 0; Set cl = chunk.keySet(); Iterator<ChunkLocation> it = cl.iterator(); while (it.hasNext()){ ChunkLocation temp = it.next(); for (Position p : chunk.get(temp)){ counter ++; NBTTagCompound tag = new NBTTagCompound(); int[] arr = {p.getX(), p.getY(), p.getZ(), p.getW()}; tag.setIntArray("position", arr); itemList.appendTag(tag); } } nbt.setTag("tracker", itemList); KGBlocks.textOut("Blocks saved to NBT: " + counter); } I added Constants.NBT.TAG_INT_ARRAY to the following line. Not sure if this was correct: NBTTagList tagList = nbt.getTagList("tracker", Constants.NBT.TAG_INT_ARRAY); I also replaced tagAt with getCompoundTagAt. Not sure about that either, but tagAt was not available.
  14. So I've attempted to follow at least three different tutorials. I follow them to the letter and I get the same errors every time. Edit: NEVERMIND WHAT WAS HERE BEFORE. I have now solved that previous issue... It was quite stupid :I However, i still get this error message "Project 'Minecraft' is missing required library: 'C:\MinecraftModding\ForgeN\unresolved dependency - forgeSrc 1.7.2-10.12.0.1024'"
  15. Edit: The bug is fixed. Now I have another problem. Previously my doors had an Item an a Block. The Block had a texture consisting of two pieces and the item had another texture that was flat projected like vanilla doors. However, now that I changed the Item to an ItemBlock, it now uses the lower Block texture. This is not right at all! I even pass the ItemBlock the texture it SHOULD use, but it seems to override it.
  16. What do you mean? Each door has an Item and an associated Block. This is how vanilla does doors. When you use the item, the associated block is placed.
  17. Is there any way to fix this without using the NEI API? I have a set of custom door blocks and items for placing them, and NEI wants to list both blocks AND their items (which it interestingly enough does not do with vanilla doors).
  18. I changed the forWorld method to the following and it worked
  19. Not entirely clear on what you mean. My guess is you mean that I should remove this: instance = result; (?)
  20. So I have a problem. Let me explain WHAT I want to do, what actually happens, and what I actually do (the code), in that order... What I want to do: I have a block called the Stopper. When a stopper block is placed, it sends its coordinates to a Tracker. The Tracker is a class extending WorldSavedData and it keeps track of the location of all placed stoppers and in which chunk they are stored. The Tracker saves its own data to the NBT. Note that the Tracker is "global" for all dimensions, so the "coordinates" fed to the Tracker is of the x, y, z, w format, where w is the dimension id. The Tracker exists so that I can quickly check whether or not there is a stopper within some particular chunk. What happens: It turns out the Tracker is too persistent. If I leave the game and go to the start menu and enter another save, the Tracker data from the last save remains when it should most definitely not do so. I tried to fix this using a method to clear the Tracker upon WorldEvent.Unload, but this only made it so that the Tracker doesn't even remember stuff at all. It seem to fail even writing and restoring data from the NBT so if I restart the game, it loses track of all stoppers. What I do: This static method in Tracker generates a new Tracker instance. This is called from a WorldEvent.Load. Note the null check, followed by a check to see if a tracker was already connected to the mapStorage. I suspect if there's anything wrong, that will be in this particular method. This is the event listener (registered from my main mod class). It calls the static method Tracker.forWorld(world) which generates a new Tracker instance if one does not exist, and links it to the world so that it will be saved correctly in nbt. The Tracker only needs to be available for some events, so I have made its creation server only. These are the save/load nbt methods in Tracker.
  21. Huh... For some reason it works as it should when I test it today... But... It seems that the Tracker stays in memory when you exit the world to the main menu. So when I start a new game in a new world, the old Tracker remains. I probably need to clear the Tracker somehow. This might actually explain why I didn't see the NBT read/write behavior yesterday. For some reason those methods were not called and it looked as if things were working correctly because the Tracker retains data between worlds... Edit: Will restart this topic in a new thread with better focus. Consider this current one solved.
  22. Figured code would make little sense in this scenario given that I know the code executes, it just does not show up in stdout. Here you go. This code is from the Tracker. The code correctly reads and writes to the NBT: @Override public void readFromNBT(NBTTagCompound nbt) { System.out.println("----------------------------------------------------------Reading Tracker from NBT"); // this does not show up NBTTagList tagList = nbt.getTagList("tracker"); for (int i = 0; i < tagList.tagCount(); i++) { NBTTagCompound tag = (NBTTagCompound)tagList.tagAt(i); int[] arr = tag.getIntArray("position"); addMobstopper(arr[0], arr[1], arr[2], arr[3]); } } @Override public void writeToNBT(NBTTagCompound nbt) { System.out.println("----------------------------------------------------------Writing Tracker to NBT"); // this does not show up NBTTagList itemList = new NBTTagList(); int counter = 0; Set cl = chunk.keySet(); Iterator<ChunkLocation> it = cl.iterator(); while (it.hasNext()){ ChunkLocation temp = it.next(); for (Position p : chunk.get(temp)){ counter ++; NBTTagCompound tag = new NBTTagCompound(); int[] arr = {p.getX(), p.getY(), p.getZ(), p.getW()}; tag.setIntArray("position", arr); itemList.appendTag(tag); } } nbt.setTag("tracker", itemList); System.out.println("Blocks saved to NBT: " + counter); // this does not show up }
  23. I have a class, Tracker, which contains a hashtable and some other data. Tracker extends WorldSavedData and reads and writes correctly from and to the NBT. The tracker stores locations of some mod related blocks so that I can quickly find out if one of these blocks exist in some particular chunk. There's a mysteriou issue, however: The read and write NBT methods both output a message along the lines of "Tracker saved to NBT" and "Tracker loaded from NBT" (System.out.println())... But the weird thing is that this does not always happen. This indicates either that the code does not always run or that something is preventing it from writing to stdout. This is one such scenario: *I start a new world and place a block tracked by Tracker. My print functions indicate the block is registered correctly by the Tracker. There is no message from the NBT write that it is passively saving. *I exit to main menu. There is no message now either from the write method. *I return to the world. There is no message from the load method. *I use another print test feature to see that yes, the block positions are correctly stored in the Tracker. This behavior indicates to me that SOMEHOW the Tracker both loaded and saved data from the NBT, but my print calls from those two methods did not successfully print to stdout. What could cause this? All I can think of is that this might have something to do with the server/client side divide. It would be nice if someone could explain why this is happening and how I can fix it.
  24. I have a particular block whose locations are tracked by a separate class. Whenever my custom block is placed, the tracker is updated. The problem is handling the block being removed. Is there some Block function that runs whenever that block is removed? Something that is guaranteed? I only found one that triggesr when the player destroys a block, and one that triggers when the block explodes. For safety's sake I want something that covers absolutely EVERY scenario possible.
  25. I can imagine a hack for this. Seeing that you only occasionally will want to investigate whether a block is natural or placed, you can use an octree structure. The octree would represent the status of some particular block as a boolean where the tree would simply return "false" if a search finds no node at that point. The big problem is how to update the octree whenever a player places a block. There might be a block placement event or something like that you can use. Whenever that event is triggered, update the tree.
×
×
  • Create New...

Important Information

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