The Meaning of Life, the Universe, and Everything.
Location:
Colorado
Join Date:
3/27/2016
Posts:
208
Location:
Colorado
Minecraft:
ProfessorOro
Discord:
gargatheoro
PMC:
GargatheOro
Member Details
I want to be able to create a system to add weapon speed, weapon attack range (melee and ranged would be helpful), and set knock back.
For instance: Dagger has 3 block reach, high attack speed, and low knock back
Spear has 6 block reach, medium attack speed, and low knock back
Hammer has 4 block reach, low attack speed, and high knock back
Only problem is I do not know how, especially for 1.7.10. Can someone help me or give me a few base guide lines? Really the only thing IK how to do is what is posted on youtube.
Increasing knockback is pretty simple. In your item class, override the hitEntity method, then inside it, modify the entity's motion. For example:
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase wielder){
// Gets a vector of length 1 in the direction the player holding this item is looking
Vec3 look = wielder.getLookVec().normalize();
// Play around with this value until you get the amount of knockback you want
double knockback = 1.5;
// Adds velocity to the target
target.addVelocity(look.xCoord*knockback, look.yCoord*knockback, look.zCoord*knockback);
return true;
}
This probably won't be perfect, but it's a good start. Feel free to copy-paste, but make sure you know what it does, that's why I've included comments.
Range for a ranged weapon is just a case of changing the speed of the projectile. I'll let you figure out how to do that, it's very straightforward.
Reach for a melee weapon is a bit more difficult. To increase it, you'll have to use raytracing. To decrease it, I think you need to use AttackEntityEvent in net.minecraftforge.event.entity.player, then test if the player is holding your item, and if so check how far from the entity they are and cancel the event if they are too far away.
Weapon speed is irrelevant in 1.7.10 because the old combat system means you can spam-click as fast as you like with any weapon...
Increasing knockback is pretty simple. In your item class, override the hitEntity method, then inside it, modify the entity's motion. For example:
@Override
public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase wielder){
// Gets a vector of length 1 in the direction the player holding this item is looking
Vec3 look = wielder.getLookVec().normalize();
// Play around with this value until you get the amount of knockback you want
double knockback = 1.5;
// Adds velocity to the target
target.addVelocity(look.xCoord*knockback, look.yCoord*knockback, look.zCoord*knockback);
return true;
}
This probably won't be perfect, but it's a good start. Feel free to copy-paste, but make sure you know what it does, that's why I've included comments.
Range for a ranged weapon is just a case of changing the speed of the projectile. I'll let you figure out how to do that, it's very straightforward.
Reach for a melee weapon is a bit more difficult. To increase it, you'll have to use raytracing. To decrease it, I think you need to use AttackEntityEvent in net.minecraftforge.event.entity.player, then test if the player is holding your item, and if so check how far from the entity they are and cancel the event if they are too far away.
Weapon speed is irrelevant in 1.7.10 because the old combat system means you can spam-click as fast as you like with any weapon...
Thank you so much for the input, however I do not want spam clicking heavy weapons to be realistic on my medieval server. I don't think people back then were swinging hammers twice a second.
I can provide my class and stuff. I was fine until I got to the part that messes with packets. Got errors and stuff. Then the thing about a network gave me even more errors. Please help me. I know nothing about raytracing, or what it is.
Yeah that's a good tutorial, although there's some fairly advanced stuff in it!
I can provide my class and stuff. I was fine until I got to the part that messes with packets. Got errors and stuff. Then the thing about a network gave me even more errors. Please help me. I know nothing about raytracing, or what it is.
When you say error, do you mean an actual error in you development environment or does the game just crash? If it's a crash, a crash report would be useful, and please post all the classes used in that tutorial anyway, it will help me figure out what's wrong.
Also, this might have something to do with it:
Note: This tutorial has code for 1.8. For earlier versions, the same technique works but some method names may have changed.
Perhaps you just need to rename a few things?
Since you asked, raytracing = checking all the points along an imaginary line until you find one that's inside something, like a block or entity. In this case, the line starts at the player's head and goes in the direction they are looking. Luckily, you shouldn't have to worry about it because Jabelar has written it all for you in getMouseOverExtended.
By the way, did you get the other things working? As for reducing the weapon speed, you could use IExtendedEntityProperties to add in an attack cooldown for the player, then use events to reduce or cancel damage from your heavy weapons when it hasn't fully recharged.
Yeah that's a good tutorial, although there's some fairly advanced stuff in it!
When you say error, do you mean an actual error in you development environment or does the game just crash? If it's a crash, a crash report would be useful, and please post all the classes used in that tutorial anyway, it will help me figure out what's wrong.
Also, this might have something to do with it:
Perhaps you just need to rename a few things?
Since you asked, raytracing = checking all the points along an imaginary line until you find one that's inside something, like a block or entity. In this case, the line starts at the player's head and goes in the direction they are looking. Luckily, you shouldn't have to worry about it because Jabelar has written it all for you in getMouseOverExtended.
By the way, did you get the other things working? As for reducing the weapon speed, you could use IExtendedEntityProperties to add in an attack cooldown for the player, then use events to reduce or cancel damage from your heavy weapons when it hasn't fully recharged.
The class with the packet thing Jabelar described.
public static class Handler implements IMessageHandler<MessageExtendedReachAttack,
IMessage>
{
@Override
public IMessage onMessage(final MessageExtendedReachAttack message,
MessageContext ctx)
{
// DEBUG
System.out.println("Message received");
// Know it will be on the server so make it thread-safe
final EntityPlayerMP thePlayer = (EntityPlayerMP) Main.proxy.
getPlayerEntityFromContext(ctx);
thePlayer.getServerForPlayer().addScheduledTask(
new Runnable()
{
@Override
public void run()
{
Entity theEntity = thePlayer.worldObj.
getEntityByID(message.entityId);
// DEBUG
System.out.println("Entity = "+theEntity);
// Need to ensure that hackers can't cause trick kills,
// so double check weapon type and reach
if (thePlayer.getCurrentEquippedItem() == null)
{
return;
}
if (thePlayer.getCurrentEquippedItem().getItem() instanceof
IExtendedReach)
{
IExtendedReach theExtendedReachWeapon =
(IExtendedReach)thePlayer.getCurrentEquippedItem().
getItem();
double distanceSq = thePlayer.getDistanceSqToEntity(
theEntity);
double reachSq =theExtendedReachWeapon.getReach()*
theExtendedReachWeapon.getReach();
if (reachSq >= distanceSq)
{
thePlayer.attackTargetEntityWithCurrentItem(
theEntity);
}
}
return; // no response in this case
}
}
);
return null; // no response message
}
}
}
Below is my client proxy with the MouseEvent thing. I put this in the init handler method.
@SideOnly(Side.CLIENT)
@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
public void onEvent(MouseEvent event)
{
if (event.button == 0 && event.buttonstate)
{
Minecraft mc = Minecraft.getMinecraft();
EntityPlayer thePlayer = mc.thePlayer;
if (thePlayer != null)
{
ItemStack itemstack = thePlayer.getCurrentEquippedItem();
IExtendedReach ieri;
if (itemstack != null)
{
if (itemstack.getItem() instanceof IExtendedReach)
{
ieri = (IExtendedReach) itemstack.getItem();
} else
{
ieri = null;
}
if (aabb.isVecInside(pos))
{
if (0.0D < d || d == 0.0D)
{
pointedEntity = entity;
d = 0.0D;
}
} else if (mop0 != null)
{
double d1 = pos.distanceTo(mop0.hitVec);
if (d1 < d || d == 0.0D)
{
pointedEntity = entity;
d = d1;
}
}
}
}
if (pointedEntity != null && (d < calcdist || returnMOP == null))
{
returnMOP = new MovingObjectPosition(pointedEntity);
}
}
return returnMOP;
}
Put the following into the init of my Common Proxy:
int packetId = 0; // register messages from client to server Main.network.registerMessage(MessageExtendedReachAttack.Handler.class, MessageExtendedReachAttack.class, packetId++, Side.SERVER);
IExtendedReach Interface:
package com.GargatheOro.Weapons;
public interface IExtendedReach {
public float getReach(); // default is 1.0D
}
My weapon class:
package com.GargatheOro.Weapons;
import net.minecraft.item.ItemSword;
public class Alumaxe extends ItemSword implements IExtendedReach {
public Alumaxe(ToolMaterial p_i45356_1_) { super(p_i45356_1_); } @Override public float getReach() { return 5.0F; }}
Crash report, which the crash is this because it was working before I tried making the attack range:
---- Minecraft Crash Report -------- Minecraft Crash Report ----// Don't do that.
Time: 7/11/17 7:09 AMDescription: Initializing game
java.lang.StringIndexOutOfBoundsException: String index out of range: 6 at java.lang.String.charAt(Unknown Source) at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:232) at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:250) at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:245) at com.GargatheOro.Background.CraftingManager.addCraftingRec(CraftingManager.java:18) at com.GargatheOro.Background.CraftingManager.Main(CraftingManager.java:13) at com.GargatheOro.LichlandCore.Main.PreLoad(Main.java:35) 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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243) at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) at net.minecraft.client.Minecraft.run(Minecraft.java:942) at net.minecraft.client.main.Main.main(Main.java:164) 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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source)
A detailed walkthrough of the error, its code path and all known details is as follows:---------------------------------------------------------------------------------------
-- Head --Stacktrace: at java.lang.String.charAt(Unknown Source) at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:232) at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:250) at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:245) at com.GargatheOro.Background.CraftingManager.addCraftingRec(CraftingManager.java:18) at com.GargatheOro.Background.CraftingManager.Main(CraftingManager.java:13) at com.GargatheOro.LichlandCore.Main.PreLoad(Main.java:35) 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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243) at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)
-- Initialization --Details:Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:942) at net.minecraft.client.main.Main.main(Main.java:164) 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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source)
-- System Details --Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_121, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 592479032 bytes (565 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 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 UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCH FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UCH Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UCE lichlandcore{2.0.0} [Lichland Core Mod] (bin) GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13474 Compatibility Profile Context 22.19.162.4' Renderer: 'AMD Radeon (TM) R7 360 Series' Launched Version: 1.7.10 LWJGL: 2.9.1 OpenGL: AMD Radeon (TM) R7 360 Series GL version 4.5.13474 Compatibility Profile Context 22.19.162.4, ATI Technologies Inc. GL Caps: Using GL 1.3 multitexturing.Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.Anisotropic filtering is supported and maximum anisotropy is 16.Shaders are available because OpenGL 2.1 is supported.
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) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Anisotropic Filtering: Off (1)
Thank you for the help so far Electroblob. BTW your mod is awesome I made a wizardry modpack with it.
I'm sorry if I'm not much help on the extended reach weapons (I tried it for my mod, It's hard and I gave up... )
But as a tip for the spam clicking hammer, you could always call onUpdate() on your hammer and if it isSelected, you can create a mining fatigue potion effect preferably or a slowness effect. That might help you with one of the problems.
I'm sorry if I'm not much help on the extended reach weapons (I tried it for my mod, It's hard and I gave up... )
But as a tip for the spam clicking hammer, you could always call onUpdate() on your hammer and if it isSelected, you can create a mining fatigue potion effect preferably or a slowness effect. That might help you with one of the problems.
That is a good idea. I will use it unless something better is shared with me.
Mining fatigue.. now that's a good idea. Good thinking, AstroNoodles.
That crash report you posted has nothing to do with the weapon, instead it seems to have happened when registering a crafting recipe. Are you sure it's the right one? If it is the right crash report, then there's another error somewhere in your crafting recipes that needs fixing first, or you could just comment out the crafting recipes for the time being since they're not needed for testing the extended reach thing.
Other than that, I can't see anything wrong with your code, and since it's mostly copied from the tutorial there's no reason why it shouldn't work.
The Meaning of Life, the Universe, and Everything.
Location:
Colorado
Join Date:
3/27/2016
Posts:
208
Location:
Colorado
Minecraft:
ProfessorOro
Discord:
gargatheoro
PMC:
GargatheOro
Member Details
New crash report:
---- Minecraft Crash Report -------- Minecraft Crash Report ----// My bad.
Time: 7/15/17 10:47 AMDescription: There was a severe problem during mod loading that has caused the game to fail
cpw.mods.fml.common.LoaderException: java.lang.Error: Unresolved compilation problems: void is an invalid type for the variable onEvent Syntax error on token "(", ; expected Syntax error on token ")", ; expected The method getMouseOverExtended(float) is undefined for the type ClientProxy Illegal modifier for parameter getMouseOverExtended; only final is permitted Syntax error on token "(", ; expected Syntax error on token ")", ; expected The method getRenderViewEntity() is undefined for the type Minecraft The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible The method rayTrace(double, int) is undefined for the type Entity The method getPositionEyes(int) is undefined for the type Entity The method getLook(int) is undefined for the type Entity The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible Void methods cannot return a value
at cpw.mods.fml.common.LoadController.transition(LoadController.java:163) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:739) at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311) at net.minecraft.client.Minecraft.startGame(Minecraft.java:597) at net.minecraft.client.Minecraft.run(Minecraft.java:942) at net.minecraft.client.main.Main.main(Main.java:164) 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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source)Caused by: java.lang.Error: Unresolved compilation problems: void is an invalid type for the variable onEvent Syntax error on token "(", ; expected Syntax error on token ")", ; expected The method getMouseOverExtended(float) is undefined for the type ClientProxy Illegal modifier for parameter getMouseOverExtended; only final is permitted Syntax error on token "(", ; expected Syntax error on token ")", ; expected The method getRenderViewEntity() is undefined for the type Minecraft The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible The method rayTrace(double, int) is undefined for the type Entity The method getPositionEyes(int) is undefined for the type Entity The method getLook(int) is undefined for the type Entity The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible Void methods cannot return a value
at com.GargatheOro.LichlandCore.ClientProxy.init(ClientProxy.java:35) at com.GargatheOro.LichlandCore.Main.load(Main.java:40) 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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737) ... 12 more
A detailed walkthrough of the error, its code path and all known details is as follows:---------------------------------------------------------------------------------------
-- System Details --Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_121, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 670247312 bytes (639 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 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 UCHI mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHI FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UCHI Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UCHE lichlandcore{2.0.0} [Lichland Core Mod] (bin) GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13474 Compatibility Profile Context 22.19.162.4' Renderer: 'AMD Radeon (TM) R7 360 Series'
@AstroNoodles Ah, well spotted. Though technically, as long as the client proxy is registered as an event handler with Forge then it should work, but it's much better to keep them separate. Also, the event handler that deals with the MouseEvent needs to be registered from the client proxy rather than the main mod file or common proxy, because it deals with a client-only event and therefore should not be instantiated on the server side. I use two different event handler classes, one for common code and one for client-only code (I haven't had to use any server-only events yet, but if I did then that would require a third event handler).
@arisalanna
java.lang.Error: Unresolved compilation problems
This means that the compiler has failed, meaning you have some sort of syntax or semantic error. These are different to exceptions, because exceptions (like NullPointerException) can only be detected by trying to run the game, whereas syntax/semantic errors are like spelling or grammar errors, but for java.
If you are using an IDE (like eclipse or Intellij idea) then these sorts of things will have red underlines and it will warn you about them if you try to launch the game. If you have red underlines and you don't know why, hover over them and something should appear telling you what the error is. In this case, it's more helpful to us if you post what it says there (and the line number) instead of running the game and getting a crash report.
Apologies if you know all this, but I'm confused as to why you would run the game when there are errors displayed in the code.
The Meaning of Life, the Universe, and Everything.
Location:
Colorado
Join Date:
3/27/2016
Posts:
208
Location:
Colorado
Minecraft:
ProfessorOro
Discord:
gargatheoro
PMC:
GargatheOro
Member Details
Thank you electroblob. I will check it out. Yes, I am using eclipse. And the reason I decided to run it anyway is because a lot of them didn't say why it was errored or what will fix it. Also thank you AstroNoodles. That helps me out a lot. And I am a noob modder so everything you guys told me is new knowledge. I am not able to find a consistant tutorial
The Meaning of Life, the Universe, and Everything.
Location:
Colorado
Join Date:
3/27/2016
Posts:
208
Location:
Colorado
Minecraft:
ProfessorOro
Discord:
gargatheoro
PMC:
GargatheOro
Member Details
I cannot seem to get rid of all of my errors. Should I upload my mod files for you guys so you can see the errors in Eclipse? There are too many to sit here and log them here. I have moved the following from my client proxy to my client handler:
package com.GargatheOro.LichlandCore;package com.GargatheOro.LichlandCore;
import java.util.List;
import com.GargatheOro.Weapons.IExtendedReach;import com.GargatheOro.Weapons.MessageExtendedReachAttack;
import cpw.mods.fml.client.FMLClientHandler;import cpw.mods.fml.common.eventhandler.EventPriority;import cpw.mods.fml.common.eventhandler.SubscribeEvent;import cpw.mods.fml.relauncher.Side;import cpw.mods.fml.relauncher.SideOnly;import net.minecraft.client.Minecraft;import net.minecraft.entity.Entity;import net.minecraft.entity.player.EntityPlayer;import net.minecraft.item.ItemStack;import net.minecraft.util.AxisAlignedBB;import net.minecraft.util.MovingObjectPosition;import net.minecraft.util.Vec3;import net.minecraftforge.client.event.MouseEvent;
public class ClientHandler {
@SideOnly(Side.CLIENT) @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) public void onEvent(MouseEvent event) { if (event.button == 0 && event.buttonstate) { Minecraft mc = Minecraft.getMinecraft(); EntityPlayer thePlayer = mc.thePlayer; if (thePlayer != null) { ItemStack itemstack = thePlayer.getCurrentEquippedItem(); IExtendedReach ieri; if (itemstack != null) { if (itemstack.getItem() instanceof IExtendedReach) { ieri = (IExtendedReach) itemstack.getItem(); } else { ieri = null; } if (ieri != null) { float reach = ieri.getReach(); MovingObjectPosition mov = getMouseOverExtended(reach); if (mov != null) { if (mov.entityHit != null && mov.entityHit.hurtResistantTime == 0) { if (mov.entityHit != thePlayer ) { Main.network.sendToServer(new MessageExtendedReachAttack( mov.entityHit.getEntityId())); } } } } } } } } // This is mostly copied from the EntityRenderer#getMouseOver() method public static MovingObjectPosition getMouseOverExtended(float dist) { Minecraft mc = FMLClientHandler.instance().getClient(); Entity theRenderViewEntity = mc.getRenderViewEntity(); AxisAlignedBB theViewBoundingBox = new AxisAlignedBB( theRenderViewEntity.posX-0.5D, theRenderViewEntity.posY-0.0D, theRenderViewEntity.posZ-0.5D, theRenderViewEntity.posX+0.5D, theRenderViewEntity.posY+1.5D, theRenderViewEntity.posZ+0.5D ); MovingObjectPosition returnMOP = null; if (mc.theWorld != null) { double var2 = dist; returnMOP = theRenderViewEntity.rayTrace(var2, 0); double calcdist = var2; Vec3 pos = theRenderViewEntity.getPositionEyes(0); var2 = calcdist; if (returnMOP != null) { calcdist = returnMOP.hitVec.distanceTo(pos); } Vec3 lookvec = theRenderViewEntity.getLook(0); Vec3 var8 = pos.addVector(lookvec.xCoord * var2, lookvec.yCoord * var2, lookvec.zCoord * var2); Entity pointedEntity = null; float var9 = 1.0F; @SuppressWarnings("unchecked") List<Entity> list = mc.theWorld.getEntitiesWithinAABBExcludingEntity( theRenderViewEntity, theViewBoundingBox.addCoord( lookvec.xCoord * var2, lookvec.yCoord * var2, lookvec.zCoord * var2).expand(var9, var9, var9)); double d = calcdist; for (Entity entity : list) { if (entity.canBeCollidedWith()) { float bordersize = entity.getCollisionBorderSize(); AxisAlignedBB aabb = new AxisAlignedBB( entity.posX-entity.width/2, entity.posY, entity.posZ-entity.width/2, entity.posX+entity.width/2, entity.posY+entity.height, entity.posZ+entity.width/2); aabb.expand(bordersize, bordersize, bordersize); MovingObjectPosition mop0 = aabb.calculateIntercept(pos, var8); if (aabb.isVecInside(pos)) { if (0.0D < d || d == 0.0D) { pointedEntity = entity; d = 0.0D; } } else if (mop0 != null) { double d1 = pos.distanceTo(mop0.hitVec); if (d1 < d || d == 0.0D) { pointedEntity = entity; d = d1; } } } } if (pointedEntity != null && (d < calcdist || returnMOP == null)) { returnMOP = new MovingObjectPosition(pointedEntity); } } return returnMOP; }}}
Okay, before you upload your mod files here are a few things which might help you get rid of some of the errors.
Firstly, press Ctrl + Shift + O when viewing any class with errors, and that will fix your imports. This often gets rid of quite a few errors.
There are two types of error, syntax errors and semantic errors. You can think of syntax errors as punctuation errors, and usually you will have missed a bracket or a semicolon somewhere. Eclipse will display a large red circle in the margin to indicate a syntax error, and if you hover over that it will say something like "syntax error on token ";", ) expected". This particular example would mean there is a semicolon where there ought to be a bracket. Generally, just do what it says and you can't go too far wrong.
Semantic errors mean that Java can't work out what something means. There are a huge number of reasons for this; it might be because you're referring to a variable/method/field/class that doesn't exist, you might have not imported something (see above) or you might have put the wrong type of variable into a method or field, to name a few. Eclipse usually shows a light bulb icon in the margin, and if you hover over this it will show some suggestions for how to fix the error. Sometimes these will work, sometimes they won't, and sometimes they will get rid of the error but you won't end up with the result you wanted.
Here are the semantic errors from the crash report you posted earlier and what's wrong with them. The good news is that a lot of them are because the tutorial was written for 1.8, and luckily I know quite a bit about the differences between versions because I'm in the process of updating my mod.
void is an invalid type for the variable onEvent - No idea why this is happening, but it might go away if you fix the other errors.
The method getMouseOverExtended(float) is undefined for the type ClientProxy - You only need to move the onEvent method to the ClientHandler, not getMouseOverExtended. Fix this by moving just the getMouseOverExtended method back to the ClientProxy.
Illegal modifier for parameter getMouseOverExtended; only final is permitted - Again, no idea why this is happening, but it might go away if you fix the other errors.
The method getRenderViewEntity() is undefined for the type Minecraft - In 1.7.10 you can use renderViewEntity (it's a field, not a method) directly.
The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible - In 1.7.10, you can't use the constructor to create an AxisAlignedBB directly, instead you need to use AxisAlignedBB.getBoundingBoxFromPool(*the same stuff that was inside the constructor*).
The method rayTrace(double, int) is undefined for the type Entity
The method getPositionEyes(int) is undefined for the type Entity
Both of these are referencing methods that were only added in Minecraft 1.8, so you'll have to put them in manually. Add the following lines to your ClientProxy:
These are just the missing methods with a few alterations to make them work with 1.7.10. Now change theRenderViewEntity.rayTrace(var2, 0) to rayTrace(theRenderViewEntity, var2, 0) and theRenderViewEntity.getPositionEyes(0) to getPositionEyes(theRenderViewEntity, 0), and it should work.
The method getLook(int) is undefined for the type Entity - In 1.7.10 it's called getLookVec instead of getLook, I think.
The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible - See above.
Void methods cannot return a value - This means exactly what it says: you have a method that says [public/private] void someMethod(...), but in that method you have a line that says return [something]. Void means the method doesn't return anything, so you need to remove the [something]. Be aware, however, that whilst this will get rid of the error it might mean your code doesn't work as intended.
The Meaning of Life, the Universe, and Everything.
Location:
Colorado
Join Date:
3/27/2016
Posts:
208
Location:
Colorado
Minecraft:
ProfessorOro
Discord:
gargatheoro
PMC:
GargatheOro
Member Details
It removed some errors I guess, but created a few more. Yay! One error less! Got to loading phase 5/7 before crashing this time. I am going to upload my mod files I guess.
Okay, I will take a look at that when I get the chance, thanks.
Edit: I had a brief look and you seem to be referring to some classes/packages that aren't there. Is that your entire mod? And if so, are you using any other mods as dependencies?
I looked at your code that you placed in GitHub and I have one small syntax error for you to clean up. If you get any more errors in Eclipse, let me and @Electroblob_ know :
In ClientHandler, you have a couple typos with your AxisAlignedBB.getBoundingBoxFromPool(...) methods, this is because the methods are static meaning you don't need the new operator. Also keep in mind that the method returns a AxisAlignedBB, so you don't need to return the entire method.
Just a side thing, but in the future, it's easier to read code from GitHub instead from a spoiler bubble, so when you next need help, just update the repository.
The Meaning of Life, the Universe, and Everything.
Location:
Colorado
Join Date:
3/27/2016
Posts:
208
Location:
Colorado
Minecraft:
ProfessorOro
Discord:
gargatheoro
PMC:
GargatheOro
Member Details
No, I am not using any mods as dependencies. I have updated GitHub to have all of my mod files. I couldn't figure out how to make folders in GitHub, so don't worry because all the mod classes are organized into packages.
Astro, I don't understand what you mean by operator and return the method. If you could please copy the code and then put in the correct look? Thank you.
I want to be able to create a system to add weapon speed, weapon attack range (melee and ranged would be helpful), and set knock back.
For instance: Dagger has 3 block reach, high attack speed, and low knock back
Spear has 6 block reach, medium attack speed, and low knock back
Hammer has 4 block reach, low attack speed, and high knock back
Only problem is I do not know how, especially for 1.7.10. Can someone help me or give me a few base guide lines? Really the only thing IK how to do is what is posted on youtube.
An SF Towny server! Join our Discord: Click here
Increasing knockback is pretty simple. In your item class, override the hitEntity method, then inside it, modify the entity's motion. For example:
This probably won't be perfect, but it's a good start. Feel free to copy-paste, but make sure you know what it does, that's why I've included comments.
Range for a ranged weapon is just a case of changing the speed of the projectile. I'll let you figure out how to do that, it's very straightforward.
Reach for a melee weapon is a bit more difficult. To increase it, you'll have to use raytracing. To decrease it, I think you need to use AttackEntityEvent in net.minecraftforge.event.entity.player, then test if the player is holding your item, and if so check how far from the entity they are and cancel the event if they are too far away.
Weapon speed is irrelevant in 1.7.10 because the old combat system means you can spam-click as fast as you like with any weapon...
Thank you so much for the input, however I do not want spam clicking heavy weapons to be realistic on my medieval server. I don't think people back then were swinging hammers twice a second.
An SF Towny server! Join our Discord: Click here
I tried following this tutorial but something made the game error : http://jabelarminecraft.blogspot.com/p/minecraft-modding-extending-reach-of.html
I can provide my class and stuff. I was fine until I got to the part that messes with packets. Got errors and stuff. Then the thing about a network gave me even more errors. Please help me. I know nothing about raytracing, or what it is.
An SF Towny server! Join our Discord: Click here
Yeah that's a good tutorial, although there's some fairly advanced stuff in it!
When you say error, do you mean an actual error in you development environment or does the game just crash? If it's a crash, a crash report would be useful, and please post all the classes used in that tutorial anyway, it will help me figure out what's wrong.
Also, this might have something to do with it:
Perhaps you just need to rename a few things?
Since you asked, raytracing = checking all the points along an imaginary line until you find one that's inside something, like a block or entity. In this case, the line starts at the player's head and goes in the direction they are looking. Luckily, you shouldn't have to worry about it because Jabelar has written it all for you in getMouseOverExtended.
By the way, did you get the other things working? As for reducing the weapon speed, you could use IExtendedEntityProperties to add in an attack cooldown for the player, then use events to reduce or cancel damage from your heavy weapons when it hasn't fully recharged.
The class with the packet thing Jabelar described.
package com.GargatheOro.Weapons;
import com.GargatheOro.LichlandCore.Main;
import com.oracle.webservices.internal.api.message.MessageContext;
import cpw.mods.fml.common.network.ByteBufUtils;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayerMP;
public class MessageExtendedReachAttack implements IMessage
{
private int entityId ;
public MessageExtendedReachAttack()
{
// need this constructor
}
public MessageExtendedReachAttack(int parEntityId)
{
entityId = parEntityId;
// DEBUG
System.out.println("Constructor");
}
@Override
public void fromBytes(ByteBuf buf)
{
entityId = ByteBufUtils.readVarInt(buf, 4);
// DEBUG
System.out.println("fromBytes");
}
@Override
public void toBytes(ByteBuf buf)
{
ByteBufUtils.writeVarInt(buf, entityId, 4);
// DEBUG
System.out.println("toBytes encoded");
}
public static class Handler implements IMessageHandler<MessageExtendedReachAttack,
IMessage>
{
@Override
public IMessage onMessage(final MessageExtendedReachAttack message,
MessageContext ctx)
{
// DEBUG
System.out.println("Message received");
// Know it will be on the server so make it thread-safe
final EntityPlayerMP thePlayer = (EntityPlayerMP) Main.proxy.
getPlayerEntityFromContext(ctx);
thePlayer.getServerForPlayer().addScheduledTask(
new Runnable()
{
@Override
public void run()
{
Entity theEntity = thePlayer.worldObj.
getEntityByID(message.entityId);
// DEBUG
System.out.println("Entity = "+theEntity);
// Need to ensure that hackers can't cause trick kills,
// so double check weapon type and reach
if (thePlayer.getCurrentEquippedItem() == null)
{
return;
}
if (thePlayer.getCurrentEquippedItem().getItem() instanceof
IExtendedReach)
{
IExtendedReach theExtendedReachWeapon =
(IExtendedReach)thePlayer.getCurrentEquippedItem().
getItem();
double distanceSq = thePlayer.getDistanceSqToEntity(
theEntity);
double reachSq =theExtendedReachWeapon.getReach()*
theExtendedReachWeapon.getReach();
if (reachSq >= distanceSq)
{
thePlayer.attackTargetEntityWithCurrentItem(
theEntity);
}
}
return; // no response in this case
}
}
);
return null; // no response message
}
}
}
Below is my client proxy with the MouseEvent thing. I put this in the init handler method.
Put the following into the init of my Common Proxy:
Main.network = NetworkRegistry.INSTANCE.newSimpleChannel(Main.NETWORK_CHANNEL_NAME); Main.network = NetworkRegistry.INSTANCE.newSimpleChannel(Main.NETWORK_CHANNEL_NAME);
int packetId = 0; // register messages from client to server Main.network.registerMessage(MessageExtendedReachAttack.Handler.class, MessageExtendedReachAttack.class, packetId++, Side.SERVER);
IExtendedReach Interface:
package com.GargatheOro.Weapons;
public interface IExtendedReach {
public float getReach(); // default is 1.0D
}
My weapon class:
package com.GargatheOro.Weapons;
import net.minecraft.item.ItemSword;
public class Alumaxe extends ItemSword implements IExtendedReach {
public Alumaxe(ToolMaterial p_i45356_1_) { super(p_i45356_1_); } @Override public float getReach() { return 5.0F; }}
Crash report, which the crash is this because it was working before I tried making the attack range:
---- Minecraft Crash Report -------- Minecraft Crash Report ----// Don't do that.
Time: 7/11/17 7:09 AMDescription: Initializing game
java.lang.StringIndexOutOfBoundsException: String index out of range: 6 at java.lang.String.charAt(Unknown Source) at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:232) at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:250) at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:245) at com.GargatheOro.Background.CraftingManager.addCraftingRec(CraftingManager.java:18) at com.GargatheOro.Background.CraftingManager.Main(CraftingManager.java:13) at com.GargatheOro.LichlandCore.Main.PreLoad(Main.java:35) 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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243) at net.minecraft.client.Minecraft.startGame(Minecraft.java:522) at net.minecraft.client.Minecraft.run(Minecraft.java:942) at net.minecraft.client.main.Main.main(Main.java:164) 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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source)
A detailed walkthrough of the error, its code path and all known details is as follows:---------------------------------------------------------------------------------------
-- Head --Stacktrace: at java.lang.String.charAt(Unknown Source) at net.minecraft.item.crafting.CraftingManager.addRecipe(CraftingManager.java:232) at cpw.mods.fml.common.registry.GameRegistry.addShapedRecipe(GameRegistry.java:250) at cpw.mods.fml.common.registry.GameRegistry.addRecipe(GameRegistry.java:245) at com.GargatheOro.Background.CraftingManager.addCraftingRec(CraftingManager.java:18) at com.GargatheOro.Background.CraftingManager.Main(CraftingManager.java:13) at com.GargatheOro.LichlandCore.Main.PreLoad(Main.java:35) 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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.preinitializeMods(Loader.java:556) at cpw.mods.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:243) at net.minecraft.client.Minecraft.startGame(Minecraft.java:522)
-- Initialization --Details:Stacktrace: at net.minecraft.client.Minecraft.run(Minecraft.java:942) at net.minecraft.client.main.Main.main(Main.java:164) 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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source)
-- System Details --Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_121, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 592479032 bytes (565 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 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 UCH mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCH FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UCH Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UCE lichlandcore{2.0.0} [Lichland Core Mod] (bin) GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13474 Compatibility Profile Context 22.19.162.4' Renderer: 'AMD Radeon (TM) R7 360 Series' Launched Version: 1.7.10 LWJGL: 2.9.1 OpenGL: AMD Radeon (TM) R7 360 Series GL version 4.5.13474 Compatibility Profile Context 22.19.162.4, ATI Technologies Inc. GL Caps: Using GL 1.3 multitexturing.Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported.Anisotropic filtering is supported and maximum anisotropy is 16.Shaders are available because OpenGL 2.1 is supported.
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) Vec3 Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used Anisotropic Filtering: Off (1)
Thank you for the help so far Electroblob. BTW your mod is awesome I made a wizardry modpack with it.
An SF Towny server! Join our Discord: Click here
I'm sorry if I'm not much help on the extended reach weapons (I tried it for my mod, It's hard and I gave up... )
But as a tip for the spam clicking hammer, you could always call onUpdate() on your hammer and if it isSelected, you can create a mining fatigue potion effect preferably or a slowness effect. That might help you with one of the problems.
That is a good idea. I will use it unless something better is shared with me.
An SF Towny server! Join our Discord: Click here
Mining fatigue.. now that's a good idea. Good thinking, AstroNoodles.
That crash report you posted has nothing to do with the weapon, instead it seems to have happened when registering a crafting recipe. Are you sure it's the right one? If it is the right crash report, then there's another error somewhere in your crafting recipes that needs fixing first, or you could just comment out the crafting recipes for the time being since they're not needed for testing the extended reach thing.
Other than that, I can't see anything wrong with your code, and since it's mostly copied from the tutorial there's no reason why it shouldn't work.
New crash report:
---- Minecraft Crash Report -------- Minecraft Crash Report ----// My bad.
Time: 7/15/17 10:47 AMDescription: There was a severe problem during mod loading that has caused the game to fail
cpw.mods.fml.common.LoaderException: java.lang.Error: Unresolved compilation problems: void is an invalid type for the variable onEvent Syntax error on token "(", ; expected Syntax error on token ")", ; expected The method getMouseOverExtended(float) is undefined for the type ClientProxy Illegal modifier for parameter getMouseOverExtended; only final is permitted Syntax error on token "(", ; expected Syntax error on token ")", ; expected The method getRenderViewEntity() is undefined for the type Minecraft The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible The method rayTrace(double, int) is undefined for the type Entity The method getPositionEyes(int) is undefined for the type Entity The method getLook(int) is undefined for the type Entity The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible Void methods cannot return a value
at cpw.mods.fml.common.LoadController.transition(LoadController.java:163) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:739) at cpw.mods.fml.client.FMLClientHandler.finishMinecraftLoading(FMLClientHandler.java:311) at net.minecraft.client.Minecraft.startGame(Minecraft.java:597) at net.minecraft.client.Minecraft.run(Minecraft.java:942) at net.minecraft.client.main.Main.main(Main.java:164) 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 net.minecraftforge.gradle.GradleStartCommon.launch(Unknown Source) at GradleStart.main(Unknown Source)Caused by: java.lang.Error: Unresolved compilation problems: void is an invalid type for the variable onEvent Syntax error on token "(", ; expected Syntax error on token ")", ; expected The method getMouseOverExtended(float) is undefined for the type ClientProxy Illegal modifier for parameter getMouseOverExtended; only final is permitted Syntax error on token "(", ; expected Syntax error on token ")", ; expected The method getRenderViewEntity() is undefined for the type Minecraft The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible The method rayTrace(double, int) is undefined for the type Entity The method getPositionEyes(int) is undefined for the type Entity The method getLook(int) is undefined for the type Entity The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible Void methods cannot return a value
at com.GargatheOro.LichlandCore.ClientProxy.init(ClientProxy.java:35) at com.GargatheOro.LichlandCore.Main.load(Main.java:40) 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 cpw.mods.fml.common.FMLModContainer.handleModStateEvent(FMLModContainer.java:532) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.sendEventToModContainer(LoadController.java:212) at cpw.mods.fml.common.LoadController.propogateStateMessage(LoadController.java:190) 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 com.google.common.eventbus.EventSubscriber.handleEvent(EventSubscriber.java:74) at com.google.common.eventbus.SynchronizedEventSubscriber.handleEvent(SynchronizedEventSubscriber.java:47) at com.google.common.eventbus.EventBus.dispatch(EventBus.java:322) at com.google.common.eventbus.EventBus.dispatchQueuedEvents(EventBus.java:304) at com.google.common.eventbus.EventBus.post(EventBus.java:275) at cpw.mods.fml.common.LoadController.distributeStateMessage(LoadController.java:119) at cpw.mods.fml.common.Loader.initializeMods(Loader.java:737) ... 12 more
A detailed walkthrough of the error, its code path and all known details is as follows:---------------------------------------------------------------------------------------
-- System Details --Details: Minecraft Version: 1.7.10 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_121, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 670247312 bytes (639 MB) / 1037959168 bytes (989 MB) up to 1037959168 bytes (989 MB) JVM Flags: 3 total; -Xincgc -Xmx1024M -Xms1024M AABB Pool Size: 0 (0 bytes; 0 MB) allocated, 0 (0 bytes; 0 MB) used IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 FML: MCP v9.05 FML v7.10.99.99 Minecraft Forge 10.13.4.1614 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 UCHI mcp{9.05} [Minecraft Coder Pack] (minecraft.jar) UCHI FML{7.10.99.99} [Forge Mod Loader] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UCHI Forge{10.13.4.1614} [Minecraft Forge] (forgeSrc-1.7.10-10.13.4.1614-1.7.10.jar) UCHE lichlandcore{2.0.0} [Lichland Core Mod] (bin) GL info: ' Vendor: 'ATI Technologies Inc.' Version: '4.5.13474 Compatibility Profile Context 22.19.162.4' Renderer: 'AMD Radeon (TM) R7 360 Series'
@electroblob_
An SF Towny server! Join our Discord: Click here
I got a new crash report (Forgot to tag you in the post)
An SF Towny server! Join our Discord: Click here
You have one minor flaw in your code,
The onEvent() method should be in a event handler not the client proxy.
That should clean up some of your errors.
@AstroNoodles Ah, well spotted. Though technically, as long as the client proxy is registered as an event handler with Forge then it should work, but it's much better to keep them separate. Also, the event handler that deals with the MouseEvent needs to be registered from the client proxy rather than the main mod file or common proxy, because it deals with a client-only event and therefore should not be instantiated on the server side. I use two different event handler classes, one for common code and one for client-only code (I haven't had to use any server-only events yet, but if I did then that would require a third event handler).
@arisalanna
This means that the compiler has failed, meaning you have some sort of syntax or semantic error. These are different to exceptions, because exceptions (like NullPointerException) can only be detected by trying to run the game, whereas syntax/semantic errors are like spelling or grammar errors, but for java.
If you are using an IDE (like eclipse or Intellij idea) then these sorts of things will have red underlines and it will warn you about them if you try to launch the game. If you have red underlines and you don't know why, hover over them and something should appear telling you what the error is. In this case, it's more helpful to us if you post what it says there (and the line number) instead of running the game and getting a crash report.
Apologies if you know all this, but I'm confused as to why you would run the game when there are errors displayed in the code.
Thank you electroblob. I will check it out. Yes, I am using eclipse. And the reason I decided to run it anyway is because a lot of them didn't say why it was errored or what will fix it. Also thank you AstroNoodles. That helps me out a lot. And I am a noob modder so everything you guys told me is new knowledge. I am not able to find a consistant tutorial
An SF Towny server! Join our Discord: Click here
I cannot seem to get rid of all of my errors. Should I upload my mod files for you guys so you can see the errors in Eclipse? There are too many to sit here and log them here. I have moved the following from my client proxy to my client handler:
package com.GargatheOro.LichlandCore;package com.GargatheOro.LichlandCore;
import java.util.List;
import com.GargatheOro.Weapons.IExtendedReach;import com.GargatheOro.Weapons.MessageExtendedReachAttack;
import cpw.mods.fml.client.FMLClientHandler;import cpw.mods.fml.common.eventhandler.EventPriority;import cpw.mods.fml.common.eventhandler.SubscribeEvent;import cpw.mods.fml.relauncher.Side;import cpw.mods.fml.relauncher.SideOnly;import net.minecraft.client.Minecraft;import net.minecraft.entity.Entity;import net.minecraft.entity.player.EntityPlayer;import net.minecraft.item.ItemStack;import net.minecraft.util.AxisAlignedBB;import net.minecraft.util.MovingObjectPosition;import net.minecraft.util.Vec3;import net.minecraftforge.client.event.MouseEvent;
public class ClientHandler {
@SideOnly(Side.CLIENT) @SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true) public void onEvent(MouseEvent event) { if (event.button == 0 && event.buttonstate) { Minecraft mc = Minecraft.getMinecraft(); EntityPlayer thePlayer = mc.thePlayer; if (thePlayer != null) { ItemStack itemstack = thePlayer.getCurrentEquippedItem(); IExtendedReach ieri; if (itemstack != null) { if (itemstack.getItem() instanceof IExtendedReach) { ieri = (IExtendedReach) itemstack.getItem(); } else { ieri = null; } if (ieri != null) { float reach = ieri.getReach(); MovingObjectPosition mov = getMouseOverExtended(reach); if (mov != null) { if (mov.entityHit != null && mov.entityHit.hurtResistantTime == 0) { if (mov.entityHit != thePlayer ) { Main.network.sendToServer(new MessageExtendedReachAttack( mov.entityHit.getEntityId())); } } } } } } } } // This is mostly copied from the EntityRenderer#getMouseOver() method public static MovingObjectPosition getMouseOverExtended(float dist) { Minecraft mc = FMLClientHandler.instance().getClient(); Entity theRenderViewEntity = mc.getRenderViewEntity(); AxisAlignedBB theViewBoundingBox = new AxisAlignedBB( theRenderViewEntity.posX-0.5D, theRenderViewEntity.posY-0.0D, theRenderViewEntity.posZ-0.5D, theRenderViewEntity.posX+0.5D, theRenderViewEntity.posY+1.5D, theRenderViewEntity.posZ+0.5D ); MovingObjectPosition returnMOP = null; if (mc.theWorld != null) { double var2 = dist; returnMOP = theRenderViewEntity.rayTrace(var2, 0); double calcdist = var2; Vec3 pos = theRenderViewEntity.getPositionEyes(0); var2 = calcdist; if (returnMOP != null) { calcdist = returnMOP.hitVec.distanceTo(pos); } Vec3 lookvec = theRenderViewEntity.getLook(0); Vec3 var8 = pos.addVector(lookvec.xCoord * var2, lookvec.yCoord * var2, lookvec.zCoord * var2); Entity pointedEntity = null; float var9 = 1.0F; @SuppressWarnings("unchecked") List<Entity> list = mc.theWorld.getEntitiesWithinAABBExcludingEntity( theRenderViewEntity, theViewBoundingBox.addCoord( lookvec.xCoord * var2, lookvec.yCoord * var2, lookvec.zCoord * var2).expand(var9, var9, var9)); double d = calcdist; for (Entity entity : list) { if (entity.canBeCollidedWith()) { float bordersize = entity.getCollisionBorderSize(); AxisAlignedBB aabb = new AxisAlignedBB( entity.posX-entity.width/2, entity.posY, entity.posZ-entity.width/2, entity.posX+entity.width/2, entity.posY+entity.height, entity.posZ+entity.width/2); aabb.expand(bordersize, bordersize, bordersize); MovingObjectPosition mop0 = aabb.calculateIntercept(pos, var8); if (aabb.isVecInside(pos)) { if (0.0D < d || d == 0.0D) { pointedEntity = entity; d = 0.0D; } } else if (mop0 != null) { double d1 = pos.distanceTo(mop0.hitVec); if (d1 < d || d == 0.0D) { pointedEntity = entity; d = d1; } } } } if (pointedEntity != null && (d < calcdist || returnMOP == null)) { returnMOP = new MovingObjectPosition(pointedEntity); } } return returnMOP; }}}
An SF Towny server! Join our Discord: Click here
Okay, before you upload your mod files here are a few things which might help you get rid of some of the errors.
Firstly, press Ctrl + Shift + O when viewing any class with errors, and that will fix your imports. This often gets rid of quite a few errors.
There are two types of error, syntax errors and semantic errors. You can think of syntax errors as punctuation errors, and usually you will have missed a bracket or a semicolon somewhere. Eclipse will display a large red circle in the margin to indicate a syntax error, and if you hover over that it will say something like "syntax error on token ";", ) expected". This particular example would mean there is a semicolon where there ought to be a bracket. Generally, just do what it says and you can't go too far wrong.
Semantic errors mean that Java can't work out what something means. There are a huge number of reasons for this; it might be because you're referring to a variable/method/field/class that doesn't exist, you might have not imported something (see above) or you might have put the wrong type of variable into a method or field, to name a few. Eclipse usually shows a light bulb icon in the margin, and if you hover over this it will show some suggestions for how to fix the error. Sometimes these will work, sometimes they won't, and sometimes they will get rid of the error but you won't end up with the result you wanted.
Here are the semantic errors from the crash report you posted earlier and what's wrong with them. The good news is that a lot of them are because the tutorial was written for 1.8, and luckily I know quite a bit about the differences between versions because I'm in the process of updating my mod.
void is an invalid type for the variable onEvent - No idea why this is happening, but it might go away if you fix the other errors.
The method getMouseOverExtended(float) is undefined for the type ClientProxy - You only need to move the onEvent method to the ClientHandler, not getMouseOverExtended. Fix this by moving just the getMouseOverExtended method back to the ClientProxy.
Illegal modifier for parameter getMouseOverExtended; only final is permitted - Again, no idea why this is happening, but it might go away if you fix the other errors.
The method getRenderViewEntity() is undefined for the type Minecraft - In 1.7.10 you can use renderViewEntity (it's a field, not a method) directly.
The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible - In 1.7.10, you can't use the constructor to create an AxisAlignedBB directly, instead you need to use AxisAlignedBB.getBoundingBoxFromPool(*the same stuff that was inside the constructor*).
The method rayTrace(double, int) is undefined for the type Entity
The method getPositionEyes(int) is undefined for the type Entity
Both of these are referencing methods that were only added in Minecraft 1.8, so you'll have to put them in manually. Add the following lines to your ClientProxy:
These are just the missing methods with a few alterations to make them work with 1.7.10. Now change theRenderViewEntity.rayTrace(var2, 0) to rayTrace(theRenderViewEntity, var2, 0) and theRenderViewEntity.getPositionEyes(0) to getPositionEyes(theRenderViewEntity, 0), and it should work.
The method getLook(int) is undefined for the type Entity - In 1.7.10 it's called getLookVec instead of getLook, I think.
The constructor AxisAlignedBB(double, double, double, double, double, double) is not visible - See above.
Void methods cannot return a value - This means exactly what it says: you have a method that says [public/private] void someMethod(...), but in that method you have a line that says return [something]. Void means the method doesn't return anything, so you need to remove the [something]. Be aware, however, that whilst this will get rid of the error it might mean your code doesn't work as intended.
Hopefully you can get somewhere with all that!
It removed some errors I guess, but created a few more. Yay! One error less! Got to loading phase 5/7 before crashing this time. I am going to upload my mod files I guess.
https://github.com/ArIlIlI/1.7.10-Modding
Download and put into eclipse or whatever else is necessary. Thank you so much. I appreciate all the help. You are a good teacher electroblob.
An SF Towny server! Join our Discord: Click here
Okay, I will take a look at that when I get the chance, thanks.
Edit: I had a brief look and you seem to be referring to some classes/packages that aren't there. Is that your entire mod? And if so, are you using any other mods as dependencies?
Hey,
I looked at your code that you placed in GitHub and I have one small syntax error for you to clean up. If you get any more errors in Eclipse, let me and @Electroblob_ know :
In ClientHandler, you have a couple typos with your AxisAlignedBB.getBoundingBoxFromPool(...) methods, this is because the methods are static meaning you don't need the new operator. Also keep in mind that the method returns a AxisAlignedBB, so you don't need to return the entire method.
Just a side thing, but in the future, it's easier to read code from GitHub instead from a spoiler bubble, so when you next need help, just update the repository.
No, I am not using any mods as dependencies. I have updated GitHub to have all of my mod files. I couldn't figure out how to make folders in GitHub, so don't worry because all the mod classes are organized into packages.
Astro, I don't understand what you mean by operator and return the method. If you could please copy the code and then put in the correct look? Thank you.
An SF Towny server! Join our Discord: Click here