Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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.

  • 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)

{

 

}

}

 

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.