hey, amazing tutorial i really like how you presented the information.
at the moment i ran across an error of sorts. when i click on my block this happens
the diamonds in the above picture represent all the slots on the screen were an item can be placed. you may also notice that their is a slight shift in the item slots. their is also no 3x3 grid. you can shift click things into the upper single space.
this is all of my class files
mod file
package darkhax.rpg.crafting;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.src.*;
@Mod(modid = "mod", name = "Runes", version = "1.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false,
clientPacketHandlerSpec =
@SidedPacketHandler(channels = {"TutorialMod" }, packetHandler = ClientPacketHandler.class),
serverPacketHandlerSpec =
@SidedPacketHandler(channels = {"TutorialMod" }, packetHandler = ServerPacketHandler.class))
public class Rune{
@Instance
public static Rune instance = new Rune();
//Blocks
public static Block BlockNullWall;
public static Block BlockSpazzSpell;
public static Block BlockLV1Spell;
public static Block BlockLV2Spell;
public static Block BlockLV3Spell;
public static Block BlockLV4Spell;
public static Block BlockLV5Spell;
//public static Block ArcaneInfuser;
//Block Integers?????
public static int BlockLV1SpellId = 238;
public static int BlockLV2SpellId = 239;
public static int BlockLV3SpellId = 240;
public static int BlockLV4SpellId = 241;
public static int BlockLV5SpellId = 242;
//Gems
public static Item FireGem;
public static Item WaterGem;
public static Item GreenGem;
public static Item EarthGem;
public static Item PureGem;
public static Item CurruptGem;
//wands
public static Item FireWand;
private GuiHandler guiHandler = new GuiHandler();
public static final Block BlockArcaneInfuser = new BlockArcaneInfuser(243);
@SidedProxy(clientSide = "client.darkhax.rpg.magic.ClientProxyRune", serverSide = "darkhax.rpg.crafting.CommonProxyRune")
public static CommonProxyRune proxy;
@Init
public void Init(FMLInitializationEvent event){
//Arcane infuser
NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
GameRegistry.registerTileEntity(TileArcaneInfuser.class, "tileEntityArcaneInfuser");
GameRegistry.registerBlock(BlockArcaneInfuser);
LanguageRegistry.addName(BlockArcaneInfuser, "BlockArcaneInfuser");
//FireGem
FireGem = new ItemFireGem(7000).setIconIndex(1).setItemName("FireGem");
LanguageRegistry.addName(FireGem, "\u00a74Fire Gem");
//WaterGem
WaterGem = new ItemWaterGem(7001).setIconIndex(1).setItemName("WaterGem");
LanguageRegistry.addName(WaterGem, "\u00a71Water Gem");
//GreenGem
GreenGem = new ItemGreenGem(7002).setIconIndex(1).setItemName("GreenGem");
LanguageRegistry.addName(GreenGem, "\u00a72Green Gem");
//EarthGem
EarthGem = new ItemEarthGem(7003).setIconIndex(1).setItemName("EarthGem");
LanguageRegistry.addName(EarthGem, "\u00a7EEarth Gem");
//pureGem
PureGem = new ItemPureGem(7004).setIconIndex(1).setItemName("PureGem");
LanguageRegistry.addName(PureGem, "\u00a7FPure Gem");
//CurruptGem
CurruptGem = new ItemCurruptGem(7005).setIconIndex(1).setItemName("CurruptGem");
LanguageRegistry.addName(CurruptGem, "\u00a70Currupt Gem");
//weak fire wand
FireWand = new WeaponWeakFireWand(7006).setIconIndex(1).setItemName("WeakFireWand");
LanguageRegistry.addName(FireWand, "\u00a74Weak Fire Wand");
//Level 1 Spells
BlockLV1Spell = new BlockLV1Spell(BlockLV1SpellId, 238).setStepSound(Block.soundStoneFootstep).setHardness(3F).setResistance(1.0F).setBlockName("BlockLV1Spell");
Item.itemsList[BlockLV1SpellId] = new ItemLV1Spell(BlockLV1SpellId-256, BlockLV1SpellId).setItemName("ItemBlockLV1Spell");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Fire.name", "Fire Spell Lv1");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Water.name", "Water Spell Lv1");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Earth.name", "Earth Spell Lv1");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Spazz.name", "Spazz Spell Lv1");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Null.name", "Null Spell Lv1");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Void.name", "Void Spell Lv1");
//Level 2 Spells
BlockLV2Spell = new BlockLV2Spell(BlockLV2SpellId, 239).setStepSound(Block.soundStoneFootstep).setHardness(3F).setResistance(1.0F).setBlockName("BlockLV2Spell");
Item.itemsList[BlockLV2SpellId] = new ItemLV2Spell(BlockLV2SpellId-256, BlockLV2SpellId).setItemName("ItemBlockLV2Spell");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Fire.name", "Fire Spell Lv2");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Water.name", "Water Spell Lv2");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Earth.name", "Earth Spell Lv2");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Spazz.name", "Spazz Spell Lv2");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Null.name", "Null Spell Lv2");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Void.name", "Void Spell Lv2");
//Level 3 Spells
BlockLV3Spell = new BlockLV3Spell(BlockLV3SpellId, 240).setStepSound(Block.soundStoneFootstep).setHardness(3F).setResistance(1.0F).setBlockName("BlockLV3Spell");
Item.itemsList[BlockLV3SpellId] = new ItemLV3Spell(BlockLV3SpellId-256, BlockLV3SpellId).setItemName("ItemBlockLV3Spell");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Fire.name", "Fire Spell Lv3");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Water.name", "Water Spell Lv3");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Earth.name", "Earth Spell Lv3");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Spazz.name", "Spazz Spell Lv3");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Null.name", "Null Spell Lv3");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Void.name", "Void Spell Lv3");
//Level 4 Spells
BlockLV4Spell = new BlockLV4Spell(BlockLV4SpellId, 241).setStepSound(Block.soundStoneFootstep).setHardness(3F).setResistance(1.0F).setBlockName("BlockLV4Spell");
Item.itemsList[BlockLV4SpellId] = new ItemLV4Spell(BlockLV4SpellId-256, BlockLV4SpellId).setItemName("ItemBlockLV4Spell");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Fire.name", "Fire Spell Lv4");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Water.name", "Water Spell Lv4");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Earth.name", "Earth Spell Lv4");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Spazz.name", "Spazz Spell Lv4");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Null.name", "Null Spell Lv4");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Void.name", "Void Spell Lv4");
}
@PreInit
public void PreInit(FMLPreInitializationEvent event){
System.out.println("It looks like the PreInit is working");
}
@PostInit
public void PostInit(FMLPostInitializationEvent event){
System.out.println("It looks like the PostInit is working");
}
}
GUI ArcaneInfuser
package darkhax.rpg.crafting;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.*;
public class GUIArcaneInfuser extends GuiContainer{
public GUIArcaneInfuser(InventoryPlayer player_inventory, TileArcaneInfuser tile_entity){
super(new ContainerArcaneInfuser(tile_entity, player_inventory));
}
@Override
protected void drawGuiContainerForegroundLayer(){
fontRenderer.drawString("Arcane Infuser", 6, 6, 0xffffff);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 6, ySize - 96 + 2, 0xffffff);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j){
int picture = mc.renderEngine.getTexture("/darkhax/rpg/gui.png");
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
this.mc.renderEngine.bindTexture(picture);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
}
}
Guihandler
package darkhax.rpg.crafting;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.src.*;
public class GuiHandler implements IGuiHandler{
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
if(tile_entity instanceof TileArcaneInfuser){
return new ContainerArcaneInfuser((TileArcaneInfuser) tile_entity, player.inventory);
}
return null;
}
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
if(tile_entity instanceof TileArcaneInfuser){
return new GUIArcaneInfuser(player.inventory, (TileArcaneInfuser) tile_entity);
}
return null;
}
}
package darkhax.rpg.crafting;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
public class ClientPacketHandler implements IPacketHandler{
@Override
public void onPacketData(NetworkManager manager, Packet250CustomPayload payload, Player player){
DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data));
}
}
// This is my package declaration, do not mess with the standard (package net.minecraft.src;) like I did,
// Because I know what Im doing in this part, If you don't know what your doing keep it the normal (package net.minecraft.src;)
package darkhax.rpg.crafting;
// These are all the imports you need for this
import java.util.Random;
import net.minecraft.src.*;
public class BlockArcaneInfuser extends BlockContainer{
protected BlockArcaneInfuser(int blockId){
super(blockId, Material.rock);
setBlockName("blockTutorial");
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t){
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
if(tile_entity == null || player.isSneaking()){
return false;
}
player.openGui(Rune.instance, 0, world, x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int i, int j){
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, i, j);
}
private void dropItems(World world, int x, int y, int z){
Random rand = new Random();
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
if(!(tile_entity instanceof IInventory)){
return;
}
IInventory inventory = (IInventory) tile_entity;
for(int i = 0; i < inventory.getSizeInventory(); i++){
ItemStack item = inventory.getStackInSlot(i);
if(item != null && item.stackSize > 0){
float rx = rand.nextFloat() * 0.6F + 0.1F;
float ry = rand.nextFloat() * 0.6F + 0.1F;
float rz = rand.nextFloat() * 0.6F + 0.1F;
EntityItem entity_item = new EntityItem(world, x + rx, y + ry, z + rz, new ItemStack(item.itemID, item.stackSize, item.getItemDamage()));
if(item.hasTagCompound()){
entity_item.item.setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.5F;
entity_item.motionX = rand.nextGaussian() * factor;
entity_item.motionY = rand.nextGaussian() * factor + 0.2F;
entity_item.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entity_item);
item.stackSize = 0;
}
}
}
@Override
public TileEntity createNewTileEntity(World world){
return new TileArcaneInfuser();
}
}
ServerPacket
package darkhax.rpg.crafting;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
public class ServerPacketHandler implements IPacketHandler{
@Override
public void onPacketData(NetworkManager manager, Packet250CustomPayload payload, Player player){
DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data));
EntityPlayer sender = (EntityPlayer) player;
}
}
thanks for all of the great help.
and yes the image for my gui was taken from thaumncraft i don't intend on using it, it is simply a placeholder.
~Darkhax
Edit: i made several changes and replaced some of the tile tutorial things i missed.
Umm you have to "map" out where the slots go, and for the slots being "shifted" you probably missed a number or some bad formulations in the equation, just look at mine and yours and compare, or you drew the slots on the GUI using poor placement... Honestly the opengl texturing can be hard if not done properly or correctly if you have no experience in that subject...
thanks for the fast reply i will take another look. what file is the gui slots rendered in again?
i noticed their were quite a few.
edit:1 i looked around for a bit and saw no notable differences. i then went to make a new mcp folder and made a direct copy of your examples and the problem persists. any ideas?
edit: 2 i also changed it to the original crafting gui and same problem.
hey, amazing tutorial i really like how you presented the information.
at the moment i ran across an error of sorts. when i click on my block this happens
the diamonds in the above picture represent all the slots on the screen were an item can be placed. you may also notice that their is a slight shift in the item slots. their is also no 3x3 grid. you can shift click things into the upper single space.
this is all of my class files
mod file
package darkhax.rpg.crafting;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.src.*;
@Mod(modid = "mod", name = "Runes", version = "1.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false,
clientPacketHandlerSpec =
@SidedPacketHandler(channels = {"TutorialMod" }, packetHandler = ClientPacketHandler.class),
serverPacketHandlerSpec =
@SidedPacketHandler(channels = {"TutorialMod" }, packetHandler = ServerPacketHandler.class))
public class Rune{
@Instance
public static Rune instance = new Rune();
//Blocks
public static Block BlockNullWall;
public static Block BlockSpazzSpell;
public static Block BlockLV1Spell;
public static Block BlockLV2Spell;
public static Block BlockLV3Spell;
public static Block BlockLV4Spell;
public static Block BlockLV5Spell;
//public static Block ArcaneInfuser;
//Block Integers?????
public static int BlockLV1SpellId = 238;
public static int BlockLV2SpellId = 239;
public static int BlockLV3SpellId = 240;
public static int BlockLV4SpellId = 241;
public static int BlockLV5SpellId = 242;
//Gems
public static Item FireGem;
public static Item WaterGem;
public static Item GreenGem;
public static Item EarthGem;
public static Item PureGem;
public static Item CurruptGem;
//wands
public static Item FireWand;
private GuiHandler guiHandler = new GuiHandler();
public static final Block BlockArcaneInfuser = new BlockArcaneInfuser(243);
@SidedProxy(clientSide = "client.darkhax.rpg.magic.ClientProxyRune", serverSide = "darkhax.rpg.crafting.CommonProxyRune")
public static CommonProxyRune proxy;
@Init
public void Init(FMLInitializationEvent event){
//Arcane infuser
NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
GameRegistry.registerTileEntity(TileArcaneInfuser.class, "tileEntityArcaneInfuser");
GameRegistry.registerBlock(BlockArcaneInfuser);
LanguageRegistry.addName(BlockArcaneInfuser, "BlockArcaneInfuser");
//FireGem
FireGem = new ItemFireGem(7000).setIconIndex(1).setItemName("FireGem");
LanguageRegistry.addName(FireGem, "\u00a74Fire Gem");
//WaterGem
WaterGem = new ItemWaterGem(7001).setIconIndex(1).setItemName("WaterGem");
LanguageRegistry.addName(WaterGem, "\u00a71Water Gem");
//GreenGem
GreenGem = new ItemGreenGem(7002).setIconIndex(1).setItemName("GreenGem");
LanguageRegistry.addName(GreenGem, "\u00a72Green Gem");
//EarthGem
EarthGem = new ItemEarthGem(7003).setIconIndex(1).setItemName("EarthGem");
LanguageRegistry.addName(EarthGem, "\u00a7EEarth Gem");
//pureGem
PureGem = new ItemPureGem(7004).setIconIndex(1).setItemName("PureGem");
LanguageRegistry.addName(PureGem, "\u00a7FPure Gem");
//CurruptGem
CurruptGem = new ItemCurruptGem(7005).setIconIndex(1).setItemName("CurruptGem");
LanguageRegistry.addName(CurruptGem, "\u00a70Currupt Gem");
//weak fire wand
FireWand = new WeaponWeakFireWand(7006).setIconIndex(1).setItemName("WeakFireWand");
LanguageRegistry.addName(FireWand, "\u00a74Weak Fire Wand");
//Level 1 Spells
BlockLV1Spell = new BlockLV1Spell(BlockLV1SpellId, 238).setStepSound(Block.soundStoneFootstep).setHardness(3F).setResistance(1.0F).setBlockName("BlockLV1Spell");
Item.itemsList[BlockLV1SpellId] = new ItemLV1Spell(BlockLV1SpellId-256, BlockLV1SpellId).setItemName("ItemBlockLV1Spell");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Fire.name", "Fire Spell Lv1");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Water.name", "Water Spell Lv1");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Earth.name", "Earth Spell Lv1");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Spazz.name", "Spazz Spell Lv1");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Null.name", "Null Spell Lv1");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV1Spell.Void.name", "Void Spell Lv1");
//Level 2 Spells
BlockLV2Spell = new BlockLV2Spell(BlockLV2SpellId, 239).setStepSound(Block.soundStoneFootstep).setHardness(3F).setResistance(1.0F).setBlockName("BlockLV2Spell");
Item.itemsList[BlockLV2SpellId] = new ItemLV2Spell(BlockLV2SpellId-256, BlockLV2SpellId).setItemName("ItemBlockLV2Spell");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Fire.name", "Fire Spell Lv2");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Water.name", "Water Spell Lv2");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Earth.name", "Earth Spell Lv2");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Spazz.name", "Spazz Spell Lv2");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Null.name", "Null Spell Lv2");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV2Spell.Void.name", "Void Spell Lv2");
//Level 3 Spells
BlockLV3Spell = new BlockLV3Spell(BlockLV3SpellId, 240).setStepSound(Block.soundStoneFootstep).setHardness(3F).setResistance(1.0F).setBlockName("BlockLV3Spell");
Item.itemsList[BlockLV3SpellId] = new ItemLV3Spell(BlockLV3SpellId-256, BlockLV3SpellId).setItemName("ItemBlockLV3Spell");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Fire.name", "Fire Spell Lv3");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Water.name", "Water Spell Lv3");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Earth.name", "Earth Spell Lv3");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Spazz.name", "Spazz Spell Lv3");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Null.name", "Null Spell Lv3");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV3Spell.Void.name", "Void Spell Lv3");
//Level 4 Spells
BlockLV4Spell = new BlockLV4Spell(BlockLV4SpellId, 241).setStepSound(Block.soundStoneFootstep).setHardness(3F).setResistance(1.0F).setBlockName("BlockLV4Spell");
Item.itemsList[BlockLV4SpellId] = new ItemLV4Spell(BlockLV4SpellId-256, BlockLV4SpellId).setItemName("ItemBlockLV4Spell");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Fire.name", "Fire Spell Lv4");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Water.name", "Water Spell Lv4");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Earth.name", "Earth Spell Lv4");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Spazz.name", "Spazz Spell Lv4");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Null.name", "Null Spell Lv4");
LanguageRegistry.instance().addStringLocalization("tile.BlockLV4Spell.Void.name", "Void Spell Lv4");
}
@PreInit
public void PreInit(FMLPreInitializationEvent event){
System.out.println("It looks like the PreInit is working");
}
@PostInit
public void PostInit(FMLPostInitializationEvent event){
System.out.println("It looks like the PostInit is working");
}
}
GUI ArcaneInfuser
package darkhax.rpg.crafting;
import org.lwjgl.opengl.GL11;
import net.minecraft.src.*;
public class GUIArcaneInfuser extends GuiContainer{
public GUIArcaneInfuser(InventoryPlayer player_inventory, TileArcaneInfuser tile_entity){
super(new ContainerArcaneInfuser(tile_entity, player_inventory));
}
@Override
protected void drawGuiContainerForegroundLayer(){
fontRenderer.drawString("Arcane Infuser", 6, 6, 0xffffff);
fontRenderer.drawString(StatCollector.translateToLocal("container.inventory"), 6, ySize - 96 + 2, 0xffffff);
}
@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j){
int picture = mc.renderEngine.getTexture("/darkhax/rpg/gui.png");
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
this.mc.renderEngine.bindTexture(picture);
int x = (width - xSize) / 2;
int y = (height - ySize) / 2;
this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
}
}
Guihandler
package darkhax.rpg.crafting;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.src.*;
public class GuiHandler implements IGuiHandler{
@Override
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
if(tile_entity instanceof TileArcaneInfuser){
return new ContainerArcaneInfuser((TileArcaneInfuser) tile_entity, player.inventory);
}
return null;
}
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z){
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
if(tile_entity instanceof TileArcaneInfuser){
return new GUIArcaneInfuser(player.inventory, (TileArcaneInfuser) tile_entity);
}
return null;
}
}
package darkhax.rpg.crafting;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
public class ClientPacketHandler implements IPacketHandler{
@Override
public void onPacketData(NetworkManager manager, Packet250CustomPayload payload, Player player){
DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data));
}
}
// This is my package declaration, do not mess with the standard (package net.minecraft.src;) like I did,
// Because I know what Im doing in this part, If you don't know what your doing keep it the normal (package net.minecraft.src;)
package darkhax.rpg.crafting;
// These are all the imports you need for this
import java.util.Random;
import net.minecraft.src.*;
public class BlockArcaneInfuser extends BlockContainer{
protected BlockArcaneInfuser(int blockId){
super(blockId, Material.rock);
setBlockName("blockTutorial");
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int i, float f, float g, float t){
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
if(tile_entity == null || player.isSneaking()){
return false;
}
player.openGui(Rune.instance, 0, world, x, y, z);
return true;
}
@Override
public void breakBlock(World world, int x, int y, int z, int i, int j){
dropItems(world, x, y, z);
super.breakBlock(world, x, y, z, i, j);
}
private void dropItems(World world, int x, int y, int z){
Random rand = new Random();
TileEntity tile_entity = world.getBlockTileEntity(x, y, z);
if(!(tile_entity instanceof IInventory)){
return;
}
IInventory inventory = (IInventory) tile_entity;
for(int i = 0; i < inventory.getSizeInventory(); i++){
ItemStack item = inventory.getStackInSlot(i);
if(item != null && item.stackSize > 0){
float rx = rand.nextFloat() * 0.6F + 0.1F;
float ry = rand.nextFloat() * 0.6F + 0.1F;
float rz = rand.nextFloat() * 0.6F + 0.1F;
EntityItem entity_item = new EntityItem(world, x + rx, y + ry, z + rz, new ItemStack(item.itemID, item.stackSize, item.getItemDamage()));
if(item.hasTagCompound()){
entity_item.item.setTagCompound((NBTTagCompound) item.getTagCompound().copy());
}
float factor = 0.5F;
entity_item.motionX = rand.nextGaussian() * factor;
entity_item.motionY = rand.nextGaussian() * factor + 0.2F;
entity_item.motionZ = rand.nextGaussian() * factor;
world.spawnEntityInWorld(entity_item);
item.stackSize = 0;
}
}
}
@Override
public TileEntity createNewTileEntity(World world){
return new TileArcaneInfuser();
}
}
ServerPacket
package darkhax.rpg.crafting;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet250CustomPayload;
import cpw.mods.fml.common.network.IPacketHandler;
import cpw.mods.fml.common.network.Player;
public class ServerPacketHandler implements IPacketHandler{
@Override
public void onPacketData(NetworkManager manager, Packet250CustomPayload payload, Player player){
DataInputStream data = new DataInputStream(new ByteArrayInputStream(payload.data));
EntityPlayer sender = (EntityPlayer) player;
}
}
thanks for all of the great help.
and yes the image for my gui was taken from thaumncraft i don't intend on using it, it is simply a placeholder.
~Darkhax
Edit: i made several changes and replaced some of the tile tutorial things i missed.
Your problem in the bindPlayerInventory() method. In a rare whoopsie, Asyncronous goofed up the numbers. Here is the correct one:
protected void bindPlayerInventory(InventoryPlayer player_inventory){
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
addSlotToContainer(new Slot(player_inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for(int i = 0; i < 9; i++){
addSlotToContainer(new Slot(player_inventory, i, 8 + i * 18, 142));
}
}
As for the "lone" slot, you have to figure out where each of your slots should go, basically by figuring out what pixel is the top-left of that slot in the image, and then add new Slots until you're done:
Your problem in the bindPlayerInventory() method. In a rare whoopsie, Asyncronous goofed up the numbers. Here is the correct one:
protected void bindPlayerInventory(InventoryPlayer player_inventory){
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
addSlotToContainer(new Slot(player_inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for(int i = 0; i < 9; i++){
addSlotToContainer(new Slot(player_inventory, i, 8 + i * 18, 142));
}
}
As for the "lone" slot, you have to figure out where each of your slots should go, basically by figuring out what pixel is the top-left of that slot in the image, and then add new Slots until you're done:
thanks that fixed my offset problem. i am trying to make a crafting table with this tutorial. i think if i make a crafting manager and a recipe handler and adjust the container a lot i could get it working
Your problem in the bindPlayerInventory() method. In a rare whoopsie, Asyncronous goofed up the numbers. Here is the correct one:
protected void bindPlayerInventory(InventoryPlayer player_inventory){
for(int i = 0; i < 3; i++){
for(int j = 0; j < 9; j++){
addSlotToContainer(new Slot(player_inventory, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
for(int i = 0; i < 9; i++){
addSlotToContainer(new Slot(player_inventory, i, 8 + i * 18, 142));
}
}
As for the "lone" slot, you have to figure out where each of your slots should go, basically by figuring out what pixel is the top-left of that slot in the image, and then add new Slots until you're done:
thank you for reminding me lol I forgot to fix that the first time you mentioned that... ohh and no tutorials today I had to have a MRI done they think I tore my meniscus?? or something like that
thank you for reminding me lol I forgot to fix that the first time you mentioned that... ohh and no tutorials today I had to have a MRI done they think I tore my meniscus?? or something like that
that is definitely not good. i hope everything turns up ok.
i keep getting this 2012-09-28 22:38:04 [WARNING] [ForgeModLoader] A mod tried to open a gui on the server without being a NetworkMod when im right clicking my block... Help please!
Well, typically, it helps to read your error message. In the off chance that you can't actually read, let me explain:
Your mod isn't a NetworkMod.
Obviously something is wrong with the @NetworkMod part of the code. Probably you screwed up your Client/Server stuff, or you might not be registering it correctly.
Rollback Post to RevisionRollBack
Learn some Java before you mod, and skip over the chapter on ModLoader, straight to MinecraftForge. It's better. Trust me.
correct for you because there is no cookie :), and hopefully now that it is the weekend and I have more time on my hands then I can do some more tutorials I have been wanting to do
correct for you because there is no cookie , and hopefully now that it is the weekend and I have more time on my hands then I can do some more tutorials I have been wanting to do
lol yea, i cant belive their are practicly no tutorials for gui's out there. i barely managed to track down the older tutorials lol.i really like your tutorials. your comments really help when it comes to understanding the concepts.
yeah like I stated before apparently they think its a torn meniscus(no idea what that is) but im still waiting on the results of the MRI...but I can still code so hopefully tutorials are going to happen sometime this weekend
To who?
Ok
at the moment i ran across an error of sorts. when i click on my block this happens
the diamonds in the above picture represent all the slots on the screen were an item can be placed. you may also notice that their is a slight shift in the item slots. their is also no 3x3 grid. you can shift click things into the upper single space.
this is all of my class files
mod file
Guihandler
thanks for all of the great help.
and yes the image for my gui was taken from thaumncraft i don't intend on using it, it is simply a placeholder.
~Darkhax
Edit: i made several changes and replaced some of the tile tutorial things i missed.
Farewell everyone o/
i noticed their were quite a few.
edit:1 i looked around for a bit and saw no notable differences. i then went to make a new mcp folder and made a direct copy of your examples and the problem persists. any ideas?
edit: 2 i also changed it to the original crafting gui and same problem.
Farewell everyone o/
Your problem in the bindPlayerInventory() method. In a rare whoopsie, Asyncronous goofed up the numbers. Here is the correct one:
As for the "lone" slot, you have to figure out where each of your slots should go, basically by figuring out what pixel is the top-left of that slot in the image, and then add new Slots until you're done:
thanks that fixed my offset problem. i am trying to make a crafting table with this tutorial. i think if i make a crafting manager and a recipe handler and adjust the container a lot i could get it working
Farewell everyone o/
thank you for reminding me lol I forgot to fix that the first time you mentioned that... ohh and no tutorials today I had to have a MRI done they think I tore my meniscus?? or something like that
that is definitely not good. i hope everything turns up ok.
Farewell everyone o/
Well, typically, it helps to read your error message. In the off chance that you can't actually read, let me explain:
Your mod isn't a NetworkMod.
Obviously something is wrong with the @NetworkMod part of the code. Probably you screwed up your Client/Server stuff, or you might not be registering it correctly.
lol yea, i cant belive their are practicly no tutorials for gui's out there. i barely managed to track down the older tutorials lol.i really like your tutorials. your comments really help when it comes to understanding the concepts.
Farewell everyone o/