• 1

    posted a message on Where Is The Source Code For minecraft:shears

    In Eclipse:


    Referenced Libraries>forge-x.xx.x-xx.x.x>net>minecraft>item.ShearsItem


    Below example is for 1.15.2



    public class ShearsItem extends Item {
       public ShearsItem(Item.Properties builder) {
          super(builder);
       }
    
       /**
        * Called when a Block is destroyed using this Item. Return true to trigger the "Use Item" statistic.
        */
       public boolean onBlockDestroyed(ItemStack stack, World worldIn, BlockState state, BlockPos pos, LivingEntity entityLiving) {
          if (!worldIn.isRemote) {
             stack.damageItem(1, entityLiving, (p_220036_0_) -> {
                p_220036_0_.sendBreakAnimation(EquipmentSlotType.MAINHAND);
             });
          }
    
          Block block = state.getBlock();
          return !state.isIn(BlockTags.LEAVES) && block != Blocks.COBWEB && block != Blocks.GRASS && block != Blocks.FERN && block != Blocks.DEAD_BUSH && block != Blocks.VINE && block != Blocks.TRIPWIRE && !block.isIn(BlockTags.WOOL) ? super.onBlockDestroyed(stack, worldIn, state, pos, entityLiving) : true;
       }
    
       /**
        * Check whether this Item can harvest the given Block
        */
       public boolean canHarvestBlock(BlockState blockIn) {
          Block block = blockIn.getBlock();
          return block == Blocks.COBWEB || block == Blocks.REDSTONE_WIRE || block == Blocks.TRIPWIRE;
       }
    
       public float getDestroySpeed(ItemStack stack, BlockState state) {
          Block block = state.getBlock();
          if (block != Blocks.COBWEB && !state.isIn(BlockTags.LEAVES)) {
             return block.isIn(BlockTags.WOOL) ? 5.0F : super.getDestroySpeed(stack, state);
          } else {
             return 15.0F;
          }
       }
    
       /**
        * Returns true if the item can be used on the given entity, e.g. shears on sheep.
        */
       @SuppressWarnings("deprecation")
       @Override
       public boolean itemInteractionForEntity(ItemStack stack, net.minecraft.entity.player.PlayerEntity playerIn, LivingEntity entity, net.minecraft.util.Hand hand) {
          if (entity.world.isRemote) return false;
          if (entity instanceof net.minecraftforge.common.IShearable) {
             net.minecraftforge.common.IShearable target = (net.minecraftforge.common.IShearable)entity;
             BlockPos pos = new BlockPos(entity.getPosX(), entity.getPosY(), entity.getPosZ());
             if (target.isShearable(stack, entity.world, pos)) {
                java.util.List<ItemStack> drops = target.onSheared(stack, entity.world, pos,
                        net.minecraft.enchantment.EnchantmentHelper.getEnchantmentLevel(net.minecraft.enchantment.Enchantments.FORTUNE, stack));
                java.util.Random rand = new java.util.Random();
                drops.forEach(d -> {
                   net.minecraft.entity.item.ItemEntity ent = entity.entityDropItem(d, 1.0F);
                   ent.setMotion(ent.getMotion().add((double)((rand.nextFloat() - rand.nextFloat()) * 0.1F), (double)(rand.nextFloat() * 0.05F), (double)((rand.nextFloat() - rand.nextFloat()) * 0.1F)));
                });
                stack.damageItem(1, entity, e -> e.sendBreakAnimation(hand));
             }
             return true;
          }
          return false;
       }
    }


    Posted in: Modification Development
  • 1

    posted a message on Tinkers Construct Compatibility Help [1.7.10]

    They would have to make an API to integrate your mod into theirs.

    Posted in: Modification Development
  • 2

    posted a message on Where to start learning about modding?

    I've found, in my experience, I always turn to Jabelar's Modding Tutorials. In addition, they also link to other great modder's depending on what you're programming currently.


    The first thing anyone will tell you though, is 'Learn the basics of JAVA before trying to mod' for minecraft. It's really not that hard, especially if you've picked up on other programming languages.

    Posted in: Modification Development
  • 1

    posted a message on I cannot make a recipe work with coal

    Coal actually has a metadata value. Need to use this:



    "key": {
        "C": {
          "item": "minecraft:coal",
          "data": 0
        }


    Posted in: Modification Development
  • 1

    posted a message on [SOLVED] Armour model texture not working

    In your imports, I noticed you imported Entity from



    import com.sun.xml.internal.stream.Entity;


    Entity should be imported from



    net.minecraft.entity.Entity;



    see if that might help any

    Posted in: Modification Development
  • 1

    posted a message on Two Containers nearly identical.... One gets an error.

    I see 3 errors in your crash log. I have you checked all 3 to be sure they are correct?

    Posted in: Modification Development
  • 1

    posted a message on Adding Lore/Information to an Item [Solved]

    I tinkered around with addInformation and, this is what I got to work:



    @Override
    public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn)
    {
         super.addInformation(stack, worldIn, tooltip, flagIn);
    
         tooltip.add("your lore here");
    }



    Quote from MadHatAk»

    I tinkered around with addInformation and, this is what I got to work:



    @Override
    public void addInformation(ItemStack stack, World worldIn, List<String> tooltip, ITooltipFlag flagIn)
    {
         super.addInformation(stack, worldIn, tooltip, flagIn);
    
         tooltip.add("your lore here");
    }





    I got this idea from looking at the Item#ItemEnchantedBook.class

    Posted in: Modification Development
  • 1

    posted a message on Crash after adding a block in eclipse

    Caused by: java.lang.IllegalStateException: Attempted to set registry name with existing registry name! New: first:charcoal block Old: first:charcoal block

    Do you have 2 blocks with the same name?

    Posted in: Modification Development
  • 1

    posted a message on [SOLVED] Minecraft in Eclipse shows mod in mods list but not items in creative inventory (no errors)

    Typically if the items you have created in your mod do not show up in minecraft, there is a registry issue somewhere, Where is your Registry Handler Class?

    Posted in: Modification Development
  • 1

    posted a message on ItemStack Help with Metadata issue

    In your recipe, X is 1 item, and Y is another item. Both X and Y are used to make your new (Items.dye, 2, 1)

    Posted in: Modification Development
  • To post a comment, please .