Jump to content

Recommended Posts

Posted (edited)

Guten Tag zusammen,

Ich bin gerade dabei, einen Mob einzufügen. Dieser Mob soll ein Skorpion sein, und bei "Peaceful" spanwn und auch angreiffen.

Das besondere an diesem Mob ist, das dieser vergiftet und den Trankeffekt "Übelkeit" austeilt. bzw es soll.. Da ich mit JAVA natürlich nicht so erfahren bin, möchte ich hier um Hilfe bitten.

Das Problem ist folgender:

Ich kann diese 2 public booleans nicht in 1ner Datei verwenden..

public boolean attackEntityAsMob(Entity par1Entity)    {        if (super.attackEntityAsMob(par1Entity))        {            if (par1Entity instanceof EntityLiving)            {                byte var2 = 0;                if (this.worldObj.difficultySetting >= 0)                {                    if (this.worldObj.difficultySetting >= 0)                    {                        var2 = 7;                    }                    else if (this.worldObj.difficultySetting >= 0)                    {                        var2 = 15;                    }                }                if (var2 > 0)                {                    ((EntityLiving)par1Entity).addPotionEffect(new PotionEffect(Potion.confusion.id, var2 * 300, 0));                                    }            }            return true;        }        else        {            return false;        }    } 

Und

public boolean attackEntityAsMob(Entity par1Entity)    {        int var2 = this.isTamed() ? 4 : 2;        return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), var2);    }

Hier ist der ganze Code des Scorpions:

package net.minecraft.src;public class EntityScorpion extends EntityTameable{    public EntityScorpion(World par1World)    {        super(par1World);        this.texture = "/mob/scorpion.png";        this.setSize(1.4F, 0.9F);        this.moveSpeed = 0.4F;        this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityPlayer.class, this.moveSpeed, true));        this.tasks.addTask(2, new EntityAILeapAtTarget(this, 0.4F));        this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 16.0F, 0, true));        this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, true));        this.targetTasks.addTask(3, new EntityAITargetNonTamed(this, EntityLiving.class, 16.0F, 200, false));    }        public boolean isAIEnabled()    {        return true;    }    public boolean attackEntityAsMob(Entity par1Entity)    {        if (super.attackEntityAsMob(par1Entity))        {            if (par1Entity instanceof EntityLiving)            {                byte var2 = 0;                if (this.worldObj.difficultySetting >= 0)                {                    if (this.worldObj.difficultySetting >= 0)                    {                        var2 = 7;                    }                    else if (this.worldObj.difficultySetting >= 0)                    {                        var2 = 15;                    }                }                if (var2 > 0)                {                    ((EntityLiving)par1Entity).addPotionEffect(new PotionEffect(Potion.confusion.id, var2 * 300, 0));                                    }            }            return true;        }        else        {            return false;        }    }         public boolean attackEntityAsMob(Entity par1Entity)    {        int var2 = this.isTamed() ? 4 : 2;        return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), var2);    }        public int getAttackStrength(Entity par1Entity)    {        return 1;    }    protected int getDropItemId()    {        return Item.redstone.itemID;    }    	public int getMaxHealth() {		return 5;	}	public float spiderScaleAmount() {		return 1.3F;	}	public EntityAgeable createChild(EntityAgeable var1) {		return null;	}	    public void initCreature() {}}

Ich brauche leider beide Codes in einem.. wie mache ich das?

Oder gibt es ne einfache Methode, das 1ner der 2 Codes irgendwo eingefügt werden kann?

PS: Ich arbeite mit Eclipse und OHNE Modloader, was natürlich seine Gründe hat

Gruß, Endless.

Edited by Endless.
Posted

Ich kenn mich zwar mit Java aus, aber leider nicht mit Mods.

Außerdem verstehe ich deine Frage nicht ganz. Was meinst du denn mit "einer Datei"? Eine Klasse oder was?

Posted (edited)

Wie gesagt, ich kenn mich mit Mods zwar nicht aus aber dort wird eine Größe angegeben:

this.setSize(1.4F, 0.9F);
if (par1Entity instanceof EntityLiving){    byte var2 = 0;    if (this.worldObj.difficultySetting >= 0)    {        if (this.worldObj.difficultySetting >= 0)        {             var2 = 7;        }        else if (this.worldObj.difficultySetting >= 0)        {             var2 = 15;        }     }

Warum hast du eig beim Schwierigkeitsgrad überall >= 0? Dann brauchst du if nicht, da der Schwierigkeitsgrad immer über 0 ist, oder?

Edited by Salocin
Posted

Hab diesen Code von "EntityCaveSpider" und das >= ist für Peaceful oder auch höher.

Die größe hat keinen Einfluss darauf, das sie mich angreifft oder nicht. Und das ist leider das Problem das dort 2 public booleans

sind, für diese Funktion "attackEntityAsMob(Entity par1Entity)" und ich suche nach ner Lösung um die 2 Codes sozusagen zu "vereinen"

Posted

Kannst du den zweiten boolean nicht einfach mit in den ersten packen? Sind ja beides die selben.

Kenn mich in der Richtung leider net so gut aus, aber vllt klappts ja ^^

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...
B
B