Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 :)

  • Author

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 :)

 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/

  • Author

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 :)

  • Author

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 :)

  • Author

Thats my eventhandler

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 :)

  • Author

dunno if thats a problem i will do it another way

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 :)

  • Author

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 :)

  • Author

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 :)

entitySheep.getFleeceColor();

Where entitySheep is the name of the variable containing the EntitySheep.

 

Simple Java, if you can't figure out this, then you need to go look at some Java tutorials.

Don't make mods if you don't know Java.

Check out my website: http://shadowfacts.net

Developer of many mods

  • Author

wow ok im ashamed of myself ..

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 :)

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.