Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Ernio

Forge Modder
  • Joined

  • Last visited

Everything posted by Ernio

  1. I am going to crucify you here a little bit, so sorry my friend. CAN YOU READ GODDAMIT?! (There is a NEED for heavier words here) You have almost step by step solution for problem at start of thread (quote above) and you still wonder what to do. And seriously people - you keep on throwing random ideas that are simply wrong in this case, and that only leads to confusing our friend (OP) here. I am speaking on behalf of proper way of solving this - how do expect e.g TossEvent to solve his problem? Rather: public void onEvent(EntityJoinedWorldEvent event) { //check if entity is EntityItem //check if EntityItem contains Blaze Rod //if it is Blaze Rod -> cancel spawning and spawn OTHER SpecialEntityItem //SpecialEntityItem is a extension of EntityItem with onUpdate() method overrided. //onUpdate() method has additional check for water. } class SpecialEntityItem extends EntityItem { //constructors and shit @Override public void onUpdate() { //Check for water/wetness //If true -> kill this entity and spawn new one. New one is EntityItem with Cooled Rod inside. }
  2. TickEvent's sub-events. Eventually LivingUpdateEvent. Acceleration is probably in Entity itself. I don't remember.
  3. 2. Tells you quite well what to do (been there, done that). 3. Also tells you quite well what to do. To be more helpful: You want to extends GuiInventory.class and: - Normally I'd say: "drawSlot" - but it's private, so that gives us bigger problems with hackier solutions: - Override "public void drawScreen(int mouseX, int mouseY, float partialTicks)". drawScreen handles a lot of stuff, which also includes calling this thing: for (int i1 = 0; i1 < this.inventorySlots.inventorySlots.size(); ++i1) { Slot slot = (Slot)this.inventorySlots.inventorySlots.get(i1); this.drawSlot(slot); /////////////////////////////////////////////// THIS THING! if (this.isMouseOverSlot(slot, mouseX, mouseY) && slot.canBeHovered()) { this.theSlot = slot; GlStateManager.disableLighting(); GlStateManager.disableDepth(); int j1 = slot.xDisplayPosition; k1 = slot.yDisplayPosition; GlStateManager.colorMask(true, true, true, false); this.drawGradientRect(j1, k1, j1 + 16, k1 + 16, -2130706433, -2130706433); GlStateManager.colorMask(true, true, true, true); GlStateManager.enableLighting(); GlStateManager.enableDepth(); } } So in your extending class you will want to literally copy drawScreen method from super class (mind that GuiInventory extends InventoryEffectRenderer extends GuiContainer which requires you to ALSO copy code from InventoryEffectRenderer#drawScreen). Then on stage of calling this.drawSlot, you will simply make a call to custom-made method that will be (literally) a copy of vanilla method (the private one) with small change as to what to render (add your string rendering there). As said - to actually replace Gui with another Gui you need to use proper event in which you will open your custom extension instead of vanilla. (search in client events, I don't remember exact event names, but somewhere aroung OpenGuiEvent). That's it. Similar logic goes with (2.) - look how GuiIngame (GuiIngameForge? I don't remember now.) handles hotbar. *Insta-read Draco's post* Goddamit, well-said (true that). But alredy wrote that shit above so here it goes. EDIT Oh and P.S: If you decide to go with ASM - yeah, you want to manipulate GuiContainer#drawSlot or replace call to it in GuiContainer#drawScreen with call to your custom method. (I mean, that would do nicely for all containers in game , but there are more cases).
  4. First things first: Toss event is NOT the right tool in this case. It will never cover all cases of item-dropping and suggested approach of making watcher entity is unnecessary performance hit (good outside box thinking when you didn't know Forge yet). As to why EntityItem would ever give you bad data: EntityConstructing, you wrote: EntityConstructing is called at end of Entity.class constructor. Logically - anything written in EntityItem constructor will not yet be accessible to this event. That includes "event.entity.getEntityItem()".
  5. 1. If you want items to render like that for any possible gui (mod or not) then only way would be to ASM vanilla rendering methods. 2. If you want to do this per-gui, e.g be ONLY rendering like that in GameOverlay (normal game view) then you would have to use RenderGameOverlay and cancel hotbar rendering, then basically re-render it yourself using vanilla-like methods (I mean - literally copy rendering methods and edit them to display additional stuff). 3. You can try tricks like that for any known gui (inventory, creative, furnace, workbench, etc...) by replacing its GUI with OpenGui event (not sure naming), but that will always require you to remake stuff and will be incomatybile with other mods that do similar. So basically - yeah: ASM (1) or not-fully-gratifying-simple-solution (2) or crazy-works-of-a-mad-man (3) (you don't want this). EDIT Additional note, since all that is not strongly backed by MC source. It might be that 2D item rendering methods are defined in instance object (meaning, they are not static). In that case you could replace (game startup) given object with your own extension that applies changes to some methods.
  6. TileEntity is assigned to block (e.g Furnace has TileEntityFurnace), you can't replace it without breaking stuff. I seriously don't understand your worrying about performance... Just make TileEntity handle additional interfaces. If you need separation between static and ticking ones - just make two of them.
  7. For vanilla items (Blaze Rod) you need to use EntityJoinedWorld event and if entity is EntityItem check if it is Blaze Rod. If so - cancel spawning (kill it) and spawn other entity. That other entity will be an extension to EntityItem with changes applied. You want to override onUpdate() method and check if item is wet or is in water (wet also check rain I think, there were some differences, you would just have to read some vanilla code). If so - again - kill item and spawn new one (normal EntityItem with your Cooled Blaze Rode). This covers logical side. If you have questions about coding it - look into vanilla for spawning codes or ask here.
  8. applyEntityAttributes() is called by super-constructor of this entity (in EntityLivingBase i think) at which time any global member of your object variable is not yet set (which happens after call to super(); ). Therefore at the time of calling applyEntityAttributes() your global this.maxHealth is 0.0D. Proper way to go about this is declare static baseMaxHealth for all entities or put value direclty in method (like test(10.0D); ).
  9. Because we still don't know what are you trying to do - I will encolse the idea in few words: TileEntity is a VERY simple idea - a list of objects in world assigned to some x/y/z where each tick, the world calls onUpdate() on TE that need it and save/load the list to/from memory on unload/load. If you really must (and there is no other way, because some stuff can be done on without any big tricks) you can reinvent the wheel and simply add second "TileEntity" layer with your own implementation. Can be done with WorldSaveData, Server/ClientTickEvent and some smart packet system. Been there, done that. So just saying as a last resort.
  10. Assuming you have quite some experience with mods/servers it is still hard to setup if not even impossible. You need to pick proper versions first - 1.8? The main problem is that both server (one) and client cannot just do what you want. If you would have one server with multiple worlds with different mods, the server will have to run all these mods and mods would have to allow per-world configuration (which almost none of them have). Even if that was possible for all your mods the client would have to have all of those mods installed which then gives next problem that client would display stuff (e.g items in creative inventory or some inventories from different mods) which are not currently allowed in world you are in (e.g no Pixelmon items in vanilla world). The only way to go about it is to setup Spigot hub (?) that allows any type of connection and then redirects to different server with specific mod. In this case you would have to setup multiple servers connected to hub. I can only speak from current Forge Modding side, I had too long break from administrating servers to know what changed. Google is probably your best friend - lookup bungecoord, spigot, cauldron, etc...
  11. Battle gear (2) is open source. And I don't really recommend it as a source of knowledge. Unless something changed - they are overhauling a lot of stuff there. Stay safe with forge hooks. Just cancel goddamn arm rendering and render new one. What is so hard (I should re-read thread, but can't now, so maybe I'll repost).?
  12. Where to hold mod-specific data is up to you to decide, but indeed - textures should be in ResourcePack. I don't know if it will seem more "proper" to you but it is entirely possible to have load multiple texturepacks at once, meaning: There is e.g global texturepack used by MC and there is additional one for your usage. You could simply create MyModSpecialTextures.zip in resourcepacks location and load it as additional resource. All contents of this zip will be treated like normal resource thus - you can use ResourceLocation in your code. To do that: (speaking code-wise only): Call this in init/postInit: List<IResourcePack> defaultResourcePacks = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao"); defaultResourcePacks.add(new SpecialResourcePack(new File("C:\Users\Me\AppData\Roaming\.minecraft\MyModSpecialTextures.zip"))); Minecraft.getMinecraft().refreshResources(); // Needs to be called. Implementation (you don't have to do that): @SideOnly(Side.CLIENT) public class SpecialResourcePack extends FileResourcePack { public SpecialResourcePack(File file) { super(file); } @Override public String getPackName() { return this.resourcePackFile.getName().replace(".zip", ""); } } Do note that you can also make your own IResourcePack and load files directly from file structure or any URL really.
  13. GODDAMIT MOON MOON! YELL warning, I will yell at you because you will never learn. NBTTagCompound works LIKE A MAP, but IS NOT A MAP. 1. Tell me - what are you expecting to get here? Iterator it = message.mapData.getKeySet().iterator(); // A KEY SET of String KEYS while(it.hasNext()) { Map.Entry<String, Float> pair = (Map.Entry<String, Float>)it.next(); // Suddenly an entry in String KEY set becomes a PAIR? seriously... 2. Why do you even need iterator? Why are you using remove? What is the point? 3. Working code: NBTTagCompound map = message.data.getCompoundTag("M"); for (Object o : map.getKeySet()) { String key = (String) o; Integer value = map.getInteger(key); // You need to KNOW what values you expect, in this case you want integer weights. } 4. Please, I beg you - use IDE sometimes, if there is no method like "getEntrySet" (and you want to have keys and values), you just think about how to make it - above is like obvious thing to do. 5. Grumble, grumble... <angry>
  14. Too much "sorrying" and thanking. (especially the 1st one). Anyway - yeah, you should most definitely read json once and put its proper contents (not every user-written stuff is "proper", 1stcheck if entry exists in item/block registry, if not - make some print warning) to actual Java Map. As stated before - map can be easily encoded to NBT (some may say that you should write straight to buffer, but that won't save you lots, still - "cutting middlemen" is often better) and then recreated on client.
  15. Bruh... Before stating a question, just think about it for a while. You need your client to have access to server-set configuration. Configuration is NOTHING more than data - good as ANY. It could be whole damn book or a goddamn dinosaur model - you don't care - it's all data. How do you synchronize data? You send it. How? Packets. Now the question is - do you want to send .json file and load it on client (same way server does it) or maybe you want to send data itself (alredy parsed by server). In any case - you just need to pack it all to packet and send it. In 1.8+ (or even earlier) packets server->client doen't even care about size (auto-splitted) - so that's a big plus, but back on track: I do belive you want to send that Map of item weights. Simple (clear) way would be to pack a Map into NBT and send it. Then read it on client and put it is the place that data normally would be. So yeah - just make a packet that sends NBTTagCompound to some player, and on receiver client - just read it. Simple design: NBTTagCompound is nothing less/more than a MAP. compound.setInteger( KEY, VALUE ) - can be literally used to literally encode a MAP. on client you just grab that NBTTagCompound and do compound.keySet() - on which you iterate and recreate a java Map from it. Where are all your problems coming from? BTW: What? You just send that packet with PlayerJoinedEvent (from server) or as suggested before - with other methods. PS. I belive you have my Skype so you can always call if you need (even) more help.
  16. Oh MY GOD, FALSE, this is 1.7.10. goddamn me, I should be more careful (sorry, 1.7.10 is so ancient I forgot to consider its existence *looks at OP with laser-eyes*). EDIT Yeah, basically below.
  17. Why do you ask what you alredy know? Just use the damn Comparator.
  18. Not to be rude, but have you considered actually learning how to use JSON? Any basic tutorial will give you proper introduction and rest can be easily found in docs or receive better help on StackOverflow. I am not saying anything bad but really - learn and understand is much better than "do this, do that". Might even come in handy if you'd ever expand outside MC. Please look into docs. As to current problem, you might want to use factory methods or actual Reader.
  19. Why is this method static? Where is it located? How do you call it? Show me your Food class, I belive you can simply return new ItemStack when you finish using food (eating it). If not return, just add new one when curren is done being eaten.
  20. There is not much to say here. Black hole should most certainly be an Entity (not a TileEntity like you wrote). You want to use its onUpdate method to gather entities around it and pull them into singularity's coords. To get entities you can use world.getEntitiesWithAABB (might not be exact name) or just grab world.entityList and check each against distance to black hole. Pulling is a matter of math, so "have fun" As to storing data - If you need your singularity to suck stuff and make it retrievable (meaning - it is 100% saved and can be pulled out from BH), then you want to implement IInventory and save it to Entity's (BH's) NBT. If not - simply destroy all EntityItems and other stuff and just add some number to counter (which will be field in BH's class. As to rendering and size - you need to make your own Renderer (extend it) and register it to entity. Then in renderer you can use you BH Entity's field (e.g: "magnitude" based on sucked stuff) to properly resize BH. As to containing BH with your stabilizer - simply check adjacent blocks (in onUpdate method) for your stabilizer. Do note that all onUpdate actions (especially checking blocks around) doesn't need to happen every tick, but in this case (since BH aren't exacly your common everyday thing), you can really use as much computation as you like. There is not really much to say here. Outside some GL rendering and vector Math, there is jsut basic entity modding.
  21. I seriously don't see all the fuss about what to use to read that shit up. Once read, data will be saved as java objects, loading happens once. Only debatable thing is whether you want user-input error handling. Why can't you just use Forge Config? Oh, wait, you can! What is better in .json? I'd say nothing, maybe slight difference in reading. But of all - .txt was the choice >.< As to how implement json - MC has gson library shipped within, you google how it works. It is really just a txt file with shitload of brackets and " " all over the place, fun to use when you actually need it. For configs - not so much (I don't really enjoy reading it, at least not those big ones).
  22. Not really hacking as long as it doesn't e.g: Mine stuff that is behind you, but yeah - that is at least botting and is just stupid... If you can code - checking out PlayerConroller will suffice, you will know what to do. Just to note out: you still won't be able to mine more than one block, nor mine with "long-range" or something, just saying, don't expect magic to happen. INSTA EDIT: 1. If it is for your server, why client-side only? 2. Noone can stop you, I can only say it is waste of time and 0 creativity. 3. Learn to read MC's code. It is very simple and will teach you much more than we here. In this case - seriously, you just have to look at Minecraft.class and find where input happens.
  23. Simply draw one in RenderGameOverlayEvent. You can extend Gui class for additional helper methods.
  24. Leave vanilla alone. You can do it with events (HarvestDropsEvent or something like that) by checking the event.player's currently equipped item and then adjusting drop list to your needs. Done.
  25. Create helper method that has lookup on static HashMap<String, Integer>, where string is "mod:name" and integer your weight. Fill this map on game startup using forge's Configuration file. To lear config files you literally have to look at some super-basic tutorial on how to setup it and then I'd recommed looking at other open source mods

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.