Jump to content

Recommended Posts

Posted

i am making sword which spawns lighting when attacks mob i know how to do this with older versions of minecraft but no ide how can i do this with 1.8.9

 

if someone can update this code

public boolean hitEntity(ItemStack par1ItemStack, EntityLiving par2EntityLiving, EntityLiving par3EntityLiving)
{
 fireEffect(3, par2EntityLiving);
 lightningEffect(par2EntityLiving);
 par1ItemStack.damageItem(1, par3EntityLiving);
 return true;
}
  
public void lightningEffect(EntityLiving par1EntityLiving)
{
 double x = par1EntityLiving.posX;
 double y = par1EntityLiving.posY;
 double z = par1EntityLiving.posZ;
 World world = par1EntityLiving.worldObj;
 EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z);
 lightning.setPosition(x, y + 1, z);
 world.spawnEntityInWorld(lightning);
}

Posted

That code will not work correctly even in older versions of Minecraft, so, don't lie.

 

You need to use addWeatherEffect to spawn lightning entities.

Woops. Looks like I'm doing this wrong, too, though it works just fine when I use it. I'll change it to use addWeatherEffect.

Posted

i updated my code i don't get any error but it don't seem to work either

	public ItemStack onItemRightClick(ItemStack par1ItemStack, World par1World, EntityPlayer par3EntityPlayer, double p_i1703_2_, double p_i1703_4_, double p_i1703_6_, EntityLivingBase par3EntityLivingBase)
	{

	par1World.addWeatherEffect(new EntityLightningBolt(par1World, p_i1703_2_, p_i1703_4_, p_i1703_6_));

	return par1ItemStack;
}

Posted

Item#onItemRightClick

doesn't have that signature, so you've created a new method that's never called instead of overriding the method that Minecraft calls.

 

Always add the

@Override

annotation to override methods so you get a compilation error if it doesn't actually override a super method. I suggest using your IDE to auto-generate override methods, this way the override method will always have the correct signature and the

@Override

annotation.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Item#onItemRightClick

doesn't have that signature, so you've created a new method that's never called instead of overriding the method that Minecraft calls.

 

Always add the

@Override

annotation to override methods so you get a compilation error if it doesn't actually override a super method. I suggest using your IDE to auto-generate override methods, this way the override method will always have the correct signature and the

@Override

annotation.

But it doesn't seem to like it

Posted

But it doesn't seem to like it

 

Be more specific. What doesn't like what? What's the error message and what part of the code is it for?

 

If

@Override

gives you a compilation error, the method doesn't override a super method.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

But it doesn't seem to like it

 

The signature you're looking for is:

public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)

 

but now game keep crashing when rig click

2016-03-05 20:17:13,858 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream

2016-03-05 20:17:13,859 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream

[20:17:13] [main/INFO] [GradleStart]: Extra: []

[20:17:13] [main/INFO] [GradleStart]: Running with arguments: [--userProperties, {}, --assetsDir, C:/Users/GIORGI/.gradle/caches/minecraft/assets, --assetIndex, 1.8, --accessToken{REDACTED}, --version, 1.8.9, --tweakClass, net.minecraftforge.fml.common.launcher.FMLTweaker, --tweakClass, net.minecraftforge.gradle.tweakers.CoremodTweaker]

[20:17:13] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker

[20:17:13] [main/INFO] [LaunchWrapper]: Using primary tweak class name net.minecraftforge.fml.common.launcher.FMLTweaker

[20:17:13] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.CoremodTweaker

[20:17:13] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLTweaker

[20:17:13] [main/INFO] [FML]: Forge Mod Loader version 11.15.1.1764 for Minecraft 1.8.9 loading

[20:17:13] [main/INFO] [FML]: Java is Java HotSpot 64-Bit Server VM, version 1.8.0_73, running on Windows 7:amd64:6.1, installed at C:\Program Files\Java\jre1.8.0_73

[20:17:13] [main/INFO] [FML]: Managed to load a deobfuscated Minecraft name- we are in a deobfuscated environment. Skipping runtime deobfuscation

[20:17:13] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.CoremodTweaker

[20:17:13] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.fml.relauncher.FMLCorePlugin

[20:17:13] [main/INFO] [GradleStart]: Injecting location in coremod net.minecraftforge.classloading.FMLForgePlugin

[20:17:13] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker

[20:17:13] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.FMLDeobfTweaker

[20:17:13] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.gradle.tweakers.AccessTransformerTweaker

[20:17:13] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker

[20:17:13] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLInjectionAndSortingTweaker

[20:17:13] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper

[20:17:14] [main/ERROR] [FML]: The binary patch set is missing. Either you are in a development environment, or things are not going to work!

[20:17:14] [main/ERROR] [FML]: FML appears to be missing any signature data. This is not a good thing

[20:17:14] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.relauncher.CoreModManager$FMLPluginWrapper

[20:17:14] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.FMLDeobfTweaker

[20:17:15] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.gradle.tweakers.AccessTransformerTweaker

[20:17:15] [main/INFO] [LaunchWrapper]: Loading tweak class name net.minecraftforge.fml.common.launcher.TerminalTweaker

[20:17:15] [main/INFO] [LaunchWrapper]: Calling tweak class net.minecraftforge.fml.common.launcher.TerminalTweaker

[20:17:15] [main/INFO] [LaunchWrapper]: Launching wrapped minecraft {net.minecraft.client.main.Main}

2016-03-05 20:17:15,520 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream

2016-03-05 20:17:15,542 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream

2016-03-05 20:17:15,544 WARN Unable to instantiate org.fusesource.jansi.WindowsAnsiOutputStream

[20:17:15] [Client thread/INFO]: Setting user: Player501

[20:17:18] [Client thread/INFO]: LWJGL Version: 2.9.4

[20:17:18] [Client thread/WARN] [FML]: =============================================================

[20:17:18] [Client thread/WARN] [FML]: MOD HAS DIRECT REFERENCE System.exit() THIS IS NOT ALLOWED REROUTING TO FML!

[20:17:18] [Client thread/WARN] [FML]: Offendor: com/sun/jna/Native.main([Ljava/lang/String;)V

[20:17:18] [Client thread/WARN] [FML]: Use FMLCommonHandler.exitJava instead

[20:17:18] [Client thread/WARN] [FML]: =============================================================

[20:17:19] [Client thread/INFO] [sTDOUT]: [net.minecraftforge.fml.client.SplashProgress:start:246]: ---- Minecraft Crash Report ----

// Shall we play a game?

 

Time: 05.03.16 20:17

Description: Loading screen debug info

 

This is just a prompt for computer specs to be printed. THIS IS NOT A ERROR

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- System Details --

Details:

Minecraft Version: 1.8.9

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.8.0_73, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 379422928 bytes (361 MB) / 642252800 bytes (612 MB) up to 1895825408 bytes (1808 MB)

JVM Flags: 0 total;

IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0

FML:

Loaded coremods (and transformers):

GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.4.0 NVIDIA 344.75' Renderer: 'GeForce GT 730/PCIe/SSE2'

[20:17:19] [Client thread/INFO] [FML]: MinecraftForge v11.15.1.1764 Initialized

[20:17:19] [Client thread/INFO] [FML]: Replaced 204 ore recipies

[20:17:19] [Client thread/INFO] [FML]: Found 0 mods from the command line. Injecting into mod discoverer

[20:17:19] [Client thread/INFO] [FML]: Searching C:\Users\GIORGI\Desktop\Modder\Modding 1.8.9\run\mods for mods

[20:17:20] [Client thread/INFO] [FML]: Forge Mod Loader has identified 4 mods to load

[20:17:20] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, lm] at CLIENT

[20:17:20] [Client thread/INFO] [FML]: Attempting connection with missing mods [mcp, FML, Forge, lm] at SERVER

[20:17:21] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:LegendaryMod

[20:17:21] [Client thread/INFO] [FML]: Processing ObjectHolder annotations

[20:17:21] [Client thread/INFO] [FML]: Found 384 ObjectHolder annotations

[20:17:21] [Client thread/INFO] [FML]: Identifying ItemStackHolder annotations

[20:17:21] [Client thread/INFO] [FML]: Found 0 ItemStackHolder annotations

[20:17:21] [Client thread/INFO] [FML]: Configured a dormant chunk cache size of 0

[20:17:21] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Starting version check at http://files.minecraftforge.net/maven/net/minecraftforge/forge/promotions_slim.json

[20:17:21] [Client thread/INFO] [FML]: Applying holder lookups

[20:17:21] [Client thread/INFO] [FML]: Holder lookups applied

[20:17:21] [Client thread/INFO] [FML]: Injecting itemstacks

[20:17:21] [Client thread/INFO] [FML]: Itemstack injection complete

[20:17:21] [sound Library Loader/INFO]: Starting up SoundSystem...

[20:17:21] [Forge Version Check/INFO] [ForgeVersionCheck]: [Forge] Found status: AHEAD Target: null

[20:17:21] [Thread-9/INFO]: Initializing LWJGL OpenAL

[20:17:21] [Thread-9/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)

[20:17:21] [Thread-9/INFO]: OpenAL initialized.

[20:17:22] [sound Library Loader/INFO]: Sound engine started

[20:17:24] [Client thread/INFO] [FML]: Max texture size: 16384

[20:17:24] [Client thread/INFO]: Created: 16x16 textures-atlas

[20:17:25] [Client thread/INFO] [FML]: Injecting itemstacks

[20:17:25] [Client thread/INFO] [FML]: Itemstack injection complete

[20:17:25] [Client thread/INFO] [FML]: Forge Mod Loader has successfully loaded 4 mods

[20:17:25] [Client thread/INFO]: Reloading ResourceManager: Default, FMLFileResourcePack:Forge Mod Loader, FMLFileResourcePack:Minecraft Forge, FMLFileResourcePack:LegendaryMod

[20:17:25] [Client thread/INFO]: SoundSystem shutting down...

[20:17:25] [Client thread/WARN]: Author: Paul Lamb, www.paulscode.com

[20:17:25] [sound Library Loader/INFO]: Starting up SoundSystem...

[20:17:26] [Thread-11/INFO]: Initializing LWJGL OpenAL

[20:17:26] [Thread-11/INFO]: (The LWJGL binding of OpenAL.  For more information, see http://www.lwjgl.org)

[20:17:26] [Thread-11/INFO]: OpenAL initialized.

[20:17:26] [sound Library Loader/INFO]: Sound engine started

[20:17:28] [Client thread/INFO] [FML]: Max texture size: 16384

[20:17:29] [Client thread/INFO]: Created: 512x512 textures-atlas

[20:17:30] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id

[20:17:32] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id

[20:17:32] [server thread/INFO]: Starting integrated minecraft server version 1.8.9

[20:17:32] [server thread/INFO]: Generating keypair

[20:17:32] [server thread/INFO] [FML]: Injecting existing block and item data into this server instance

[20:17:32] [server thread/INFO] [FML]: Found a missing id from the world lm:DryBlock

[20:17:33] [server thread/INFO] [FML]: Applying holder lookups

[20:17:33] [server thread/INFO] [FML]: Holder lookups applied

[20:17:33] [server thread/INFO] [FML]: Loading dimension 0 (New World) (net.minecraft.server.integrated.IntegratedServer@37d242b4)

[20:17:33] [server thread/INFO] [FML]: Loading dimension 1 (New World) (net.minecraft.server.integrated.IntegratedServer@37d242b4)

[20:17:33] [server thread/INFO] [FML]: Loading dimension -1 (New World) (net.minecraft.server.integrated.IntegratedServer@37d242b4)

[20:17:33] [server thread/INFO]: Preparing start region for level 0

[20:17:34] [server thread/INFO]: Changing view distance to 12, from 10

[20:17:34] [Realms Notification Availability checker #1/INFO]: Could not authorize you against Realms server: Invalid session id

[20:17:35] [Netty Local Client IO #0/INFO] [FML]: Server protocol version 2

[20:17:35] [Netty Server IO #1/INFO] [FML]: Client protocol version 2

[20:17:35] [Netty Server IO #1/INFO] [FML]: Client attempting to join with 4 mods : lm@V 0.1,[email protected],[email protected],[email protected]

[20:17:35] [Netty Local Client IO #0/INFO] [FML]: [Netty Local Client IO #0] Client side modded connection established

[20:17:35] [server thread/INFO] [FML]: [server thread] Server side modded connection established

[20:17:35] [server thread/INFO]: Player501[local:E:345da086] logged in with entity id 312 at (-24.13766130674821, 67.0, 96.58274732771623)

[20:17:35] [server thread/INFO]: Player501 joined the game

[20:17:36] [pool-2-thread-1/WARN]: Couldn't look up profile properties for com.mojang.authlib.GameProfile@6fc00ce2[id=c6d05243-c020-3d93-ad43-aa68ef2f4bcb,name=Player501,properties={},legacy=false]

com.mojang.authlib.exceptions.AuthenticationException: The client has sent too many requests within a certain amount of time

at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.makeRequest(YggdrasilAuthenticationService.java:65) ~[YggdrasilAuthenticationService.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillGameProfile(YggdrasilMinecraftSessionService.java:175) [YggdrasilMinecraftSessionService.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:59) [YggdrasilMinecraftSessionService$1.class:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService$1.load(YggdrasilMinecraftSessionService.java:56) [YggdrasilMinecraftSessionService$1.class:?]

at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3524) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2317) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2280) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2195) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache.get(LocalCache.java:3934) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3938) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4821) [guava-17.0.jar:?]

at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4827) [guava-17.0.jar:?]

at com.mojang.authlib.yggdrasil.YggdrasilMinecraftSessionService.fillProfileProperties(YggdrasilMinecraftSessionService.java:165) [YggdrasilMinecraftSessionService.class:?]

at net.minecraft.client.Minecraft.func_181037_M(Minecraft.java:2915) [Minecraft.class:?]

at net.minecraft.client.resources.SkinManager$3.run(SkinManager.java:130) [skinManager$3.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_73]

at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_73]

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_73]

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_73]

at java.lang.Thread.run(Unknown Source) [?:1.8.0_73]

[20:17:37] [server thread/FATAL]: Error executing task

java.util.concurrent.ExecutionException: java.lang.NullPointerException

at java.util.concurrent.FutureTask.report(Unknown Source) ~[?:1.8.0_73]

at java.util.concurrent.FutureTask.get(Unknown Source) ~[?:1.8.0_73]

at net.minecraft.util.Util.runTask(Util.java:23) [util.class:?]

at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:736) [MinecraftServer.class:?]

at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:681) [MinecraftServer.class:?]

at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:159) [integratedServer.class:?]

at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:548) [MinecraftServer.class:?]

at java.lang.Thread.run(Unknown Source) [?:1.8.0_73]

Caused by: java.lang.NullPointerException

at net.minecraft.item.Item.getDamage(Item.java:939) ~[item.class:?]

at com.Legendary.mod.items.tools.LMLimoniteSword.onItemRightClick(LMLimoniteSword.java:26) ~[LMLimoniteSword.class:?]

at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:170) ~[itemStack.class:?]

at net.minecraft.server.management.ItemInWorldManager.tryUseItem(ItemInWorldManager.java:364) ~[itemInWorldManager.class:?]

at net.minecraft.network.NetHandlerPlayServer.processPlayerBlockPlacement(NetHandlerPlayServer.java:607) ~[NetHandlerPlayServer.class:?]

at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:70) ~[C08PacketPlayerBlockPlacement.class:?]

at net.minecraft.network.play.client.C08PacketPlayerBlockPlacement.processPacket(C08PacketPlayerBlockPlacement.java:10) ~[C08PacketPlayerBlockPlacement.class:?]

at net.minecraft.network.PacketThreadUtil$1.run(PacketThreadUtil.java:15) ~[PacketThreadUtil$1.class:?]

at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) ~[?:1.8.0_73]

at java.util.concurrent.FutureTask.run(Unknown Source) ~[?:1.8.0_73]

at net.minecraft.util.Util.runTask(Util.java:22) ~[util.class:?]

... 5 more

[20:17:38] [server thread/INFO]: Stopping server

[20:17:38] [server thread/INFO]: Saving players

[20:17:38] [server thread/INFO]: Saving worlds

[20:17:38] [server thread/INFO]: Saving chunks for level 'New World'/Overworld

[20:17:38] [server thread/INFO]: Saving chunks for level 'New World'/Nether

[20:17:38] [server thread/INFO]: Saving chunks for level 'New World'/The End

[20:17:39] [server thread/INFO] [FML]: Unloading dimension 0

[20:17:39] [server thread/INFO] [FML]: Unloading dimension -1

[20:17:39] [server thread/INFO] [FML]: Unloading dimension 1

[20:17:39] [Client thread/FATAL]: Unreported exception thrown!

java.lang.NullPointerException

at net.minecraft.item.Item.getDamage(Item.java:939) ~[item.class:?]

at com.Legendary.mod.items.tools.LMLimoniteSword.onItemRightClick(LMLimoniteSword.java:26) ~[LMLimoniteSword.class:?]

at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:170) ~[itemStack.class:?]

at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:471) ~[PlayerControllerMP.class:?]

at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1598) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2123) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080) ~[Minecraft.class:?]

at net.minecraft.client.Minecraft.run(Minecraft.java:380) [Minecraft.class:?]

at net.minecraft.client.main.Main.main(Main.java:116) [Main.class:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_73]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_73]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_73]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_73]

at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]

at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_73]

at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_73]

at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_73]

at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_73]

at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]

at GradleStart.main(GradleStart.java:26) [start/:?]

[20:17:39] [server thread/INFO] [FML]: Applying holder lookups

[20:17:39] [server thread/INFO] [FML]: Holder lookups applied

[20:17:39] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:612]: ---- Minecraft Crash Report ----

// But it works on my machine.

 

Time: 05.03.16 20:17

Description: Unexpected error

 

java.lang.NullPointerException: Unexpected error

at net.minecraft.item.Item.getDamage(Item.java:939)

at com.Legendary.mod.items.tools.LMLimoniteSword.onItemRightClick(LMLimoniteSword.java:26)

at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:170)

at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:471)

at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1598)

at net.minecraft.client.Minecraft.runTick(Minecraft.java:2123)

at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1080)

at net.minecraft.client.Minecraft.run(Minecraft.java:380)

at net.minecraft.client.main.Main.main(Main.java:116)

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:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

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.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)

at GradleStart.main(GradleStart.java:26)

 

 

A detailed walkthrough of the error, its code path and all known details is as follows:

---------------------------------------------------------------------------------------

 

-- Head --

Stacktrace:

at net.minecraft.item.Item.getDamage(Item.java:939)

at com.Legendary.mod.items.tools.LMLimoniteSword.onItemRightClick(LMLimoniteSword.java:26)

at net.minecraft.item.ItemStack.useItemRightClick(ItemStack.java:170)

at net.minecraft.client.multiplayer.PlayerControllerMP.sendUseItem(PlayerControllerMP.java:471)

at net.minecraft.client.Minecraft.rightClickMouse(Minecraft.java:1598)

 

-- Affected level --

Details:

Level name: MpServer

All players: 1 total; [EntityPlayerSP['Player501'/312, l='MpServer', x=-24,14, y=67,00, z=96,58]]

Chunk stats: MultiplayerChunkCache: 470, 470

Level seed: 0

Level generator: ID 00 - default, ver 1. Features enabled: false

Level generator options:

Level spawn location: -37,00,64,00,285,00 - World: (-37,64,285), Chunk: (at 11,4,13 in -3,17; contains blocks -48,0,272 to -33,255,287), Region: (-1,0; contains chunks -32,0 to -1,31, blocks -512,0,0 to -1,255,511)

Level time: 57660 game time, 6937 day time

Level dimension: 0

Level storage version: 0x00000 - Unknown?

Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false)

Level game mode: Game mode: survival (ID 0). Hardcore: false. Cheats: false

Forced entities: 125 total; [EntityChicken['Chicken'/313, l='MpServer', x=-20,97, y=64,00, z=71,34], EntityItem['item.item.egg'/314, l='MpServer', x=-19,90, y=64,00, z=69,66], EntityCreeper['Creeper'/315, l='MpServer', x=-5,88, y=13,00, z=67,22], EntityBat['Bat'/316, l='MpServer', x=-53,25, y=33,10, z=77,16], EntityChicken['Chicken'/317, l='MpServer', x=-29,28, y=64,00, z=53,41], EntityItem['item.item.egg'/318, l='MpServer', x=-20,28, y=64,52, z=56,19], EntityItem['item.item.egg'/319, l='MpServer', x=-28,20, y=64,11, z=53,09], EntitySkeleton['Skeleton'/320, l='MpServer', x=-41,50, y=13,00, z=56,50], EntityChicken['Chicken'/321, l='MpServer', x=-32,28, y=63,00, z=48,88], EntityChicken['Chicken'/322, l='MpServer', x=-36,75, y=63,00, z=43,99], EntitySkeleton['Skeleton'/323, l='MpServer', x=-67,50, y=14,00, z=79,50], EntityCreeper['Creeper'/324, l='MpServer', x=-75,03, y=27,00, z=71,34], EntitySkeleton['Skeleton'/325, l='MpServer', x=-52,50, y=28,00, z=56,50], EntityChicken['Chicken'/326, l='MpServer', x=2,59, y=65,00, z=51,38], EntityZombie['Zombie'/327, l='MpServer', x=-6,50, y=28,00, z=37,50], EntityZombie['Zombie'/328, l='MpServer', x=-69,50, y=25,00, z=55,50], EntityEnderman['Enderman'/329, l='MpServer', x=-75,50, y=21,00, z=57,50], EntityCreeper['Creeper'/330, l='MpServer', x=-82,31, y=15,00, z=75,38], EntityZombie['Zombie'/331, l='MpServer', x=-83,03, y=15,00, z=71,63], EntityZombie['Zombie'/332, l='MpServer', x=-86,50, y=20,00, z=67,50], EntityZombie['Zombie'/333, l='MpServer', x=-89,38, y=17,00, z=72,91], EntitySkeleton['Skeleton'/334, l='MpServer', x=-81,88, y=16,00, z=76,50], EntityBat['Bat'/335, l='MpServer', x=-80,75, y=20,10, z=70,25], EntityCreeper['Creeper'/336, l='MpServer', x=8,50, y=23,00, z=38,50], EntityCreeper['Creeper'/337, l='MpServer', x=8,94, y=20,00, z=46,44], EntitySkeleton['Skeleton'/338, l='MpServer', x=-75,50, y=15,00, z=34,50], EntityZombie['Zombie'/339, l='MpServer', x=-74,94, y=57,00, z=38,63], EntitySkeleton['Skeleton'/340, l='MpServer', x=-75,25, y=56,00, z=39,69], EntityChicken['Chicken'/341, l='MpServer', x=-69,38, y=64,00, z=34,41], EntityZombie['Zombie'/342, l='MpServer', x=20,41, y=21,00, z=35,31], EntityChicken['Chicken'/343, l='MpServer', x=21,33, y=65,00, z=29,72], EntityChicken['Chicken'/344, l='MpServer', x=42,06, y=62,70, z=58,91], EntityCow['Cow'/89, l='MpServer', x=-98,47, y=76,00, z=91,34], EntityZombie['Zombie'/346, l='MpServer', x=-77,50, y=49,00, z=27,50], EntitySkeleton['Skeleton'/90, l='MpServer', x=-104,16, y=19,00, z=165,28], EntityZombie['Zombie'/347, l='MpServer', x=49,50, y=31,00, z=60,50], EntityZombie['Zombie'/91, l='MpServer', x=-99,50, y=30,00, z=168,50], EntityChicken['Chicken'/348, l='MpServer', x=49,19, y=62,53, z=54,88], EntityBat['Bat'/92, l='MpServer', x=-96,25, y=20,63, z=176,72], EntityBat['Bat'/352, l='MpServer', x=-92,25, y=34,10, z=24,75], EntitySkeleton['Skeleton'/353, l='MpServer', x=-83,22, y=49,00, z=28,28], EntityCreeper['Creeper'/354, l='MpServer', x=-84,50, y=52,00, z=22,50], EntityCreeper['Creeper'/355, l='MpServer', x=-85,53, y=63,00, z=24,47], EntitySkeleton['Skeleton'/99, l='MpServer', x=-97,21, y=30,00, z=89,45], EntityChicken['Chicken'/356, l='MpServer', x=-84,50, y=70,00, z=25,50], EntityZombie['Zombie'/100, l='MpServer', x=-81,50, y=20,00, z=94,50], EntityZombie['Zombie'/101, l='MpServer', x=-93,50, y=31,00, z=90,50], EntityCreeper['Creeper'/102, l='MpServer', x=-87,50, y=44,00, z=106,48], EntitySpider['Spider'/103, l='MpServer', x=-87,50, y=43,00, z=98,50], EntitySquid['Squid'/104, l='MpServer', x=-81,44, y=61,67, z=103,53], EntitySkeleton['Skeleton'/361, l='MpServer', x=-103,31, y=12,70, z=20,28], EntityCreeper['Creeper'/113, l='MpServer', x=-69,50, y=15,00, z=86,50], EntityZombie['Zombie'/114, l='MpServer', x=-69,50, y=18,00, z=91,50], EntityCreeper['Creeper'/123, l='MpServer', x=-54,50, y=42,00, z=87,97], EntityCreeper['Creeper'/124, l='MpServer', x=-55,50, y=30,00, z=111,50], EntitySkeleton['Skeleton'/125, l='MpServer', x=-62,44, y=50,00, z=97,91], EntityCreeper['Creeper'/126, l='MpServer', x=-49,00, y=47,00, z=126,38], EntityZombie['Zombie'/127, l='MpServer', x=-51,88, y=45,00, z=140,69], EntityZombie['Zombie'/128, l='MpServer', x=-59,81, y=11,00, z=172,84], EntityBat['Bat'/129, l='MpServer', x=-53,34, y=34,85, z=166,36], EntitySpider['Spider'/140, l='MpServer', x=-34,72, y=40,91, z=88,78], EntitySkeleton['Skeleton'/141, l='MpServer', x=-32,47, y=59,00, z=93,06], EntityXPOrb['Experience Orb'/142, l='MpServer', x=-47,75, y=62,00, z=100,53], EntityItem['item.item.seeds'/143, l='MpServer', x=-39,75, y=63,00, z=110,47], EntityCreeper['Creeper'/144, l='MpServer', x=-47,03, y=29,00, z=119,59], EntityItem['item.item.seeds'/145, l='MpServer', x=-41,88, y=63,00, z=113,22], EntityBat['Bat'/146, l='MpServer', x=-37,75, y=29,10, z=128,50], EntityChicken['Chicken'/147, l='MpServer', x=-40,00, y=62,67, z=130,50], EntityEnderman['Enderman'/148, l='MpServer', x=-36,53, y=30,00, z=153,72], EntityZombie['Zombie'/149, l='MpServer', x=-41,50, y=32,00, z=167,50], EntityChicken['Chicken'/150, l='MpServer', x=-39,41, y=67,00, z=171,53], EntityCreeper['Creeper'/160, l='MpServer', x=-21,50, y=42,00, z=86,50], EntityChicken['Chicken'/161, l='MpServer', x=-19,41, y=66,00, z=91,38], EntityItem['item.item.egg'/162, l='MpServer', x=-22,16, y=66,00, z=89,81], EntityCreeper['Creeper'/163, l='MpServer', x=-17,44, y=16,00, z=98,03], EntityCreeper['Creeper'/164, l='MpServer', x=-28,97, y=25,00, z=123,44], EntityChicken['Chicken'/165, l='MpServer', x=-22,72, y=66,00, z=123,50], EntityBat['Bat'/166, l='MpServer', x=-22,34, y=24,10, z=137,75], EntityBat['Bat'/167, l='MpServer', x=-20,44, y=24,05, z=134,43], EntityXPOrb['Experience Orb'/168, l='MpServer', x=-21,47, y=63,00, z=142,91], EntityItem['item.item.egg'/169, l='MpServer', x=-28,31, y=63,00, z=138,56], EntityBat['Bat'/170, l='MpServer', x=-19,39, y=30,88, z=145,46], EntityXPOrb['Experience Orb'/171, l='MpServer', x=-21,19, y=63,00, z=144,41], EntityZombie['Zombie'/172, l='MpServer', x=-31,50, y=26,00, z=167,50], EntityZombie['Zombie'/173, l='MpServer', x=-29,91, y=32,00, z=164,50], EntityChicken['Chicken'/185, l='MpServer', x=-2,47, y=74,00, z=96,63], EntityItem['item.item.egg'/186, l='MpServer', x=-1,78, y=74,00, z=96,13], EntityChicken['Chicken'/187, l='MpServer', x=-1,78, y=70,00, z=110,50], EntityItem['item.item.egg'/188, l='MpServer', x=-7,38, y=67,00, z=111,44], EntityZombie['Zombie'/189, l='MpServer', x=-1,88, y=20,00, z=144,31], EntityItem['item.item.rottenFlesh'/190, l='MpServer', x=-11,63, y=64,00, z=157,00], EntityXPOrb['Experience Orb'/191, l='MpServer', x=-1,31, y=69,00, z=187,41], EntityXPOrb['Experience Orb'/192, l='MpServer', x=-10,28, y=64,00, z=177,56], EntityCreeper['Creeper'/204, l='MpServer', x=8,50, y=68,00, z=93,91], EntityCreeper['Creeper'/205, l='MpServer', x=8,50, y=57,00, z=120,50], EntitySkeleton['Skeleton'/206, l='MpServer', x=10,06, y=56,00, z=124,53], EntityBat['Bat'/207, l='MpServer', x=0,50, y=21,10, z=139,25], EntityPlayerSP['Player501'/312, l='MpServer', x=-24,14, y=67,00, z=96,58], EntityChicken['Chicken'/214, l='MpServer', x=21,81, y=62,50, z=127,25], EntityItem['item.item.egg'/215, l='MpServer', x=20,97, y=62,00, z=126,72], EntityChicken['Chicken'/216, l='MpServer', x=23,28, y=62,72, z=139,31], EntityChicken['Chicken'/217, l='MpServer', x=27,88, y=62,59, z=149,56], EntityItem['item.item.egg'/218, l='MpServer', x=29,16, y=61,00, z=149,50], EntityXPOrb['Experience Orb'/220, l='MpServer', x=26,97, y=66,00, z=202,25], EntityXPOrb['Experience Orb'/221, l='MpServer', x=27,28, y=66,00, z=204,88], EntityXPOrb['Experience Orb'/222, l='MpServer', x=21,25, y=67,00, z=208,22], EntityBat['Bat'/226, l='MpServer', x=45,75, y=10,81, z=102,25], EntityChicken['Chicken'/227, l='MpServer', x=35,00, y=62,47, z=112,91], EntityChicken['Chicken'/228, l='MpServer', x=32,47, y=62,57, z=119,88], EntityChicken['Chicken'/229, l='MpServer', x=42,47, y=62,69, z=113,47], EntityItem['item.item.egg'/230, l='MpServer', x=32,44, y=62,00, z=120,00], EntityItem['item.item.egg'/231, l='MpServer', x=34,38, y=62,00, z=112,88], EntityZombie['Zombie'/232, l='MpServer', x=39,13, y=55,00, z=121,38], EntityZombie['Zombie'/233, l='MpServer', x=41,50, y=53,00, z=117,94], EntitySkeleton['Skeleton'/234, l='MpServer', x=42,59, y=30,00, z=142,88], EntityZombie['Zombie'/235, l='MpServer', x=46,34, y=32,00, z=137,91], EntityCreeper['Creeper'/236, l='MpServer', x=46,47, y=29,00, z=150,66], EntityCreeper['Creeper'/237, l='MpServer', x=46,50, y=29,00, z=151,50], EntityChicken['Chicken'/238, l='MpServer', x=36,34, y=62,63, z=155,16], EntityItem['item.item.egg'/239, l='MpServer', x=35,22, y=62,00, z=155,13], EntityCreeper['Creeper'/243, l='MpServer', x=52,50, y=28,00, z=122,50], EntityXPOrb['Experience Orb'/250, l='MpServer', x=52,66, y=66,00, z=187,47], EntityXPOrb['Experience Orb'/253, l='MpServer', x=59,03, y=64,00, z=227,72], EntityXPOrb['Experience Orb'/254, l='MpServer', x=57,72, y=64,00, z=229,69], EntityXPOrb['Experience Orb'/255, l='MpServer', x=60,31, y=64,00, z=227,72]]

Retry entities: 0 total; []

Server brand: fml,forge

Server type: Integrated singleplayer server

Stacktrace:

at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:383)

at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2645)

at net.minecraft.client.Minecraft.run(Minecraft.java:409)

at net.minecraft.client.main.Main.main(Main.java:116)

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:135)

at net.minecraft.launchwrapper.Launch.main(Launch.java:28)

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.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97)

at GradleStart.main(GradleStart.java:26)

 

-- System Details --

Details:

Minecraft Version: 1.8.9

Operating System: Windows 7 (amd64) version 6.1

Java Version: 1.8.0_73, Oracle Corporation

Java VM Version: Java HotSpot 64-Bit Server VM (mixed mode), Oracle Corporation

Memory: 278681800 bytes (265 MB) / 888143872 bytes (847 MB) up to 1895825408 bytes (1808 MB)

JVM Flags: 0 total;

IntCache: cache: 0, tcache: 0, allocated: 12, tallocated: 94

FML: MCP 9.19 Powered by Forge 11.15.1.1764 4 mods loaded, 4 mods active

States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored

UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar)

UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.8.9-11.15.1.1764.jar)

UCHIJAAAA Forge{11.15.1.1764} [Minecraft Forge] (forgeSrc-1.8.9-11.15.1.1764.jar)

UCHIJAAAA lm{V 0.1} [LegendaryMod] (bin)

Loaded coremods (and transformers):

GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.4.0 NVIDIA 344.75' Renderer: 'GeForce GT 730/PCIe/SSE2'

Launched Version: 1.8.9

LWJGL: 2.9.4

OpenGL: GeForce GT 730/PCIe/SSE2 GL version 4.4.0 NVIDIA 344.75, NVIDIA Corporation

GL Caps: Using GL 1.3 multitexturing.

Using GL 1.3 texture combiners.

Using framebuffer objects because OpenGL 3.0 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: No

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: 8x Intel® Core i7-4770 CPU @ 3.40GHz

[20:17:39] [Client thread/INFO] [sTDOUT]: [net.minecraft.init.Bootstrap:printToSYSOUT:612]: #@!@# Game crashed! Crash report saved to: #@!@# C:\Users\GIORGI\Desktop\Modder\Modding 1.8.9\run\.\crash-reports\crash-2016-03-05_20.17.39-client.txt

AL lib: (EE) alc_cleanup: 1 device not closed

 

 

Posted
java.lang.NullPointerException: Unexpected error

  at net.minecraft.item.Item.getDamage(Item.java:939)

  at com.Legendary.mod.items.tools.LMLimoniteSword.onItemRightClick(LMLimoniteSword.java:26)

 

A

NullPointerException

means that you tried to call a method or access a field of a null value.

 

If you look at

Item#getDamage

(line 939), the only value that's having a method called or a field accessed is the

stack

argument.

 

Item#getDamage

is being called with

null

as its argument from

LMLimoniteSword#onItemRightClick

(line 26).

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I tried this but it dosn't like blockx , blockY, blockZ i have no ide to do this other way

	@Override
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn) {
      
          {
        	   MovingObjectPosition objectMouseOver = playerIn.rayTrace(200, 1.0F);

   			if (objectMouseOver != null && objectMouseOver.typeOfHit == MovingObjectType.BLOCK) 
   			{
   				int x = objectMouseOver.blockX;
   				int y = objectMouseOver.blockY;
   				int z = objectMouseOver.blockZ;
   				
   				worldIn.addWeatherEffect(new EntityLightningBolt(worldIn, x, y, z));
        	   
           }
           return itemStackIn;

Posted

If you look at the

MovingObjectPosition

class in your IDE, you'll see that it doesn't have

blockX

/

Y

/

Z

fields. The position of the block that was hit is stored in the

blockPos

field as a

BlockPos

object which contains the individual coordinates.

 

Entity#rayTrace

is a client-only method, using it in common code like

Item#onItemRightClick

will crash the dedicated server. Use

ForgeHooks.rayTraceEyes

to ray-trace a custom distance, always ignoring liquids or use

Item#getMovingObjectPositionFromPlayer

to ray-trace the block reach distance (default is 5.0), optionally ignoring liquids.

 

Like regular entities, weather effects should only be spawned on the server (when

World#isRemote

is

false

).

 

Don't bump your thread, especially if it's still on the first page. People will respond when they have something to say, bumping will only annoy them.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I have no ide how to use ForgeHooks.rayTraceEyes

What do you not understand about it?

Please try to at least have an attitude of "I want to learn", not just "feed me my code", "no this doesn't work, give other".

 

i don't understend how to use ForgeHooks i tryed. if you have any tutorials about how to use it pls give it me. i am searching for tutorials to learn how to mod. but there are a few ones on 1.8.9. i didn't say this doesn't work give me other no i sayd i dont understend how to use it and i am searching for ways that i can use. i am traing to make sword that spawn lighting where ar you looking at when righ click i read tutorial about raytrac outdated one and tryd to update it.

Posted

it is same as raytrace ?

if so how to do that this code give

EntityLightningBolt lightning = new EntityLightningBolt(world, x, y, z);

x, and z cordinants if theare ar no blockX, blockY, blockZ

Posted

it is my problem i dont know java and eithrt don't know enough english to learn java so best way of coding for my is tutorials with codes or video tutorials  :-[

Posted

it is my problem i dont know java

This forum says that we don't teach Java here. Modders must find other Java help. I too started Forge modding without any Java experience. Nor had I ever used "reflection" in any language before. I invested two whole weeks immersed in the Minecraft source code before asking help here.

 

There are resources on the net for learning Java. Some Java tutorials might be in your language (search). Eclipse helps with Java too.

 

Eclipse also helps to trace code -- Learn to use Eclipse to find things like ForgeHooks.rayTraceEyes, and its parameters, and what it does.

 

 

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

Posted

i set up forgehooks.raytraceeyes look for vanila odes but can't figure out how i can get x y and z coords for spawning lightingbolt :C

 

ForgeHooks.rayTraceEyes

returns a

MovingObjectPosition

. I explained how to get the block position from the

MovingObjectPosition

in the same post I told you to use

ForgeHooks.rayTraceEyes

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

i set up forgehooks.raytraceeyes look for vanila odes but can't figure out how i can get x y and z coords for spawning lightingbolt :C

 

ForgeHooks.rayTraceEyes

returns a

MovingObjectPosition

. I explained how to get the block position from the

MovingObjectPosition

in the same post I told you to use

ForgeHooks.rayTraceEyes

.

But addWeatherEffect dosn't  like BlockPos

Posted

But addWeatherEffect dosn't  like BlockPos

 

You need to extract the individual x/y/z coordinates from the

BlockPos

. How about you look at

BlockPos

and its parent class to see how that can be done?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

I can't spoon feed you every piece of information. At some point, you're going to have to learn Java properly if you want to make a mod.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

most of information you give me i don't understend becouse my knowledge of english so can you just tell me what port of this code i need to use for my sword? best way for me to teach something is read proper code

 

package net.minecraft.util;

import com.google.common.collect.AbstractIterator;
import java.util.Iterator;
import net.minecraft.entity.Entity;

public class BlockPos extends Vec3i
{
    /** The BlockPos with all coordinates 0 */
    public static final BlockPos ORIGIN = new BlockPos(0, 0, 0);
    private static final int NUM_X_BITS = 1 + MathHelper.calculateLogBaseTwo(MathHelper.roundUpToPowerOfTwo(30000000));
    private static final int NUM_Z_BITS = NUM_X_BITS;
    private static final int NUM_Y_BITS = 64 - NUM_X_BITS - NUM_Z_BITS;
    private static final int Y_SHIFT = 0 + NUM_Z_BITS;
    private static final int X_SHIFT = Y_SHIFT + NUM_Y_BITS;
    private static final long X_MASK = (1L << NUM_X_BITS) - 1L;
    private static final long Y_MASK = (1L << NUM_Y_BITS) - 1L;
    private static final long Z_MASK = (1L << NUM_Z_BITS) - 1L;

    public BlockPos(int x, int y, int z)
    {
        super(x, y, z);
    }

    public BlockPos(double x, double y, double z)
    {
        super(x, y, z);
    }

    public BlockPos(Entity source)
    {
        this(source.posX, source.posY, source.posZ);
    }

    public BlockPos(Vec3 source)
    {
        this(source.xCoord, source.yCoord, source.zCoord);
    }

    public BlockPos(Vec3i source)
    {
        this(source.getX(), source.getY(), source.getZ());
    }

    /**
     * Add the given coordinates to the coordinates of this BlockPos
     */
    public BlockPos add(double x, double y, double z)
    {
        return x == 0.0D && y == 0.0D && z == 0.0D ? this : new BlockPos((double)this.getX() + x, (double)this.getY() + y, (double)this.getZ() + z);
    }

    /**
     * Add the given coordinates to the coordinates of this BlockPos
     */
    public BlockPos add(int x, int y, int z)
    {
        return x == 0 && y == 0 && z == 0 ? this : new BlockPos(this.getX() + x, this.getY() + y, this.getZ() + z);
    }

    /**
     * Add the given Vector to this BlockPos
     */
    public BlockPos add(Vec3i vec)
    {
        return vec.getX() == 0 && vec.getY() == 0 && vec.getZ() == 0 ? this : new BlockPos(this.getX() + vec.getX(), this.getY() + vec.getY(), this.getZ() + vec.getZ());
    }

    /**
     * Subtract the given Vector from this BlockPos
     */
    public BlockPos subtract(Vec3i vec)
    {
        return vec.getX() == 0 && vec.getY() == 0 && vec.getZ() == 0 ? this : new BlockPos(this.getX() - vec.getX(), this.getY() - vec.getY(), this.getZ() - vec.getZ());
    }

    /**
     * Offset this BlockPos 1 block up
     */
    public BlockPos up()
    {
        return this.up(1);
    }

    /**
     * Offset this BlockPos n blocks up
     */
    public BlockPos up(int n)
    {
        return this.offset(EnumFacing.UP, n);
    }

    /**
     * Offset this BlockPos 1 block down
     */
    public BlockPos down()
    {
        return this.down(1);
    }

    /**
     * Offset this BlockPos n blocks down
     */
    public BlockPos down(int n)
    {
        return this.offset(EnumFacing.DOWN, n);
    }

    /**
     * Offset this BlockPos 1 block in northern direction
     */
    public BlockPos north()
    {
        return this.north(1);
    }

    /**
     * Offset this BlockPos n blocks in northern direction
     */
    public BlockPos north(int n)
    {
        return this.offset(EnumFacing.NORTH, n);
    }

    /**
     * Offset this BlockPos 1 block in southern direction
     */
    public BlockPos south()
    {
        return this.south(1);
    }

    /**
     * Offset this BlockPos n blocks in southern direction
     */
    public BlockPos south(int n)
    {
        return this.offset(EnumFacing.SOUTH, n);
    }

    /**
     * Offset this BlockPos 1 block in western direction
     */
    public BlockPos west()
    {
        return this.west(1);
    }

    /**
     * Offset this BlockPos n blocks in western direction
     */
    public BlockPos west(int n)
    {
        return this.offset(EnumFacing.WEST, n);
    }

    /**
     * Offset this BlockPos 1 block in eastern direction
     */
    public BlockPos east()
    {
        return this.east(1);
    }

    /**
     * Offset this BlockPos n blocks in eastern direction
     */
    public BlockPos east(int n)
    {
        return this.offset(EnumFacing.EAST, n);
    }

    /**
     * Offset this BlockPos 1 block in the given direction
     */
    public BlockPos offset(EnumFacing facing)
    {
        return this.offset(facing, 1);
    }

    /**
     * Offsets this BlockPos n blocks in the given direction
     */
    public BlockPos offset(EnumFacing facing, int n)
    {
        return n == 0 ? this : new BlockPos(this.getX() + facing.getFrontOffsetX() * n, this.getY() + facing.getFrontOffsetY() * n, this.getZ() + facing.getFrontOffsetZ() * n);
    }

    /**
     * Calculate the cross product of this and the given Vector
     */
    public BlockPos crossProduct(Vec3i vec)
    {
        return new BlockPos(this.getY() * vec.getZ() - this.getZ() * vec.getY(), this.getZ() * vec.getX() - this.getX() * vec.getZ(), this.getX() * vec.getY() - this.getY() * vec.getX());
    }

    /**
     * Serialize this BlockPos into a long value
     */
    public long toLong()
    {
        return ((long)this.getX() & X_MASK) << X_SHIFT | ((long)this.getY() & Y_MASK) << Y_SHIFT | ((long)this.getZ() & Z_MASK) << 0;
    }

    /**
     * Create a BlockPos from a serialized long value (created by toLong)
     */
    public static BlockPos fromLong(long serialized)
    {
        int i = (int)(serialized << 64 - X_SHIFT - NUM_X_BITS >> 64 - NUM_X_BITS);
        int j = (int)(serialized << 64 - Y_SHIFT - NUM_Y_BITS >> 64 - NUM_Y_BITS);
        int k = (int)(serialized << 64 - NUM_Z_BITS >> 64 - NUM_Z_BITS);
        return new BlockPos(i, j, k);
    }

    public static Iterable<BlockPos> getAllInBox(BlockPos from, BlockPos to)
    {
        final BlockPos blockpos = new BlockPos(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()), Math.min(from.getZ(), to.getZ()));
        final BlockPos blockpos1 = new BlockPos(Math.max(from.getX(), to.getX()), Math.max(from.getY(), to.getY()), Math.max(from.getZ(), to.getZ()));
        return new Iterable<BlockPos>()
        {
            public Iterator<BlockPos> iterator()
            {
                return new AbstractIterator<BlockPos>()
                {
                    private BlockPos lastReturned = null;
                    protected BlockPos computeNext()
                    {
                        if (this.lastReturned == null)
                        {
                            this.lastReturned = blockpos;
                            return this.lastReturned;
                        }
                        else if (this.lastReturned.equals(blockpos1))
                        {
                            return (BlockPos)this.endOfData();
                        }
                        else
                        {
                            int i = this.lastReturned.getX();
                            int j = this.lastReturned.getY();
                            int k = this.lastReturned.getZ();

                            if (i < blockpos1.getX())
                            {
                                ++i;
                            }
                            else if (j < blockpos1.getY())
                            {
                                i = blockpos.getX();
                                ++j;
                            }
                            else if (k < blockpos1.getZ())
                            {
                                i = blockpos.getX();
                                j = blockpos.getY();
                                ++k;
                            }

                            this.lastReturned = new BlockPos(i, j, k);
                            return this.lastReturned;
                        }
                    }
                };
            }
        };
    }

    public static Iterable<BlockPos.MutableBlockPos> getAllInBoxMutable(BlockPos from, BlockPos to)
    {
        final BlockPos blockpos = new BlockPos(Math.min(from.getX(), to.getX()), Math.min(from.getY(), to.getY()), Math.min(from.getZ(), to.getZ()));
        final BlockPos blockpos1 = new BlockPos(Math.max(from.getX(), to.getX()), Math.max(from.getY(), to.getY()), Math.max(from.getZ(), to.getZ()));
        return new Iterable<BlockPos.MutableBlockPos>()
        {
            public Iterator<BlockPos.MutableBlockPos> iterator()
            {
                return new AbstractIterator<BlockPos.MutableBlockPos>()
                {
                    private BlockPos.MutableBlockPos theBlockPos = null;
                    protected BlockPos.MutableBlockPos computeNext()
                    {
                        if (this.theBlockPos == null)
                        {
                            this.theBlockPos = new BlockPos.MutableBlockPos(blockpos.getX(), blockpos.getY(), blockpos.getZ());
                            return this.theBlockPos;
                        }
                        else if (this.theBlockPos.equals(blockpos1))
                        {
                            return (BlockPos.MutableBlockPos)this.endOfData();
                        }
                        else
                        {
                            int i = this.theBlockPos.getX();
                            int j = this.theBlockPos.getY();
                            int k = this.theBlockPos.getZ();

                            if (i < blockpos1.getX())
                            {
                                ++i;
                            }
                            else if (j < blockpos1.getY())
                            {
                                i = blockpos.getX();
                                ++j;
                            }
                            else if (k < blockpos1.getZ())
                            {
                                i = blockpos.getX();
                                j = blockpos.getY();
                                ++k;
                            }

                            this.theBlockPos.x = i;
                            this.theBlockPos.y = j;
                            this.theBlockPos.z = k;
                            return this.theBlockPos;
                        }
                    }
                };
            }
        };
    }

    /**
     * Returns a version of this BlockPos that is guaranteed to be Immutable.
     * In most cases this will return 'this', but if 'this' is an instance of
     * MutableBlockPos it will return a new instance of BlockPos with the same values.
     *
     * When storing a parameter given to you for an extended period of time, make sure you
     * use this in case the value is changed internally.
     *
     * @return An immutable BlockPos.
     */
    public BlockPos getImmutable()
    {
        return this;
    }

    public static final class MutableBlockPos extends BlockPos
        {
            /** Mutable X Coordinate */
            private int x;
            /** Mutable Y Coordinate */
            private int y;
            /** Mutable Z Coordinate */
            private int z;

            public MutableBlockPos()
            {
                this(0, 0, 0);
            }

            public MutableBlockPos(int x_, int y_, int z_)
            {
                super(0, 0, 0);
                this.x = x_;
                this.y = y_;
                this.z = z_;
            }

            /**
             * Get the X coordinate
             */
            public int getX()
            {
                return this.x;
            }

            /**
             * Get the Y coordinate
             */
            public int getY()
            {
                return this.y;
            }

            /**
             * Get the Z coordinate
             */
            public int getZ()
            {
                return this.z;
            }

            /**
             * Set the values
             *  
             * @param xIn The X value
             * @param yIn The Y value
             * @param zIn The Z value
             */
            public BlockPos.MutableBlockPos set(int xIn, int yIn, int zIn)
            {
                this.x = xIn;
                this.y = yIn;
                this.z = zIn;
                return this;
            }

            @Override public BlockPos getImmutable() { return new BlockPos(this); }
        }
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Version 1.19 - Forge 41.0.63 I want to create a wolf entity that I can ride, so far it seems to be working, but the problem is that when I get on the wolf, I can’t control it. I then discovered that the issue is that the server doesn’t detect that I’m riding the wolf, so I’m struggling with synchronization. However, it seems to not be working properly. As I understand it, the server receives the packet but doesn’t register it correctly. I’m a bit new to Java, and I’ll try to provide all the relevant code and prints *The comments and prints are translated by chatgpt since they were originally in Spanish* Thank you very much in advance No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. No player is mounted, or the passenger is not a player. MountableWolfEntity package com.vals.valscraft.entity; import com.vals.valscraft.network.MountSyncPacket; import com.vals.valscraft.network.NetworkHandler; import net.minecraft.client.Minecraft; import net.minecraft.network.syncher.EntityDataAccessor; import net.minecraft.network.syncher.EntityDataSerializers; import net.minecraft.network.syncher.SynchedEntityData; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.Mob; import net.minecraft.world.entity.ai.attributes.AttributeSupplier; import net.minecraft.world.entity.ai.attributes.Attributes; import net.minecraft.world.entity.animal.Wolf; import net.minecraft.world.entity.player.Player; import net.minecraft.world.entity.Entity; import net.minecraft.world.InteractionHand; import net.minecraft.world.InteractionResult; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.level.Level; import net.minecraft.world.phys.Vec3; import net.minecraftforge.event.TickEvent; import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.network.PacketDistributor; public class MountableWolfEntity extends Wolf { private boolean hasSaddle; private static final EntityDataAccessor<Byte> DATA_ID_FLAGS = SynchedEntityData.defineId(MountableWolfEntity.class, EntityDataSerializers.BYTE); public MountableWolfEntity(EntityType<? extends Wolf> type, Level level) { super(type, level); this.hasSaddle = false; } @Override protected void defineSynchedData() { super.defineSynchedData(); this.entityData.define(DATA_ID_FLAGS, (byte)0); } public static AttributeSupplier.Builder createAttributes() { return Wolf.createAttributes() .add(Attributes.MAX_HEALTH, 20.0) .add(Attributes.MOVEMENT_SPEED, 0.3); } @Override public InteractionResult mobInteract(Player player, InteractionHand hand) { ItemStack itemstack = player.getItemInHand(hand); if (itemstack.getItem() == Items.SADDLE && !this.hasSaddle()) { if (!player.isCreative()) { itemstack.shrink(1); } this.setSaddle(true); return InteractionResult.SUCCESS; } else if (!level.isClientSide && this.hasSaddle()) { player.startRiding(this); MountSyncPacket packet = new MountSyncPacket(true); // 'true' means the player is mounted NetworkHandler.CHANNEL.sendToServer(packet); // Ensure the server handles the packet return InteractionResult.SUCCESS; } return InteractionResult.PASS; } @Override public void travel(Vec3 travelVector) { if (this.isVehicle() && this.getControllingPassenger() instanceof Player) { System.out.println("The wolf has a passenger."); System.out.println("The passenger is a player."); Player player = (Player) this.getControllingPassenger(); // Ensure the player is the controller this.setYRot(player.getYRot()); this.yRotO = this.getYRot(); this.setXRot(player.getXRot() * 0.5F); this.setRot(this.getYRot(), this.getXRot()); this.yBodyRot = this.getYRot(); this.yHeadRot = this.yBodyRot; float forward = player.zza; float strafe = player.xxa; if (forward <= 0.0F) { forward *= 0.25F; } this.flyingSpeed = this.getSpeed() * 0.1F; this.setSpeed((float) this.getAttributeValue(Attributes.MOVEMENT_SPEED) * 1.5F); this.setDeltaMovement(new Vec3(strafe, travelVector.y, forward).scale(this.getSpeed())); this.calculateEntityAnimation(this, false); } else { // The wolf does not have a passenger or the passenger is not a player System.out.println("No player is mounted, or the passenger is not a player."); super.travel(travelVector); } } public boolean hasSaddle() { return this.hasSaddle; } public void setSaddle(boolean hasSaddle) { this.hasSaddle = hasSaddle; } @Override protected void dropEquipment() { super.dropEquipment(); if (this.hasSaddle()) { this.spawnAtLocation(Items.SADDLE); this.setSaddle(false); } } @SubscribeEvent public static void onServerTick(TickEvent.ServerTickEvent event) { if (event.phase == TickEvent.Phase.START) { MinecraftServer server = net.minecraftforge.server.ServerLifecycleHooks.getCurrentServer(); if (server != null) { for (ServerPlayer player : server.getPlayerList().getPlayers()) { if (player.isPassenger() && player.getVehicle() instanceof MountableWolfEntity) { MountableWolfEntity wolf = (MountableWolfEntity) player.getVehicle(); System.out.println("Tick: " + player.getName().getString() + " is correctly mounted on " + wolf); } } } } } private boolean lastMountedState = false; @Override public void tick() { super.tick(); if (!this.level.isClientSide) { // Only on the server boolean isMounted = this.isVehicle() && this.getControllingPassenger() instanceof Player; // Only print if the state changed if (isMounted != lastMountedState) { if (isMounted) { Player player = (Player) this.getControllingPassenger(); // Verify the passenger is a player System.out.println("Server: Player " + player.getName().getString() + " is now mounted."); } else { System.out.println("Server: The wolf no longer has a passenger."); } lastMountedState = isMounted; } } } @Override public void addPassenger(Entity passenger) { super.addPassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(true)); } } } @Override public void removePassenger(Entity passenger) { super.removePassenger(passenger); if (passenger instanceof Player) { Player player = (Player) passenger; if (!this.level.isClientSide && player instanceof ServerPlayer) { // Send the packet to the server to indicate the player is no longer mounted NetworkHandler.CHANNEL.send(PacketDistributor.PLAYER.with(() -> (ServerPlayer) player), new MountSyncPacket(false)); } } } @Override public boolean isControlledByLocalInstance() { Entity entity = this.getControllingPassenger(); return entity instanceof Player; } @Override public void positionRider(Entity passenger) { if (this.hasPassenger(passenger)) { double xOffset = Math.cos(Math.toRadians(this.getYRot() + 90)) * 0.4; double zOffset = Math.sin(Math.toRadians(this.getYRot() + 90)) * 0.4; passenger.setPos(this.getX() + xOffset, this.getY() + this.getPassengersRidingOffset() + passenger.getMyRidingOffset(), this.getZ() + zOffset); } } } MountSyncPacket package com.vals.valscraft.network; import com.vals.valscraft.entity.MountableWolfEntity; import net.minecraft.network.FriendlyByteBuf; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; import net.minecraft.world.entity.Entity; import net.minecraft.world.entity.player.Player; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class MountSyncPacket { private final boolean isMounted; public MountSyncPacket(boolean isMounted) { this.isMounted = isMounted; } public void encode(FriendlyByteBuf buffer) { buffer.writeBoolean(isMounted); } public static MountSyncPacket decode(FriendlyByteBuf buffer) { return new MountSyncPacket(buffer.readBoolean()); } public void handle(NetworkEvent.Context context) { context.enqueueWork(() -> { ServerPlayer player = context.getSender(); // Get the player from the context if (player != null) { // Verifies if the player has dismounted if (!isMounted) { Entity vehicle = player.getVehicle(); if (vehicle instanceof MountableWolfEntity wolf) { // Logic to remove the player as a passenger wolf.removePassenger(player); System.out.println("Server: Player " + player.getName().getString() + " is no longer mounted."); } } } }); context.setPacketHandled(true); // Marks the packet as handled } } networkHandler package com.vals.valscraft.network; import com.vals.valscraft.valscraft; import net.minecraft.resources.ResourceLocation; import net.minecraftforge.network.NetworkRegistry; import net.minecraftforge.network.simple.SimpleChannel; import net.minecraftforge.network.NetworkEvent; import java.util.function.Supplier; public class NetworkHandler { private static final String PROTOCOL_VERSION = "1"; public static final SimpleChannel CHANNEL = NetworkRegistry.newSimpleChannel( new ResourceLocation(valscraft.MODID, "main"), () -> PROTOCOL_VERSION, PROTOCOL_VERSION::equals, PROTOCOL_VERSION::equals ); public static void init() { int packetId = 0; // Register the mount synchronization packet CHANNEL.registerMessage( packetId++, MountSyncPacket.class, MountSyncPacket::encode, MountSyncPacket::decode, (msg, context) -> msg.handle(context.get()) // Get the context with context.get() ); } }  
    • Do you use features of inventory profiles next (ipnext) or is there a change without it?
    • Remove rubidium - you are already using embeddium, which is a fork of rubidium
  • Topics

×
×
  • Create New...

Important Information

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