Topic category: Advanced modding
I'd really like to have colored item names but whenever I try to put them in the game, I always get this
Executing gradle command: clean runClient
Microsoft Windows [Version 10.0.10586]
(c) 2015 Microsoft Corporation. All rights reserved.
C:\Users\~~~~l\Desktop\Mcreator 1.10.2\MCreator170>cd forge
C:\Users\~~~~\Desktop\Mcreator 1.10.2\MCreator170\forge>SET "JAVA_HOME=C:\Users\~~~~\Desktop\Mcreator 1.10.2\MCreator170\jdk64\"
C:\Users\~~~~\Desktop\Mcreator 1.10.2\MCreator170\forge>SET JAVA_EXE=%JAVA_HOME%\bin\java.exe
C:\Users\~~~~\Desktop\Mcreator 1.10.2\MCreator170\forge>SET PATH=%JAVA_HOME%\bin\;%PATH%
C:\Users\~~~~l\Desktop\Mcreator 1.10.2\MCreator170\forge>gradlew -Dorg.gradle.jvmargs="-Xms625m -Xmx2048m" clean runClient
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.7/userguide/gradle_daemon.html.
This mapping 'snapshot_20160518' was designed for MC 1.9.4! Use at your own peril.
#################################################
ForgeGradle 2.2-SNAPSHOT-c438b06
https://github.com/MinecraftForge/ForgeGradle
#################################################
Powered by MCP unknown
http://modcoderpack.com
by: Searge, ProfMobius, Fesh0r,
R4wk, ZeuX, IngisKahn, bspkrs
#################################################
:clean
:deobfCompileDummyTask
:deobfProvidedDummyTask
:sourceApiJava
:compileApiJava UP-TO-DATE
:processApiResources UP-TO-DATE
:apiClasses UP-TO-DATE
:sourceMainJava
C:\Users\~~~~\Desktop\Mcreator 1.10.2\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_lightningDust.java:23: error: '.' expected
import I18n;
^
C:\Users\~~~~\Desktop\Mcreator 1.10.2\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_lightningDust.java:23: error: ';' expected
import I18n;
^
C:\Users\~~~~\Desktop\Mcreator 1.10.2\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_lightningDust.java:25: error: class, interface, or enum expected
@SuppressWarnings("unchecked")
^
3 errors
:compileJava FAILED
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.
BUILD FAILED
Total time: 22.364 secs
C:\Users\~~~~\Desktop\Mcreator 1.10.2\MCreator170\forge>
Task completed with return code 0 in 23300 milliseconds
Here's the code:
package mod.mcreator;
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.minecraft.world.World;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.Entity;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.Minecraft;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.Block;
import java.util.Random;
import java.util.List;
import I18n;
@SuppressWarnings("unchecked")
public class mcreator_lightningDust {
public mcreator_lightningDust() {
}
public static Item block;
public static Object instance;
public void load(FMLInitializationEvent event) {
if (event.getSide() == Side.CLIENT)
Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
.register(block, 0, new ModelResourceLocation("TestEnvironmentMod:LightningDust", "inventory"));
}
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 addInformation(ItemStack itemstack, EntityPlayer par2EntityPlayer, List list, boolean par4)
{
itemstack.setStackDisplayName(EnumChatFormatting.BLUE + I18n.format(this.getUnlocalizedName() + "LightningDust"));
}
public void serverLoad(FMLServerStartingEvent event) {
}
public void preInit(FMLPreInitializationEvent event) {
}
public void registerRenderers() {
}
static {
block = (new ItemlightningDust(477));
}
static class ItemlightningDust extends Item {
public ItemlightningDust(int par1) {
setMaxDamage(0);
maxStackSize = 64;
setUnlocalizedName("LightningDust");
GameRegistry.registerItem(this, "LightningDust");
setCreativeTab(CreativeTabs.MISC);
}
@Override
public int getItemEnchantability() {
return 0;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
return 0;
}
@Override
public float getStrVsBlock(ItemStack par1ItemStack, IBlockState par2Block) {
return 1.0F;
}
@Override
public void onUpdate(ItemStack itemstack, World world, Entity entity, int par4, boolean par5) {
int i = (int) entity.posX;
int j = (int) entity.posY;
int k = (int) entity.posZ;
if ((Math.random() * 100) <= 1) {
world.spawnEntityInWorld(new EntityLightningBolt(world, i, j, k, false));
}
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
list.add("Powerful");
list.add("but very unstable");
}
}
}
Any help?
still no
[spoiler]
C:\Users\pppp\Desktop\Mcreator 1.10.2\MCreator170\forge\build\sources\main\java\mod\mcreator\mcreator_lightningDust.java:104: error: cannot find symbol
par1ItemStack.setStackDisplayName(TextFormatting.BLUE + I18n.format(this.getUnlocalizedName() + "LightningDust"));
^
symbol: variable TextFormatting
location: class ItemlightningDust
1 error
:compileJava FAILED
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.
BUILD FAILED
[/spoiler]
I have the import
Can I see your current whole code? + what version of MC do you use?
Okay. I use 1.7.0 (1.10.2)
[spoiler]
package mod.mcreator;
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.minecraft.world.World;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Item;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.Entity;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.client.Minecraft;
import net.minecraft.block.state.IBlockState;
import net.minecraft.block.Block;
import net.minecraft.client.resources.I18n;
import java.util.Random;
import java.util.List;
@SuppressWarnings("unchecked")
public class mcreator_lightningDust {
public mcreator_lightningDust() {
}
public static Item block;
public static Object instance;
public void load(FMLInitializationEvent event) {
if (event.getSide() == Side.CLIENT)
Minecraft.getMinecraft().getRenderItem().getItemModelMesher()
.register(block, 0, new ModelResourceLocation("TestEnvironmentMod:LightningDust", "inventory"));
}
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 {
block = (new ItemlightningDust(477));
}
static class ItemlightningDust extends Item {
public ItemlightningDust(int par1) {
setMaxDamage(0);
maxStackSize = 64;
setUnlocalizedName("LightningDust");
GameRegistry.registerItem(this, "LightningDust");
setCreativeTab(CreativeTabs.MISC);
}
@Override
public int getItemEnchantability() {
return 0;
}
@Override
public int getMaxItemUseDuration(ItemStack par1ItemStack) {
return 0;
}
@Override
public float getStrVsBlock(ItemStack par1ItemStack, IBlockState par2Block) {
return 1.0F;
}
@Override
public void onUpdate(ItemStack itemstack, World world, Entity entity, int par4, boolean par5) {
int i = (int) entity.posX;
int j = (int) entity.posY;
int k = (int) entity.posZ;
if ((Math.random() * 100) <= 1) {
world.spawnEntityInWorld(new EntityLightningBolt(world, i, j, k, false));
}
}
@Override
public void addInformation(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
par1ItemStack.setStackDisplayName(TextFormatting.BLUE + I18n.format(this.getUnlocalizedName() + "LightningDust"));
list.add("Powerful");
list.add("but very unstable");
}
}
[/spoiler]
import net.minecraft.utils.*;
do i just add that to the code?
Becuase I did and its still not working.
By the way, I owe you a thank-you.
try change
par1ItemStack.setStackDisplayName(TextFormatting.BLUE + I18n.format(this.getUnlocalizedName() + "LightningDust"));
to a:
par1ItemStack.setStackDisplayName(new TextComponentString(I18n.format(this.getUnlocalizedName()) + "LightningDust").getChatStyle().setColor(TextFormatting.BLUE));
+ add this import:
import net.minecraft.util.text.*;