Everything posted by Tschallacka
-
[1.7.10] [SOLVED] Get all blocks in virtual pyramid.
Ah, okay. It would still be more efficient to pass an array of bounding boxes though. A bounding box has 6 ints to store, and you can use them as easy to loop through as you do with your blockpos set. And its more memory efficient. Looping through and storing block posses only makes sense if you test for specific blocks. And not all blocks like you are doing now. Setting to null actually does make sense. For all your vectors that you store in your array, and in the loop, set them to null when you are done. Those are the only existing references to that object. By setting it to null you are actively saying that they are ready to be cleaned up. That way the garbage collector has a few references less to check. You can also set them to final, then the gc also has an easier job to check stuff because it's not mutable. I prefer nulling stuff, then I know what state a thing is in what point in code. And nullpointer exceptions can help track variables through a maze of code if it does get passed by reference when it shouldn't. You are initialising the vectors, so you can clean them up because after the method they are not needed, they are not passed on to other objects, so you can safely discard them, telling the gc it can clean them up. Now back to your code. I would simply make an array of bounding boxes, because looking at your bounding box reference they are overlapping, so you would have a lot of overlapping spaces. Then you can use the bounding boxes to calculate trails that you can iterate over. I'm doing this from memory, so not all method names will be correct but you can get the gist. //bounding boxes being the array you iterate over from your first vector set // preinitialising ints so we only take up ten spots on the stack. int c,x,y,z,startx,starty,startz,endx,endy,endz; boolean escapeHatch = false;; for(c=0;c<boundingboxes.length;c++) { escapeHatch = false; AxisAlignedBB current = boundingboxes[c]; else { startx = current.minX < current.maxX ? current.minX : current.maxX; starty = current.minY < current.maxY ? current.minY : current.maxY; startz = current.minZ < current.maxZ ? current.minZ : current.maxZ; endx = current.minX > current.maxX ? current.minX : current.maxX; endy = current.minY > current.maxY ? current.minY : current.maxY; endz = current.minZ > current.maxZ ? current.minZ : current.maxZ; for(x=startx;x<endx;x++) { for(y=starty;y<endy;y++) { for(z=startz;z<endz;z++) { if(boundingboxes[c+1].intersectsWith(x,y,z)) { // See if you will make a new object if it needs it or you simply check manually(more memory efficient) //check if we intersect with the next one, which will always be larger, thus preferable I really think this one is messed up in my memory escapeHatch = true; // let us know we need to escape! break;// continue to the preferable set. } //do whatever you ultimately need to do with all the blocks. Setting a meteor on them seems fun? } if(escapeHatch) {break;} } if(escapeHatch) {break;} } if(escapeHatch) {break;} } }
-
[1.7.10] [SOLVED] Get all blocks in virtual pyramid.
Looking at your code... you are making the vector pyramid... okay.. You have a pyramid. Then you turn it in a bounding box. Your pyramid is a square now. Then you iterate through every block in that square and a new BlockPos to your map. how big is your bounding box? Its a simple matter of x * x to see how many blocks it is and how long it takes to iterate. Like a bounding box of 25x25x25 = 15625 new Objects to create in memory, assign to a map, update map. Doing that once per tick I can see how this could potentially getting laggy. Lets just say for arguments sake a blockpos takes up 100 bits of space. you are creating within a tick(50ms) 1562500 bytes of data which is 190kb. which is not too bad. Times 20 for a second its 3,72MB. which is also not too bad. But then remember all the vectors you are creating and not cleaning up yourself. Each vector wil aslo be about 100 bits of data each, so now we have 3 vectors * 100 * 15625 = 572kb of data per tick, which is 11mb of data you are creating and discarding. So our tally is already at 15mb per second roughly. Now you are also adding it all to the hashset individually. This means the hashset has to allocate, check, add, do stuff. Which also costs memory. Then you return the hashset. Overall, I count this as a very expensive operation, that gets exponentially more expensive with each block larger radius(26 large Boudning box takes up 16mb per second, 30 block bounding box 25mb) Now we have the garbage collector. It has to check and verify every object in the set if it's still bound, has a reference somewhere, if not, unset it. But until it does that your ram will fill up with your objects with a rate of 15-25mb the second. if not more. In other words, you are giving your pc a lot of work to do, and I assume you are discarding the hashset each tick too since you are calculating each tick. You are simply giving java and the garbage collector a lot of work to do in terms of memory management. Wouldn' t it be more dreadfully efficient to just save the bounding box since you are returning everything within that cube wether its air or not...
-
[1.8] writing json to create an structure what library is avaliable ???
You might be referring to my answer in another thread. You can use whatever libary you want to do json and you can use your own structure.. this is the format I use though. You might find it helpfull { "blocklist":{ "-1621009973":// Unique block id for THIS file. it could be anything, as long as its unique for this file { "blockid":"blockDarkstoneSlab", // The blockname you would use in GameRegistry.findBlock(modname,blockname); "modid":"MagicCookie",// The modname you would use in GameRegistry.findBlock(modname,blockname); "metadata":8//Metadata of the block } }, , "locations": [ { "endz":2, "startx":0, "isRange":true,// if its a range I know I have to use fillWithMetadataBlocks for a range "endy":6, "starty":6, "endx":1, "block":"-160139907",// the unique block id as defined in blocklist "startz":6 }, { "isRange":false,// no range, single block "block":"1676165786",// the block id as defined in blocklist "z":6, "y":5, "x":6 } ] } full example that I use in my magic cookies mod https://gist.github.com/anonymous/65ac13603d26c3f72a76 Please note, dont make the error I made and rely on the minecraft way to load resources, it will break in server enviroment. use Modmain.getClass().getResource("/assets/modid/structures/stufftoload.json"); The first / is important, that is the root folder of your jar folder. Other wise it will load relative to where your main mod class is. I am planning on writing a mod that will help modders save structures more easely. I already have the code, I just need to put it in a seperate mod heh. You can download my magic cookies mod for now if you want. In creative there is an item called worldgenstripper. Use the red one to save single blocks, the yellow one to save air, water and lave blocks(remember to also save flowblocks seperately). This is a ranged selector it needs two taps. one to set start and one to set finish. You can have start and finish on the same block. You can use the orange one to save singular blocks within the ranged cuboid. it will save them one by one. this is handy for speed trials of how a structure comes out during generation. Use the whiteish one to save full ranges of the same block. for big areas of the same stuff like walls, pillars and floors and such this is the one you want. the more is done this way the more you have a speed increase because theres no need for block look up whilst placing blocks(same goes for the yellow one). To save to json name the red one in an anvil and stab a pig with it. The pig wont get hurt but the stuff will get saved to a json file in a folder in your .minecraft directory. Please note, the code isnt perfect yet, its just something I hacked together for my use and not for distribution. Everything you saved in the worldgen stripper will get lost when server/singleplayer client restarts. It will get lost if you hit an entity with the red one because the saved memory space gets cleared. Everything will be saved relative to where you first struck ground with a stripper. Please note! its just something that works for me! and it works good for me, but it isnt optimised yet for use by others Take some time to get used to it if you use it. **Note, my mod is for 1.7.10 but as far as I can see not much has changed in structure gen between 1.7 and 1.8
-
How many blocks per tick max is recommended for custom structure generation?
Yes, having to recalculate light levels is fairly intensive because per block it polls the blocks around it to calculate. This is why I do my structure generation during world gen. There is no light updates to worry about sorta speak, at least not that I have noticed. And when I come to my structure in time I still have "black spots" where the server hasnt updated light levels yet. That might be why my structure is fast as opposed to yours. Could you try to put the generation in the worldgen, and see how fast it is during the world generation? Register it as a structure whilst you are at it with proper bounding boxes. then other mods can test for your structure at that location instead of barraging straight through your castle ;-)
-
How to let a mod make screenshots?
in eclipse on your left you have the file tree where you have your java classes. scroll down until you see forgeSrc. unfold it, then find the net.minecraft files, then look for net.minecraft.client and then start digging through the source, to see where the f2 is bound. Usually stuff has a logical name, so try to use a bit of logic
-
How to let a mod make screenshots?
Take a look in the minecraft source that's bound to F2
-
How many blocks per tick max is recommended for custom structure generation?
In my mod i'm generating a nether fortress sized structured with multiple hallways etc.. and quite some blocks and it's really fast, and I even load the structure components from json. What I found how crazy as it sounds is that loading everything from a json file and then rendering it would go really fast. Also what helps is that I split up my structure in components like the nether fortress does. Stuff only gets rendered if the chunk is generated. Also it has the added benefit of having specific bounding boxes for mob spawns. Are you generating the entire structure in one pass or have you split it up in multiple pieces? If your structure crosses chunk boundaries and it gets generated when one chunk is loaded and the other is not yet populated by world gen it might end up waiting for the other chunk to be populated before it can continue. What is your algorithm to start it? Do you first register the bounding boxes and then when the world calls for the generation generate the structures? or do you immedeately generate it?
-
[1.8.*] Trouble Setting Item to NULL
From your first post you have this.item = null; Please note that this does absolutely nothing of the sort what you want and makes you kill all code that uses that specific itemstack. What it does is clear your reference to the itemstack object, but also all references all other objects have to that memory space, which throws the nullpointer exceptions. Now, you are trying to clean up the itemstack I gather, don' t set it to null. It's like taking a sledgehammer to make a birdhouse. Plus the code doesn't expect things to go 0 at unexpected times(thats why the nullpointer exceptions). Just use the code as it's designed. Look at how the crafting tables do it when something is crafted. Look at how the furnace does it when it smelts an item. Just set the stacksize to 0, It will clean itself up. Or if you need it to be NULL for one reason or another, do Itemstack.copy() when passing it to another object. That way the other object won't hold a reference to your Itemstack, that you set to null. Your object.itemstack is the "Master" key. if you set that to null it will get cleaned up even though you have references somewhere else to that itemstack. Use itemstack.copy() when transferring itemstacks between slots if you have a direct link to that itemstack. That way you know there is a clean cut from the reference and you don't have to worry about that anymore. itemstack = this.item; is the cause of your trouble. You are making a reference to your itemstack object. That you clear. Better would be itemstack = this.item.copy();
-
[1.7.10][Solved]Load resource from jar serverside
nvm, I fixed it. For those interested. if you start your directory structure with a / it will take the root dir the base of your jar. Then you can load your files in. try { String filestrname = "/assets/magiccookie/structures/EntropyTemple/"+filename+(this.isInversion() ? (this.inversedInverse ? "" :"I"):(this.inversedInverse ? "I":""))+".json"; in = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filestrname))); builder = (JSONObject)JSONValue.parse(in); } catch(Exception ex) { }
-
[1.7.10][Solved]Load resource from jar serverside
I put the json files in the asset dir. my main class dir is a few directories up in tschallacka magiccookies. Do I need to prepend file location with ../../assets?
-
[1.7.10][Solved]Load resource from jar serverside
okay, the difficult way it is.
-
[1.7.10][Solved]Load resource from jar serverside
Clientside I can do res = Minecraft.getMinecraft().getResourceManager().getResource(resource); But how do I do this serverside? I only need access to the resource manager to load a specific text file from the jar.
-
[1.7.10][Solved] Cancel mouse input possible?
Actually that doesnt cancel the event what i've read on a topic from someone who wanted to do stuff with touchscreen. I delved into the GUI class and I found a delicously simple way to cancel out the mouse so it doesn't interfere as much with the steering which makes the drunkeness that more harsh now if(e.getPlayer().worldObj.isRemote) { if(Drunk.instance.grabbedCursor) { Drunk.instance.grabbedCursor = false; Minecraft.getMinecraft().mouseHelper.grabMouseCursor(); } } Minecraft.getMinecraft().mouseHelper.grabMouseCursor(); Makes the crosshair control the movements allowing the player to do 360 degree turns and such. Minecraft.getMinecraft().mouseHelper.ungrabMouseCursor(); turns control over to the OS, allowing very limited steering by the player. I love it where there is a simple solution.
-
[1.7.10][Solved] Cancel mouse input possible?
I was wondering if it is possible to cancel mouse input in forge by canceling a specific event or an instruction for minecraft to not accept mouse input for steering. Like when you are in a bed or have a GUI open. At this point i'm considering making an invsible gui for the moment just so the mouse is disconnected from steering inputs, but I was wondering if there's a more standard way to accomplish this. I really would like a standard way that disconnects the mouse but not the keyboard. If you are wondering why I want this. I have delicious grog in my mod and it has some effect on the way your head looks. You kinda swerve all over the place, left right intermittently. So if you walk when drunk you can suddenly swerve sideways. The problem comes when the player steers against the movement it becomes really jittery and not the smooth swerving you have if you don't steer against it.
-
[1.7.10][Solved] Best way to deal with a full Potions array
Yea draco, I had come to that conclusion thanks go google myself already. I literally just finished up my own potion handler. I send packages from the server to client to update the nbt data in the extended player, which then gets read out by my code. I only had to modify 75 lines luckily, and make about 50 new lines heh, but I have it working. Now... what should I call my potions now that i'm loose from the official potions api... moonshine? Now I'm back to another nifty problem. But i'll post that in a seperate thread. better for Google. For those who are curious what I did to solve this: Write my own Potion handler where I register my potions instead of the Potions.potionTypes array. Have in it methods to write NBT data to the entity you wish to afflict with all relevant data(id, duration, amplification, etc..) Add an IEntityExtendedProperties to the player/entity Have all methods needed to set/get and update the Extended Entity upon spawn, death, etc... For 1.7.10 see https://github.com/coolAlias/Tutorial-Demo/blob/1.7.10/src/main/java/tutorial/TutorialMain.java it's a really good guide which things you have to consider. Then in the entityliving make a call to extended property and ask it to update and parse all possible potions effects from there. In the potion handler after afflicting the player have a method to get hte potion nbt from the player and sync it clientside. Basically something like that. I'm not posting code samples cause its all little bits over the place. + CoolAlias tutorial has all the basics needed but the potion handling, and you should be able to do that yourself ;-)
-
[1.7.10][Solved] Best way to deal with a full Potions array
What I have found that an entityLiving does have nbt data but it doesn't get synced. I can use it perfectly to store potion status and such and it gets read out the moment I log in, but only server side, so It doesn't sync it. Currently im writing my own messaging class to communicate the potion status
-
[1.7.10][Solved] Best way to deal with a full Potions array
I anticipated that. Next question on my original qurstion combo. Whats the best way to sync entity nbt data? IMessage?
-
[1.7.10][Solved] Best way to deal with a full Potions array
Thats what i already do. But when my mod gets coupled with other mods the other mods fill up the 128 max available slots. Leaving no room for my potions. 128 is the max size of the array. Thats why im looking for solution of how to deal with my potions when the array is maxed out.
-
[1.7.10][Solved] Best way to deal with a full Potions array
I'm building a MagicCookies mod and a have a few custom potions that are quite essential(to me) as part of the experience in my mod, and I have many more planned. However, when my mod is coupled with botania and witchery and a few other mods the Potions array reaches it 128 limit and my Potions can't be added anymore. Is there any thing forge provides for that eventuality or should I simply write my own potion handler? If I use my own potion handler which packet communicator can I use best to push data from server to client about potion id, duration and amplifyers? I use those to provide some graphical effects, but the client doesn't get my nbt data updates unless I'd push them with a packet handler. Most of my potions are serverside effect needed only, but some are client side.
-
Question about where to put something
I know, but im not really in the mood to write a tutorial ;-) that costs a lot of time. I'd rather share the commented file.
-
Question about where to put something
I spent 5 days digging through the nether fortress generation code and I finally figured out how it works and how it chooses how to generate stuff. I now have two files commented in the workings(might not be perfect, but if you have general programming knowledge you should be able to figure out my ramblings) and given variables logical traceable names. I think people might be interested how to safely generate multichunk structures and have the structures not collide with other structures. Now i'm not comfortable with just blatantly posting the mojang source code on the forum, but I do feel this is something to share with the community, so where do I leave it? I modified the code so it will spawn the nether fortress in the overworld pretty closely packed but not touching eachother. If you pm me i'd be happy to give you a d/l link so you can see for yourself until someone can point me where I can post this/leave this.
-
Fences dont register when testing with world.isRemote
Usefull guys. If I was interested in a discussion about the merit of clientside vs serverside i would have posted a different question. What I'm interested in is why a fence does not trigger the in itemuse when clientside but all other blocks do.
-
[1.7.10]Help with this suggestion
Use the renderpasses for icon of items to render your item. That way you can store in nbt data which rodtype you have, which type of toolhead. Then in the first renderpass you render the rod, in the second the toolhead and each following renderpass you add whatever you deem neccesary. Diamond studded gold rodded emerald hoe sounds nice. You can use the when in inventory method to check if its wielded and give certain buffs/debuffs that way. Stone rodded iron plated shield Sounds nice.
-
[1.7.10] Help I'm stuck. Literally!
Try giving the speedboost only serverside, not clientside. Also imagine this. Your speed is 1 you move at 1 block per tick. Suddenly your speed is 1.5 moving 1.5 blocks per tick. Client promply adjusts and puts you in the wall/block on the side. Server says. Hey. You cant be in a wall. Get out. Client says my speed is 1.5 im gonna put player to far again and so a tug o war happens between client and server.
-
Fences dont register when testing with world.isRemote
Thats the thing, like i mentioned it, I want it to be clientside only. What i do is add the information to a hashmap and then put it in an output. Prefably i have this running clientside so I can use it on my server without having to dive into the server files. It all works beatifully, except for fences. Walls, torches etc... All get registered, but the fences never trigger on the remote world. Im just interested why that is. Im suspecting the leashing code interfering somehow. But that doesn't explain for me why it does work server side but not clientside.
IPS spam blocked by CleanTalk.