Skocz do zawartości
Minecraft.pl Server Banner
  • 0
HARDKAMIL

[Solved]Problemy z tworzeniem modów ML

Pytanie

HARDKAMIL    16

Witam, proszę o poprawienie/napisanie mi co źle zrobiłem:

 

 

 

 

Entity Steve:

package net.minecraft.src;

public class EntitySteve extends EntityAnimal
{
    public EntitySteve(World par1World)
    {
        super(par1World);
        this.texture = "/HardKamil/Steve.png";
        this.setSize(0.9F, 1.3F);
        this.getNavigator().setAvoidsWater(true);
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIPanic(this, 0.38F));
        this.tasks.addTask(2, new EntityAIMate(this, 0.2F));
        this.tasks.addTask(3, new EntityAITempt(this, 0.25F, Item.wheat.shiftedIndex, false));
        this.tasks.addTask(4, new EntityAIFollowParent(this, 0.25F));
        this.tasks.addTask(5, new EntityAIWander(this, 0.2F));
        this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(7, new EntityAILookIdle(this));
    }

    /**
     * Returns true if the newer Entity AI code should be run
     */
    public boolean isAIEnabled()
    {
        return true;
    }

    public int getMaxHealth()
    {
        return 30;
    }

    /**
     * Returns the sound this mob makes while it's alive.
     */
    protected String getLivingSound()
    {
        return "mob.none.say";
    }

    /**
     * Returns the sound this mob makes when it is hurt.
     */
    protected String getHurtSound()
    {
        return "mob.none.hurt";
    }

    /**
     * Returns the sound this mob makes on death.
     */
    protected String getDeathSound()
    {
        return "mob.none.hurt";
    }

    /**
     * Plays step sound at given x, y, z for the entity
     */
    protected void playStepSound(int par1, int par2, int par3, int par4)
    {
        this.func_85030_a("mob.none.step", 0.15F, 1.0F);
    }

    /**
     * Returns the volume for the sounds this mob makes.
     */
    protected float getSoundVolume()
    {
        return 0.4F;
    }

    /**
     * Returns the item ID for the item the mob drops on death.
     */
    protected int getDropItemId()
    {
        return Item.ingotIron.shiftedIndex;
    }

    /**
     * Drop 0-2 items of this living's type
     */
    protected void dropFewItems(boolean par1, int par2)
    {
        int var3 = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);
        int var4;

        for (var4 = 0; var4 < var3; ++var4)
        {
            this.dropItem(Item.ingotIron.shiftedIndex, 1);
        }

        var3 = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + par2);

        for (var4 = 0; var4 < var3; ++var4)
        {
            if (this.isBurning())
            {
                this.dropItem(Item.redstone.shiftedIndex, 1);
            }
            else
            {
                this.dropItem(Item.ingotGold.shiftedIndex, 1);
            }
        }
    }

    /**
     * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
     */
    public boolean interact(EntityPlayer par1EntityPlayer)
    {
        ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem();

        if (var2 != null && var2.itemID == Item.bucketEmpty.shiftedIndex)
        {
            if (--var2.stackSize <= 0)
            {
                par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, new ItemStack(Item.bucketLava));
            }
            else if (!par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bucketLava)))
            {
                par1EntityPlayer.dropPlayerItem(new ItemStack(Item.bucketLava.shiftedIndex, 1, 0));
            }

            return true;
        }
        else
        {
            return super.interact(par1EntityPlayer);
        }
    }

    /**
     * This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
     */
    public EntitySteve spawnBabyAnimal(EntityAgeable par1EntityAgeable)
    {
        return new EntitySteve(this.worldObj);
    }

    public EntityAgeable func_90011_a(EntityAgeable par1EntityAgeable)
    {
        return this.spawnBabyAnimal(par1EntityAgeable);
    }
}

Entity Notch:

package net.minecraft.src;

public class EntityNotch extends EntityAnimal
{
    public EntityNotch(World par1World)
    {
        super(par1World);
        this.texture = "/HardKamil/Notch.png";
        this.setSize(0.9F, 1.3F);
        this.getNavigator().setAvoidsWater(true);
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIPanic(this, 0.38F));
        this.tasks.addTask(2, new EntityAIMate(this, 0.2F));
        this.tasks.addTask(3, new EntityAITempt(this, 0.25F, Item.wheat.shiftedIndex, false));
        this.tasks.addTask(4, new EntityAIFollowParent(this, 0.25F));
        this.tasks.addTask(5, new EntityAIWander(this, 0.2F));
        this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(7, new EntityAILookIdle(this));
    }

    /**
     * Returns true if the newer Entity AI code should be run
     */
    public boolean isAIEnabled()
    {
        return true;
    }

    public int getMaxHealth()
    {
        return 30;
    }

    /**
     * Returns the sound this mob makes while it's alive.
     */
    protected String getLivingSound()
    {
        return "mob.none.say";
    }

    /**
     * Returns the sound this mob makes when it is hurt.
     */
    protected String getHurtSound()
    {
        return "mob.none.hurt";
    }

    /**
     * Returns the sound this mob makes on death.
     */
    protected String getDeathSound()
    {
        return "mob.none.hurt";
    }

    /**
     * Plays step sound at given x, y, z for the entity
     */
    protected void playStepSound(int par1, int par2, int par3, int par4)
    {
        this.func_85030_a("mob.none.step", 0.15F, 1.0F);
    }

    /**
     * Returns the volume for the sounds this mob makes.
     */
    protected float getSoundVolume()
    {
        return 0.4F;
    }

    /**
     * Returns the item ID for the item the mob drops on death.
     */
    protected int getDropItemId()
    {
        return Item.appleRed.shiftedIndex;
    }

    /**
     * Drop 0-2 items of this living's type
     */
    protected void dropFewItems(boolean par1, int par2)
    {
        int var3 = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);
        int var4;

        for (var4 = 0; var4 < var3; ++var4)
        {
            this.dropItem(Item.minecartEmpty.shiftedIndex, 1);
        }

        var3 = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + par2);

        for (var4 = 0; var4 < var3; ++var4)
        {
            if (this.isBurning())
            {
                this.dropItem(Item.cookie.shiftedIndex, 1);
            }
            else
            {
                this.dropItem(Block.obsidian, 1);
            }
        }
    }

    /**
     * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
     */
    public boolean interact(EntityPlayer par1EntityPlayer)
    {
        ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem();

        if (var2 != null && var2.itemID == Item.bucketEmpty.shiftedIndex)
        {
            if (--var2.stackSize <= 0)
            {
                par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, new ItemStack(Item.bucketLava));
            }
            else if (!par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bucketLava)))
            {
                par1EntityPlayer.dropPlayerItem(new ItemStack(Item.bucketLava.shiftedIndex, 1, 0));
            }

            return true;
        }
        else
        {
            return super.interact(par1EntityPlayer);
        }
    }

    /**
     * This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
     */
    public EntitySteve spawnBabyAnimal(EntityAgeable par1EntityAgeable)
    {
        return new EntityNotch(this.worldObj);
    }

    public EntityAgeable func_90011_a(EntityAgeable par1EntityAgeable)
    {
        return this.spawnBabyAnimal(par1EntityAgeable);
    }
}

Entity People:

package net.minecraft.src;

public class EntityPeople extends EntityAnimal
{
    public EntityPeople(World par1World)
    {
        super(par1World);
        this.texture = "/HardKamil/People.png";
        this.setSize(0.9F, 1.3F);
        this.getNavigator().setAvoidsWater(true);
        this.tasks.addTask(0, new EntityAISwimming(this));
        this.tasks.addTask(1, new EntityAIPanic(this, 0.38F));
        this.tasks.addTask(2, new EntityAIMate(this, 0.2F));
        this.tasks.addTask(3, new EntityAITempt(this, 0.25F, Item.wheat.shiftedIndex, false));
        this.tasks.addTask(4, new EntityAIFollowParent(this, 0.25F));
        this.tasks.addTask(5, new EntityAIWander(this, 0.2F));
        this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F));
        this.tasks.addTask(7, new EntityAILookIdle(this));
    }

    /**
     * Returns true if the newer Entity AI code should be run
     */
    public boolean isAIEnabled()
    {
        return true;
    }

    public int getMaxHealth()
    {
        return 30;
    }

    /**
     * Returns the sound this mob makes while it's alive.
     */
    protected String getLivingSound()
    {
        return "mob.none.say";
    }

    /**
     * Returns the sound this mob makes when it is hurt.
     */
    protected String getHurtSound()
    {
        return "mob.none.hurt";
    }

    /**
     * Returns the sound this mob makes on death.
     */
    protected String getDeathSound()
    {
        return "mob.none.hurt";
    }

    /**
     * Plays step sound at given x, y, z for the entity
     */
    protected void playStepSound(int par1, int par2, int par3, int par4)
    {
        this.func_85030_a("mob.none.step", 0.15F, 1.0F);
    }

    /**
     * Returns the volume for the sounds this mob makes.
     */
    protected float getSoundVolume()
    {
        return 0.4F;
    }

    /**
     * Returns the item ID for the item the mob drops on death.
     */
    protected int getDropItemId()
    {
        return Item.ingotIron.shiftedIndex;
    }

    /**
     * Drop 0-2 items of this living's type
     */
    protected void dropFewItems(boolean par1, int par2)
    {
        int var3 = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);
        int var4;

        for (var4 = 0; var4 < var3; ++var4)
        {
            this.dropItem(Item.saddle.shiftedIndex, 1);
        }

        var3 = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + par2);

        for (var4 = 0; var4 < var3; ++var4)
        {
            if (this.isBurning())
            {
                this.dropItem(Item.lapisLazuri.shiftedIndex, 1);
            }
            else
            {
                this.dropItem(Item.blazeRod.shiftedIndex, 1);
            }
        }
    }

    /**
     * Called when a player interacts with a mob. e.g. gets milk from a cow, gets into the saddle on a pig.
     */
    public boolean interact(EntityPlayer par1EntityPlayer)
    {
        ItemStack var2 = par1EntityPlayer.inventory.getCurrentItem();

        if (var2 != null && var2.itemID == Item.bucketEmpty.shiftedIndex)
        {
            if (--var2.stackSize <= 0)
            {
                par1EntityPlayer.inventory.setInventorySlotContents(par1EntityPlayer.inventory.currentItem, new ItemStack(Item.bucketLava));
            }
            else if (!par1EntityPlayer.inventory.addItemStackToInventory(new ItemStack(Item.bucketLava)))
            {
                par1EntityPlayer.dropPlayerItem(new ItemStack(Item.bucketLava.shiftedIndex, 1, 0));
            }

            return true;
        }
        else
        {
            return super.interact(par1EntityPlayer);
        }
    }

    /**
     * This function is used when two same-species animals in 'love mode' breed to generate the new baby animal.
     */
    public EntitySteve spawnBabyAnimal(EntityAgeable par1EntityAgeable)
    {
        return new EntityPeople(this.worldObj);
    }

    public EntityAgeable func_90011_a(EntityAgeable par1EntityAgeable)
    {
        return this.spawnBabyAnimal(par1EntityAgeable);
    }
}

mod_MinePeople:

package net.minecraft.src;

import java.util.Map;


public class mod_MinePeople extends BaseMod
{
public void load()
{
ModLoader.registerEntityID(EntitySteve.class, "Steve", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntitySteve.class, 12, 4, 4, EnumCreatureType.monster);
ModLoader.registerEntityID(EntityNotch.class, "Steve", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityNotch.class, 12, 4, 4, EnumCreatureType.monster);
ModLoader.registerEntityID(EntityPeople.class, "Steve", ModLoader.getUniqueEntityId());
ModLoader.addSpawn(EntityPeople.class, 12, 4, 4, EnumCreatureType.monster);
}

public void addRenderer(Map map)
{
map.put(EntitySteve.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityNotch.class, new RenderBiped(new ModelBiped(), 0.5F));
map.put(EntityPeople.class, new RenderBiped(new ModelBiped(), 0.5F));
}

public String getVersion()
{
return "v1.0";
}

public mod_MinePeople()
{

}
}

Kod błędu:

Pierwszy:

EntityNotch.java: 141

incompatible types found:net.minecraft.src Entity Notch
                                         net.minecraft.src Entity Steve

return new EntityNotch (this.worldObj);


Drugi:


EntityPeople java:101
cannot find symbol: variable lapisLazuri


Trzeci:
EntityPeople.java: 141

incompatible types found:net.minecraft.src Entity Notch
                                         net.minecraft.src Entity Steve

return new EntityPeople (this.worldObj);




Czwarty:
EntityNotch.java:105
Entity cannot be applied to net.minecraft.src.Block.int

this.dropItem(Block.obsidian, 1);
incompatible types found:net.minecraft.src Entity Notch
                                         net.minecraft.src Entity Steve

return new EntityNotch (this.worldObj);

 

Udostępnij tę odpowiedź


Odnośnik do odpowiedzi
Udostępnij na innych stronach

3 odpowiedzi na to pytanie

Rekomendowane odpowiedzi

  • 0
Chormon    136

1.

public EntitySteve spawnBabyAnimal(EntityAgeable par1EntityAgeable)
    {
        return new EntityNotch(this.worldObj);
    }

Zwracasz zły typ. Deklarujesz EntitySteve, a zwracasz EntityNotch. Powino być:

public EntityNotch spawnBabyAnimal(EntityAgeable par1EntityAgeable)
    {
        return new EntityNotch(this.worldObj);
    }

2.

    protected void dropFewItems(boolean par1, int par2)
    {
        int var3 = this.rand.nextInt(3) + this.rand.nextInt(1 + par2);
        int var4;

        for (var4 = 0; var4 < var3; ++var4)
        {
            this.dropItem(Item.saddle.shiftedIndex, 1);
        }

        var3 = this.rand.nextInt(3) + 1 + this.rand.nextInt(1 + par2);

        for (var4 = 0; var4 < var3; ++var4)
        {
            if (this.isBurning())
            {
                this.dropItem(Item.lapisLazuri.shiftedIndex, 1);
            }
            else
            {
                this.dropItem(Item.blazeRod.shiftedIndex, 1);
            }
        }
    }

Zrobiłeś literówkę. Nie lapisLazuri, tylko lapisLazuli.

3.

To samo, co w 1. Zamiast:

    public EntitySteve spawnBabyAnimal(EntityAgeable par1EntityAgeable)
    {
        return new EntityPeople(this.worldObj);
    }

Powinno być:

    public EntityPeople spawnBabyAnimal(EntityAgeable par1EntityAgeable)
    {
        return new EntityPeople(this.worldObj);
    }

4.

Zamiast Block.obsidian, powinno być Block.obsidian.shiftedIndex

 

Ogólnie rzecz biorąc NIGDY nie pisałem modyfikacji do MC, a czytając output kompilatora od razu znalazłem błędy. Jak chcesz pisać programy, to naucz się korzystać z tych informacji, a nie przy każdym niepowodzeniu błagać innych o pomoc. Mi pisanie tego dopisku zajęło więcej czasu, niż znalezienie błędów w kodzie i myślę, że tobie również nie zajęło to dłużej czasu, gdybyś naprawdę przeczytał treści błędów.

Udostępnij tę odpowiedź


Odnośnik do odpowiedzi
Udostępnij na innych stronach
  • 0
HARDKAMIL    16

Dziękuję za pomoc.

Nie miałem do tego głowy, bo tworzę grę ;)

Udostępnij tę odpowiedź


Odnośnik do odpowiedzi
Udostępnij na innych stronach
Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.

  • Podobna zawartość

    • Przez marcin009988
      Witam

      Znacie jakieś mody które dodają roboty (lub coś w tym stylu), które można programować, aby np wydobywały surowce, eksplorowały, broniły wyznaczonego obszaru itp
      Coś na podobnej zasadzie jak
      Zaloguj lub zarejestruj się aby zobaczyć ten link.
       lub Zaloguj lub zarejestruj się aby zobaczyć ten link.
      .
      Najlepiej pod 1.11, ale mogą też być pod starsze wersje.
    • Przez Moxpouro
      Cześć wszystkim!
       
         Zapraszam do przeczytania mojego pierwszego posta na tym forum. Choć będzie on po części powitaniem wszystkich Użytkowników, to chciałbym jeszcze rozwiązać w nim pewien problem. Chodzi mi mianowicie o niemożność zapisania gry w najnowszej wersji Minecrafta, 1.8.1. Po wejściu na świat i spauzowaniu gry, a następnie kliknięciu przycisk ,,wyjdź i zapisz'' gra zacina się na nieokreślony z góry czas, a przy próbie podejmowania jakichkolwiek działań - crashuje. Występują też jakieś anomalie związane z renderowaniem świata gry, ponieważ mimo iż posiadam dobry technicznie komputer, i ustawione w opcjach wszystko na maximum, chunków ładuje się tylko połowa z tylu, ilu powinno.
       
         To jest wszystko co chciałem Wam zaprezentować, mam nadzieję że znajdziecie (albo już znaleźliście) rozwiązanie tego problemu. Jestem również ciekaw, czy u Was ten problem również występuję. Na koniec chciałbym się przywitać, i pozdrowić całą Administrację oraz członków Forum, mam nadzieję że razem na nim mile spędzimy czas.
       
         Pozdrawiam i życzę przyjemnej rozgrywki.
       
         Moxpouro
    • Przez agakon
      Witam Droga Administracjo!
       
      14 lutego na serwerze pojawiła się white-lista sprawa została wytłumaczona. Powiedziano, że serwer po godzinie lub dwóch wróci do normy. Jednak przynajmniej u mnie na komputerze serwer nie powrócił. Nie wymaga on white-listy tylko po prostu nie chce się włączyć. Jest nie dostępny. Pytanie brzmi tylko czy to moja sieć nie chce odtworzyć serwera? Czy też jest znów jakiś problem?  :(
       
       
       
      Proszę o jak najszybszą odpowiedź agakon :D
×
×
  • Dodaj nową pozycję...