KakesRevenge Posted May 9, 2015 Share Posted May 9, 2015 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 Quote 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 More sharing options...
KakesRevenge Posted May 9, 2015 Author Share Posted May 9, 2015 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; } Quote 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 More sharing options...
larsgerrits Posted May 9, 2015 Share Posted May 9, 2015 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. Quote 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 More sharing options...
KakesRevenge Posted May 9, 2015 Author Share Posted May 9, 2015 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; } Quote 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 More sharing options...
KakesRevenge Posted May 9, 2015 Author Share Posted May 9, 2015 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 )); } } Quote 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 More sharing options...
KakesRevenge Posted May 9, 2015 Author Share Posted May 9, 2015 Thats my eventhandler Quote 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 More sharing options...
larsgerrits Posted May 9, 2015 Share Posted May 9, 2015 Why are you not using itemInteractionForEntity in your Item class? Quote 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 More sharing options...
KakesRevenge Posted May 9, 2015 Author Share Posted May 9, 2015 dunno if thats a problem i will do it another way Quote 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 More sharing options...
KakesRevenge Posted May 9, 2015 Author Share Posted May 9, 2015 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... Quote 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 More sharing options...
KakesRevenge Posted May 9, 2015 Author Share Posted May 9, 2015 ok but how to get the color of the sheep taht im interacting with ? Quote 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 More sharing options...
shadowfacts Posted May 9, 2015 Share Posted May 9, 2015 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. Quote Don't make mods if you don't know Java. Check out my website: http://shadowfacts.net Developer of many mods Link to comment Share on other sites More sharing options...
KakesRevenge Posted May 9, 2015 Author Share Posted May 9, 2015 wow ok im ashamed of myself .. Quote 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 More sharing options...
Recommended Posts
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.