
jgp22805
Members-
Posts
12 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
jgp22805's Achievements

Tree Puncher (2/8)
0
Reputation
-
Minecraft crashes when I try to run code to summon a lightning bolt
jgp22805 replied to jgp22805's topic in Modder Support
Do you have any suggestions for learning java -
Minecraft crashes when I try to run code to summon a lightning bolt
jgp22805 replied to jgp22805's topic in Modder Support
no not on the EntityPlayer just in general a lot of the variables were instantiated that way a lot of them were like: public static final ItemSword RUBY_SWORD = new ToolSword("ruby_sword", MATERIAL_RUBY); but I now understand what you mean by you can't just create another player and it is referring to the player that is right-clicking -
Minecraft crashes when I try to run code to summon a lightning bolt
jgp22805 replied to jgp22805's topic in Modder Support
okay so I was trying to do that before I started this thread but it gave me the error cannot instantiate the type entity player I was setting EntityPlayer player to new EntityPlayer, like so, EntityPlayer player = new EntityPlayer(); I am probably setting that wrong but throughout all of the mod tutorials that I have watched they were doing this a lot so I assumed that this is what I had to do so if I set it wrong can you please tell me what I did wrong. -
Minecraft crashes when I try to run code to summon a lightning bolt
jgp22805 replied to jgp22805's topic in Modder Support
by field do you mean like say static final and declaring variables like so? -
Minecraft crashes when I try to run code to summon a lightning bolt
jgp22805 replied to jgp22805's topic in Modder Support
getting rid of the code at the top stops it from crashing now because I used a combination of DavidM's and Draco18's advice by moving some of it into the method but when I play the mod the lightning doesn't work. And what does Animefan8888 mean when they say I never set the player field or any other fields? -
Minecraft crashes when I try to run code to summon a lightning bolt
jgp22805 replied to jgp22805's topic in Modder Support
DavidM I will try again but I believe I have tried that and it has not worked thus far. -
Minecraft crashes when I try to run code to summon a lightning bolt
jgp22805 replied to jgp22805's topic in Modder Support
I have just uploaded my workspace to GitHub. https://github.com/jgp22805/MinecraftForgeFirstModTest -
Minecraft crashes when I try to run code to summon a lightning bolt
jgp22805 replied to jgp22805's topic in Modder Support
I already learned something new, I did not know that it tells you what line caused the error so thanks already. -
Minecraft crashes when I try to run code to summon a lightning bolt
jgp22805 replied to jgp22805's topic in Modder Support
that would be this one float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; -
Minecraft crashes when I try to run code to summon a lightning bolt
jgp22805 replied to jgp22805's topic in Modder Support
that is the LightningBolt class that all of the code, in the beginning, is stored -
I got some code from an old thread on how to summon a lightning bolt in Minecraft forge and adjusted it to where I had no errors because some functions were named different things but even after that my game still crashes. Here is the code I am currently running: World world; EntityPlayer player; float f = 1.0f; float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; double d = (double)f; double d1 = player.prevPosX + (player.posX - player.prevPosX) * d; double d2 = (player.prevPosY + (player.posY - player.prevPosY) * d + 1.6200000000000001d) - (double)player.getYOffset(); double d3 = player.prevPosZ + (player.posZ - player.prevPosZ) * d; Vec3d vec1 = new Vec3d(d1, d2, d3); float f11 = MathHelper.cos(-f2 * 0.01745329f - 3.141593f); float f12 = MathHelper.sin(-f2 * 0.01745329f - 3.141593f); float f13 = -MathHelper.cos(-f1 * 0.01745329f); float f14 = MathHelper.sin(-f1 * 0.01745329f); float f15 = f12 * f13; float f16 = f14; float f17 = f11 * f13; double d11 = 5000d; Vec3d vec2 = vec1.addVector((double)f15 * d11, (double)f16 * d11, (double)f17 * d11); RayTraceResult position = world.rayTraceBlocks(vec1, vec2, false, true, true); public LightningBolt(String name, ToolMaterial material) { super(material); setUnlocalizedName(name); setRegistryName(name); setCreativeTab(CreativeTabs.COMBAT); ModItems.ITEMS.add(this); if (position != null) { if(Minecraft.getMinecraft().gameSettings.keyBindAttack.isPressed()) { int x = position.getBlockPos().getX(); int y = position.getBlockPos().getY(); int z = position.getBlockPos().getZ(); EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z, false); world.spawnEntity(lightning); } } } @Override public void registerModels() { Main.proxy.registerItemRenderer(this, 0, "inventory"); } here is the error I am getting: ---- Minecraft Crash Report ---- // I feel sad now :( Time: 8/14/19 9:28 PM Description: Initializing game java.lang.ExceptionInInitializerError at com.scream0228.FirstModTest.Blocks.BlockBase.<init>(BlockBase.java:25) at com.scream0228.FirstModTest.Blocks.RubyBlock.<init>(RubyBlock.java:12) at com.scream0228.FirstModTest.init.ModBlocks.<clinit>(ModBlocks.java:18) at com.scream0228.FirstModTest.util.handlers.RegistryHandler.onBlockRegister(RegistryHandler.java:30) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_RegistryHandler_onBlockRegister_Register.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:777) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252) at net.minecraft.client.Minecraft.init(Minecraft.java:513) at net.minecraft.client.Minecraft.run(Minecraft.java:421) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:25) Caused by: java.lang.NullPointerException at com.scream0228.FirstModTest.items.tools.LightningBolt.<init>(LightningBolt.java:38) at com.scream0228.FirstModTest.init.ModItems.<clinit>(ModItems.java:51) ... 26 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at com.scream0228.FirstModTest.Blocks.BlockBase.<init>(BlockBase.java:25) at com.scream0228.FirstModTest.Blocks.RubyBlock.<init>(RubyBlock.java:12) at com.scream0228.FirstModTest.init.ModBlocks.<clinit>(ModBlocks.java:18) at com.scream0228.FirstModTest.util.handlers.RegistryHandler.onBlockRegister(RegistryHandler.java:30) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_4_RegistryHandler_onBlockRegister_Register.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:144) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182) at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:777) at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:628) at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:252) at net.minecraft.client.Minecraft.init(Minecraft.java:513) -- Initialization -- Details: Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:421) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:25) -- System Details -- Details: Minecraft Version: 1.12.2 Operating System: Mac OS X (x86_64) version 10.14.5 Java Version: 1.8.0_221, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 774035592 bytes (738 MB) / 1038876672 bytes (990 MB) up to 1038876672 bytes (990 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP 9.42 Powered by Forge 14.23.5.2768 5 mods loaded, 5 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored | State | ID | Version | Source | Signature | |:----- |:--------- |:------------ |:-------------------------------- |:--------- | | UCH | minecraft | 1.12.2 | minecraft.jar | None | | UCH | mcp | 9.42 | minecraft.jar | None | | UCH | FML | 8.0.99.99 | forgeSrc-1.12.2-14.23.5.2768.jar | None | | UCH | forge | 14.23.5.2768 | forgeSrc-1.12.2-14.23.5.2768.jar | None | | UCH | fmt | 1.0 | bin | None | Loaded coremods (and transformers): GL info: ' Vendor: 'Intel Inc.' Version: '2.1 INTEL-12.9.22' Renderer: 'Intel HD Graphics 4000 OpenGL Engine' Launched Version: 1.12.2 LWJGL: 2.9.2 OpenGL: Intel HD Graphics 4000 OpenGL Engine GL version 2.1 INTEL-12.9.22, Intel Inc. GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because ARB_framebuffer_object is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: Current Language: English (US) Profiler Position: N/A (disabled) CPU: 4x Intel(R) Core(TM) i5-3210M CPU @ 2.50GHz I believe I have narrowed the error down to the top part of the code based on some commenting out some lines and trying to find the error but I have had no luck so far. Here is where I believe the error is occurring: World world; EntityPlayer player; float f = 1.0f; float f1 = player.prevRotationPitch + (player.rotationPitch - player.prevRotationPitch) * f; float f2 = player.prevRotationYaw + (player.rotationYaw - player.prevRotationYaw) * f; double d = (double)f; double d1 = player.prevPosX + (player.posX - player.prevPosX) * d; double d2 = (player.prevPosY + (player.posY - player.prevPosY) * d + 1.6200000000000001d) - (double)player.getYOffset(); double d3 = player.prevPosZ + (player.posZ - player.prevPosZ) * d; Vec3d vec1 = new Vec3d(d1, d2, d3); float f11 = MathHelper.cos(-f2 * 0.01745329f - 3.141593f); float f12 = MathHelper.sin(-f2 * 0.01745329f - 3.141593f); float f13 = -MathHelper.cos(-f1 * 0.01745329f); float f14 = MathHelper.sin(-f1 * 0.01745329f); float f15 = f12 * f13; float f16 = f14; float f17 = f11 * f13; double d11 = 5000d; Vec3d vec2 = vec1.addVector((double)f15 * d11, (double)f16 * d11, (double)f17 * d11); RayTraceResult position = world.rayTraceBlocks(vec1, vec2, false, true, true); If anyone is able to help that would be greatly appreciated thank you very much. p.s. here is the thread I was following: I have already tried to ask the question on there and someone told me to start a new thread so that is what I am doing. thank you
-
jgp22805 joined the community