Topic category: Troubleshooting, bugs, and solutions
I am coming across an error when I set an item to damage itself when right clicking... Here is the gradle log:
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_voidSword.java:85: error: cannot find symbol
itemstack.damageItem(1, entity);
^
symbol: variable itemstack
1 error
1 warning
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.
Da Freak? I NEED HELP!
If you are using MCreator 1.7.5, rightclick events don't works.
Ps: remember to put the maximal damage that item can absorb
Umm... Right clicking works though... The damaging doesn't...
warning: [options] bootstrap class path not set in conjunction with -source 1.6
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_voidSword.java:126: error: cannot find symbol
itemstack.damageItem(1, entity);
^
symbol: variable itemstack
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_voidPickaxe.java:107: error: cannot find symbol
itemstack.damageItem(1, entity);
^
symbol: variable itemstack
C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_voidBreaker.java:89: error: cannot find symbol
itemstack.damageItem(1, entity);
^
symbol: variable itemstack
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Pylo\MCreator175\forge\build\sources\main\java\mod\mcreator\mcreator_voidGun.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
1 warning
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.
I tried again... Here is the log
And here is the code for one of the items
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.common.util.EnumHelper;
import net.minecraft.world.World;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ActionResult;
import net.minecraft.server.MinecraftServer;
import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemPickaxe;
import net.minecraft.item.Item;
import net.minecraft.init.Blocks;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.Minecraft;
import java.util.Set;
import java.util.Random;
import java.util.HashMap;
public class mcreator_voidPickaxe {
public mcreator_voidPickaxe() {
}
public static Item block;
public static Object instance;
public void load(FMLInitializationEvent event) {
ItemStack stack = new ItemStack(block, 1);
if (event.getSide() == Side.CLIENT)
Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
.register(block, 0, new ModelResourceLocation("testenvironmentmod:voidpickaxe", "inventory"));
GameRegistry.addRecipe(stack, new Object[]{"012", "345", "678", Character.valueOf('0'), mcreator_voidBlock.block, Character.valueOf('1'),
mcreator_voidBlock.block, Character.valueOf('2'), mcreator_voidBlock.block, Character.valueOf('3'), mcreator_netherStarBlock.block,
Character.valueOf('4'), Blocks.OBSIDIAN, Character.valueOf('5'), mcreator_netherStarBlock.block, Character.valueOf('6'),
mcreator_netherStarBlock.block, Character.valueOf('7'), Blocks.OBSIDIAN, Character.valueOf('8'), mcreator_netherStarBlock.block,});
}
public void generateNether(World world, Random random, int chunkX, int chunkZ) {
}
public void generateSurface(World world, Random random, int chunkX, int chunkZ) {
}
public int addFuel(ItemStack fuel) {
return 0;
}
public void serverLoad(FMLServerStartingEvent event) {
}
public void preInit(FMLPreInitializationEvent event) {
}
public void registerRenderers() {
}
static {
Item.ToolMaterial enumt = EnumHelper.addToolMaterial("VOIDPICKAXE", 5, 1000, 30F, 5, 50);
block = (Item) (new ItemPickaxe(enumt) {
public Set<String> getToolClasses(ItemStack stack) {
HashMap<String, Integer> ret = new HashMap<String, Integer>();
ret.put("pickaxe", 5);
return ret.keySet();
}
@Override
public ActionResult<ItemStack> onItemRightClick(World world, EntityPlayer entity, EnumHand hand) {
float var4 = 1.0F;
ActionResult<ItemStack> ar = super.onItemRightClick(world, entity, hand);
int i = (int) (entity.prevPosX + (entity.posX - entity.prevPosX) * (double) var4);
int j = (int) (entity.prevPosY + (entity.posY - entity.prevPosY) * (double) var4 + 1.62D);
int k = (int) (entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double) var4);
if (true) {
if (entity instanceof EntityPlayerMP) {
MinecraftServer minecraftserver = FMLCommonHandler.instance().getMinecraftServerInstance();
if (minecraftserver != null)
minecraftserver.getCommandManager().executeCommand((EntityPlayerMP) entity, "gamerule sendCommandFeedback false");
}
}
if (true) {
if (entity instanceof EntityPlayerMP) {
MinecraftServer minecraftserver = FMLCommonHandler.instance().getMinecraftServerInstance();
if (minecraftserver != null)
minecraftserver.getCommandManager().executeCommand((EntityPlayerMP) entity, "fill ~5 ~5 ~5 ~-5 ~ ~-5 air 0 destroy");
}
}
if (true) {
world.spawnParticle(EnumParticleTypes.PORTAL, (double) i, (double) 1, (double) k, 2.0D, 2.0D, 2.0D);
}
if (true) {
itemstack.damageItem(1, entity);
}
return ar;
}
@Override
public void onCreated(ItemStack itemstack, World world, EntityPlayer entity) {
super.onCreated(itemstack, world, entity);
float var4 = 1.0F;
int i = (int) (entity.prevPosX + (entity.posX - entity.prevPosX) * (double) var4);
int j = (int) (entity.prevPosY + (entity.posY - entity.prevPosY) * (double) var4 + 1.62D);
int k = (int) (entity.prevPosZ + (entity.posZ - entity.prevPosZ) * (double) var4);
if (true) {
world.spawnEntity(new EntityLightningBolt(world, i, j, k, false));
}
}
}).setUnlocalizedName("VoidPickaxe");
block.setRegistryName("VoidPickaxe");
GameRegistry.register(block);
block.setCreativeTab(mcreator_voidTab.tab);
}
}