Posted May 9, 201510 yr 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
May 9, 201510 yr 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
May 9, 201510 yr 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/
May 9, 201510 yr 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
May 9, 201510 yr 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
May 9, 201510 yr 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
May 9, 201510 yr 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/
May 9, 201510 yr 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
May 9, 201510 yr 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
May 9, 201510 yr 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
May 9, 201510 yr 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
May 9, 201510 yr 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.