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

    • Museumbola merupakan wadah judi online terkhusus untuk sbobet atau judi bola. Dengan daftar dan deposit menggunakan BANK BCA, Anda berkesempatan mendapatkan prediksi jitu pertandingan secara update setiap hari yang bisa anda jadikan acuan untuk bermain judi bola. Hanya dengan 10 ribu rupiah dan anda bermain Mix Parlay menggunakan prediksi yang telah di sediakan oleh kami, anda akan memenangkan jutaan rupiah. Yuk segera klik DAFTAR sekarang juga.
    • I was just trying to play my modded world when i randomly got this crash for no reason. I sorted through like every mod and eventually I realized it was LLibrary but I can't seem to find a solution to fix the crashing. I can't lose the world that I have that uses this mod please help me. Here's the report: https://pastebin.com/0D00B79i If anyone has a solution please let me know.  
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Ligawin88 adalah bocoran slot rekomendasi gacor dari Ligawin88 yang bisa anda temukan di SLOT Ligawin88. Situs SLOT Ligawin88 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Ligawin88 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Ligawin88 merupakan SLOT Ligawin88 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Ligawin88. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Ligawin88 hari ini yang telah disediakan SLOT Ligawin88. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Ligawin88 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Ligawin88 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Ligawin88 di link SLOT Ligawin88.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑   Daftar Slot Asusslot adalah bocoran slot rekomendasi gacor dari Asusslot yang bisa anda temukan di SLOT Asusslot. Situs SLOT Asusslot hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Asusslot terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Asusslot merupakan SLOT Asusslot hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Asusslot. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Asusslot hari ini yang telah disediakan SLOT Asusslot. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Asusslot terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Asusslot terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Asusslot di link SLOT Asusslot.
    • 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 🤑DAFTAR & LOGIN🤑 Daftar Slot Galeri555 adalah bocoran slot rekomendasi gacor dari Galeri555 yang bisa anda temukan di SLOT Galeri555. Situs SLOT Galeri555 hari ini yang kami bagikan di sini adalah yang terbaik dan bersiaplah untuk mengalami sensasi tak terlupakan dalam permainan slot online. Temukan game SLOT Galeri555 terbaik dengan 100 pilihan provider ternama yang dipercaya akan memberikan kepuasan dan kemenangan hari ini untuk meraih x500. RTP SLOT Galeri555 merupakan SLOT Galeri555 hari ini yang telah menjadi pilihan utama bagi pemain judi online di seluruh Indonesia. Setiap harinya jutaan pemain memasuki dunia maya untuk memperoleh hiburan seru dan kemenangan besar dalam bermain slot dengan adanya bocoran RTP SLOT Galeri555. Tidak ada yang lebih menyenangkan daripada mengungguli mesin slot dan meraih jackpot x500 yang menggiurkan di situs SLOT Galeri555 hari ini yang telah disediakan SLOT Galeri555. Menangkan jackpot besar x500 rajanya maxwin dari segala slot dan raih kemenangan spektakuler di situs Galeri555 terbaik 2024 adalah tempat yang menyediakan mesin slot dengan peluang kemenangan lebih tinggi daripada situs slot lainnya. Bagi anda yang mencari pengalaman judi slot paling seru dan mendebarkan, situs bo SLOT Galeri555 terbaik 2024 adalah pilihan yang tepat. Jelajahi dunia slot online melalui situs SLOT Galeri555 di link SLOT Galeri555.
  • Topics

×
×
  • Create New...

Important Information

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