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. Bruh... Width = x, height = y.
  2. https://github.com/TheGreyGhost/MinecraftByExample If you are asking "what is proxy?" - think of it as a way to reference things that are not there. Some of fields/methods/classes are marked with SideOnly - that means thay will be loaded only by given side (Client.jar or Dedicated.jar). On other side they will be not loaded to VM which will result in NoClassDefFound when trying to access them with common code. That's why there are proxies - proxy will be setup for given side and can safely call SideOnly methods. All calls should be redirected there.
  3. Above and just maybe: For 1.7.10: IItemRenderer and GL (in your case kinda lot of it). 1.8+: ISmartItemModel (not sure about "I" at beginning) or any other interface + manipulating model registry. In both cases you could also utilize layers (but those can be only 5 last time I checked).
  4. Learn to read stacktrace - "at mimohad.helpfulmod.HelpFulMod.preInit(HelpFulMod.java:971)" Also: Since 1.7 item and block IDs are handled INTERNALLY and ANY attempt to manipulate them on your own WILL cause issues in future. You need to simply register: GameRegistry.registerBlock(instance, unlocalizedName); // same for item. Nothing more. IDs will be assigned internally on world creation - that said note that each world will most likely have different ID (based on order of registration).
  5. Container is something created when you need lookup on inventory, Inventory itself exists always (not counting few cases). You simply access inventory and check if item is in inventory.
  6. Your TE needs to implement IUpdatePlayerListBox.
  7. TickEvent. For player-based inventory: PlayerTickEvent. For mob-based: LivingUpdateEvent. Note: player is also living, you can use that. When using TickEvent, choose event.phase, otherwise code runs twice.
  8. Few things: 1. There is only one Item instance in whole game. You can't have any field there as they will be shared. 2. I might have been unclear with "Item+IInventory", sorry. You want rather separate implementations since as told - there is one Item per game, but there may be more inventories. You want to create inventory and fill it with data from ItemStack's NBT when you open your Container and make container display this inventory. I don't know why I didn't link this alredy: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571597-forge-1-6-4-1-8-custom-inventories-in-items-and
  9. Cancel model rendering with RenderPlayerEvent. Then render your own model (OBJ). OBJ model can be loaded with obj model loader - which I think is shipped with Forge in 1.7.10. You need some exp with GL. You probably want to extend RenderPlayer and just use it to render model.
  10. prevFoodLevel should exist AT LEAST on server and MAYBE on client (only if you need it). Not other way around. Read up about enum. You can save it as String or as byte/int. Then to read it you use Enum.valueOf (or other methods).
  11. That's why I said I wasn't seeing relation. You always HAVE TO assume that Client LIES! Client can be anything - it can be not even minecraft, it jut need to "act" like one. Said that - client-side anticheat is like a cake without flour (possible, but stupid, you get the idea). P.S: I might not be seeing big picture.
  12. http://www.minecraftforge.net/forum/index.php/topic,28516.msg146771.html#msg146771 As this was waaay back, now I can say I strongly support that response (while back then I just didn't care). As to if it is possible - it is with at least extensive knowledge about compilators. You would basically have to rewrite whole compilation process. Why is it "soo" hard? There is no static Forge-MC.jar that could play "library" part during obfuscation with external program like ProGuard since Forge and mods are being loaded during game startup. Have fun making this work. Waste of time and dick move as suggested in link. Edit: As to your "anticheat" - there is no logical explanation as to why you need to obfuscate mod to make anticheat better (what I'm saying is I don't see relation between obfuscation and the fact that it is anticheat mod). Anticheat can only be server-sided, you don't (and shouldn't) need client for that and certainly no obfuscation.
  13. Design with Item+IInventory, saving to ItemStack's NBT, showing with GuiContainer and Container.
  14. 1. WorldSaveData for world-specific saving (possibly global one). 2. Or own design with IO, CompressedStreamTools and WorldUnloadEvent. In this case 1. is preferred.
  15. I'd like to note that there is alredy method that has size args (...withCustomSize() or something). Since you are drawing container, I'd also like to note: (might come in handy) http://www.minecraftforge.net/forum/index.php/topic,31297.msg165510.html#msg165510
  16. In order to set Nashorn's permissions (to e.g have access only to packages of your choice) you need to create ClassFilter and apply it to "getScriptEngine(ClassFilter)" method that is ONLY available in nashorn's class (NashornScriptEngineFactory). It is officially stated that you can and should interact with NashornScriptEngineFactory in order to apply this kind of ClassFilter, BUT Forge Mod-loading system doesn't allow you to do so (don't ask me why :C), because who-knows-why - while nashorn's classes are loaded and working fine, Forge doesn't seem to recognise them (like they are not loaded). This doesn't allow you to apply ClassFilter, since ClassFilter is nashorn-specific.
  17. Anyway, seems like noone is remotely close (talking about non-forge forums) to solving this shit so here goes in-your-face-java way: public void initScriptEngine() { try { ClassLoader cl = Launcher.getLauncher().getClassLoader(); // sun.misc.Launcher, seems like only loader that has access to jdk.nashorn.* packages. Class<?> factoryClass = cl.loadClass("jdk.nashorn.api.scripting.NashornScriptEngineFactory"); Class<?> filterClass = cl.loadClass("jdk.nashorn.api.scripting.ClassFilter"); Class<?> jsFilterClass = cl.loadClass("something.ernio.core.script.JSClassFilter"); // I also have to load my own classes, since this class extends nashorn's package class and using it directly will also crash. ScriptEngineFactory sef = (ScriptEngineFactory) factoryClass.getConstructor().newInstance(); // Obvious thing to do. Method getScriptEngine = sef.getClass().getMethod("getScriptEngine", filterClass); Object filter = jsFilterClass.newInstance(); // Initialize my filter. this.scriptEngine = (ScriptEngine) getScriptEngine.invoke(sef, filter); // BOOM - da engine runz! } catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); // Obvious bad try-catch code is obvious. } } Note that while above gives what we want it to give, it is: 1. Almost badly coded; 2. I'd say rather not really secure; 3. WTF?! Note: I have no idea what can happen outside dev. env. - above is used as a fallback method of getting engine to work after trying to initialize it normal way. So yeah... thread is open if someone finds a way.
  18. God... those Bindings and Contextes are so confusing... @shadowfacts I just saw (your repo) you also started using the "way of Manager" (new ScriptEngineManager(null)). Does this mean that "NashornScriptEngineFactory" also doesn't work for you anymore? Because of that I now can't apply ClassFilter on ScriptEngine. Have you found any workarounds (without reflection)? I kinda feel like this (the problem) originates from MC/Forge because hell - I cannot replicate it anywhere outside Forge workspace.
  19. Question is too broad for you to get cover-all answer. Vanilla client is designed to be able to interpret data sent from server. Server loads/saves/computes data which is send to client to show to player, ANYTHING that client was not designed to do, well - can't be interpreted. Note that you can use client's code to represent something it was not directly designed to show. E.g: you can use vanilla GUIs to represent custom server inventories. Since client cannot interpret custom packets, you can only use vanilla ones. Server mods can do pretty much anything they want, problem is that clients wont be able to display it or even crash trying. E.g: Making custom entity in server mod would be problem since client wouldn't be able to spawn it locally (since it doesn't have it), BUT - with ASM you could edit server in a way to tell clients to spawn zombies as representation of custom entities with stats (health, speed, etc) set by server. But that still won't give you full experience sice not every entity is zombie-like (or other vanilla entity).
  20. There is no well-defined algorithm to do such thing. Although note that this issue could be adressed with D&C approach ( https://en.wikipedia.org/wiki/Divide_and_conquer_algorithms ), to gain maximum performance. jablelar answer was good, just saying. For example, structure like this: OXO XOXX OXO Could be defined as: OXO XOX + X in some direction from center+1 OXO
  21. I will send you to documentation (yes, read the comment in BlockEvent$HarvestDropsEvent class).
  22. It is bad practice to make new ItemStack just to compate items. Only case in which you could justify it would be compating whole Stacks (their NBT and size/damage). Also, in any case, that (what you did) won't work. "==" is instance comparing. Currently held item will be only ever equal to itself. If you want to compare it to other ItemStack instance you need to use .equals (note: idk if ItemStack uses equals ).
  23. Read aboud Forge Events. Use @SubscribeEvent to setup HarvestDropsEvent. Modify droplist (event.drops) depending on miner's tool (event.harvester). To get the tool you need to access inventory (held item): event.harvester.inventory.getCurrentItem(); Comparing item should be made on Item.class with "==" (items are singletons),e.g: ItemStack#getItem() == MyMod.mySuperPickaxeInstance Finally, post your code (what you tried) to get more help/tips.
  24. It was in dev, seems like problem is quite common (after googling). I will look into this later, for now - if anyone deals in JS/Nashorn - you could answer some of those: http://stackoverflow.com/questions/34239629/lifespan-of-code-loaded-with-nashorn-evalfile-string I honestly have too little exp in JS to be 100% sure just by reading documentations.
  25. @shadowfacts Did you have any problems with NoClassDefFound when trying to access Nashorn? You code: NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); scriptEngine = factory.getScriptEngine(new SJSClassFilter()); Would give me NCDF saying Nashorn is not loaded by ClassLoader (wtf?). I tried using ScriptEngineManager#getEngineByName("nashorn"); but that returned "null" - so basically, again, Nashorn was not loaded and not registered as engine. Then I managed to make it work with "new ScriptEngineManager(null)" - where null (god knows why) magically made everything work. Something to do with ClassLoaders obviously, but if anyone knows the deal, I'd be happy to hear it (tho issue is resolved?).

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.