Jump to content

[SORTA SOLVED][1.6.4] getting int with metadata from ItemStack


saxon564

Recommended Posts

Heres the code i need help with:

 

this.tasks.addTask(3, new ChickAITempt(this, 1.0D, new ItemStack(Item.dyePowder, 1, 3).itemID, false));

 

i need to pass new ItemStack(Item.dyePowder, 1, 3).itemID on to ChickAITempt with the metadata of 3. but i cant get it to send without changing the constructor of ChickAITempt, which will break it with all the other mobs. could someone show me what i need to do to send the metadata to the ChickAITempt class?

Link to comment
Share on other sites

You probably can't, as the constructor deals with only an item ID (which, why you'd create an item stack only to get the item's ID out of it, when you could just skip the item stack, I have no idea).  If you take a peek inside AITempt, you'll either find out that it doesn't care OR you'll find the variable that holds the information and how to set it.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

the constructor asks for an int, i can change that if i wanted, but i would have to change several other classes to match it, as for it not caring, thats because it simply is just that, unless there is a way, it doesnt care, and any dye will do what im trying to do, but i only want the cocoa beans to be used.

 

heres the code for EntityAIChick:

package mods.mochickens.misc;

import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;

public class ChickAITempt extends EntityAIBase
{
    /** The entity using this AI that is tempted by the player. */
    private EntityCreature temptedEntity;
    private double field_75282_b;

    /** X position of player tempting this mob */
    private double targetX;

    /** Y position of player tempting this mob */
    private double targetY;

    /** Z position of player tempting this mob */
    private double targetZ;
    private double field_75278_f;
    private double field_75279_g;

    /** The player that is tempting the entity that is using this AI. */
    private EntityPlayer temptingPlayer;

    /**
     * A counter that is decremented each time the shouldExecute method is called. The shouldExecute method will always
     * return false if delayTemptCounter is greater than 0.
     */
    private int delayTemptCounter;

    /** True if this EntityAITempt task is running */
    private boolean isRunning;

    /**
     * This field saves the ID of the items that can be used to breed entities with this behaviour.
     */
    private int breedingFood;

    /**
     * Whether the entity using this AI will be scared by the tempter's sudden movement.
     */
    private boolean scaredByPlayerMovement;
    private boolean field_75286_m;

    public ChickAITempt(EntityCreature par1EntityCreature, double par2, int par4, boolean par5)
    {
        this.setTemptedEntity(par1EntityCreature);
        this.field_75282_b = par2;
        this.setBreedingFood(par4);
        this.scaredByPlayerMovement = par5;
        this.setMutexBits(3);
    }

    /**
     * Returns whether the EntityAIBase should begin execution.
     */
    public boolean shouldExecute()
    {
    	String owner = this.getTemptedEntity().getDataWatcher()
    			.getWatchableObjectString(17);
    	
    	if (this.getDelayTemptCounter() > 0) {
		this.setDelayTemptCounter(this.getDelayTemptCounter() - 1);
		return false;
	} else {
		this.setTemptingPlayer(this.getTemptedEntity().worldObj
				.getClosestPlayerToEntity(this.getTemptedEntity(), 10.0D));

		if (this.getTemptingPlayer() == null) {
			return false;
		} else if (this.getTemptingPlayer().getEntityName() != owner) {
			return false;
		} else {
			ItemStack itemstack = this.getTemptingPlayer()
					.getCurrentEquippedItem();
			return itemstack == null ? false : itemstack.itemID == this
					.getBreedingFood();
		}
	}
    }

    /**
     * Returns whether an in-progress EntityAIBase should continue executing
     */
    public boolean continueExecuting()
    {
        if (this.scaredByPlayerMovement)
        {
            if (this.getTemptedEntity().getDistanceSqToEntity(this.getTemptingPlayer()) < 36.0D)
            {
                if (this.getTemptingPlayer().getDistanceSq(this.targetX, this.targetY, this.targetZ) > 0.010000000000000002D)
                {
                    return false;
                }

                if (Math.abs((double)this.getTemptingPlayer().rotationPitch - this.field_75278_f) > 5.0D || Math.abs((double)this.getTemptingPlayer().rotationYaw - this.field_75279_g) > 5.0D)
                {
                    return false;
                }
            }
            else
            {
                this.targetX = this.getTemptingPlayer().posX;
                this.targetY = this.getTemptingPlayer().posY;
                this.targetZ = this.getTemptingPlayer().posZ;
            }

            this.field_75278_f = (double)this.getTemptingPlayer().rotationPitch;
            this.field_75279_g = (double)this.getTemptingPlayer().rotationYaw;
        }

        return this.shouldExecute();
    }

    /**
     * Execute a one shot task or start executing a continuous task
     */
    public void startExecuting()
    {
        this.targetX = this.getTemptingPlayer().posX;
        this.targetY = this.getTemptingPlayer().posY;
        this.targetZ = this.getTemptingPlayer().posZ;
        this.isRunning = true;
        this.field_75286_m = this.getTemptedEntity().getNavigator().getAvoidsWater();
        this.getTemptedEntity().getNavigator().setAvoidsWater(false);
    }

    /**
     * Resets the task
     */
    public void resetTask()
    {
        this.setTemptingPlayer(null);
        this.getTemptedEntity().getNavigator().clearPathEntity();
        this.setDelayTemptCounter(100);
        this.isRunning = false;
        this.getTemptedEntity().getNavigator().setAvoidsWater(this.field_75286_m);
    }

    /**
     * Updates the task
     */
    public void updateTask()
    {
        this.getTemptedEntity().getLookHelper().setLookPositionWithEntity(this.getTemptingPlayer(), 30.0F, (float)this.getTemptedEntity().getVerticalFaceSpeed());

        if (this.getTemptedEntity().getDistanceSqToEntity(this.getTemptingPlayer()) < 6.25D)
        {
            this.getTemptedEntity().getNavigator().clearPathEntity();
        }
        else
        {
            this.getTemptedEntity().getNavigator().tryMoveToEntityLiving(this.getTemptingPlayer(), this.field_75282_b);
        }
    }

    /**
     * @see #isRunning
     */
    public boolean isRunning()
    {
        return this.isRunning;
    }

public int getDelayTemptCounter() {
	return delayTemptCounter;
}

public void setDelayTemptCounter(int delayTemptCounter) {
	this.delayTemptCounter = delayTemptCounter;
}

public EntityPlayer getTemptingPlayer() {
	return temptingPlayer;
}

public void setTemptingPlayer(EntityPlayer temptingPlayer) {
	this.temptingPlayer = temptingPlayer;
}

public EntityCreature getTemptedEntity() {
	return temptedEntity;
}

public void setTemptedEntity(EntityCreature temptedEntity) {
	this.temptedEntity = temptedEntity;
}

public int getBreedingFood() {
	return breedingFood;
}

public void setBreedingFood(int breedingFood) {
	this.breedingFood = breedingFood;
}
}

Link to comment
Share on other sites

You know you can have multiple constructors...right?

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

tried multiple constructors and it still didnt work, so i decided just to make another AI class to deal with meta blocks which now works.

 

package mods.mochickens.misc;

import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.ai.EntityAIBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.server.MinecraftServer;

public class ChickAITemptDye extends EntityAIBase {
/** The entity using this AI that is tempted by the player. */
private EntityCreature temptedEntity;
private double field_75282_b;

/** X position of player tempting this mob */
private double targetX;

/** Y position of player tempting this mob */
private double targetY;

/** Z position of player tempting this mob */
private double targetZ;
private double field_75278_f;
private double field_75279_g;

/** The player that is tempting the entity that is using this AI. */
private EntityPlayer temptingPlayer;

/**
 * A counter that is decremented each time the shouldExecute method is
 * called. The shouldExecute method will always return false if
 * delayTemptCounter is greater than 0.
 */
private int delayTemptCounter;

/** True if this EntityAITempt task is running */
private boolean isRunning;

/**
 * This field saves the ID of the items that can be used to breed entities
 * with this behaviour.
 */
private String breedingFood;

/**
 * Whether the entity using this AI will be scared by the tempter's sudden
 * movement.
 */
private boolean scaredByPlayerMovement;
private boolean field_75286_m;

public ChickAITemptDye(EntityCreature par1EntityCreature, double par2,
		String par4, boolean par5) {
	this.setTemptedEntity(par1EntityCreature);
	this.field_75282_b = par2;
	this.setBreedingFood(par4);
	this.scaredByPlayerMovement = par5;
	this.setMutexBits(3);
}

/**
 * Returns whether the EntityAIBase should begin execution.
 */
public boolean shouldExecute() {
	String owner = this.getTemptedEntity().getDataWatcher()
			.getWatchableObjectString(17);

	if (this.getDelayTemptCounter() > 0) {
		this.setDelayTemptCounter(this.getDelayTemptCounter() - 1);
		return false;
	} else {
		this.setTemptingPlayer(this.getTemptedEntity().worldObj
				.getClosestPlayerToEntity(this.getTemptedEntity(), 10.0D));

		if (this.getTemptingPlayer() == null) {
			return false;
		} else if (this.getTemptingPlayer().getEntityName() != owner) {
			return false;
		} else {
			ItemStack itemstack = this.getTemptingPlayer()
					.getCurrentEquippedItem();
			return itemstack == null ? false : itemstack.getDisplayName().equalsIgnoreCase(this.getBreedingFood());
		}
	}
}

/**
 * Returns whether an in-progress EntityAIBase should continue executing
 */
public boolean continueExecuting() {
	if (this.scaredByPlayerMovement) {
		if (this.getTemptedEntity().getDistanceSqToEntity(
				this.getTemptingPlayer()) < 36.0D) {
			if (this.getTemptingPlayer().getDistanceSq(this.targetX,
					this.targetY, this.targetZ) > 0.010000000000000002D) {
				return false;
			}

			if (Math.abs((double) this.getTemptingPlayer().rotationPitch
					- this.field_75278_f) > 5.0D
					|| Math.abs((double) this.getTemptingPlayer().rotationYaw
							- this.field_75279_g) > 5.0D) {
				return false;
			}
		} else {
			this.targetX = this.getTemptingPlayer().posX;
			this.targetY = this.getTemptingPlayer().posY;
			this.targetZ = this.getTemptingPlayer().posZ;
		}

		this.field_75278_f = (double) this.getTemptingPlayer().rotationPitch;
		this.field_75279_g = (double) this.getTemptingPlayer().rotationYaw;
	}

	return this.shouldExecute();
}

/**
 * Execute a one shot task or start executing a continuous task
 */
public void startExecuting() {
	this.targetX = this.getTemptingPlayer().posX;
	this.targetY = this.getTemptingPlayer().posY;
	this.targetZ = this.getTemptingPlayer().posZ;
	this.isRunning = true;
	this.field_75286_m = this.getTemptedEntity().getNavigator()
			.getAvoidsWater();
	this.getTemptedEntity().getNavigator().setAvoidsWater(false);
}

/**
 * Resets the task
 */
public void resetTask() {
	this.setTemptingPlayer(null);
	this.getTemptedEntity().getNavigator().clearPathEntity();
	this.setDelayTemptCounter(100);
	this.isRunning = false;
	this.getTemptedEntity().getNavigator()
			.setAvoidsWater(this.field_75286_m);
}

/**
 * Updates the task
 */
public void updateTask() {
	this.getTemptedEntity()
			.getLookHelper()
			.setLookPositionWithEntity(this.getTemptingPlayer(), 30.0F,
					(float) this.getTemptedEntity().getVerticalFaceSpeed());

	if (this.getTemptedEntity().getDistanceSqToEntity(
			this.getTemptingPlayer()) < 6.25D) {
		this.getTemptedEntity().getNavigator().clearPathEntity();
	} else {
		this.getTemptedEntity()
				.getNavigator()
				.tryMoveToEntityLiving(this.getTemptingPlayer(),
						this.field_75282_b);
	}
}

/**
 * @see #isRunning
 */
public boolean isRunning() {
	return this.isRunning;
}

public int getDelayTemptCounter() {
	return delayTemptCounter;
}

public void setDelayTemptCounter(int delayTemptCounter) {
	this.delayTemptCounter = delayTemptCounter;
}

public EntityPlayer getTemptingPlayer() {
	return temptingPlayer;
}

public void setTemptingPlayer(EntityPlayer temptingPlayer) {
	this.temptingPlayer = temptingPlayer;
}

public EntityCreature getTemptedEntity() {
	return temptedEntity;
}

public void setTemptedEntity(EntityCreature temptedEntity) {
	this.temptedEntity = temptedEntity;
}

public String getBreedingFood() {
	return breedingFood;
}


public void setBreedingFood(String par4) {
	this.breedingFood = par4;
}
}

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Tayo4D : Bandar Online Togel Dan Slot Terbesar Di Indonesia     Pemain taruhan Tayo4D yang berkualitas memerlukan platform yang aman, terpercaya, dan mudah digunakan. Dalam era teknologi ini, banyak situs online yang menawarkan layanan taruhan togel 4D, tetapi memilih yang tepat menjadi tuntas. Berikut adalah cara untuk membuat artikel yang membahas tentang situs online terpercaya untuk permainan taruhan togel 4D.  
    • OLXTOTO: Platform Maxwin dan Gacor Terbesar Sepanjang Masa OLXTOTO telah menetapkan standar baru dalam dunia perjudian dengan menjadi platform terbesar untuk pengalaman gaming yang penuh kemenangan dan kegacoran, sepanjang masa. Dengan fokus yang kuat pada menyediakan permainan yang menghadirkan kesenangan tanpa batas dan peluang kemenangan besar, OLXTOTO telah menjadi pilihan utama bagi para pencinta judi berani di Indonesia. Maxwin: Mengejar Kemenangan Terbesar Maxwin bukan sekadar kata-kata kosong di OLXTOTO. Ini adalah konsep yang ditanamkan dalam setiap aspek permainan yang mereka tawarkan. Dari permainan slot yang menghadirkan jackpot besar hingga berbagai opsi permainan togel dengan hadiah fantastis, para pemain dapat memperoleh peluang nyata untuk mencapai kemenangan terbesar dalam setiap taruhan yang mereka lakukan. OLXTOTO tidak hanya menawarkan kesempatan untuk menang, tetapi juga menjadi wadah bagi para pemain untuk meraih impian mereka dalam perjudian yang berani. Gacor: Keberuntungan yang Tak Tertandingi Keberuntungan seringkali menjadi faktor penting dalam perjudian, dan OLXTOTO memahami betul akan hal ini. Dengan berbagai strategi dan analisis yang disediakan, pemain dapat menemukan peluang gacor yang tidak tertandingi dalam setiap taruhan. Dari hasil togel yang tepat hingga putaran slot yang menguntungkan, OLXTOTO memastikan bahwa setiap taruhan memiliki potensi untuk menjadi momen yang mengubah hidup. Inovasi dan Kualitas Tanpa Batas Tidak puas dengan prestasi masa lalu, OLXTOTO terus berinovasi untuk memberikan pengalaman gaming terbaik kepada para pengguna. Dengan menggabungkan teknologi terbaru dengan desain yang ramah pengguna, platform ini menyajikan antarmuka yang mudah digunakan tanpa mengorbankan kualitas. Setiap pembaruan dan peningkatan dilakukan dengan tujuan tunggal: memberikan pengalaman gaming yang tanpa kompromi kepada setiap pengguna. Komitmen Terhadap Kepuasan Pelanggan Di balik kesuksesan OLXTOTO adalah komitmen mereka terhadap kepuasan pelanggan. Tim dukungan pelanggan yang profesional siap membantu para pemain dalam setiap langkah perjalanan gaming mereka. Dari pertanyaan teknis hingga bantuan dengan transaksi keuangan, OLXTOTO selalu siap memberikan pelayanan terbaik kepada para pengguna mereka. Penutup: Mengukir Sejarah dalam Dunia Perjudian Daring OLXTOTO bukan sekadar platform perjudian berani biasa. Ini adalah ikon dalam dunia perjudian daring Indonesia, sebuah destinasi yang menyatukan kemenangan dan keberuntungan dalam satu tempat yang mengasyikkan. Dengan komitmen mereka terhadap kualitas, inovasi, dan kepuasan pelanggan, OLXTOTO terus mengukir sejarah dalam perjudian dunia berani, menjadi nama yang tak terpisahkan dari pengalaman gaming terbaik. Bersiaplah untuk mengalami sensasi kemenangan terbesar dan keberuntungan tak terduga di OLXTOTO - platform maxwin dan gacor terbesar sepanjang masa.
    • OLXTOTO - Bandar Togel Online Dan Slot Terbesar Di Indonesia OLXTOTO telah lama dikenal sebagai salah satu bandar online terkemuka di Indonesia, terutama dalam pasar togel dan slot. Dengan reputasi yang solid dan pengalaman bertahun-tahun, OLXTOTO menawarkan platform yang aman dan andal bagi para penggemar perjudian daring. DAFTAR OLXTOTO DISINI DAFTAR OLXTOTO DISINI DAFTAR OLXTOTO DISINI Beragam Permainan Togel Sebagai bandar online terbesar di Indonesia, OLXTOTO menawarkan berbagai macam permainan togel. Mulai dari togel Singapura, togel Hongkong, hingga togel Sidney, pemain memiliki banyak pilihan untuk mencoba keberuntungan mereka. Dengan sistem yang transparan dan hasil yang adil, OLXTOTO memastikan bahwa setiap taruhan diproses dengan cepat dan tanpa keadaan. Slot Online Berkualitas Selain togel, OLXTOTO juga menawarkan berbagai permainan slot online yang menarik. Dari slot klasik hingga slot video modern, pemain dapat menemukan berbagai opsi permainan yang sesuai dengan preferensi mereka. Dengan grafis yang memukau dan fitur bonus yang menggiurkan, pengalaman bermain slot di OLXTOTO tidak akan pernah membosankan. Keamanan dan Kepuasan Pelanggan Terjamin Keamanan dan kepuasan pelanggan merupakan prioritas utama di OLXTOTO. Mereka menggunakan teknologi enkripsi terbaru untuk melindungi data pribadi dan keuangan para pemain. Tim dukungan pelanggan yang ramah dan responsif siap membantu pemain dengan setiap pertanyaan atau masalah yang mereka hadapi. Promosi dan Bonus Menarik OLXTOTO sering menawarkan promosi dan bonus menarik kepada para pemainnya. Mulai dari bonus selamat datang hingga bonus deposit, pemain memiliki kesempatan untuk meningkatkan kemenangan mereka dengan memanfaatkan berbagai penawaran yang tersedia. Penutup Dengan reputasi yang solid, beragam permainan berkualitas, dan komitmen terhadap keamanan dan kepuasan pelanggan, OLXTOTO tetap menjadi salah satu pilihan utama bagi para pecinta judi online di Indonesia. Jika Anda mencari pengalaman berjudi yang menyenangkan dan terpercaya, OLXTOTO layak dipertimbangkan.
    • I have been having a problem with minecraft forge. Any version. Everytime I try to launch it it always comes back with error code 1. I have tried launching from curseforge, from the minecraft launcher. I have also tried resetting my computer to see if that would help. It works on my other computer but that one is too old to run it properly. I have tried with and without mods aswell. Fabric works, optifine works, and MultiMC works aswell but i want to use forge. If you can help with this issue please DM on discord my # is Haole_Dawg#6676
    • Add the latest.log (logs-folder) with sites like https://paste.ee/ and paste the link to it here  
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.