Jump to content

[1.7.10][SOLVED] How to find out color of sheep


KakesRevenge

Recommended Posts

Hey,

Im trying to find out what wool color a particular sheep has.

So when I right click the sheep, I want to get the color it has.

And I want to make the sheep sheared when I get the wool out of it.

 

Any ideas will be appreciated :)

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

i have looked and i dont understand it :/

this is the interactwithentity method in ItemShears

 

 

@Override

    public boolean itemInteractionForEntity(ItemStack itemstack, EntityPlayer player, EntityLivingBase entity)

    {

        if (entity.worldObj.isRemote)

        {

            return false;

        }

        if (entity instanceof IShearable)

        {

            IShearable target = (IShearable)entity;

            if (target.isShearable(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ))

            {

                ArrayList<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ,

                        EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));

 

                Random rand = new Random();

                for(ItemStack stack : drops)

                {

                    EntityItem ent = entity.entityDropItem(stack, 1.0F);

                    ent.motionY += rand.nextFloat() * 0.05F;

                    ent.motionX += (rand.nextFloat() - rand.nextFloat()) * 0.1F;

                    ent.motionZ += (rand.nextFloat() - rand.nextFloat()) * 0.1F;

                }

                itemstack.damageItem(1, entity);

            }

            return true;

        }

        return false;

    }

 

 

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

 ArrayList<ItemStack> drops = target.onSheared(itemstack, entity.worldObj, (int)entity.posX, (int)entity.posY, (int)entity.posZ,
                        EnchantmentHelper.getEnchantmentLevel(Enchantment.fortune.effectId, itemstack));

Shears call

IShearable#onSheared

, and sheep implement that interface. So go to

EntitySheep#onSheared

and look how they figure out the color of the sheep.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

ok thank you it looks like this :

 

 

@Override

    public ArrayList<ItemStack> onSheared(ItemStack item, IBlockAccess world, int x, int y, int z, int fortune)

    {

        ArrayList<ItemStack> ret = new ArrayList<ItemStack>();

        setSheared(true);

        int i = 1 + rand.nextInt(3);

        for (int j = 0; j < i; j++)

        {

            ret.add(new ItemStack(Blocks.wool, 1, getFleeceColor()));

        }

        this.playSound("mob.sheep.shear", 1.0F, 1.0F);

        return ret;

    }

 

 

But i cant get the datawatcher in

 

public int getFleeceColor()
    {
        return EntitySheep.getDataWatcher().getWatchableObjectByte(16) & 15;
    }

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

This is what ive got so far ... but its crashing

public class ClayBucketHandler {

    protected DataWatcher dataWatcher;
    
    public boolean getSheared()
    {
        return (this.dataWatcher.getWatchableObjectByte(16) & 16) != 0;
    }
    
@SubscribeEvent
    public void EntityInteract(EntityInteractEvent event) {
	if(event.target instanceof EntitySheep) {
		Item equipped = event.entityPlayer.getCurrentEquippedItem().getItem();
		EntityPlayer player = event.entityPlayer;
		int color = dataWatcher.getWatchableObjectByte(16) & 15;
	    if(equipped == ItemsHandler.ClayBucketFired) {
	    	player.inventory.setInventorySlotContents(player.inventory.currentItem, new ItemStack(ItemsHandler.ClayBucketWool));
	    	player.inventory.addItemStackToInventory(new ItemStack(Blocks.wool, 1, color ));
	    	
		}
	}

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

Why are you not using itemInteractionForEntity in your Item class?

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

Link to comment
Share on other sites

Im stilll wondering how EXACTLY get the color of the sheep that im interacting with ...

in entitysheep class the getFleeceColor method isnt static so i cant use it...

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

ok but how to get the color of the sheep taht im interacting with ?

I'm beginner in java and in minecraft modding.

Please be specific.

Any code examples are appreciated.

Sorry for my english i'm from Czech republic.

Please hit that thank you button if i helped :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • the mods are crashing and I'm not sure why so heres everything  crash log https://pastebin.com/RxLKbMNR  L2 Library (12library) has failed to load correctly java.lang.NoClassDefFoundError: org/antarcticgardens/newage/content/energiser/EnergiserBlock L2 Screen Tracker (12screentracker) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.12library.base.L2Registrate Create: Interiors (interiors) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.tterrag.registrate.AbstractRegistrate L2 Damage Tracker (12damagetracker) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.l2library.base.L2Registrate Create Enchantment Industry (create_enchantment_industry) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.simibubi.create.foundation.data.Createfiegistrate Create Crafts & Additions (createaddition) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.simibubi.create.foundation.data.CreateRegistrate Create Slice & Dice (sliceanddice) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.simibubi.create.foundation.data.CreateRegistrate L2 Tabs (12tabs) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.l2library.base.L2Registrate Modular Golems (modulargolems) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.l2library.base.L2Registrate Create: Steam 'n' FRails (railways) has failed to load correctly java.lang.NoClassDefFoundError : Could not initialize class com.simibubi.create.foundation.data.Createfregistrate Cuisine Delight (cuisinedelight) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.12library.base.L2Registrate Create (create) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.simibubi.create.Create Guardian Beam Defense (creategbd) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class com.simibubi.create.foundation.data.CreateRegistrate L2 Item Selector (12itemselector) has failed to load correctly java.lang.NoClassDefFoundError: Could not initialize class dev.xkmc.l2library.base.L2Registrate
    • hey there, I have been using Forge for years without any problems, but for some time now I have been getting this error message when I click on “Installer” under the downloads. This happens on all versions. I have tried various things but have not gotten any results. If anyone has a solution, I would be very grateful!
    • I don't have mcreator installed.
    • the session has expired, what if the modified LAN Server displays the same screen after logging in as after logging in to the premium server from a non-premium account? Minecraft Forge 1.20.1 CurseForge. I also use Mod LAN World Plug n Play
    • Hello There! In today's video I will be showing you guys the Minecraft and Google Collaboration they are doing for the 15th anniversary for Minecraft! If you guys wanna try this out for yourself go to google and type in "Minecraft"!  
  • Topics

×
×
  • Create New...

Important Information

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