-
Posts
2638 -
Joined
-
Last visited
-
Days Won
4
Everything posted by Ernio
-
Hey, Could someone say how correct is my thinking and answer later question: In Multiplayer all NBT data for ItemStacks is saved on server side. Then the ItemStack (with its NBT) is sent to every player that will need to have it, and it will be saved to client's RAM. Now let's say I have 3 string fields (i'll later convert them to integer Id's for .png) in NBT for every MyItem.class ItemStack that hold: "hand_txt", "body_txt" and "blade_txt". Those strings are being read for all items that are instance of MyItem at least one time per tick (not sure) when custom renderer calls it. public void renderItem(IItemRenderer.ItemRenderType type, ItemStack item, Object... data) In this method renderer reads from NBT those 3 fields, pickups right icons and then renders them into one whole item. The question is: Is reading from NBT on client side (since it is renderer) occurs "virtually" on client from itemstack's NBT saved inside RAM or for every tick, every player and every itemstack it is being resent from server and then read. Someone told me that ItemStack NBT is sent to player once per his session, and ONLY updated when the server will detect any change it it's NBT - is this true? (because I really hope so). We all know that reading from NBT (HDD) is something near dozens of thousands slower than RAM, and having it read every tick, for every player and loaded ItemStack will create a freaking LOT of requests to NBT. Help Thanks.
-
To post above: If by "subclassing" you mean extending - then no. Entity is a object that "lives" in world - it can move, item, mob, arrow, whatever (has to be loaded manually). TileEntity is more of a "dead" object, like static furnace or something (they are loading a chunk on their own). Overall: Both are using other methods to save data - look into net.minecarft.tileentity.TileEntity.class and net.minecarft.entity.Entity.class, tell us what exacly you want to save and why are you not simply using NBT rather than IExtendedEntityProperties? TE NBT is perfectly good way to save data. Edit: Sorry m8, I kinda was reading few threads simultaneously and kinda took your previous post as a OP's post - oh WTH, just messed up my mind - my main point was that Entity != TileEntity and NBT can be used in both without IEEP.
-
Skins are being held in AbstractClientPlayer.class They are private so you have to use reflection to access them and override with your own.
-
My researches: Every Container consists of Slots taken from Slot.class. In slot class you have getSlotStackLimit(). Normally it will return stack slot limit taken from ItemStack, it can be however different than that - but only lower. Since when you put something into slot will check both slot's MaxSize and ItemStack's maxStackSize and slotMaxSize must be lower than the ItemStack's, you will have to make it from ItemStack's side of code. And this is the problem - you can's "just" override it for all vanilla items. However there is a way to "cheat" game: There IS a possibility of saving more items in one stack than game allows - to see that simply use: new ItemStack(Item.diamond, 100000); What you would need to do is a handler that would find if there is equal() ItemStack that you are trying to put into bank, inside the bank, copy it, then incerement it with value of items you want to put into and create new ItemStack with new size (code above). BUT (always a butt) when game saves/loads itemstack's size to/from NBT and it's size is bigger than its maxStackSize it will be always (I think) auto-set to 1. That means that if you would save something with size of 2000 inside your container, after relaunch of game/server it would be 1 or simply become a ghost item (not sure YET). And here is the problem - you can't use ItemStack's NBT to hold your values I suggest making an slotArray<slotindex, sizeofstack> that will be saved in NBT for BankContainer and when someone calls openContainer it will loop through all slots, get their ItemStack, copy it, then apply sizeofstack from slotArray, and make a new ItemStack with new size in given slot. I MIGHT be wrong when it comes to the part where I am claiming that you have to "cheat" the game, but that's only idea I have in mind at the moment. Also - you will have to make a hella-lot of nulls, ifs, loops, but: happy thing is that the container itself is not called on tick, so it won't lag EDIT P.S - I really wouldn't dare to f** with Stack sizes, it will probably glitch like hell, but that's what you asked for so I wrote it. Consider making a withdraw system - a single slot in container where you can put an item and click "deposit" or you can choose an item from some scroll list and click withdraw (and amount). Data would be also stored in bankContainer NBT.
-
[1.7.10] Breaking a block without hitting it with a tool
Ernio replied to Syndaryl's topic in Modder Support
I was simply explaining that it should be that way. There is a reason they are being called on both sides by vanilla and it should stay that way. Only real fact is that when you for e.g generate random it will be different on both sides - BUT the server side value will most likely take over - I was having fun with those some time ago and I simply said "nah, it works so better leave it". And back to issue: You want to have a tool that when it breaks block, the block broken will scan blocks around and if block == blockaround it will break too giving loot (without recurrency/chain reaction)? If so - take a look at BlockEvent.class You have two events you can use - both seem good for what you want to do. How would i do it? 1. Subscribe to BreakEvent. 2. Read neat documentation with nice addnotation: Reference to the Player who broke the block. 3. If (equipeditem == sledgehammer) - BAM, launch "reaction" 4. Scan blocks around with simple +/- x/y/z scanner 5. If (blockaround == sameblock) 6. Wait... <miracles happening> 7. BOOOOOOOM!!! Stomp, crush, destroy, smash! Set(0) and drop! 8. Profit! And yes... this is me in free time: Hope it helped P.S - you can probably do that all from tool side of code, but I am too lazy to look into that, unless you want me to. Using event will cost you one "get" (itemequiped) and one "if" statement per block broken (the rest of actual code would be launched anyway), so I guess that's not worst way to do it, but there is better. -
I belive you can use normal recipe registry and in place where you create new ItemStack you can call NBT field and set it to other name for item. I'm not sure if that will work for any Item tho. Why not looking into Anvli code where it outputs new item?
-
I have problem in interpretation: *"I have a custom gui." *"store more than 127 items in a stack" I really don't see any connection here. 1. You either want to have a Item that can have maximum stack size of X. If that is your goal then I have no idea what is the problem since ItemStack's field stackSize is an int which can store a quite big number. 2. You want to have a GUI in which items react differently than in normal GUI. Let's say you can suddenly stack sword (which in normal GUI is impossible). Please explain what exacly you have to store.
-
[1.7.10] Breaking a block without hitting it with a tool
Ernio replied to Syndaryl's topic in Modder Support
"for reasons not obvious to me" Break event is called twice because it's both client and server side method, so if you want to make some calculations you can always make it server side. (Every client has "client" and "server" which is virtually taking care of most things) In the end client will always sync with server, unless you make some radical error. EDIT: As to finding method, if you won't find it until i get back home, I will write how to make it. -
Hey, I've ran into most annoying bug (well known) when it comes to rendering/entities. Sometimes Minecraft (SP) creates glitch and makes entity (item bounding box) simply jump up and down. One time its about 1pixel, sometimes it can reach half of block height. Has anyone been able to fix it with some custom entity extension? In my case in which I'm making "glow" effect around custom-laying items (picture above) it's just the most disturbing event for my eyes.
-
"I did exactly what it says on the wiki article." Uhm... Never used that one, I'll just point you in this direction: http://www.minecraftforge.net/forum/index.php/topic,14048.0.html
-
Hey, Is there a pre-made method for adding custom-nbt item to tabs? To make it clear: I've initialized default item with overriden method onCreated() that will set 3 NBT boolean fields to something depending on how it has been crafted (with what material or whatever). In creative tab the item itself has no NBTs since it hasn't been created and if I'd pull it out it will have no custom NBT at all. I want custom-nbt items to be shown inside Tab like this: (there will be 9 of them + one empty (default)) Item(none) Item(0,0,0) Item(0,0,1) Item(0,1,1) etc...
-
"I currently try to know how find the nearest chest to my entity." And how do you do that? Maybe we could make your code a little bit more optimal. "choose the shortest path" Thats perfectly good option and probably only one. "I don't think we can calculate (...) distance." And why is that? You have Entity with x,y,z, you have chest list. I assume that if you have chest you do have its coord (x,y,z) so you just use math. Vectors sir, vectors. And why do you even ask about reflection, there is no connection here.
-
Well, I am not sure what author ment by "redstone in motion", but if you simply want to move block then all above is probably the best way to handle it. Then there are ofc few "extras" that depend on what you actually want to archieve. 1. "Pushing" block in x/z plane with "cross" style: You simply use: public void onBlockClicked(world, x, y, z, player) Since you have player here you can calculate its relative position and setBlock to 0, then set the same block on +1 cooridnate (in given direction). 2. "Pushing" block in x/z circle plane: In case you want to get farther "push" and you want block to go in some direction under angle I suggest learning Java Math and sin/cos. You can always look/get code from MC source (it is commonly used in a lot of classes). 3. Actually making MOTION - this is fun. You will again use onBlockClicked() but this time you have to use entity and some math. The momnt you click/hit block you generate new Entity and give it a block render with same texture. Every entity has a motion X,Y,Z. Use this to give it a speed and actually move it in some direction, then get it's position, calculate the coordinate and "kill" the entity, then place there your block. Last option will require some expo with renderers and enTITIES (lol) so if you are "new" don't expect miracles. P.S: if you want to apply "pushy" effect to all blocks (even vanilla ones) you can use PlayerEvents to get when player hits stuff, get this "stuff" data and then do same like in any of 1,2,3, only this time not in block class.
-
[1.7.2] Texture name from NBT. Edit: Updating texture.
Ernio replied to Ernio's topic in Modder Support
Well, the whole idea of sending anything bigger than 1kB (the image 16x16, or bigger) in NBT is just plain stupid, updating it happes I think once per tick and having more players on server would simply kill the transfer. I will simply write mod that launches process that downloads texture files from server before registration of IIcon. The other thing is reloading the actual image in runtime. I'm doing tests now to find neat way of doing it. 1. .png files are downloaded to /x/ directory. 2. We have Test.class which extends Item and has a HashMap<String, IIcon> in it. Then we register them .png from /x/ dir on client startup. protected HashMap<String, IIcon> NBTIcons = new HashMap<String, IIcon>(); @Override public void registerIcons(IIconRegister iconRegister) { registerNBTIcons(iconRegister); this.itemIcon = iconRegister.registerIcon(this.getIconString()); //everything stays like it was, i am just adding void in line above } public void registerNBTIcons(IIconRegister iconRegister) { //There is a loop here for actual loading and putting stuff into HashMap, i just made example below. NBTIcons.put("itworksbaby", iconRegister.registerIcon(InitUtil.ModID + ":" + "yay")); } Right now we have to load those registered icons for the actual items using this Test.class as constructor. So I made this: @Override public IIcon getIcon(ItemStack stack, int pass) { String s = ""; if (stack.getTagCompound() != null) { System.out.println(stack.getTagCompound().getString("texture")); s = stack.getTagCompound().getString("texture"); } return NBTIcons.get(s); } Ofc. NBT itself exist (defined in onCreated()). Problem is - this forge function is only used to update this "in-hand" renderer. So the result is that I have item with missing texture when in inventory/on ground. And with texture when held. How do I update icons for the item itself? (Probably something in resourcepack manager, but can't find anything particular). Any idea? Thanks, And here is a potato for long post: http://barringtonstageco.org/media/potato.jpg -
[1.7.2] Texture name from NBT. Edit: Updating texture.
Ernio replied to Ernio's topic in Modder Support
TheGreyGhost I am not quite sure about client-server compatybility here. I've seen this in Item code: public boolean getShareTag() { return true; } Which is by default set to true. Till this time i was sure that client only saves data when you are on SP, and when you login on MP you get all data from server files (read: server NBT). Please, answer if you know: Is the itemstack saved somewhere on client Hard Drive during mulitplayer session and then removed on close, or is it just sent to him in runtime (RAM) as a copy of server data? Would generating a byte-image as you said work if I'd do it on server side and send it over to all players as above said - itemstack's NBT? -
Hello, Could someone knowledgeable tell me how stupid (or not) is the idea of holding texture name for current itemstack in its NBT created in Item.onCreated() method? I have a lot of sword types which textures are defined by items used to craft them. What exacly I am writing is a system that using "improved" crafting will count some factors and generate texture for item in runtime (using some pre-made shapes and colour maps) for all clients that need to have it - and by that I mean they actually need to get texture to any renderer (ofc. if they alredy seen it once it is stored as id.png for given itemstack, the problem of cleaning that up I'll probably solve with timestamps that will manage deleting files). Note: (if you didn't understand "generate texture for item in runtime"): Question is - how can I nicely load textures in runtime? Edit: The other option would be to pre-make images (a lot of them) and load them once on client startup, but then again - metadata for item is 16 big (unless they have changed it since I've used it last time - first Full Minecarft Version) so I'd have to store it in NBT - would simple itemstack.readFromNBT(texturename) in getIconIndex() work?
-
Bro, I wouldn't be here wihtout making sure it is not my mistake. Alredy done step by step initialization. Tabs alredy exist when I declare items. Fun fact: Well, I think I'm just gonna cleanup workspace, maybe there is some troll code somewhere from .git
-
I have no idea why but this doesn't work: TAB: public class RoATab extends CreativeTabs { Item icon; public RoATab(String lable, Item icon) { super(lable); this.icon = icon; } @Override public Item getTabIconItem() { return icon; } } InitTabs: RoATab TabWeapons = new RoATab("RoAWeapons", Items.iron_sword); ITEM: public class ItemCore extends Item { public ItemCore(String UN, CreativeTabs Tab) { super(); GameRegistry.registerItem(this, UN); setUnlocalizedName(UN); setTextureName(InitUtil.ModID + ":" + UN); this.setCreativeTab(Tab); } ....... ... . InitItems: MyItem = new ItemCore("Steel", InitTabs.TabWeapons); SAME code works with Blocks (I mean this tab and setCreativeTab() works with extended Block) Any idea? Is Item tab declaration different? Note: setCreativeTab(tab) doesn't work only if I place there my Tab name, vanilla ones work.
-
Well, I wasn't aware of some of the methods in MC code (it has changed a bit over versions and I really don't track every change). Since you may know something more and I'd like to optimalize my code, please tell me what should I rewrite (connect to base MC code). Interface (only showing 3 that use playerTick()) /** * This method is called when player is holding an item. */ public void onHeld(ItemStack stack, EntityLivingBase player); /** * This method is called when player is wearing an item in equipment slot. */ public void onWorn(ItemStack stack, EntityLivingBase player); /** * This method is called when player has an item inside inventory. */ public void onCarried(ItemStack stack, EntityLivingBase player); Handling @SubscribeEvent public void playerTick(PlayerEvent.LivingUpdateEvent event) //Tracks: onHeld() //Checks if player.getCurrentEquippedItem() instanceof Interface and does stuff onWorn() //Scans 12 slots (extended equipment) and checks instanceof onCarried() //Scans 36 EQ slots + if backpack (custom bp) is present -> scans it too Now: Is thare are way to keep tracking players EQ without scanning up to 70 slots (backpack) every tick? I was thinking about tracking adding/removing items from inventory, but that will be too pain in the ass (a lot of nulls and unexpected situations).
-
Retarded me Found answer just a few topics below mine. ticker + player.getCurrentEquippedItem() Shame on me
-
Hello, I am writing huge combat/weapon/armour API, I've managed to do interfaces that include a bunch of nice wearing/equipping trackers and now trying to add effects whether player is holding something or not. Where can I find a method which tell us which of 9 HotBar slots is a "Held Item" one? Also I am not sure - is this a server side data or local client? (which would be a shame, but i don't think it is). T.Hanks in advance
-
Hey, I couldn't find any well made tutorial about setting up ForgeGradle with Git and even with my knowledge of Git (I worked with it for a while now) I cannot simply make it work with Gradle (mainly because of whole filesystem). Is there any build-in support for Git inside ForgeGradle, and if not, could you guys help me setting it up? *Using BitBucket (like it matters...) *Git installed *Fresh workspace (gradlew setupDecompWorkspace, gradlew eclipse) I would love to have single ForgeGradle for all my mods (versioning and separate projects), I know you can do it, but I have no idea how to make it work. Ofc. I managed to create a almost-decent single-project setup, but it's all buggy (missing sounds/assets) and I really think that's was bad way to do it. Any links, step tuts, non-step tuts? Thanks in advance (btw. this could be useful not only for me, just saying)
-
Oh, Last time I was doing something with login/out events they were located in different place (or I just made mistake lol). Well, started using NetworkHandler, but I can see now that it can be done MUCH easier with this event u gave me, thanks. SOLVED
-
Hello, I have CLIENTSIDE mod that does some reflection with: onEntityJoinWorld() -> if (event.entity instanceof AbstractClientPlayer) To override some player visual stats (head and graphics). It's making an update of properties for EVERY player (listed on my website txt file, it's kinda like "for this nick, change his head to a TNT") that joins (including the client that is logged in). Now, i need to make a cleanup when the client-player leaves the server (client-player = the guy who is now using my CLIENTSIDE mod). 1. How can I track down when you disconnect from server? -Player 'you' left the game. 2. Also: how would I do that check for any other player? -Player 'other' left the game. NOTE: I want it WITHOUT holding player list inside some 20/sec ticker.
-
Hello fellow Minecrafters! Note: WE ARE NOT A HOSTING COMPANY that wants to advertise itself by Minecraft. What? Yes, I want you to become part of MidstCraft community and host your server FOR FREE (don't get too excited, this is for professional people only). If you are interested please visit this page: (I really want to keep this in one thread) http://www.minecraftforum.net/topic/2446227-midstcraft-opportunity-awaits-free-hostingnot-a-hosting-company/ Thank you for your time, hope our help will make someones dream come true Posted Image Sincerely, MidstCraft Team and MidstCraft Manager, Ernio P.S - If this is forbidden/in wrong forum, I am sorry and please delete/move this thread.