AdityaGupta1 / minecraft-modding-book

The repository for the Minecraft Modding book by O-Reilly.
58 stars 16 forks source link

Not importing the necessary things for the first mod #24

Open ghost opened 7 years ago

ghost commented 7 years ago

Is it possible I performed the setup incorrectly? I already the the JDK installed. I went through the forge install and the build was successful. Here is the code and here are the errors displayed..

package org.devoxx4kids.forge.mods;

import net.minecraft.util.ChatComponentText; import net.minecraft.util.EnumChatFormatting; import net.minecraftforge.event.world.BlockEvent.BreakEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;

public class BlockBreakMessage { @SubscribeEvent public void sendMessage(BreakEvent event) { event .getPlayer() .addChatMessage( new ChatComponentText(EnumChatFormatting.GOLD

minecraft modding 1 minecraft modding 2

Please help!

sirhill commented 7 years ago

Hello Rokin4life7,

You are using forge-1.11-13 which is for minecraft 1.11. The book is based on forge 1.8 and minecraft 1.8.

Between the two version, the api has been changed. If you want to continue with forge-1.11 then you will have to adapt by exploring the API.

I can suggest the following approach: event.getPlayer().sendMessage(new TextComponentString("You broke a block!"));

Reference: http://www.minecraftforge.net/forum/topic/44175-1112-send-local-clientside-chat-messages/

ghost commented 7 years ago

Thank you! Is there a way to get and use forge 1.8 and have minecraft revert to 1.8? How do I explore the API? What does that mean? I'm new to development so forgive my ignorance!n I took a core java course and am using this book to get familiar with an actual fun application of the language.

sirhill commented 7 years ago

I hope it helps you.

arun-gupta commented 7 years ago

@rokin4life7 The book is based on Forge 1.8. The current version is 1.11 and the APIs have introduced backwards incompatibility. We are in the process of updating the book to be compatible with 1.11, stay tuned.

ghost commented 7 years ago

Fantastic! Thank you everyone. I look forward to it Arun! I'm the meantime I'll try and download 1.8 and work with that. This community is so helpful. Thanks for the fast responses. I may have many more questions so thank you all for your patience with me!

jb840w commented 7 years ago

Thank you for your work @arun-gupta, I have recently purchased the book and am also learning this with my son. Also big thanks to @sirhill, Control+click just opened up a new world for us, we will continue to play around with API 1.11, all part of the learning experience.

Cheers!

minecraftchest1 commented 6 years ago

can you show me a screenshot of your launcher? If I know what launcher you are using, I can tell you how to change versions.

minecraftchest1 commented 6 years ago

Just incase you can't find forge 1.8, here is the link.