Topic category: Help with Minecraft modding (Java Edition)
Hey, it's me again here with another complex idea I need help with.
I want my entity throwable to have a boomerang type function. So I kind of know the function of this. I have code for damaging the entity. But I need help with actual code for the rest of it. here is my idea for the mechanic:
so, entity throwable dissapears when it hits a block or entity is because of set dead. what I need is to delete that part (I need it later though) and add in a motion, so in place of set dead when it hits a block or entity it has a motion. When it hits an entity or a block the motion will return/be backwards. Then I need CollideWithPlayer that will 1. Set dead the entity and 2. give the player the item back.
If anyone wants to help or has code or something please reply. I am working in 1.7.10 version.
@#13
oh, it is boolean. for some reason I keep thinking of int!
:@#13
:compileApiJava UP-TO-DATE
>:processApiResources UP-TO-DATE
>:apiClasses UP-TO-DATE
>:sourceMainJava
>/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_shield.java:153: error: variable hasCollided might not have been initialized
>:compileJava FAILED
> > ^
if>BUILD FAILED
(hasCollided){
>Note: /Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_sugilitesFlail.java uses unchecked or unsafe operations.
you must initialize it. In constructor or directly in the declaration asign to it a value , to be more exact - false
@#14
hmm, now my entity does not move at all
Did you kept the code that you had in onUpdate() before?
@#15
well this is my code:
public static class Entityshield extends EntityThrowable{
/** How many ticks the arrow has been in the air. */
public int inAirTicks;
public Entityshield(World par1World, double par2, double par4, double par6)
{
super(par1World, par2, par4, par6);
}
public Entityshield(World par1World, EntityLivingBase par2EntityLivingBase)
{
super(par1World, par2EntityLivingBase);
}
public Entityshield(World par1World)
{
super(par1World);
}
@Override
public void onUpdate() {
boolean hasCollided = false;
if(hasCollided){
inAirTicks++;
if(inAirTicks > 60){
setDead();
}
}
Wich onUpdate code are you talking about? is it this one:
@Override
public void onUpdate() {
if (--distance < -LIFESPAN && !worldObj.isRemote) {
worldObj.spawnEntityInWorld(new EntityItem(worldObj, posX, posY, posZ, getshield()));
setDead();
}
}
@#14
I did a test, and it seems that if the code has this:@Override
public void onUpdate() {
the projectile doesn't move.
Hm no. Call a super method.
@#16
so I need to add something like this?
super.OnUpdate();
With lowercase "O"
super.onUpdate();
and this goes on line on top of
inAirTicks++;
@#17
this is full code by the way
@Override
public void onUpdate() {
boolean hasCollided = false;
if(hasCollided){
inAirTicks++;
if(inAirTicks > 60){
setDead();
}
}
}
1st no , it is must be compeltly first thing in the void , also why do you declare the boolean in the void? Do you know that if you do this , it will every tick set the value to false and also it will not be accesable from rest of code?
@#19
oh, boolean should can be put under where i put int for inAirTicks?