• 1

    posted a message on Getting block within a certain radius when button pressed?

    Be aware that calling any methods from the GUI is client-side only. If you want to run anything on the server (which you usually do), you need to send a packet to the server with information about where the TileEntity is and which button was pressed.

    Posted in: Modification Development
  • 1

    posted a message on Item With Crafting Damage
    new ItemStack(ModItems.chisel, OreDictionary.WILDCARD_VALUE, -1)

    You have the arguments mixed up. The constructor of ItemStack is new ItemStack(Item item, int stackSize, int metadata)

    Change it to have 1 (not -1) as stack size and WILDCARD_VALUE as metadata.

    Posted in: Modification Development
  • 1

    posted a message on Item With Crafting Damage
    Quote from M_Dragon4»

    Where do I want to create the new ItemStack of my item? Also, where do I do damage to the item?


    Both of these will be done inside getContainerItem(ItemStack) where you will return that ItemStack you just made and damaged.

    @AdityaSF It's better to use ItemStack stack2 = stack1.copy() in case there are important NBT tags, such as enchantments. The rest of your suggestion is correct, so follow that M_Dragon4
    Posted in: Modification Development
  • 1

    posted a message on Item With Crafting Damage
    Quote from M_Dragon4»

    I'm sorry, but I don't follow. Do I need to add @Override hasContainerItem(ItemStack itemStack){ return true; } ?


    Yes, if you're not familiar with overriding methods, read this. Overriding is something you will do quite a lot to add custom behavior to your blocks, items, entities, etc.
    This is the exact syntax (make sure to include the modifier and return type -- in this case, public boolean)

    @Override // this is just for your compiler, but it helps you
    public boolean hasContainerItem(ItemStack stack)
    {
            return true;
    }
    Posted in: Modification Development
  • 1

    posted a message on How to update from 1.8.9 to 1.10

    Most of the Minecraft blocks make a public static final AxisAlignedBB for each set of bounds so they aren't making a new one every time it is called.

    Other than that, TechMage66 is correct.

    Posted in: Modification Development
  • 1

    posted a message on Different block drops depending on tool

    HarvestDropsEvent contains a List<ItemStack> of all the items that will drop from that block. All you have to do is modify that list based on whatever conditions. To replace drops, you always have to clear the list -- to add "bonus" drops, clearing is not necessary. I have an example here where breaking gravel with my custom tool has a 50% chance to drop flint (as opposed to the normal 10% chance).


    I got a lot of crashes if I forgot to check that getHarvester() is not null -- this code is called by explosions, too, where there is no harvester.


    Jabelar has a good explanation of what events are, how to use them, etc. here.

    Posted in: Modification Development
  • 1

    posted a message on How to update from 1.8.9 to 1.10

    setBlockBoundsBasedOnState --> public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos)

    ChatComponentText --> TextComponentBase and TextComponentTranslation

    EnumChatFormatting --> TextFormatting

    EnumBlockLayer --> BlockRenderLayer


    Many of these you can find just by looking in the Block class or other places where you first found the old one. All of them can be found at the MCP changelog page, which I know Choonster has a link to but I can never find.

    Posted in: Modification Development
  • 1

    posted a message on Edit Player Hunger?
    FoodStats fs = new FoodStats();

    You're going to have to get the actual FoodStats from the player instead of making a new one and hoping it will magically sync to the player's stats.


    Side note: Your List intialization can be simplified to this:

    aliases = Lists.newArrayList("eat", "feed");
    Posted in: Modification Development
  • 1

    posted a message on [1.8.x and 1.9] Complex Structure Generation Tutorial

    Oh, getMaterial() should be called from the IBlockState, eg, Blocks.log.getDefaultState.getMaterial() or World#getBlockState(pos).getMaterial()

    Posted in: Mapping and Modding Tutorials
  • 1

    posted a message on [1.9.4]When you add a rotation options block model with a model disappears.

    See how to make metadata block in 1.8+


    You need to override getStateFromMeta, getMetaFromState, and createBlockState like I do here.

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