I am trying to make a basic mod for minecraft and am following a tutorial for the same. When I run runClient, it gives me the following error
Reference to undefined variable MC_VERSION
Here is my main.java for reference:
package rattandeep.basicmod;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.Mod.Instance;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import rattandeep.basicmod.proxy.CommonProxy;
import rattandeep.basicmod.util.Reference;
#Mod(modid = Reference.MOD_ID, name = Reference.NAME, version = Reference.VERSION)
public class Main {
#Instance
public static Main instance;
#SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.COMMON_PROXY_CLASS)
public static CommonProxy proxy;
#EventHandler
public static void PreInit(FMLPreInitializationEvent event) {
}
#EventHandler
public static void init(FMLInitializationEvent event) {
}
#EventHandler
public static void Postinit(FMLPostInitializationEvent event) {
}
}
I have searched for a solution but found none. How do I solve this?
I found out how to solve it. I just needed to change the variable value of MC_VERSION in my runClient launch file to my minecraft version.
Related
I'm trying to see if someone joined a world and then print something to console but the event doesn't seem to fire. Can someone help me? Here is my code:
package pl00py_TR.pl00pyspvpmod;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.LivingSpawnEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
#Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
public class Pl00pysPVPMod {
#EventHandler
public void preInit(FMLPreInitializationEvent event) {
}
#EventHandler
public void init(FMLInitializationEvent event) {
}
#EventHandler
public void postInit(FMLPostInitializationEvent event) {
System.out.println("DIRT BLOCK >> " + Blocks.dirt.getUnlocalizedName());
}
public class EventTest {
#SubscribeEvent
public void OnEvent(LivingSpawnEvent event) {
System.out.println("Event Test");
if (event.entity instanceof EntityPlayer) {
System.out.println("Player Joined");
}
}
}
public void RegisterEvents() {
System.out.println("Registering Events...");
MinecraftForge.EVENT_BUS.register(EventTest.class);
}
}
The code is for 1.8.9 and I am trying to find out if someone joins a server/world. I am trying to get the players coords and print them to console but the event doesn't fire or initialize. Could someone explain why this is happening and give me an idea of how to fix this?
Could be wrong but try MinecraftForge.EVENT_BUS.register(new EventTest()); instead of MinecraftForge.EVENT_BUS.register(EventTest.class);
In the documentation for EventBus
void register(java.lang.Object target)
This is my code, I have errors on line 16 and 17, i don't know where im going wrong, this is in the main ModItems class and i have been using this video as a guide If you need the rest of my class files i have uploaded the current copy of my classes here
The error on both lines is The constructor Item(Item, Item) is undefined
package TheStraying11.QuarkyPower.init;
import TheStraying11.QuarkyPower.Reference;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraft.item.ItemSoup;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.ModelLoader;
import net.minecraftforge.fml.common.registry.GameRegistry;
import TheStraying11.QuarkyPower.items.QuarkUp;
import TheStraying11.QuarkyPower.items.QuarkDown;
public class ModItems {
public static Item QuarkUp;
public static Item QuarkDown;
public static void init() {
QuarkUp = new Item(QuarkUp, QuarkUp);
QuarkDown = new Item(QuarkDown, QuarkDown);
}
public static void register() {
registerItem(QuarkUp);
registerItem(QuarkDown);
}
public static void registerRenders() {
}
public static void registerItem(Item item) {
GameRegistry.register(item);
}
public static void registerRender(Item item) {
ModelLoader.setCustomModelResourceLocation(item, 0, new ModelResourceLocation(new ResourceLocation(Reference.MODID, item.getUnlocalizedName().substring(5)), "inventory"));
}
}
friend helped, changed
QuarkUp = new Item(QuarkUp, QuarkUp);
QuarkDown = new Item(QuarkDown, QuarkDown);
to
quark_Up = new itemQuarkUp();
quark_Down = new itemQuarkDown();
EDIT:
Completely started again as that video just made a mess imo, that i didn't understand, I guess ill get better soon haha, i just wish i could use Python instead
I have started making a mod, it's not registering as an item. When i type /give Fidojj222 fcm:fuel_canister it should give me the item except it says it doesn't exist! I am using eclipse as my IDE I am suspecting it might be this warning when I compile it into a jar:
JAR export finished with warnings. See details for additional information.
Can not export external class folder at 'C:\Users\J.J\.gradle\caches\minecraft\net\minecraftforge\forge\1.8-11.14.3.1450\start'.
If that is the problem, then how can I fix it? If not here's my code:
CarsMod.java:
package com.fidojj222.carsmod;
import com.fidojj222.carsmod.init.CarsItems;
import com.fidojj222.carsmod.proxy.CommonProxy;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.SidedProxy;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
#Mod(modid = Reference.MOD_ID, name = Reference.MOD_NAME, version = Reference.VERSION)
public class CarsMod {
#SidedProxy(clientSide = Reference.CLIENT_PROXY_CLASS, serverSide = Reference.SERVER_PROXY_CLASS)
public static CommonProxy proxy;
public void PreInit(FMLPreInitializationEvent event){
CarsItems.init();
CarsItems.register();
}
public void Init(FMLInitializationEvent event){
proxy.registerRenders();
}
public void PostInit(FMLPostInitializationEvent event){
}
}
Reference.java:
package com.fidojj222.carsmod;
public class Reference {
public static final String MOD_ID = "fcm";
public static final String MOD_NAME = "Fidojj222\'s Cars Mod";
public static final String VERSION = "1.0";
public static final String CLIENT_PROXY_CLASS = "com.fidojj222.carsmod.proxy.ClientProxy";
public static final String SERVER_PROXY_CLASS = "com.fidojj222.carsmod.proxy.CommonProxy";
}
CarsItems.java:
package com.fidojj222.carsmod.init;
import com.fidojj222.carsmod.Reference;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;
import net.minecraftforge.fml.common.registry.GameRegistry;
public class CarsItems {
public static Item fuel_canister;
public static void init(){
fuel_canister = new Item().setUnlocalizedName("fuel_canister");
}
public static void register(){
GameRegistry.registerItem(fuel_canister, fuel_canister.getUnlocalizedName().substring(5));
}
public static void registerRenders(){
registerRender(fuel_canister);
}
public static void registerRender(Item item){
Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(item, 0, new ModelResourceLocation(Reference.MOD_ID + ":" + item.getUnlocalizedName().substring(5), "inventory"));
}
}
CommonProxy.java:
package com.fidojj222.carsmod.proxy;
public class CommonProxy {
public void registerRenders(){
}
}
ClientProxy.java:
package com.fidojj222.carsmod.proxy;
import com.fidojj222.carsmod.init.CarsItems;
public class ClientProxy extends CommonProxy {
#Override
public void registerRenders(){
CarsItems.registerRenders();
}
}
What do you mean by not showing? The item isn't found at all in the creative search menu, or it is an untextured (purple/black checkered) block?
If it is untextured, you need to make sure these 2 things are done:
Make sure you have this texture in place src/main/resources/assets/fcm/textures/items/fuel_canister.png it needs to be 16x16 pixels.
Create a fuel_canister.json file at src/main/resources/assets/fcm/models/item/fuel_canister.json This file defines how the image should be rendered ingame.
The contents of that file should be
{
"parent": "builtin/generated",
"textures":{
"layer0":"fcm:items/fuel_canister"
},
"display":{
"thirdperson":{
"rotation":[-90, 0, 0],
"translation":[0, 1, -3],
"scale":[0.55,0.55,0.55]
},
"firstperson":{
"rotation":[0,-135,25],
"translation":[0,4,2],
"scale":[1.7,1.7,1.7]
}
}
}
I am going through the Play Framework tutorial. I am getting this error:
error: cannot find symbol
In /Users/hseritt/devel/todolist/app/controllers/Application.java at line 12.
import views.html.*;
public class Application extends Controller {
static Form<Task> taskForm = Form.form(Task.class); // ERROR IS HIGHLIGHTED AS Form.form
public static Result index() {
return redirect(routes.Application.tasks());
}
My full code for Application.java:
package controllers;
import play.*;
import play.data.*;
import play.mvc.*;
import models.*;
import views.html.*;
public class Application extends Controller {
static Form<Task> taskForm = Form.form(Task.class);
public static Result index() {
return redirect(routes.Application.tasks());
}
public static Result tasks() {
return ok(
views.html.index.render(Task.all(), taskForm)
);
}
public static Result newTask() {
return TODO;
}
public static Result deleteTask(Long id) {
return TODO;
}
}
I am wondering if I missed something in the tutorial or put something in the wrong place.
Thanks!
I think you should import the following:
import static play.data.Form.*;
As per jnoob, just change import to import play.data.Form, then do static Form<Task> taskForm = form(Task.class);, worked for me.
I am trying to create a job in java play2 using akka.
I always get the same error error: cannot find symbol
And it points to system.actorOf() Intellij and Eclipse don't give me an error msg.
But I can not find this method. I used the following imports
import play.libs.Akka;
import akka.actor.ActorSystem;
import akka.actor.ActorRef;
import akka.actor.UntypedActorFactory;
import akka.actor.UntypedActor;
import akka.actor.Props;
import akka.actor.ActorRefFactory;
Maybe the docs are outdated and they have removed the system.actorOf() ?
public class Global extends GlobalSettings {
ActorRef tickActor = system.actorOf(new Props().withCreator(new UntypedActorFactory() {
public UntypedActor create() {
return new UntypedActor() {
public void onReceive(Object message) {
if (message.equals("Log")) {
controllers.Application.log();
} else {
unhandled(message);
}
}
};
}
}));
#Override
public void onStart(Application app) {
Cancellable cancellable = system.scheduler().schedule(Duration.Zero(), Duration.create(10, TimeUnit.SECONDS),
tickActor, "Log");
}
}
EDIT:
.
oh... google redirected me to the outdated documentation. It's Akka.System() now..
Can anyone give me an example on how to create the tickActor with up2date code?
http://www.playframework.org/documentation/2.0.2/JavaAkka
I strongly suggest that you take a look at the Akka documentation about actors and schedulers.
You can also take a look at this question: Play Framework 2.0 schedules an Akka Actor at server launch
solved it.
Btw there are some typos in the documentation.
import java.util.concurrent.TimeUnit;
import play.*;
import play.mvc.*;
import play.mvc.Http.RequestHeader;
import static play.mvc.Results.*;
import play.libs.Akka;
import akka.actor.ActorSystem;
import akka.actor.ActorRef;
import akka.actor.UntypedActorFactory;
import akka.actor.UntypedActor;
import akka.actor.Props;
import akka.actor.ActorRefFactory;
import akka.util.*;
public class Global extends GlobalSettings {
ActorRef tickActor;
#Override
public void onStart(Application app) {
Logger.info("D");
tickActor = Akka.system().actorOf((new Props().withCreator(new UntypedActorFactory() {
public UntypedActor create() {
return new UntypedActor() {
public void onReceive(Object message) {
if (message.equals("Log")) {
//Do something
// controllers.Application.log();
} else {
unhandled(message);
}
}
};
}
})));
Akka.system().scheduler().schedule(
Duration.create(0, TimeUnit.MILLISECONDS),
Duration.create(30, TimeUnit.MINUTES),
tickActor,
"Log"
);
}
}