-
Posts
2638 -
Joined
-
Last visited
-
Days Won
4
Everything posted by Ernio
-
[1.7.10] [Solved]Get held item in client-sided event
Ernio replied to Enders's topic in Modder Support
To add a bit of explanation (OP seems to not know). Minecraft is a combination of Client and Server thread (as of 1.8 also network threads). On Client.jar on SP you will have Client and Server thread. On MP Client.jar will only have Client thread, while the Server.jar will be handling Server thread. Client is (in most cases) a mirror of what server has. So basically server thread send data to all client threads connected to it and fills their data-vessels with same data it has. As long as you stay in sync your mc.thePlayer will have same data as server. -
Depends what event are you talking about. There are few (use, interact, mouse click, more...). Most of events are executed on both sides. Some are only on server and some will work only on client (and in most cases send info to server using vanilla packet). What exacly do you need?
-
Why are you overriding this: public ItemStack getIconItemStack(){ return new ItemStack(bloodyStone, 1, 0); } There is really no point unless you want to use metadata as your icon-definition. @Override public Item getTabIconItem() { return InitItems.bloodyStone; } Will make your bloodystone as tab icon. Also - is bloodyStone locally saved? (you have direct reference to it). Have look at super class (CreativeTabs).
-
Guy above is right. All cpw. packages are now in mcforge. Also - why @Mod.EventHandler? Use simple @EventHandler. Other than that - redesign your main class please and use proxy. Side.X is NOT reliable in all cases, and certainly shouldnt be used when you have neat proxy system right under your hand.
-
Oh my god, yes! For whole hour I've been getting closer to total rage, then I noticed: new ResourceLocation(InitUtil.ModID + ":" + "textures/skills/Fireball.png")); new ResourceLocation(InitUtil.ModID + ":" + "textures/skills/fireball.png")); (one letter) http://d24w6bsrhbeh9d.cloudfront.net/photo/aQqBE67_460sa.gif[/img] My face .__. Thanks, thread closed
-
I am still missing something. I'll try to explain best I can. 1 - How asset would look like if it would be loaded by mod itself. 2 - The Skill.jar location that is being dynamically class-loaded AND which contains assets required by this skill. 3 - How Skill.jar looks inside (assets). Now since, as you told me, if I'd put virtual IResourcePack (SkillFireball.jar in this case) into defaultResourcePacks, it should start working: List<IResourcePack> defaultResourcePacks = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao"); defaultResourcePacks.add(new SkillResourcePack(new File("C:/Users/Ernio/git/roa/RoA/Skills/SkillFireball.jar"))); But as far as I know (I am SURE OF IT) before I attempt on doing this: ResourceLocation fireball = new ResourceLocation(InitUtil.ModID + ":" + "textures/skills/Fireball.png"); I need to actually LOAD (refresh) resources, becaouse if I don't I will get this: [23:53:49] [Client thread/WARN]: Failed to load texture: roa:textures/skills/Fireball.png java.io.FileNotFoundException: roa:textures/skills/Fireball.png at net.minecraft.client.resources.FallbackResourceManager.getResource(FallbackResourceManager.java:70) ~[FallbackResourceManager.class:?] at net.minecraft.client.resources.SimpleReloadableResourceManager.getResource(SimpleReloadableResourceManager.java:67) ~[simpleReloadableResourceManager.class:?] at net.minecraft.client.renderer.texture.SimpleTexture.loadTexture(SimpleTexture.java:34) ~[simpleTexture.class:?] ......... Now - how do I do that? That is what is bugging me. Next reply will probably solve this thread or cause me to rage quit and go to sleep, in any case - thank you Note: I am not saying I wasn't alredy looking how MC loads resourcepacks, but that is being done on /resourcepacks/ directory. The only way I noticed is to make use of this: this.mcResourceManager.reloadResources(arraylist); where array is list of all resourcepacks. Is this the right way? (do I have to reload whole game-resources to get mine working)
-
FileResourcePack answers my Edit concerns (close() of zip). I have literally no idea what am I doing. public static void init() { List<IResourcePack> defaultResourcePacks = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao"); defaultResourcePacks.add(new SkillResourcePack(new File("C:/Users/Ernio/git/roa/RoA/Skills/SkillFireball.jar"))); } For one I know: [23:02:55] [Client thread/WARN]: Unable to parse metadata section of resourcepack: SkillFireball net.minecraft.client.resources.ResourcePackFileNotFoundException: 'pack.mcmeta' in ResourcePack 'C:\Users\Ernio\git\roa\RoA\Skills\SkillFireball.jar' at net.minecraft.client.resources.FileResourcePack.getInputStreamByName(FileResourcePack.java:49) ~[FileResourcePack.class:?] at net.minecraft.client.resources.AbstractResourcePack.getPackMetadata(AbstractResourcePack.java:66) ~[AbstractResourcePack.class:?] at net.minecraft.client.resources.LanguageManager.parseLanguageMetadata(LanguageManager.java:48) [LanguageManager.class:?] at net.minecraft.client.Minecraft.refreshResources(Minecraft.java:740) [Minecraft.class:?] at net.minecraftforge.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:306) [FMLClientHandler.class:?] at net.minecraft.client.Minecraft.startGame(Minecraft.java:484) [Minecraft.class:?] at net.minecraft.client.Minecraft.run(Minecraft.java:325) [Minecraft.class:?] at net.minecraft.client.main.Main.main(Main.java:117) [Main.class:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_11] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_11] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_11] at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.11.jar:?] at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.11.jar:?] at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:78) [start/:?] at GradleStart.main(GradleStart.java:45) [start/:?] That it is somewhat working. File structure: -SkillFireball.jar --com ----packages.with.code --assets ----fireball.png How can I work it so: private static ResourceLocation fireball = new ResourceLocation("something:fireball"); Will work? (or actually anything that is ResourceLoction will work). I just dont understand relations there. Sorry for questions, but this is first time I actually can't understand it on my own (trying) ;c
-
I honestly have very little idea on how to work with it. ;/ I don't quite understand the logic behind resource management. List<IResourcePack> defaultResourcePacks = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao"); This gives me the list and then I can: defaultResourcePacks.add(new MyIResourcePackImplementation()) But then what? For what I am aware (from vanilla) - whenever you want to add resource to game you have to realod resources. So i am assuming: 1. Load all Skill.jar 2. Get all .png files and save them in Map<String, File> 3. Create new MyIResourcePackImplementation(Map<String, File>) 4. Put MyIResourcePackImplementation into defaultResourcePacks using reflection code above. Do I need to actually create new MyIResourcePackImplementation everytime or can I simply make this object once and put there files one by one? Any neat explanation is appreciated. Just so I can get what is really happening there. Edit: Also - does MC store all resources as simple directory link and use them from HDD? In that case wouldn't I need to copy files from .jar to some non-zipped dir first (to not open infinite number of JarFiles)?
-
ClientCommandHandler.instance.registerCommand(new YourCommand());
-
http://www.minecraftforge.net/forum/index.php/topic,26267.0.html Everything on this issue (and I mean it) can be leraned from here. No success - post code/jsons next time.
-
[1.8] make my items work in a server. ¿ is my code wrong
Ernio replied to perromercenary00's topic in Modder Support
Minecraft.class is only for Client.jar. mc_server.jar doesn't have it, therefore you cannot referre to it (rendering and textures are client-side). Use proxies. http://www.minecraftforge.net/forum/index.php/topic,26267.0.html You will find some examples of basic mods and proxy "in action". -
[1.8] New Workbench question (and ideas needed!)
Ernio replied to pandaninjarawr's topic in Modder Support
As to "is it possible": http://www.minecraftforum.net/forums/mapping-and-modding/minecraft-mods/1286751-1-7-10-easy-crafting-automatic-crafting-table-one Difficult - for real Java coder it's just matter of time, for just begginer modder it will take hella lot of logic and drawing stuff (gui takes time). Mod in link has github, you might wanna check it out. -
[1.8] make my items work in a server. ¿ is my code wrong
Ernio replied to perromercenary00's topic in Modder Support
int tick=0; int texturajson=0; boolean tighten=false; boolean animacion=false; boolean continuar=false; float f=0.0F; int municion=0; int municionMax=0; You can't do that, Item is just a singleton, shared between all items that use this class. You need to store NBT in ItemStack of Item. http://www.minecraftforge.net/wiki/Creating_NBT_for_items -
1. Why would you REPLACE everything? You can render more stuff using RenderGameOverlayEvent http://www.minecraftforge.net/wiki/Gui_Overlay 2. To store additional data for players you need IEEP: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571567-1-7-2-1-6-4-eventhandler-and 2nd post. 3. To store copy of inv, you will need to use IEEP and copy ItemStack[] of player.inventory to custom field in your IEEP (also use write/read NBT) 4. Any data (your "power") requres packets in order to be shared between server and client: http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/2137055-1-7-2-customizing-packet-handling-with 5. This is going to be REALLY time-consuming if you never done it before. Also - don't do it if you doubt your skills in Java, this actually requires more than total basics (if you want to code it well and understand). Side-notes: - KeyBindings are client-side only, to notife server about pressing you also need to send packet. - Yes, most of 1.7.10 works for 1.8.
-
Posting code would be cool. You've got something wrong with itembullet obviously.
-
http://www.minecraftforge.net/forum/index.php/topic,26267.0.html
-
So some might remember I am loading skills from external skill.jar files in runtime using modClassLoader. Now i'd like to also load resources placed there, how could I archieve this? ResourceLoacetion allows me to only make modid:path. To be more precise: public static Skill loadSkill(File file) { JarFile jarFile = null; try { jarFile = new JarFile(file); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry element = entries.nextElement(); String name = element.getName(); if (name.endsWith(".png")) { resourceMap.put(name, new ResourceLocation(***element I just read***); //above is an example, I will be obviously storing resources to more advanced holders. ..... How do I make something like it work?
-
Big mistake: (accssing) Proper way: int w = event.resolution.getScaledWidth(); int h = event.resolution.getScaledHeight(); And again - you are doing it wrong. Rendering ANYTHING onto overlay SHOULD happen in GuiRenderGameOverlayEvent. http://www.minecraftforge.net/wiki/Key_Binding After you have you KeyBinding object , you can chk for it's "isPressed" or something like it. Then you can use this variable inside GRGOEvent. Inside that event (overlay), you call code I gave you above.
-
How to render the "capes" of a GuiScrollingList
Ernio replied to superbas11's topic in Modder Support
I told you few weeks ago (month probably) to look into GuiSlot. protected void overlayBackground(int p_148136_1_, int p_148136_2_, int p_148136_3_, int p_148136_4_) { ... } In 1.7.10 this method is private, you might have to copy whole base class. In 1.8 they changed it to protected. You might wanna exted given class (GuiSlot) or go further - GuiListExtended, or even implement your own drawing (again - look how GuiSlot does it). -
Every world has list of ALL entities. For server there is just no getter for it. For client (there is SideOnly annotation there) there is World#getLoadedEntityList() (might not be the exact name). Field is public so you can use it. List contains all loaded entities for given world, that is Entity - so consider that you will also get stuff like EntityItem.
-
Well, I can't see your code, but e.g GuiScrollingList is a java object like any other. You just have to initialize it and in GuiScreen.drawScreen() also do scrollingList.drawScreen(). Check out callback hierarchy of those classes - they are used by e.g forge mod-list, look into that code.
-
You can't do it like that. Best way would be to write you own gui class, BUT you can use some of this: GuiScrollingList (and it's subtypes) GuiListExtended (implementation) Main point here is to make scroller and amoutScrolled and render lines from amourScrolled to max visible range. You'll get the idea when you look at proposed classes.
-
1st of all - you need to do !world.isRemote before operation to make code run on server side. 2nd - code: MinecraftServer.getServer().worldServers[].setWorldTime(6006); Is not valid java code. You need to iterate (loop) through worlds.
-
[1.8] Render a Custom Overlay When Helmet is Equipped
Ernio replied to HassanS6000's topic in Modder Support
"ALSO! When I try to check if the armor (Helmet) is equipped (currently the commented out code), the game crashes." - Solution is to first take given slot (slots are ItemStacks array) and check if itemStack != null. Only after that you can get item from non-null ItemStack. Resizing will be simply HARD. If you'd accomplish it in any way, the results will be different on different clients and it might affect how your e.g map (bottom left) is displayed. I suggest auto-aligning image to center and smooth-transition to dark on corners if size is exceeded. In this case - have look at how vanilla renders viantage or how the close-to-worldd-border effect is being done (the red-shading on borders of screen). -
Actually I've done it, it was more lack of knowledge about ClassLoaders and how Java loads classes. skillClassLoader = URLClassLoader.newInstance(urls.toArray(new URL[urls.size()]), Loader.instance().getModClassLoader()); Loads skill.jar-s to child loader. //where name is url to this class file Class<?> clazz = Loader.instance().getModClassLoader().loadClass(name.substring(0, name.length() - 6).replaceAll("/", ".")); if (SkillCast.class.isAssignableFrom(clazz)) //do stuff I was badly accessing created classes. Problem solved. And how it works: Mod processes data and has API that allows you to make Skills. There are build-in set of skills (like fireballs, some other stuff, will be more with every update), but also if there is lack of something, some dev might wanna create new skill - and he can. Config allows you to without java interaction get ANY pre-made skill to be get and used to script custom one. Most of skills can still be made without any java interaction, API is only for advanced stuff and special rendering (which is also the reason I want to send skill.jar to client). Thread closed.