The main reason I say do not learn by making a mod is that when things go wrong or don't work (which will inevitably happen), how will you know whether it is a java issue or a modding issue? So you will ask here and just get told to "go learn Java".
You NEED to be able to read and understand exceptions and be able to debug your own code.
When there is no exception, but it isn't doing what you expected, that is when you come and ask us for assistance.
The people on this forum assume that the person they are helping has java knowledge, so understands what they are telling them to do without writing the code for them.
i starting watching lessons from Stanford university, I'm surprised at how simular it is to minecraft commandblocks using scoreboards with commands, tellraw. and trigger boards etc. at first i felt like what i was learning had no connection to minecraft but I'm starting to see connections. this is the playlist I'm using the following video
I find it to be easy to fallow and somewhat entertaining. i don't know what I'm going to get out of it yet because I'm not finished. but i think when all is said and done i think its an awesome way to learn java. in the first video he does a really good job of explaining why we cant just jump into making programs (in my case mods) because i need to understand the language first
his example "writing code is just like writing an essay. you cant be a good essay writing, without learning the language you want to write in. if you don't learn English, you cant be a good English essay writer. if you don'T know java (or another coding language) you cant write good code"
i had never looked at it that way before i saw the video, and i use to always want to skip java because in my mind. i was thinking "i don't want to learn java, i want to learn forge" but now i kinda understand why learning java is so important first.
watching the video also teaches good coding habits i have better foundation as a future coder because of good habits that im setting for myself
1
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.
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.
1
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
1
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)
1
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.
1
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.
1
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.
1
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:
1
Oh, getMaterial() should be called from the IBlockState, eg, Blocks.log.getDefaultState.getMaterial() or World#getBlockState(pos).getMaterial()
1
See how to make metadata block in 1.8+
You need to override getStateFromMeta, getMetaFromState, and createBlockState like I do here.