I am still learning how to use 1.10 modding and im creating a throwable entity but I have no idea how to make a render and For some reason it doesn't fly it just falls to the ground, please help!
Entity Class:
public class EntityStaticAttack extends EntityThrowable {
public EntityStaticAttack(World worldIn)
{
super(worldIn);//EntityArrow
}
public EntityStaticAttack(World worldIn, EntityLivingBase throwerIn)
{
super(worldIn, throwerIn);
}
public EntityStaticAttack(World worldIn, double x, double y, double z)
{
super(worldIn, x, y, z);
}
public static void func_189662_a(DataFixer p_189662_0_)
{
EntityThrowable.func_189661_a(p_189662_0_, "Snowball");
(this is temporary until i can get around to doing an eventhandler)
don't use the minecraft class here, it'll crash when you're running it on a server. (same goes for your keybind, you'll need custom packets here).
You may also want to look at how snowballs get their movement and copy the corresponding code into your entity class (or just extend entitySnowball..)
Alright, this brought up a few more problems, but they are all fixable.
1) You are going to want to set up a keybinding system for your mod to properly allow for key presses. Registering keybinds through forge allows players to customize their keys.
2) A keybind is only registered client-side. The entity MUST also be thrown on the server, which means you will need to setup a packet system for your mod to send messages between the client and server. If you find a decent tutorial, it's honestly not all too complicated. Just send a packet to the server when the key is pressed, that way it knows what is going on as well. As it is currently setup, your entity is only spawned in client-side.
3) To actually fix the entity falling flat, you are going to use the setHeadingFromThrower(blah blah) method. This is used to set the direction and velocity with which your entity will be thrown from the player. Your code would look like this. All uppercase parameters can be replaced with the number you actually want.
I am still learning how to use 1.10 modding and im creating a throwable entity but I have no idea how to make a render and For some reason it doesn't fly it just falls to the ground, please help!
Entity Class:
public class EntityStaticAttack extends EntityThrowable {
public EntityStaticAttack(World worldIn)
{
super(worldIn);//EntityArrow
}
public EntityStaticAttack(World worldIn, EntityLivingBase throwerIn)
{
super(worldIn, throwerIn);
}
public EntityStaticAttack(World worldIn, double x, double y, double z)
{
super(worldIn, x, y, z);
}
public static void func_189662_a(DataFixer p_189662_0_)
{
EntityThrowable.func_189661_a(p_189662_0_, "Snowball");
}
BlockPos blockpos = new BlockPos(this.chunkCoordX, this.chunkCoordY, this.chunkCoordZ);
IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
Block block = iblockstate.getBlock();
/**
* Called when this EntityThrowable hits a block or entity.
*/
protected void onImpact(RayTraceResult result)
{
if (result.entityHit != null)
{
result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)10);
}
if (iblockstate.getMaterial() != Material.AIR)
{
this.posY= 0.0D;
this.posX *=1.1;
this.posZ *=1.1;
}
if (!this.worldObj.isRemote)
{
this.setDead();
}
}
}
First things first, let's start with the entity falling strait to the ground. Can you post the class where the entity is spawned in?
(this is temporary until i can get around to doing an eventhandler)
don't use the minecraft class here, it'll crash when you're running it on a server. (same goes for your keybind, you'll need custom packets here).
You may also want to look at how snowballs get their movement and copy the corresponding code into your entity class (or just extend entitySnowball..)
where'd you think i got the code, most/all of it was from the snowball code
Alright, this brought up a few more problems, but they are all fixable.
1) You are going to want to set up a keybinding system for your mod to properly allow for key presses. Registering keybinds through forge allows players to customize their keys.
2) A keybind is only registered client-side. The entity MUST also be thrown on the server, which means you will need to setup a packet system for your mod to send messages between the client and server. If you find a decent tutorial, it's honestly not all too complicated. Just send a packet to the server when the key is pressed, that way it knows what is going on as well. As it is currently setup, your entity is only spawned in client-side.
3) To actually fix the entity falling flat, you are going to use the setHeadingFromThrower(blah blah) method. This is used to set the direction and velocity with which your entity will be thrown from the player. Your code would look like this. All uppercase parameters can be replaced with the number you actually want.
For packet handling, use the Forge Docs.