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.
@#7
@Override
public void onUpdate() {
if (--distance < -LIFESPAN && !worldObj.isRemote) {
worldObj.spawnEntityInWorld(new EntityItem(worldObj, posX, posY, posZ,
setDead();
}
}
hmm, getshield())); is wrong. Isn't for item it must be
mcreator_stevensShield.block?
@#8
@Override
public void onUpdate() {
if(hasCollided){
inAirTicks++;
if(inAirTicks > 60){
//DO SOME STUFF
}
}
inAirTicks must have int?
@#7.3 I do not know names of all items in your mod. Also I stated GitHub is not key to all answers.
No, it is going to be a String......... :D
Of course that if you are doing timer, you will use Integer,Float,Double or Long.
@#9
won't this setDead even when I'm throwing it at the entity?
@#9.1 Why it should?
@#9.1.1
unless it is looking for the entity stopped in one place in air then setDead.
Ehmmm? What the code that I wrote does is:
If boolean hasCollided (that you will set to true in onImpact() ) is true , increase inAirTicks by 1. If inAirTicks is bigger than 60 (60 is just random value by me , you can use what you want) , then do the stuff that you want , like killing the entity and spawning the item.
@#10
like this?
@Override
public void onUpdate() {
if(hasCollided){
inAirTicks++;
if(inAirTicks > 60){
setDead();
}
}
edit:I recompiled it and I got a bunhc of errors
Is the void closed?
@#11
/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_shield.java:152: error: cannot find symbol
>:compileJava FAILED
> if(hasCollided){
> ^
> symbol: variable hasCollided
> location: class Entityshield
>/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_shield.java:152: error: illegal start of type
> if(hasCollided){
> ^
>/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_shield.java:153: error: cannot find symbol
>inAirTicks++;
>BU> symbol: variable inAirTicks
ILD FAILED
>^
>Total time: 13.825 secs
> location: class Entityshield
>/Applications/MCreator 1.5.9 [1.7.10] Mac-Linux/forge/build/sources/java/mod/mcreator/mcreator_shield.java:154: error: cannot find symbol
>if(inAirTicks > 60){
> ^
> symbol: variable inAirTicks
> location: class Entityshield
>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.
>4 errors
I thought that it is pretty obvious that you need first declare the variables
@#12
I have declared inAirTicks but am having trouble with hasCollided
What is hard about writing boolean hasCollided; ?