Jump to content

Ernio

Forge Modder
  • Posts

    2638
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Ernio

  1. To "Executing things" you also need to carry data. Anyway, I think you are missing some fact here: Minecraft (as game) consists of 2 sides: SERVER and CLIENT. (in means of .jar file) Then there is logical part: SERVER has: Server Thread Netty Server Thread CLIENT HAS: Client Thread Netty Client Thread Now - when you are on SP, the client will launch local SERVER (in background) and connect to it. Read: "SP is MP with one player connected." If you connect to some other Server - then CLINET handles Client logic, and SERVER handles Server logic. It does not matter if you are on SP or MP - packets will be used in both cases to transport data between those 2 sides. Side->Netty->Connection->Netty->OtherSide (Note: While "Connection" in most cases is internet, on SP it is "localhost connection meaning that SP still uses packets) Now, facts: * It's ALWAYS ther SERVER who loads and holds data. Client only displays it. Client always lies and it is right to assume that any data held by client is wrong. * You use packets mostly in Server->Client scenario to send data. * In Client->Server scenario you don't send data, because - as stated before - CLIENT IS ALWAYS WRONG. What you do is you send the fact that client want something (e.g clicked button) - that's why most of CLient->Server packets will be very small or empty. Now to actual thing (this thread): You wanted to use packets to launch code on server, in this case you simply don't have to, since VANILLA alrady sends packet saying "this client just did right-mouse-click" and then Item#onItemRightClick will be called on client adn on server. Any questions? (damn, this essay).
  2. It's either me not getting what you need, or you not describing what you need correctly. Java is not dynamic language (okay, reflection kinda is, but that is not 'simple java'), you can't "just" grab something and modify it (talking about classes). Anyway, what you probably need is to change your design. Loading part: 1. You read .txt files 2. You save that data to some class that will hold it for you, e.g "VehicleStructure". 3. You save those objects in some Map<String, VehicleStructure>. 5. You make some nice wrapping for getting that data. Entity part (your VaehicleBase): 1. When player spawns vehicle, you search your map for name player provided and you apply that loaded-from-txt data (stored in VehicleStructure) to your VehicleBase. 2. Your Renderer is asigned to VehicleBase and uses VehicleStructure field (assigned to VehicleBase instance) to render stuff. 3. And yes - you need to synchronize it. (spawn packet). Also - you can then save that VehicleStructure to world (WorldSaveData) or even entity itself. So that would answer your:
  3. Bro, do you even pastebin? Use java format.
  4. Hold on. "my achievement system" - so where are you running this? Achievements are one-time events which should be operated kinda like: * You do something * You get it * You save it * You read it Why ticking-checks? (you said you have them somewhere) EDIT: Also, many people seem to NOT know that - NBT are LITERALLY Map<key,value>. They are just represented that way. And yeah - they are pretty fast.
  5. Client logical side has only entites that are loaded by player. If you are (your client) not tracking server's entity, you don't have it's instance (thus, no IEEP). (Edit: So the answer is 'yes').
  6. Renderer is assigned to Entity.class, not an instance. Period. If you are loading other entities from .txt you should STILL have one renderer for all of them, you will just make renderer correspond to given name of entity. (e.g return model from entity's NBT). What you can do is to use Forge's class loader to load new classes into your mod (like an non-@Mod addon to your mod). You can use reflection to load any .class in runtime and then register it.
  7. Lemme just add one thing: You NEED to start using proxies to do client-stuff registration. Otherwise your mod will crash on dedicated server.
  8. It would be much, much better if you would just post those (in question) parts of code and say what is expected outcome. We might be able to tell you - what to not do, or maybe a better way.
  9. render a texture on the screen every time you hit a zombie I don't see how it this a particle, only thing I can think of that you want to make particles of damage done to zombie. Anyway - NO, particles are client side and can be client-only. As to why you were thinking they are server sided: Most of partcile spawtning is dictated by server, but its server->packet->client(spawn).
  10. Lol, you don't. What you literally want is to bake some amount of models somehow (can be done by registering variants to some item, or simply on your own). Then in ISmartItemModel you just get those models from registry. EverythingGames just gave example, but it is good only as example.
  11. I am guessing: event.drops.add
  12. At point of writing this I was going to sleep (no time to check), but yeah - Object[] was the shit. Until now, I always preferred (in my mod's parts of code) String[] to any List<String> - reason is obviously less memo and fact that those were used with commands and configs: execute(ICommandSender ics, String[] args) ConfigCategory#getStringList() Anyway, spent about 2h to convert like hundreds of fields and methods to ArrayList<String>. Thank for reassuring. (that was my hashing problem).
  13. I wrote essay just a second ago, but lemme 1st ask one thing: private final HashMap<String, String[]> args = new HashMap<String, String[]>(); Is this shit consistent? this.args.hashCode() Everything from docs tell me it is: * Map.hashCode() is sum of all hashcodes of entries in map * String has consistent hashCode since JVM 1.2 (I think) * Only thing left is String[] - which I THINK is also consistent? Anyway - 6 SAME (edit: their elements and order of adding) maps like this, with same input, 3 on server and 3 on client logical side - each of those return different hash! Also - if I'd loop them and put their elements into NBT the NBT will be equal, damn - even ordering is the same. Java masters - teach me. (Today I've travelled (~4hours) through 7 inheritance hashCode() methods and finally arrived where they start being different - and that is on this situation above).
  14. @Override public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (worldIn.isRemote) return true; else { ItemStack stackHeld = playerIn.getCurrentEquippedItem(); if (stackHeld != null) { BasicGearboxData bgd = (BasicGearboxData) worldIn.getTileEntity(pos); if (bgd.attemptPuttingStack(stackHeld)) // return true if succesfull { playerIn. // setHeld stack to null } } return true; } } Now in TE, you want a method that will check if you can put given stack into some slot. If you succeed then you will send packet from TE's method (e.g: #attemptPuttingStack) Note that if you are messing with player inventory on ONLY server side, client might not get synchronized - you will need to mark player's inventory dirty.
  15. 1. What MC are you on? In 1.8 you need: http://greyminecraftcoder.blogspot.com.au/2015/01/thread-safety-with-network-messages.html 2. You got the idea wrong (with dimension and worlds). 2.1. When sending data to client about some effect, you don't send "world" - client has only ONE world, that is, the one player is currently in. 2.2 You send only x/y/z, the world you get with Minecraft.getMinecraft().theWorld (Note: have look at thread safety and @SideOnly(Side.CLIENT) 2.2.1. To bypass problem of using Minecraft (client only) class in packet handler - use proxies: http://www.minecraftforge.net/forum/index.php/topic,32585.msg170364.html#msg170364 3. What else... Oh! Particles are render-stuff. Send packet about their spawn only to players around location, not all.
  16. There are none. Depending what you need (please write), you will be interested in: * Lazy NBT init (e.g: add new info when item is used 1st time) * EntityJoinedWorldEvent (e.g: to replace dropped items with new ones) * PlayerTickEvent or other events to e.g replace item or assign new data to it. I don't get "item is crafted for the first time" part. I mean, you can craft item only ONCE, how can it be crafted twice, lol If you want to know if item has beed crafted by player for the fist time - you will need IExtendedEntityProperties.
  17. Old Forge is probably even more confusing then new one. Plus, you won't get any support here for old versions. Start with at least 1.7.10, but recommended 1.8. If you need to "take a look" at some old mod, you can just read parts of code using jd-gui (underlining: "take a look"). If you want to e.g update old mod and want to decompile it 1st - forget about it. 1.4 is like a totally different API and updating so old mod WILL need you to rewrite it from base (which you can do with jd-gui).
  18. SNW: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-2-customizing-packet-handling-with Short: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-x-1-8-customizing-packet-handling-with TESR: https://github.com/TheGreyGhost/MinecraftByExample/tree/master/src/main/java/minecraftbyexample/mbe21_tileentityspecialrenderer
  19. Yeah, pretty much your best option to stay compatybile. Just note that vanilla items might be used outside vanilla - remember to replicate its behaviur (e.g enchantments saved in NBT).
  20. Only option I see without hardcode modding (ASM) would be to extend given vanilla class and do your stuff like with any other item. Then using (various) events you could replace item with your item and alter its durability/NBT as needed. You probably alredy thought of it, but jut saying. As to "various" events - best shot would be PlayerTickEvent and check held item. You might also want to alter e.g Crafting events or even drop events if you need more control.
  21. Most of the time: 1. Think of something 2. Think - "Is this in vanilla? Or maybe something simillar?" 3. Look for keywords using IDE seach. 4. Read tons of code 5. <magic happens> 6. Profit As to more basic stuff: (links) http://www.minecraftforge.net/forum/index.php/topic,26267.0.html http://greyminecraftcoder.blogspot.co.at/p/list-of-topics.html http://jabelarminecraft.blogspot.com/ As for commands (because you asked): You extend CommandBase or make your own implementation. In: @EventHandler public void serverLoad(FMLServerStartingEvent event) { // Initialize commands event.registerServerCommand(new MyCommand()); }
  22. Bro, learn Java, you probably heard that at least once now. (and please, don't give me that stuff about "you are here to help, not tell me that I don't know Java", I am helping you). You don't need to extend anything. You just make your own block, apply your model to it (campfire), and then, in YOUR block class you Override #randomDisplayTick and perform particle-spawning. You have literally ready-to-use code in BlockFurnace, only thing is that the furnace spawns flames on Front face of furnace block and you want to do it in center of block. It's like, literally, 5min to make.
  23. public int getMaxDamage() { return this.item.getMaxDamage(this); } If you look closely, ItemStack is passing "this" (ItemStack) to Item.class. For your own items you can change it to be based on NBT. That was said before, now: Question what should be asked - do you need this for vanilla items?
  24. Like diesieben would write: "That's cool!" You gave no real question and no real problem to solve. "I want" and "Someone help" won't tell us what is the problem. I alredy told you to look as vanilla's BlockFurnace. It is REALLY simple task. SHow what you tried.
×
×
  • Create New...

Important Information

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