Reputation: 13
I'm trying to make a Minecraft mod which is supposed to make Bats drop raw chicken. Minecraft does start and actually open, but when it gets to the compileJava stage there are errors displayed in the console. I have very little knowledge about Java, so I don't know how to summarize things about it.
My question is what do these error messages mean and how can I correct them?
I have asked some of my associates about the issue, but they didn't know either.
//NOTE TO SELF: Learn to indent.
package net.mcreator.trevcorp_meat_paste;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
import net.minecraftforge.fml.common.eventhandler.EventPriority;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.client.event.RenderGameOverlayEvent;
import net.minecraft.world.World;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.client.Minecraft;
import net.minecraft.entity.passive.EntityBat;
public static class GUIRenderEventClass
{@SubscribeEvent
public void playerKilledBat(livingDropsEvent event)
{
if(event.entityLiving instanceof EntityBat)
{
event.drops.clear();
itemStack itemStackToDrop = new itemStack(items.chicken, 1);
event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX,
event.entity.posY, event.entity.posZ, itemStackToDrop));
}
}
}
Minecraft does actually open but when it gets to the compileJava stage, it displays the following error messages in the console:
C:\Users\USER\MCreatorWorkspaces\trevcorp_meat_paste\build\sources\main\java\net\mcreator\trevcorp_meat_paste\MCreatorBatMeat.java:16: error: class GUIRenderEventClass is public, should be declared in a file named GUIRenderEventClass.java
public static class GUIRenderEventClass
^
C:\Users\USER\MCreatorWorkspaces\trevcorp_meat_paste\build\sources\main\java\net\mcreator\trevcorp_meat_paste\MCreatorBatMeat.java:18: error: cannot find symbol
public void playerKilledBat(livingDropsEvent event)
^
symbol: class livingDropsEvent
location: class GUIRenderEventClass
C:\Users\USER\MCreatorWorkspaces\trevcorp_meat_paste\build\sources\main\java\net\mcreator\trevcorp_meat_paste\MCreatorBatMeat.java:24: error: cannot find symbol
itemStack itemStackToDrop = new itemStack(items.chicken, 1);
^
symbol: class itemStack
location: class GUIRenderEventClass
C:\Users\USER\MCreatorWorkspaces\trevcorp_meat_paste\build\sources\main\java\net\mcreator\trevcorp_meat_paste\MCreatorBatMeat.java:24: error: cannot find symbol
itemStack itemStackToDrop = new itemStack(items.chicken, 1);
^
symbol: class itemStack
location: class GUIRenderEventClass
C:\Users\USER\MCreatorWorkspaces\trevcorp_meat_paste\build\sources\main\java\net\mcreator\trevcorp_meat_paste\MCreatorBatMeat.java:24: error: cannot find symbol
itemStack itemStackToDrop = new itemStack(items.chicken, 1);
^
symbol: variable items
location: class GUIRenderEventClass
C:\Users\USER\MCreatorWorkspaces\trevcorp_meat_paste\build\sources\main\java\net\mcreator\trevcorp_meat_paste\MCreatorBatMeat.java:25: error: cannot find symbol
event.drops.add(new EntityItem(event.entity.worldObj, event.entity.posX,
^
symbol: class EntityItem
location: class GUIRenderEventClass
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
6 errors
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 8s
Upvotes: 1
Views: 2010
Reputation: 17593
The first error message,
class GUIRenderEventClass is public, should be declared in a file named GUIRenderEventClass.java public static class GUIRenderEventClass
indicates that your Java source is in a file whose name does not match the Java class name in the source code. Both the Java source file name and the Java class name of the class in a file must match. Its how the Java compiler finds things.
You also have a number of errors of the same type that are something like:
C:\Users\USER\MCreatorWorkspaces\trevcorp_meat_paste\build\sources\main\java\net\mcreator\trevcorp_meat_paste\MCreatorBatMeat.java:18: error: cannot find symbol public void playerKilledBat(livingDropsEvent event)
This means that when the Java compiler is processing the source code it is discovering a symbol or type or name of some kind that it doesn't know about. This is an error that means the symbol or type or name that is indicated is not found when the Java compiler searches for it.
There are several reasons for this to happen.
The most usual case is a missing import
directive for a file that contains the symbol or type or name. This is the most probable cause for a "symbol not found" error that involves a type. It looks like you have several cases of a "symbol not found" which probably are due to a missing import
file such as:
class livingDropsEvent
is the symbol not foundclass itemStack
is the symbol not foundclass EntityItem
is the symbol not foundAlso the variable items
is not found. I assume it is a global variable somewhere probably in an import
file as well.
Look at this article on Jabelar's Minecraft Forge Modding Tutorials, Minecraft Forge 1.7.2/1.7.10 Changing Drops of Vanilla Entities as well as Minecraft Modding: Event Handling, for some details about these symbols.
Also look at the sample code in this mincraftforge forum, https://www.minecraftforge.net/forum/topic/28747-how-to-add-a-drop-to-a-vanilla-mob-1710/ which contains this sets of import
directives:
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.boss.EntityWither;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.WeightedRandomChestContent;
import net.minecraftforge.common.ChestGenHooks;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraftforge.event.entity.living.LivingDropsEvent;
Finally you have some warnings:
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
These warnings may or may not be important. If they are from some source that you are using from some library, you may not be able to address these. Your application may work regardless of these warnings.
Upvotes: 1