Java Code Examples for net.minecraft.init.Items.SPAWN_EGG

The following are Jave code examples for showing how to use SPAWN_EGG of the net.minecraft.init.Items class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: CustomWorldGen   File: EntityVillager.java   View Source Code Vote up 6 votes
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack)
{
    boolean flag = stack != null && stack.getItem() == Items.SPAWN_EGG;

    if (!flag && this.isEntityAlive() && !this.isTrading() && !this.isChild() && !player.isSneaking())
    {
        if (!this.worldObj.isRemote && (this.buyingList == null || !this.buyingList.isEmpty()))
        {
            this.setCustomer(player);
            player.displayVillagerTradeGui(this);
        }

        player.addStat(StatList.TALKED_TO_VILLAGER);
        return true;
    }
    else
    {
        return super.processInteract(player, hand, stack);
    }
}
 
Example 2
Project: EndermanEvolution   File: ModCreativeTab.java   View Source Code Vote up 5 votes
@Override
public void displayAllRelevantItems(NonNullList<ItemStack> items) {
	items.add(new ItemStack(ModItems.FRIENDER_PEARL));
	items.add(new ItemStack(ModItems.SKULL_ENDERMAN));
	items.add(new ItemStack(ModItems.SKULL_FRIENDERMAN));
	items.add(new ItemStack(ModItems.SKULL_EVOLVED_ENDERMAN));

	ItemStack evolvedEndermanEgg = new ItemStack(Items.SPAWN_EGG);
	NBTTagCompound evolvedEndermanTag = new NBTTagCompound();
	NBTTagCompound evolvedEndermanEntityTag = new NBTTagCompound();
	evolvedEndermanEntityTag.setString("id", ModGlobals.MODID + ":enderman_evolved");
	evolvedEndermanTag.setTag("EntityTag", evolvedEndermanEntityTag);
	evolvedEndermanEgg.setTagCompound(evolvedEndermanTag);
	items.add(evolvedEndermanEgg);

	ItemStack frindermanEgg = new ItemStack(Items.SPAWN_EGG);
	NBTTagCompound frindermanTag = new NBTTagCompound();
	NBTTagCompound frindermanEntityTag = new NBTTagCompound();
	frindermanEntityTag.setString("id", ModGlobals.MODID + ":frienderman");
	frindermanTag.setTag("EntityTag", frindermanEntityTag);
	frindermanEgg.setTagCompound(frindermanTag);
	items.add(frindermanEgg);

	ItemStack evolvedEndermiteEgg = new ItemStack(Items.SPAWN_EGG);
	NBTTagCompound evolvedEndermiteTag = new NBTTagCompound();
	NBTTagCompound evolvedEndermiteEntityTag = new NBTTagCompound();
	evolvedEndermiteEntityTag.setString("id", ModGlobals.MODID + ":evolved_endermite");
	evolvedEndermiteTag.setTag("EntityTag", evolvedEndermiteEntityTag);
	evolvedEndermiteEgg.setTagCompound(evolvedEndermiteTag);
	items.add(evolvedEndermiteEgg);

	super.displayAllRelevantItems(items);
}
 
Example 3
Project: Backmemed   File: EntityAgeable.java   View Source Code Vote up 5 votes
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (itemstack.getItem() == Items.SPAWN_EGG)
    {
        if (!this.world.isRemote)
        {
            Class <? extends Entity > oclass = (Class)EntityList.field_191308_b.getObject(ItemMonsterPlacer.func_190908_h(itemstack));

            if (oclass != null && this.getClass() == oclass)
            {
                EntityAgeable entityageable = this.createChild(this);

                if (entityageable != null)
                {
                    entityageable.setGrowingAge(-24000);
                    entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F);
                    this.world.spawnEntityInWorld(entityageable);

                    if (itemstack.hasDisplayName())
                    {
                        entityageable.setCustomNameTag(itemstack.getDisplayName());
                    }

                    if (!player.capabilities.isCreativeMode)
                    {
                        itemstack.func_190918_g(1);
                    }
                }
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 4
Project: Backmemed   File: EntityAgeable.java   View Source Code Vote up 5 votes
protected boolean func_190669_a(ItemStack p_190669_1_, Class <? extends Entity > p_190669_2_)
{
    if (p_190669_1_.getItem() != Items.SPAWN_EGG)
    {
        return false;
    }
    else
    {
        Class <? extends Entity > oclass = (Class)EntityList.field_191308_b.getObject(ItemMonsterPlacer.func_190908_h(p_190669_1_));
        return oclass != null && p_190669_2_ == oclass;
    }
}
 
Example 5
Project: CustomWorldGen   File: EntityAgeable.java   View Source Code Vote up 5 votes
public boolean processInteract(EntityPlayer player, EnumHand hand, @Nullable ItemStack stack)
{
    if (stack != null && stack.getItem() == Items.SPAWN_EGG)
    {
        if (!this.worldObj.isRemote)
        {
            Class <? extends Entity > oclass = EntityList.NAME_TO_CLASS.get(ItemMonsterPlacer.getEntityIdFromItem(stack));

            if (oclass != null && this.getClass() == oclass)
            {
                EntityAgeable entityageable = this.createChild(this);

                if (entityageable != null)
                {
                    entityageable.setGrowingAge(-24000);
                    entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F);
                    this.worldObj.spawnEntityInWorld(entityageable);

                    if (stack.hasDisplayName())
                    {
                        entityageable.setCustomNameTag(stack.getDisplayName());
                    }

                    if (!player.capabilities.isCreativeMode)
                    {
                        --stack.stackSize;
                    }
                }
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
Example 6
Project: pnc-repressurized   File: TileEntityAirCannon.java   View Source Code Vote up 4 votes
private void updateDestination() {
    doneTurning = false;
    // take dispenser upgrade in account
    double payloadFrictionY = 0.98D; // this value will differ when a dispenser upgrade is inserted.
    double payloadFrictionX = 0.98D;
    double payloadGravity = 0.04D;
    if (getUpgrades(EnumUpgrade.ENTITY_TRACKER) > 0) {
        payloadFrictionY = 0.98D;
        payloadFrictionX = 0.91D;
        payloadGravity = 0.08D;
    } else if (getUpgrades(EnumUpgrade.DISPENSER) > 0 && !inventory.getStackInSlot(CANNON_SLOT).isEmpty()) {
        Item item = inventory.getStackInSlot(CANNON_SLOT).getItem();
        if (item == Items.POTIONITEM || item == Items.EXPERIENCE_BOTTLE || item == Items.EGG || item == Items.SNOWBALL) {// EntityThrowable
            payloadFrictionY = 0.99D;
            payloadGravity = 0.03D;
        } else if (item == Items.ARROW) {
            payloadFrictionY = 0.99D;
            payloadGravity = 0.05D;
        } else if (item == Items.MINECART || item == Items.CHEST_MINECART || item == Items.HOPPER_MINECART || item == Items.TNT_MINECART || item == Items.FURNACE_MINECART) {
            payloadFrictionY = 0.95D;
        }
        // else if(itemID == Item.fireballCharge.itemID){
        // payloadGravity = 0.0D;
        // }

        // family items (throwable) which only differ in gravity.
        if (item == Items.POTIONITEM) {
            payloadGravity = 0.05D;
        } else if (item == Items.EXPERIENCE_BOTTLE) {
            payloadGravity = 0.07D;
        }

        payloadFrictionX = payloadFrictionY;

        // items which have different frictions for each axis.
        if (item == Items.BOAT) {
            payloadFrictionX = 0.99D;
            payloadFrictionY = 0.95D;
        }
        if (item == Items.SPAWN_EGG) {
            payloadFrictionY = 0.98D;
            payloadFrictionX = 0.91D;
            payloadGravity = 0.08D;
        }
    }

    // calculate the heading.
    double deltaX = gpsX - getPos().getX();
    double deltaZ = gpsZ - getPos().getZ();
    float calculatedRotationAngle;
    if (deltaX >= 0 && deltaZ < 0) {
        calculatedRotationAngle = (float) (Math.atan(Math.abs(deltaX / deltaZ)) / Math.PI * 180D);
    } else if (deltaX >= 0 && deltaZ >= 0) {
        calculatedRotationAngle = (float) (Math.atan(Math.abs(deltaZ / deltaX)) / Math.PI * 180D) + 90;
    } else if (deltaX < 0 && deltaZ >= 0) {
        calculatedRotationAngle = (float) (Math.atan(Math.abs(deltaX / deltaZ)) / Math.PI * 180D) + 180;
    } else {
        calculatedRotationAngle = (float) (Math.atan(Math.abs(deltaZ / deltaX)) / Math.PI * 180D) + 270;
    }

    // calculate the height angle.
    double distance = Math.sqrt(deltaX * deltaX + deltaZ * deltaZ);
    double deltaY = gpsY - getPos().getY();
    float calculatedHeightAngle = calculateBestHeightAngle(distance, deltaY, getForce(), payloadGravity, payloadFrictionX, payloadFrictionY);

    setTargetAngles(calculatedRotationAngle, calculatedHeightAngle);
}
 
Example 7
Project: BetterThanWeagles   File: ModVillagers.java   View Source Code Vote up 4 votes
public static void registerVillagerTrades()
{
	careerKrog.addTrade(1, new VillagerTradeItemForItem(new ItemStack(ModItems.shiny_stone), new EntityVillager.PriceInfo(1, 1),
			new ItemStack(Items.LEATHER), new EntityVillager.PriceInfo(2, 2)));

	careerKrog.addTrade(1, new VillagerTradeItemForItem(new ItemStack(Items.PAINTING), new EntityVillager.PriceInfo(1, 1),
			new ItemStack(Blocks.CACTUS), new EntityVillager.PriceInfo(8, 16)));

	careerKrog.addTrade(1, new VillagerTradeItemForItem(new ItemStack(Items.FISHING_ROD), new EntityVillager.PriceInfo(1, 1),
			new ItemStack(Items.FISH), new EntityVillager.PriceInfo(5, 8)));

	careerKrog.addTrade(2, new VillagerTradeItemForItem(new ItemStack(Items.DYE), new EntityVillager.PriceInfo(5, 10),
			new ItemStack(Blocks.VINE), new EntityVillager.PriceInfo(2, 4)));

	if (Loader.isModLoaded("tconstruct"))
	{
		Item arrowhead = Item.REGISTRY.getObject(new ResourceLocation("tconstruct", "arrow_head"));
		if (arrowhead != null)
		{
			NBTTagCompound material = new NBTTagCompound();
			material.setString("Material", "obsidian");

			ItemStack stack = new ItemStack(arrowhead);
			stack.setTagCompound(material);

			careerKrog.addTrade(2, new VillagerTradeItemForItem(new ItemStack(Items.COAL, 1, 1), new EntityVillager.PriceInfo(10, 20),
					stack, new EntityVillager.PriceInfo(1, 1)));
		}
	}

	if (Loader.isModLoaded("actuallyadditions"))
	{
		Item crystal = Item.REGISTRY.getObject(new ResourceLocation("actuallyadditions", "item_crystal"));
		if (crystal != null)
		{
			ItemStack starterKit = createChickenSpawnerKit();
			careerKrog.addTrade(3, new VillagerTradeItemForItem(new ItemStack(crystal, 1, 4), new EntityVillager.PriceInfo(1, 3),
					starterKit, new EntityVillager.PriceInfo(1, 1)));
		}
	}

	careerTorg.addTrade(1, new VillagerTradeItemForItem(new ItemStack(Items.BEEF), new EntityVillager.PriceInfo(1, 3),
			new ItemStack(Blocks.SAPLING, 1, 3), new EntityVillager.PriceInfo(1, 3)));

	careerTorg.addTrade(1, new VillagerTradeItemForItem(new ItemStack(Items.LEATHER), new EntityVillager.PriceInfo(2, 4),
			new ItemStack(Items.MELON_SEEDS), new EntityVillager.PriceInfo(4, 6)));

	Block net = Block.REGISTRY.getObject(new ResourceLocation("actuallyadditions", "block_fishing_net"));
	if (net != Blocks.AIR)
	{
		careerTorg.addTrade(2, new VillagerTradeItemForItem(new ItemStack(net), new EntityVillager.PriceInfo(1, 1),
				new ItemStack(Items.DYE, 1, 3), new EntityVillager.PriceInfo(24, 36)));
	}

	if (Loader.isModLoaded("rustic"))
	{
		NBTTagCompound parrotTag = new NBTTagCompound();
		parrotTag.setString("id", "minecraft:parrot");
		ItemStack parrotEgg = new ItemStack(Items.SPAWN_EGG, 1);
		parrotEgg.setTagInfo("EntityTag", parrotTag);

		careerTorg.addTrade(3, new VillagerTradeItemForItem(new ItemStack(rustic.common.items.ModItems.HONEYCOMB), new EntityVillager.PriceInfo(30, 40),
				parrotEgg, new EntityVillager.PriceInfo(1, 1)));
	}
}
 
Example 8
Project: Backmemed   File: EntitySkeletonHorse.java   View Source Code Vote up 4 votes
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);
    boolean flag = !itemstack.func_190926_b();

    if (flag && itemstack.getItem() == Items.SPAWN_EGG)
    {
        return super.processInteract(player, hand);
    }
    else if (!this.isTame())
    {
        return false;
    }
    else if (this.isChild())
    {
        return super.processInteract(player, hand);
    }
    else if (player.isSneaking())
    {
        this.openGUI(player);
        return true;
    }
    else if (this.isBeingRidden())
    {
        return super.processInteract(player, hand);
    }
    else
    {
        if (flag)
        {
            if (itemstack.getItem() == Items.SADDLE && !this.isHorseSaddled())
            {
                this.openGUI(player);
                return true;
            }

            if (itemstack.interactWithEntity(player, this, hand))
            {
                return true;
            }
        }

        this.mountTo(player);
        return true;
    }
}
 
Example 9
Project: Backmemed   File: AbstractChestHorse.java   View Source Code Vote up 4 votes
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);

    if (itemstack.getItem() == Items.SPAWN_EGG)
    {
        return super.processInteract(player, hand);
    }
    else
    {
        if (!this.isChild())
        {
            if (this.isTame() && player.isSneaking())
            {
                this.openGUI(player);
                return true;
            }

            if (this.isBeingRidden())
            {
                return super.processInteract(player, hand);
            }
        }

        if (!itemstack.func_190926_b())
        {
            boolean flag = this.func_190678_b(player, itemstack);

            if (!flag && !this.isTame())
            {
                if (itemstack.interactWithEntity(player, this, hand))
                {
                    return true;
                }

                this.func_190687_dF();
                return true;
            }

            if (!flag && !this.func_190695_dh() && itemstack.getItem() == Item.getItemFromBlock(Blocks.CHEST))
            {
                this.setChested(true);
                this.func_190697_dk();
                flag = true;
                this.initHorseChest();
            }

            if (!flag && !this.isChild() && !this.isHorseSaddled() && itemstack.getItem() == Items.SADDLE)
            {
                this.openGUI(player);
                return true;
            }

            if (flag)
            {
                if (!player.capabilities.isCreativeMode)
                {
                    itemstack.func_190918_g(1);
                }

                return true;
            }
        }

        if (this.isChild())
        {
            return super.processInteract(player, hand);
        }
        else if (itemstack.interactWithEntity(player, this, hand))
        {
            return true;
        }
        else
        {
            this.mountTo(player);
            return true;
        }
    }
}
 
Example 10
Project: Backmemed   File: EntityZombieHorse.java   View Source Code Vote up 4 votes
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);
    boolean flag = !itemstack.func_190926_b();

    if (flag && itemstack.getItem() == Items.SPAWN_EGG)
    {
        return super.processInteract(player, hand);
    }
    else if (!this.isTame())
    {
        return false;
    }
    else if (this.isChild())
    {
        return super.processInteract(player, hand);
    }
    else if (player.isSneaking())
    {
        this.openGUI(player);
        return true;
    }
    else if (this.isBeingRidden())
    {
        return super.processInteract(player, hand);
    }
    else
    {
        if (flag)
        {
            if (!this.isHorseSaddled() && itemstack.getItem() == Items.SADDLE)
            {
                this.openGUI(player);
                return true;
            }

            if (itemstack.interactWithEntity(player, this, hand))
            {
                return true;
            }
        }

        this.mountTo(player);
        return true;
    }
}
 
Example 11
Project: Backmemed   File: EntityHorse.java   View Source Code Vote up 4 votes
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
    ItemStack itemstack = player.getHeldItem(hand);
    boolean flag = !itemstack.func_190926_b();

    if (flag && itemstack.getItem() == Items.SPAWN_EGG)
    {
        return super.processInteract(player, hand);
    }
    else
    {
        if (!this.isChild())
        {
            if (this.isTame() && player.isSneaking())
            {
                this.openGUI(player);
                return true;
            }

            if (this.isBeingRidden())
            {
                return super.processInteract(player, hand);
            }
        }

        if (flag)
        {
            if (this.func_190678_b(player, itemstack))
            {
                if (!player.capabilities.isCreativeMode)
                {
                    itemstack.func_190918_g(1);
                }

                return true;
            }

            if (itemstack.interactWithEntity(player, this, hand))
            {
                return true;
            }

            if (!this.isTame())
            {
                this.func_190687_dF();
                return true;
            }

            boolean flag1 = HorseArmorType.getByItemStack(itemstack) != HorseArmorType.NONE;
            boolean flag2 = !this.isChild() && !this.isHorseSaddled() && itemstack.getItem() == Items.SADDLE;

            if (flag1 || flag2)
            {
                this.openGUI(player);
                return true;
            }
        }

        if (this.isChild())
        {
            return super.processInteract(player, hand);
        }
        else
        {
            this.mountTo(player);
            return true;
        }
    }
}