Jump to content

Ernio

Forge Modder
  • Posts

    2638
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Ernio

  1. Cmon bruh Arrays are mutable. You are adding n/d (infinite) BakedQuads to array of quads of one model. That will cause MASSIVE lag as soon as your array reaches X size. Do Syso(shieldFront.getGeneralQuads().size()) in your getGeneralQuads() - shit's gonna hit da fan! List<BakedQuad> quads = new ArrayList<BakedQuad>(); quads.addAll(shieldFront.getGeneralQuads()); // Or you know - use copy ;p
  2. Bruh, first of all, NEVER EVER use "wait" in minecraft, unless you know what you are doing that is. The logic here is simple: You make 2 packets and 2 handlers. Client -> Server Client sends pakcet to server telling it to change block on some pos. Server Handler Changes block and return new packet (which will go server -> client) Server -> Client From Server 1st packet's handler you send a packet to client Client Handler You get response message and do whatever the hell you want there. EDIT To be more precise: Plato.setBlockMessageDone = true; In this exact place - you perform anything you would as a "after block is set". If you need any references from outside, which I assume you want to have - you need to either send them or where to find them (x/y/z for example). EDIT 2 Minecraft methods don't wait for something to happen (receive packet in this case). But you can setup ticking execution. You would have to make some static list of Runnnables on client that would get filled before sending packet to server about something. Then utilize ClientTickEvent to try to execute every Runnable from that list, every tick (mind event.phase), if the boolean is true. Now - only thing you need to receive from server is "true" to some Runnable's ID. Note that this way - your objects in Runnable must be WeakReference and you cannot expect them to not be null as you don't know when action will occur.
  3. You have no clue what you are doing, do you? public static Property player_name; public static Property player_class; And then happily: @SubscribeEvent public void onPlayerLogin(PlayerEvent.PlayerLoggedInEvent event) { ... ProjektWow.player_class = ProjektWow.config.get(name, "Class", Reference.nul); ProjektWow.player_name = ProjektWow.config.get(name, "Player", name); .... } Dude, if this - "Reference.nul" is NULL you can't suddely use it as not-null. Also - your whole mod is (looks) totally bad designed - no per-player saving, nothing. Read about: IExtendedEntityPeoperties to save data. Packeting to synchronize data.
  4. Facing - check out GuiIngame and search for debug, I belive it had direction player is looking at in 1.7.10 (I am on 1.8, with nice EnumFacing). Staring/Looking - rayTrace - rayTracing code is like everywhere. Tuts are on net too.
  5. Boonie - bruh, animating is one of those things that doesn't have tutorials and requires you to actually sit and read code for hours to write something that will work well. If I were you I'd dig into whole vanilla rendering system before even touching writing anything on your own. Note: Renderer is same for all Entities, the renderer takes Entity argument when performing rendering - that Entity can hold data regarding animation. In case of golem it is .getAttackTimer(). To apply attack animations onto your entity you can simply save variable inside it - then when doing somethign with it - synchronize it to client and make client do animation. To apply animations to existing entities you would need to recreate and replace their renderer (EDIT: or use RenderLivingEvent) and apply IExtendedEntityProperties to save additional variables. EDIT Without checking I don't think there is method for checking if entity attacks - only player has such thing (for swinging his arms). You can only "grab" the exact moment of performing attack by LivingAttackEvent and getting attacker from damageSource.
  6. Wth is ProjektWow.player_class and why are you accessing it without player reference - it really looks like something either bad or "WIP" to-be-implemented. Error is in some null there. EDIT To post below: That is clearly "String property = ProjektWow.player_class.getString();" There is nothing else that could cause null in that method, unless Reference.Warrior would also point at null object.
  7. Packet is like one way ticket, you can't expect something to come back if you don't make it come back. In onMessage instead of returning null you can return a packet that will be sent from server->client. That would be figuratively "waiting for answer".
  8. That would be actually possible without overriding whole Gui. Right now I can think of at least few different combinations of tools that would allow you to do it. 1. Replace GuiChat with your own Chat - do whatever you want then (literally, whatever). * Use GuiOpenEvent to check if event.gui is chat, and open other (your gui). - Requires knowledge about coding Gui. 2. Utilize few hooks to do it. * Use ClientTickeEvent - Save String with text typed in chat in last tick. If the text changed in current tick (lower that to e.g 20 ticks for performance), scan changed string and pull out all new-typed words (so that you won't have to auto-correct ones that were typed before), make shitload of String operations and autocorrect stuff. Replace word with corrected string and set chat field to edited string. * Use mc.currentScreen (inside TickEvent from above) - get buttonList from current GuiChat and add new Button to every new-typed word. You can easily put that button e.g above the word. * You can use FontRenderer to get length of given text. * Adding button will do nothing - you just added it, now you need to add action to it: Use ActionPerformedEvent, check if clicked button is your new button - perform auto-correcting. Then you can remove that button. The actual problem is that last time I was doing stuff (I replaced GuiChat) in this field was year ago or more. Things might have changed, what I am not sure of is the fact if you can actually add/remove button in any moment. Pretty much all I can tell, lookup net.minecraftforge.client.event if you are looking for something more.
  9. What is strange is the fact that it doesn't lag inside dev. It should after some time. List<BakedQuad> quads = shieldFront.getGeneralQuads(); for (BakedQuad quad : (List<BakedQuad>) shieldBack.getGeneralQuads()) { if (quad.getFace() == EnumFacing.NORTH) { quads.add(quad); } } Rookies mistake. You are adding n/d number of quads to given model. That is like really bad. Aside from that - I have no idea why it lags only in exported mod. As to "ideas" - if you would do a LOT of changes in Quads in future (because right now you are not). You might wanna cache List of Quads for model. private HashMap<String, List<BakedQuad>> cachedModels = new HashMap<String, List<BakedQuad>>(); @Override public List getGeneralQuads() { String key = ""; for (String texture : this.textures) // this.textures are links from my ItemStack to models used by sword (sword is put together from few models) { key += texture; } List<BakedQuad> combinedQuadsList = this.cachedModels.get(key); if (combinedQuadsList != null) return combinedQuadsList; combinedQuadsList = new ArrayList<BakedQuad>(); //Filling list with Quads from different models this.cachedModels.put(key, combinedQuadsList); return combinedQuadsList; }
  10. I don't think there is hook for before sending anything. Depending how autocorrecting your autocorrect will be you might do some tricks. Minecraft client knows current Gui opened. (mc.currentScreen). There is ClientTickEvent that is fired by FML client-side every phase: START and END of tick (choose one always). You can check if gui instanceof GuiChat and get currently written text box and apply autocorrect, problem is you would need to do it in some tricky way to not interfere with player's input. (Obviously not every tick). If you can't think of a way to do it (I can, but don't know what are you planning) then you are left with implementing custom GuiChat (there is also GuiChatNew, look it up) and using GuiOpenEvent - replace GuiChat with yours. (better way I think, if you are planning that big feature, yet - more coding). EDIT Obviously, you can also use other events - Input events, e.g "click 'Insert' to check spelling".
  11. Lookup ANY tutorial on google, bro. Really, stuff as simple as that has milion of tuts. Don't do any other registration, but: EntityRegistry.registerModEntity(...) Update posted code.
  12. Entities should be spawned server-side. Wrap your spawning with if (!world.isRemote). (I am not sure of stuff below, I am only pointing out what you might run into) Also: After direct manipulation of ItemStack: "--itemstack.stackSize;" you might have to do player.inventory.detectAndSendChanges() (not sure about method name). You will most certainly NOT have to do this if you would run "--itemstack.stackSize;" on both sides, and spawning entity on server only.
  13. You don't understand java and/or ItemStack. A method that returns object (ItemStack) can't suddenly return two stacks. What exacly do you need to do? Right now: @Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { // When player right-clicks player.inventory.addItemStackToInventory(new ItemStack(this)); //add to player's first free or stackable slot a new ItemStack of this item return stack ; // return the stack you have right-clicked with }
  14. Indeed, that would explain it. I didn't setup ItemBlock yet (testing for now, without it). Thanks.
  15. Yup. Those are different blocks, for sure. Meta just won't display :C
  16. Could someone look if their block with variants (meta) has meta shown when in F3+H mode? Normal vanilla blocks look like e.g this: Diorite (#0001/3) My blocks (mod) are always displayed without meta: Name (#0200) I am sure they have meta, can't stack, whatever.
  17. Read about Java ClassLoader. Answer is a simple NO (it won't). Once classes are loaded nothing from outside changes them, only thing that can "mess" with anything is when you would reference .jar file directly and expect it to have something that it doesn't. As to assets - they will probably get reloaded (from new .jar) when you'd reload resources, but I am not sure. As to auto-reloading - it would be possible to reload whole .jar in runtime, but sadly MC/Forge are not designed to help you, so you probably can't.
  18. http://minecraft.gamepedia.com/Models Or just look into vanilla minecraft assets. It's not like this thing will come to you on its own. It's really easy once you dig into it for few hours. Useful stuff: http://www.minecraftforge.net/forum/index.php/topic,26267.0.html As to your question about any-side texture. You can do that. Read link (sounth, north, east, west, up, down). As to question what is parent - it's literally what it sound like - you can inherit some other model (parent) and apply your own textures onto textures (#texture) deifned in parent model. (Look wiki link: "Example: Any Block")
  19. Hey, this might be very lazy of me, but belive me I tried. Could you please share your repo/code of your TextureStitchEvent.Pre. I want to know how to add texture into sheet. Also - how to find it (the texture) later - talking ab out getting it. I'd really appreciate sharing (can be via priv msg if you want). I really don't know what is what in those atlases stuff and whatever else there it. Thanks.
  20. Don't do that man. Use Forges Configuration file. It REALLY is GOOD once you learn to use it, and allows you to do ANYTHING. Spend some time looking into it, worth it. As to finding path: public static File getMcDir() { if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDedicatedServer()) { return new File("."); } return Minecraft.getMinecraft().mcDataDir; } This will give you main MC folder - either main server folder or .minecraft for client.jar. Anything else is pure java. (Actulla above is too - pure java).
  21. MC Version? Mounting entity has offsets: public void updateRiderPosition() { if (this.riddenByEntity != null) { this.riddenByEntity.setPosition(this.posX, this.posY + this.getMountedYOffset() + this.riddenByEntity.getYOffset(), this.posZ); } } public double getYOffset() { return 0.0D; } public double getMountedYOffset() { return (double)this.height * 0.75D; } Your entity mounting player has probably bad height and/or offsets.
  22. use block/orientable (look furnace) { "parent": "block/orientable", "textures": { "top": "blocks/_top", "front": "blocks/_front", "side": "blocks/_side" } }
  23. Nice, thanks. Would you please validate my knowledge: getDescriptionPacket() and onDataPacket(...) are called initially when client loads tileEntity, only once. 1. When else is it being called and can I force it? receiveClientEvent() can be used to transport any integer to block/tileEntity. 2. Can/should it be called anywhere at any time? 3. I am guessing packet goes to everyone who loaded given BlockPos? 4. For any other synchronization I implement my own packet which will send x/y/z and data, or is there some other way I don't know about? 5. What exacly markDirty does? Tells Minecraft that chunk changed - what next? Is it "chunk changed, save it to disk" (still not sure)? 6. Should I know anything else regarding tileEntities (it's nice to know as much as possible)? Thanks
  24. You can't do that without replacing whole inventory. I was wrong. :C
  25. Block: public boolean onBlockEventReceived(World worldIn, BlockPos pos, IBlockState state, int eventID, int eventParam) { super.onBlockEventReceived(worldIn, pos, state, eventID, eventParam); TileEntity tileentity = worldIn.getTileEntity(pos); return tileentity == null ? false : tileentity.receiveClientEvent(eventID, eventParam); } TileEntity (example is from chest) public boolean receiveClientEvent(int id, int type) { if (id == 1) { this.numPlayersUsing = type; return true; } else { return super.receiveClientEvent(id, type); } } So there is this thing, used in few vanilla classes. Now, I tried to utilize it somehow, but didn't get far. onBlockEventReceived is never called, no matter what I do, same goes (obviously) for receiveClientEvent. Logically - they don't get called because there is no event for them to call. How to add event to block for those methods to use, I can't find any vanilla declaration. Also - how exacly does it work? Is it like: client performs some action with id and value and sends action to server or other way around, thet you can update client int values using those methods? This might be useful for e.g Buttons in my GuiContainer and/or sending changing values - depending on what does it do (the question above). Thanks.
×
×
  • Create New...

Important Information

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