Jump to content

Tinker

Members
  • Posts

    26
  • Joined

  • Last visited

Everything posted by Tinker

  1. Hey again everyone, sorry it's been so long. Life got in the way of modding a bit. But here we go again, new problems. I'm now able to determine if the player has the correct rotation to be viewing the sun, which is great. Issue is, now I need to make sure they can actually see the sun. I'm trying to accomplish this through raytracing. I found this really useful piece of code on Jabelar's blog. MovingObjectPosition mop = Minecraft.getMinecraft().renderViewEntity.rayTrace(200, 1.0F); if(mop != null) { Block blockLookingAt = worldObj.getBlock(mop.blockX, mop.blockY, mop.blockZ) ; } Checking if the player is rotated towards the sun and that blockLookingAt is air is almost there. The only issue is transparent blocks: I want the player to be able to see the sun through glass, leaves, etc. So my question now, is there a way I can raytrace while ignoring certain blocks? Ex: if the trace encounters glass, pretend it didn't and keep on going? Thanks!
  2. Ill just send you a bit of code that I use whenever I get home. I know this is an older thread, but mind sharing that code with everyone if you can? I'm trying to solve this same problem.
  3. Thanks for the tip! I'm gonna give this a shot tonight and get back to you guys.
  4. Hello everyone, I'm about to undertake trying to detect whether or not the player is looking at the sun, within a certain degree of error. I want to spitball my ideas with all of you before I attempt to implement this, in case there's a much better way to do this or someone has already implemented it. My idea: using player.rotationPitch and rotationYaw, I can relatively easily correlate their look direction with the current time of day, obtained by player.worldObj.getWorldTime() % 24000. Experimentation will let me figure out what angles fit nicely with what times. I'm sure I could find something precise by looking at the render code for the actual sun's movement, but I honestly think it would take me longer to figure that one out than whip up some tables. I'm still not entirely sure if this is altitude-dependent or not. Next, I haven't really looked into it too much yet, but I think there's decent support for ray-tracing/getting the block the player is looking at. Basically, I need to make sure that the sun isn't obscured by a non-transparent block. Is this efficient/possible? This is the part I don't know how to do yet. Some obvious problems: if the player is underground in an enormous cave, the sun will still show up. Hence, it will probably be considered visible to them. But this is such an edge-case that I think I'd be fine just dealing with it. Has anyone else tried this? Does anyone have suggestions? Thanks!
  5. Hello Forge, I've made appeals for help on other modding threads related specifically to this API and Smart Moving, but since I've gotten such excellent support here in the past, it's worth a shot asking for help here too. The issue: I've created custom 3D armor models. When worn, they project their models appropriately and rotate as planned with the character. However, when running alongside Smart Moving, the items from my mod do not rotate or move with the new player model. They are stuck constantly facing north. The solution to this is reworking my mod to use the Render Player API, detailed in the thread here: http://www.minecraftforum.net/topic/1261354-172api-render-player-api/. However, there is no tutorial provided and the write-up is such that I can't really begin to make sense of this on my own... Is there anyone here who has worked with or is familiar with this API that could give me a brief tutorial or some guidance on how to adapt my mod for use with it? All of my source code for the plugin is here: https://github.com/TimTinkers/FractumArmor, if that would help anyone describe to me anything. Thanks!
  6. Ah, thank you. That makes things a lot clearer. I really appreciate you swooping to my rescue. Mod working, playing nicely with others, and ready to go again. Solved.
  7. Oh! I didn't even think to test it. The whole, "That would work the same." thing made me think it was just bad coding practice on my part. I'll give that a shot in the morning and come back with the results. Thanks a ton. Any reason why that one would work, while using .equals() wouldn't though? I'm just not understanding it from a Java perspective.
  8. @ForgeSubscribe public void onRenderingCoordinates(RenderGameOverlayEvent.Pre event) { if (event.type.equals(RenderGameOverlayEvent.ElementType.TEXT)) { event.setCanceled(true); } } This code has to be the problem. It's definitely not a fine enough comb to capture only the F3 menu rendering. Is there any way I can check to see which class triggered this event, and only act if it was GuiInGame? Deperate for help here. Thanks.
  9. Is there perhaps any way to disallow the user to rebind keys? If I can override what happens when F3 is pressed, without allowing my key to appear on the "Controls" tab, I can continue implementing this.
  10. Sadly I am not using the newest version of BattleGear, I'm developing for a 1.6.4 MCPC+ server. This is my event, in all its glorious simplicity: @ForgeSubscribe public void onRenderingCoordinates(RenderGameOverlayEvent.Pre event) { if (event.type.equals(RenderGameOverlayEvent.ElementType.TEXT)) { event.setCanceled(true); } } Is there anything I can do, working within the constraints of my version right now, to fix this? Thanks.
  11. I'm reopening my plea for help here...my mod is screwing with BattleGear 2 in how they both attempt to modify the GUI. This error is thrown whenever BattleGear 2 tries rendering its own GUI. As far as I can tell, there shouldn't be any conflict since I'm only canceling the TEXT pre event. But here's the error. java.lang.NullPointerException at us.teamtinker.hide.HideEventHandler.onRenderingCoordinates(HideEventHandler.java:10) at net.minecraftforge.event.ASMEventHandler_14_HideEventHandler_onRenderingCoordinates_Pre.invoke(.dynamic) at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:39) at net.minecraftforge.event.EventBus.post(EventBus.java:108) at mods.battlegear2.client.gui.BattlegearInGameGUI.renderGameOverlay(BattlegearInGameGUI.java:123) at mods.battlegear2.client.BattlegearClientEvents.postRenderOverlay(BattlegearClientEvents.java:55) at net.minecraftforge.event.ASMEventHandler_51_BattlegearClientEvents_postRenderOverlay_Post.invoke(.dynamic) at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:39) at net.minecraftforge.event.EventBus.post(EventBus.java:108) at net.minecraftforge.client.GuiIngameForge.post(GuiIngameForge.java:874) at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:212) at net.minecraftforge.client.GuiIngameForge.func_73830_a(GuiIngameForge.java:141) at net.minecraft.client.renderer.EntityRenderer.func_78480_b(EntityRenderer.java:1014) at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:946) at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:838) at net.minecraft.client.main.Main.main(SourceFile:101) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:131) at net.minecraft.launchwrapper.Launch.main(Launch.java:27) A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Stacktrace: at us.teamtinker.hide.HideEventHandler.onRenderingCoordinates(HideEventHandler.java:10) at net.minecraftforge.event.ASMEventHandler_14_HideEventHandler_onRenderingCoordinates_Pre.invoke(.dynamic) at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:39) at net.minecraftforge.event.EventBus.post(EventBus.java:108) at mods.battlegear2.client.gui.BattlegearInGameGUI.renderGameOverlay(BattlegearInGameGUI.java:123) at mods.battlegear2.client.BattlegearClientEvents.postRenderOverlay(BattlegearClientEvents.java:55) at net.minecraftforge.event.ASMEventHandler_51_BattlegearClientEvents_postRenderOverlay_Post.invoke(.dynamic) at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:39) at net.minecraftforge.event.EventBus.post(EventBus.java:108) at net.minecraftforge.client.GuiIngameForge.post(GuiIngameForge.java:874) at net.minecraftforge.client.GuiIngameForge.renderHotbar(GuiIngameForge.java:212) at net.minecraftforge.client.GuiIngameForge.func_73830_a(GuiIngameForge.java:141) Can anyone offer a bit of input? Thanks.
  12. Ah well, such is the price they pay for excellent survival servers. Thanks for all your help guys, couldn't have done it without you all.
  13. Ah, thank you all so much. Canceling the RenderGameOverlayEvent.Pre worked so much better. The plugin appears to be working as planned right now...and chat/signs/hotbar are all still functioning as expected. Just off the top of your collective heads, do any of you know of any definite drawbacks canceling all TEXT RenderGameOverlayEvents might cause, which I should be aware of? Thanks for all the help.
  14. Okay, I see that now. Thanks. Still having problems here though. package us.teamtinker.hide; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.event.ForgeSubscribe; public class HideEventHandler { @ForgeSubscribe public void onRenderingCoordinates(RenderGameOverlayEvent event) { if (event.type.equals(RenderGameOverlayEvent.ElementType.TEXT)) { event.setCanceled(true); } } } I have this event which hopefully cancels the rendering of the debug menu. None of the other sub-events I looked at seemed to apply to it. However, as soon as I attempt to load the world with this code in place, I get the following crash: java.lang.IllegalArgumentException: Attempted to cancel a uncancelable event 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraftforge.event.Event.setCanceled(Event.java:104) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at us.teamtinker.hide.HideEventHandler.onRenderingCoordinates(HideEventHandler.java:11) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraftforge.event.ASMEventHandler_5_HideEventHandler_onRenderingCoordinates_RenderGameOverlayEvent.invoke(.dynamic) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraftforge.event.ASMEventHandler.invoke(ASMEventHandler.java:39) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraftforge.event.EventBus.post(EventBus.java:108) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraftforge.client.GuiIngameForge.post(GuiIngameForge.java:874) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraftforge.client.GuiIngameForge.renderHUDText(GuiIngameForge.java:696) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraftforge.client.GuiIngameForge.renderGameOverlay(GuiIngameForge.java:155) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraft.client.renderer.EntityRenderer.updateCameraAndRender(EntityRenderer.java:1014) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:946) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraft.client.Minecraft.run(Minecraft.java:838) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraft.client.main.Main.main(Main.java:93) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at java.lang.reflect.Method.invoke(Unknown Source) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.launch(Launch.java:131) 2014-03-19 11:32:58 [iNFO] [sTDOUT] at net.minecraft.launchwrapper.Launch.main(Launch.java:27) So it looks like the TEXT sub-event is uncancelable. Is there anything I can do here?
  15. Thank you for your help so far, I'm definitely making progress. I've managed to properly setup the RenderGameOverlayEvent, and to cancel it. However, this stops the rendering of all GUIs on the screen--no pause menus, no hotbar, no inventory, nada. This is too indiscriminate for my purposes, although it does stop the use of F3. Is there any data I can pull from the event object which would allow me to cancel only the debug menu which appears when F3 is pressed? Or maybe a way in which I can cancel/uncancel the event when F3 is toggled?
  16. Is there no event for detecting whether or not a specific key is being pressed, and then canceling that accordingly? That definitely seems to be the simplest way I could solve this problem, but I'm not able to find any keyboard events defined anywhere.
  17. I'm sorry, then I'm just a little confused as to how that event could help me. What did you have in mind?
  18. Wouldn't cancelling the event in the GuiIngame class also cancel it from rendering its other components? I.e. things that aren't simply the debug menu?
  19. I don't even pretend to be familiar with Forge, coming from an entirely Bukkit background. So there's an event for pressing F3 that I can disable?
  20. Thanks for the tutorials guys. I'm running into a lot of trouble trying to get this running though...anyone able to help troubleshoot? package us.teamtinker.hide; import java.io.File; import java.util.Map; import cpw.mods.fml.relauncher.IFMLLoadingPlugin; public class CBFMLoadingPlugin implements cpw.mods.fml.relauncher.IFMLLoadingPlugin { public static File location; @Override public String[] getLibraryRequestClass() { // TODO Auto-generated method stub return null; } @Override public String[] getASMTransformerClass() { //This will return the name of the class "mod.culegooner.CreeperBurnCore.CBClassTransformer" return new String[]{CBClassTransformer.class.getName()}; } @Override public String getModContainerClass() { //This is the name of our dummy container "mod.culegooner.CreeperBurnCore.CBDummyContainer" return CBDummyContainer.class.getName(); } @Override public String getSetupClass() { // TODO Auto-generated method stub return null; } @Override public void injectData(Map<String, Object> data) { //This will return the jar file of this mod location = (File) data.get("coremodLocation"); System.out.println("*** Transformer jar location location.getName: " +location.getName()); } } package us.teamtinker.hide; import java.io.File; import java.io.InputStream; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import net.minecraft.launchwrapper.IClassTransformer; public class CBClassTransformer implements IClassTransformer { @Override public byte[] transform(String arg0, String arg1, byte[] arg2) { // Check if the JVM is about to process the te.class or the // EntityCreeper.class if (arg0.equals("avj") || arg0.equals("net.minecraft.client.gui.GuiIngame")) { System.out .println("********* INSIDE HIDE TRANSFORMER ABOUT TO PATCH: " + arg0); arg2 = patchClassInJar(arg0, arg2, arg0, CBFMLoadingPlugin.location); } return arg2; } // a small helper method that takes the class name we want to replace and // our jar file. // It then uses the java zip library to open up the jar file and extract the // classes. // Afterwards it serializes the class in bytes and pushes it on to the JVM. // with the original bytes that JVM was about to process ignored completly public byte[] patchClassInJar(String name, byte[] bytes, String ObfName, File location) { try { // open the jar as zip ZipFile zip = new ZipFile(location); // find the file inside the zip that is called avj.class or // net.minecraft.client.gui.GuiIngame.class // replacing the . to / ZipEntry entry = zip.getEntry(name.replace('.', '/') + ".class"); if (entry == null) { System.out .println(name + " not found in " + location.getName()); } else { // serialize the class file into the bytes array InputStream zin = zip.getInputStream(entry); bytes = new byte[(int) entry.getSize()]; zin.read(bytes); zin.close(); System.out.println("[" + "Hide Coordinates" + "]: " + "Class " + name + " patched!"); } zip.close(); } catch (Exception e) { throw new RuntimeException("Error overriding " + name + " from " + location.getName(), e); } // return the new bytes return bytes; } } package us.teamtinker.hide; import java.util.Arrays; import com.google.common.eventbus.EventBus; import com.google.common.eventbus.Subscribe; import cpw.mods.fml.common.DummyModContainer; import cpw.mods.fml.common.LoadController; import cpw.mods.fml.common.ModMetadata; import cpw.mods.fml.common.event.FMLConstructionEvent; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLPostInitializationEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; public class CBDummyContainer extends DummyModContainer { public CBDummyContainer() { super(new ModMetadata()); ModMetadata meta = getMetadata(); meta.modId = "HideCoords"; meta.name = "HideCoordsCore"; meta.version = "@VERSION@"; //String.format("%d.%d.%d.%d", majorVersion, minorVersion, revisionVersion, buildVersion); meta.credits = "Roll Credits ..."; meta.authorList = Arrays.asList("Tim Clancy"); meta.description = ""; meta.url = "www.teamtinker.us"; meta.updateUrl = ""; meta.screenshots = new String[0]; meta.logoFile = ""; } @Override public boolean registerBus(EventBus bus, LoadController controller) { bus.register(this); return true; } @Subscribe public void modConstruction(FMLConstructionEvent evt){ } @Subscribe public void init(FMLInitializationEvent evt) { } @Subscribe public void preInit(FMLPreInitializationEvent evt) { } @Subscribe public void postInit(FMLPostInitializationEvent evt) { } } Far as I know, these are the three things I need in order for the plugin to run...but testing it in Eclipse consistently throws the error: 2014-03-18 22:04:32 [sEVERE] [ForgeModLoader] Unable to launch java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:131) at net.minecraft.launchwrapper.Launch.main(Launch.java:27) Caused by: java.lang.NoClassDefFoundError: net/minecraft/client/gui/GuiIngame at net.minecraft.client.main.Main.main(Main.java:37) ... 6 more Caused by: java.lang.ClassNotFoundException: net.minecraft.client.gui.GuiIngame at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:186) at java.lang.ClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) ... 7 more Caused by: java.lang.ClassFormatError: Invalid code attribute name index 0 in class file net/minecraft/client/gui/GuiIngame at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.SecureClassLoader.defineClass(Unknown Source) at net.minecraft.launchwrapper.LaunchClassLoader.findClass(LaunchClassLoader.java:178) ... 9 more What could be the problem here? My .jar looks like this: META-INF - MANIFEST.MF (points to us.teamtinker.hide.CBFMLoadingPlugin as the main plugin loading class) us/teamtinker/hide/(the three classes located above) net/minecraft/client/gui/GuiIngame.class (containing my modifications) GuiIngame.class (also modified) avj.class (modified and obfuscated) I've been troubleshooting this all day, and you guys have been so helpful thus far in getting this project rolling with me. Anyone able to help shed some light?
  21. Thanks a bunch! Now, do you have any suggestions on how I could modify this class? Would I need to use ASM and learn how to make a coremod if I wanted to change it?
  22. Hello Forge, This is one of my first real undertakings with modding. I've done a lot of work with Bukkit and am familiar with Java though. My question is simply a lack of understanding on how I'd accomplish this. For my survival server, I'd like to add a mod to the modpack I'm distributing which disallows players from seeing their coordinates. The simplest way I thought of to do so is by disabling the debug menu which appears when F3 is pressed. If I disable all action linked to the button, the problem would be solved. However, I just have no idea where to find the code responsible for this in my 1.6.4 MCP workspace. I ran a search in Eclipse for "f3" and "F3" and nothing turned up. Is there anyone here more familiar with the Minecraft code who can point me in the right direction for figuring this out? Thanks.
  23. Hello everyone, I am trying to continue in the production of my mod that I define here, where it's first stumbling block is solved: http://www.minecraftforge.net/forum/index.php/topic,2958.msg20267.html#msg20267 Now I am trying to tackle the next one. What I need to do now is make it so that the standard "Water Bottle" item from vanilla Minecraft can be enchanted using the vanilla enchanting table, but that once it has been enchanted it changes into my custom item, "Philosophick Mercury," and gets the amount of experience points used to enchant it stored inside of it somehow. I think this is possible using NBT tags or something. As usual, my problem with everything regarding Forge is that there is simply not the amount of tutorials for it that can be found for ModLoader, and I simply do not know where to start working here. Any help would be appreciated, Thank you.
  24. That didn't work. I still get an invisible toss--sound plays, and you can see the glass shattering with the experience orbs a little ways off, but no bottle is seen flying through the air. EDIT: I've also been able to verify that doRender() is not being called from RenderSnowball when I do this. EDIT #2: I've solved this problem. What I had to do was, instead of merely adding what was suggested above, add all of this to my @Init method as well: EntityRegistry.registerModEntity(EntityPhilosophickMercuryBottle.class, "Philosophick Mercury", 1, instance, 64, 10, true); RenderingRegistry.registerEntityRenderingHandler( EntityPhilosophickMercuryBottle.class, new RenderSnowball( Item.expBottle.getIconFromDamage(0)));
  25. I'm a dipshit. This was supposed to go into General Discussion.
×
×
  • Create New...

Important Information

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