Posted July 24, 201411 yr I have kind of big problem with my mod. I try to test it. I did what was needed and I ran Minecraft with the forge and the mod. Everything seemed ok, but when I started the game again, the progress was gone. To explain better, a weapon which received attributes lost them, as the player did too. Like all the variables reset. I think I might did something very stupid.
July 24, 201411 yr Author The code is pretty huge. I will show you the main modding class. package com.NeverMind.SonOfGods; import org.lwjgl.input.Keyboard; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.entity.RenderFireball; import net.minecraft.client.renderer.entity.RenderSnowball; import net.minecraft.client.settings.KeyBinding; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.enchantment.Enchantment; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.entity.projectile.EntityThrowable; import net.minecraft.init.Blocks; import net.minecraft.init.Items; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.ChatComponentText; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; import cpw.mods.fml.common.event.FMLLoadEvent; import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.registry.GameRegistry; @Mod(modid = "SonOfGods", name = "SonOfGods", version = "1.0") public class SonOfGods { public static boolean breed = false; public static final String modid = "SonOfGods"; public static boolean ifdiamond= false; public static boolean held = true; public static boolean thunderdiamond = false; public static boolean creeperkill = false; public static boolean knockbackOn = false; public static boolean falling = false; public static boolean jump = false; public static boolean skeletonkill = false; public ItemStack theItem; public InventoryPlayer inventory; public EntityPlayer player; public static Item TalismanOfGods; public static EntityThrowable FireBall; private float field_77002_a; public static Item fireball; public static boolean ghastkill = false; public static boolean blazekill = false; public static KeyBinding fKey; public static boolean endermankill = false; public static boolean barehands = false; public static boolean zombiekill = false; public static boolean dragonkill = false; public static boolean breedthunder = false; public static boolean collisionparticles = false; @EventHandler public void preInit(FMLPreInitializationEvent e) { fKey = new KeyBinding("fKey", Keyboard.KEY_F, modid); ClientRegistry.registerKeyBinding(fKey); //FMLCommonHandler.instance().bus().register(new KeyHandler()); fireball = new Item(); fireball.setUnlocalizedName("fireball").setTextureName("NeverMind2" + ":" + "fireball"); GameRegistry.registerItem(fireball, "fireball"); RenderingRegistry.registerEntityRenderingHandler(FireBall.class, new RenderSnowball(fireball)); FMLCommonHandler.instance().bus().register(new PlayerEventHandler()); MinecraftForge.EVENT_BUS.register(new itDied()); TalismanOfGods = new TalismanOfGods(); TalismanOfGods.setUnlocalizedName("TalismanOfGods"); GameRegistry.registerItem(TalismanOfGods, "TalismanOfGods"); TalismanOfGods.setTextureName("NeverMind2" + ":" + "TalismanOfGods"); TalismanOfGods.setCreativeTab(CreativeTabs.tabTools); GameRegistry.addRecipe(new ItemStack (TalismanOfGods), new Object[]{ "XX", "XX", 'X', Blocks.dirt }); TalismanOfGods.setMaxStackSize(1); } @EventHandler public void Init(FMLInitializationEvent e) { } @EventHandler public void Load(FMLLoadEvent e) { } }
July 24, 201411 yr You have to use ItemStack NBT's for items to save the data to them. For the player you can use IExtendedEntityProperties.
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.