-
Posts
2638 -
Joined
-
Last visited
-
Days Won
4
Everything posted by Ernio
-
[SOLVED][1.8] Shootable entity that heals living entities
Ernio replied to skyfir3's topic in Modder Support
Question tho - where exacly is your problem? Is it not healing or crashing? @Override protected void onImpact(MovingObjectPosition mop) { if (mop != null) { if (mop.entityHit instanceof EntityLivingBase) { EntityLivingBase entity = (EntityLivingBase) mop.entityHit; entity.heal(4.0F); } } } This doesn't work? -
Nope. You need to use vanilla/forge provided method/classes and Forge Events to manipulate anything. Second option is indeed CoreMod which requires super-advanced knowledge on Java (bytecode and said ASM) - sa have fun with that. Also - it is bad practice, since MOST of things CAN be done with Forge Events. What are you after?
-
get/setField is simple vanilla-provided abstraction layer over Tiles. It allows assigning integer to field with some id. You can use it to e.g set some "power" value insie TE using setField(idOfPowerField, value).
-
1.9 make use of item models that only exist in code
Ernio replied to UberAffe's topic in Modder Support
You can implement two? Idk, I am alredy on 1.9 where there are no longer any of those. I totally skipped 1.8.9 (meaning I didn't touch rendering knowing that it will change). And yeah - I suggest going to 1.9 directly, a lot of stuff has been replaced. -
Item - description of thing you are holding. ItemStack - thing you are holding. 1. Item simply CAN'T hold any data. Everything item can hold must be kept in ItemStack's NBT/damage/size. 2. You should NEVER, ever make "new" instance of Item outside init phase. That is simply wrong and will turn back on you in near future. 3. How I'd do it: interface IDraftable<T extends Item> which can be applied by you/users of API to make "special" Item singletons that can be handled by your system. Start implementing this interface to your base Item instances, e.g: ItemMeele. This Item instance will serve as something that can act upon data held in ItemStack's using this Item, by that I mean: - You hold ALL data in ItemStack which uses ItemMeele as definition, then in your ItemMeele you e.g: use Item#hitEntity and for-loop through list saved inside ItemStack's NBT looking for "special effects" - say - key "ignite" will mean that hit entity should be set on fire. This example is obviously super simple. As to rendering - you implement some (versions change a lot) IBakedModel that will take ItemStack and check its contends for proper NBT keys. There are 2 ways to go about it: 1. Define universal per-ItemStack format - meaning your IBakedModel will be able to handle any IDraftable: - Say you have: IDraftable#getAllQuads(ItemStack)) that will be called by IBakedModel to return all cubicals that should be rendered as Item. Those cubicals can be saved/read directly into/from ItemStack's NBT - so every stack can be different. 2. Also make this kind of format BUT. instead of making IDraftable#getAllQuads(ItemStack)), you can make IDraftable#getDraftableName(ItemStack)), meaning you will be returning String saved in ItemStack that points at NAME of alredy-generated model that can be saved in server and synced to clients on demand. Both ways have + and -: if you are saving every model into ItemStack it might get heavy on syncing, BUT - it will be always synced and saved and overally awesome. on the other hand if you would only make ItemStack save names that point at some registry of your alredy generated models you are light on packeting and data-saving, BUT you have to handle saving of models and syncing on your own (meaning you have to send model to clients whenever they connect to server and save them on server using WorldSavedData). Idk, how much of this "design" example you understand, but above is most flexible to go about it. Note: A lot of times I see draco posting links to his Artifacts mod and from what I know it does a lot around customization of ItemStacks, might be worth looking at.
-
When you render, you change GL states - just make sure you are getting back at proper state after rendering. 1. When using RenderGameOveralyEvent you ALWAYS need to pick event.type (otherwise you render multiple times per frame) - I suggest: ElementType.ALL. 2. RenderGameOveralyEvent has 2 subs - Pre and Post - Pre can be used to cancel renderings of vanilla/other mods, Post should/can be used for your stuff. Post rendering also (usually) guarantees that you "can't" really messup other renderings since you do it at the end - still - you will probably need to re-set GL attrubutes - to know which to what - see where this event is called and what attrisbs were there before (or you know - just print them). 3. Are you sure problem is code in question? (just make sure).
-
1.9 make use of item models that only exist in code
Ernio replied to UberAffe's topic in Modder Support
Are you asking how to assign custom model to Item? How do you know it's working if you never saw it working (you don't know how to use it)? -
I don't really have time to dig into that mod's forum/whatever, but you should find it. Look for either API or decompiled source. For source - just add it and you are fine. For API - throw it somewhere, go to Build Path -> "Libraries -> Add JARs.... Add API.jar. Then (as any API should) you can attach source to API (find it in list and add API-src.zip/jar. Any how-to can be found on google. Add dependency to your @Mod. @Mod(dependencies = "required-after:APIModID@[1.0.0.0,);") // adding @ defines "minimal version". There are also other dependency keys - google them. Above is how to get references to actual mod. If you want mod to just run in background - throw it into /mods/. Note - you should never do both (add to /mods/ and libraries) - it will attempts to load twice. Note: There were some changes in 1.8+ regarding running obfuscated mods - still in your case you need API/decomp src.
-
[1.9] How do I go about updating my mods from 1.8 to 1.9?
Ernio replied to Anon10W1z's topic in Modder Support
http://mcforge.readthedocs.org/en/latest/datastorage/capabilities/ https://github.com/MinecraftForge/MinecraftForge/blob/1.9/src/test/java/net/minecraftforge/test/TestCapabilityMod.java https://github.com/MinecraftForge/MinecraftForge/blob/1.9/src/test/java/net/minecraftforge/test/NoBedSleepingTest.java Give yourself time. Hour or two and you'll know everything. -
Okay after a break... So - while @NetworkCheckHandler is a nice tool to check if server, I am connecting to, has my mod (so I can disable (make if bool) all client-sided events if the server is not using mod) ...it is still not enough. I still need to figure out how to detect when you try to join Integrated server. Part on my CLIENT-ONLY mod: /** * Set to true if mod should be operational. * False cases: * - Client connected to integrated server. * - Client connected to server which doesn't have this mod. */ private static boolean OPERATIONAL; So yeah - @NetworkCheckHandler covers second "false case", but idk how to get 1st one before ANYTHING happens. Is there something NICE that is called before PlayerLoggedInEvent that would allow me to get "real" return from Minecraft.getMinecraft().isIntegratedServerRunning()? (by "real" I mean that apparently Integrated server is not really flushing. Meaning: If you would call it inside @NetworkCheckHandler it might or might not be true. Same goes for #getIntegratedServer() - it might or not return null or some instance (old one?). Awaiting
-
How can I use OpenGL directly in minecraft to draw a GUI?
Ernio replied to ManicMonkey's topic in Modder Support
https://en.wikibooks.org/wiki/OpenGL_Programming/GLStart/Tut3 Minecraft has a wrapper on GL that server you with "nice" (depends) vertex format that has ability to make nice texturing/colorizing/stuff. Anyway - when talking about GUIs - MC uses id=7 (look 1st link: GL_QUADS). All vertex formats that are shape (meaning non-line like GL_LINES) are expected to be drawn ANTI-CLOCKWISE. Mentioned "wrapper" for basic GL is (was) called Tesselator and currently all operations are in WorldRenderer (Tesselator.getInstance().getWorldRenderer()). All possible examples are placed in Gui.class (and few others). And yes - any other GL operations are possible/allowed during usage of WorldRenderer or not (it is really just a wrapper). EDIT "I also don't know how to transform the coordinate system correctly" I have no clue what you mean. top/left screen is 0/0. You just take some x/y and draw your stuff. Scaling is done automatically - depenging on GUISize - I am talking about that thing you can set in game options "large", "medium", "small", etc. , AND window scaling. There are cases where you might need manual scaling - this can be taken from ScaledResolution (lookup callbacks of this class - gives you direct examples). -
It doesn't work like that. You send packet (doesn't matter if client or server) - all you know is that you've sent it. The receiver might or might not receive it and even if it will - it might do nothing or it might return "response" packet. You can't return anything from packet, packet makes act. Proper (and only) way to handle it is to have field that will be set by packet. E.g: (total pseudo) onMessage(...) { message.player.setItemStackSomethwere(message.itemStack); //or world.setStackInSomeTile(x, y, z, slot, itemStack) // which will access Tile in x/y/z and try to set itemStack in some slot. }
-
"It doesn't work" says nothing. Always post full code on given case.
-
No, no, no, no, no... (batman ;p) I am not having problems with implementing actual caps, I am asking about adding my own handler. Where MC has: * Block + World (data) * Item + ItemStack * Entity * TileEntity I am adding: * Skill (can be "cast" by entity (+npc, player), world, block, tile, chunk, biome). * Effect (can be applied to entity (+player), world, block, tile, chunk, biome). ... which are totally new "kind" of data types. I want myself and others to be able to add Capabilities to those data types, so e.g they can attach additional values and/or event-calls to alredy-created Skills/Effects. (E.g: one mod implements "Freeze" effect (using my API) and other one attaches capability to it that not only it will act like author made it - freeze action of given holder (holder can be like said before - entity, block, tile, chunk, etc...), but also invoke anything a capability author (second one) wants to).
-
Hey again, some intro 1st: After some updates, I am rewiewing my code regarding Skills/Effects. Say we have 2 approaches of coding stuff in MC: * Multiple description singletons + one universal holder - in MC this system is used by ItemStack + Item. * Multiple classes using some hierarchy - here I am directly talking about Entities (each has own instance). My Skill/Effect system is based on a bit of both - you mainly code stuff like you do Entities (where additionally you can use shitload of listener interfaces to track anything any entity does when it is using/casting/anything given skill/effect). BUT - it also has simple wrapper that can be used toachieve Item/ItemStack -like system. This approach is nice when we are talking about writing Skills/Effects in Mod config where you can use other Entity-like coded skill as your base, but you can also hold additional data in ItemStack-like instance. Now to main thing: Since @Capability has been introduced I can't stop thinking about making my own Skill/Effect Capabilities attaching. My question/s: To this time when we wanted to have data in ItemStack we used NBT and manipulated it e.g: onUpdate() - that sadly was quite "slow" since if we would have tons of data in ItemStack, parsing it to "normal" values would take time (I am not talking about reading integer, I am talking about creating lots of objects from ItemStack NBT). Do I understand correctly - using @Capability we can read that NBT ONCE and hold it in capability instance of ItemStack, and then save it back, right? Okay - which classes/parts of code am I interested in if I wanted to make something similar for my Skills/Effects? And since @Mod != Forge/Vanilla code, will this even work? (I have no idea how Forge injects Caps to objects, not that I don't understand, I just didn't look that much).
-
1. You have 2 options: * Pack both sides into one @Mod and use @SidedProxy to load/invoke different code. * Make TWO @Mod-s and mark each one with "clientSideOnly = true" and/or "serverSideOnly = true" (look @Mod annotation). Then, you don't even have to use @SidedProxy but just code things straight away. Proxies and sides: http://mcforge.readthedocs.org/en/latest/concepts/sides/ 2.1. @NetworkCheckHandler 2.2. How does forge negotitate server configs to be loaded/override client settings. It DOESN'T! Configs (if exist) are loaded separately by client/server mod. When you are connected to server different than your own (integrated) you will be in de-sync (server will have different configs than you). Proper way to handle it is to send configs to client on @SubscribeEvent: PlayerLoggedInEvent using SimpleNetworkWrapper + IMessage. Links: http://www.minecraftforge.net/forum/index.php?topic=20135.0 + any google on Forge Events + Again: http://mcforge.readthedocs.org/en/latest/concepts/sides/
-
Yeah, cool, and your question is? Hint: This is modder support. This is not: * Java school * Mod request page
-
[SOLVED] [1.7.10] Maps and Lists clearing after startup
Ernio replied to Andavin's topic in Modder Support
CommandHandler extends CommandManager * Handler is supposed to act on data held in Manager * You are using e.g: if(!commands.contains(command)) The "commands" is an ArrayList that is currently in THIS CommandHandler (more precisely in Manager which you are extending). CommandRegistry extends CommandManager * Is yet another instance of Manager * This one actually holds your registered classes/data. You messed up this/other. UNLESS - Note: There is possibility that I am not seeing code that is responsible for actually being exact opposite of what I am saying above (meaning: I am wrong and you just provided too few classes, you should ALWAYS post @Mod class and proxies if they are used). EDIT PLEASE USE 'static" keyword! This will save you from instances and is much more prefered in this case. -
[1.9] drawTexturedModalRect and other such draw commands
Ernio replied to WaffleMan0310's topic in Modder Support
Well, there is normal, prefered way: Simply start drawing BG from x/y and end at u/v. It's REALLY simple math, just use your brain. Tricky way: Use GL to cut frame for you. GL11.glEnable(GL11.GL_SCISSOR_TEST); GL11.glScissor(x, y, w, h); // YOUR CODE (everything that should be cut). GL11.glDisable(GL11.GL_SCISSOR_TEST); Note that direct GL operation will need you to do some scaling stuff on those x,y,w,h params. This is what you can use: ScaledResolution res = new ScaledResolution(this.mc); double scaleW = this.mc.displayWidth / res.getScaledWidth_double(); double scaleH = this.mc.displayHeight / res.getScaledHeight_double(); Math I am leaving as exerice. EDIT But seriously - USE 1st one! -
With questions like that you should seriously consider using google. Every direct and somewhat common question (in this case - resource - which are used by every mod ever) is almost always answered somewhere on google. Anyway - each mod has Domain (modid) which directs to: resources folder. Basically you make this somewhere: public static final ResourceLocation txt = new ResourceLocation(ModID + ":" + "textures/gui/something.png"); This will point to: <src/main/resources>/assets/[modid]/textures/gui/something.png // Where <...> is part of workspace, I wrote it for (in)convenience. And you can sue "txt" as texture in #bindTexture().
-
[1.9] drawTexturedModalRect and other such draw commands
Ernio replied to WaffleMan0310's topic in Modder Support
Go to Gui.class and scroll alllllll the waaaayy down (few last methods) Oh... I forgot to answer questions... Okay 1st: All (?) vertex formats in GL are anti-clockwise. As to all other stuff... we need more direct question or at least "what you want" stuff -
[1.7.10] Really weird TileEntity lag issue [SOLVED]
Ernio replied to Tetawex's topic in Modder Support
Only thing I can think of is that you are changing world/block/tileEntity per tick. That is quite a lot (but still not that much). This shit: Foundry.updateBlockState(isBurning(), worldObj, xCoord, yCoord, zCoord); Aside from fact that method itself is quite badly written (that last if for example), the calling of this method is at least lame. Proper way to handle it: At start of Tile#update() you make local boolean flag = isBurning(), then you make all your logical changes which cause at some point that isBurning() will return other value than at start of method. Then at end of method you do if(flag != isBurning()) which means something just changed - and that is when you update block in world. Tho I doubt this can be that big of a problem (but knowing MC, it can) - I could guess that it happens just when block are next to each other because of light update maybe? Who knows... I seriously have no clue, and yeah - clean up your code. -
Check out literally any part of vanilla gui code. Rendering (GL): You can use GL directly or utilize Tesselator+WorldRenderer with nice vertex formats. Rendering (textures): First you bind texture using Minecraft#getTextureManager().bindTexture(ResourceLocation). Then you can draw it using Gui#drawTexturedModalRect(x, y, u, v, width, height). Do note that this method expects a .png ResourceLocation with size of multiple of 256. It will draw that .png on x/y coords (from top left) from u/v of .png file (from top/left) with width and height. Rendering Items/Blocks/Entities - for entities there is utility (lookup player inventory gui), for items and blocks you need to go into ItemRenderer, I don't remember right now. Point of interest: Useful methods re placed in Gui which you can extend and use. I personally rewritten them to be static and to accept RGBA and doubles.