Following this tutorial, but my custom gui, and gui handler aren't loading/being called. :/
Main File:
package dmillerw.mods.rfidtags;
import net.minecraft.src.Block;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.Material;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkMod.SidedPacketHandler;
import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import dmillerw.mods.ankh.CommonProxy;
@Mod (modid = "rfidtags", name = "RFID Tags", version = "1.0.0")
@NetworkMod(clientSideRequired=true, serverSideRequired=false,
clientPacketHandlerSpec =
@SidedPacketHandler(channels = {"RFIDTags" }, packetHandler = ClientPacketHandler.class),
serverPacketHandlerSpec =
@SidedPacketHandler(channels = {"RFIDTags" }, packetHandler = ServerPacketHandler.class))
public class RFIDMainFile {
@SidedProxy(clientSide = "dmillerw.mods.rfidtags.client.ClientProxy", serverSide = "dmillerw.mods.rfidtags.CommonProxy")
public static CommonProxy proxy;
public static CustomGuiHandler guiHandler = new CustomGuiHandler();
@Instance("rfidtags")
public static RFIDMainFile instance;
//BLOCKS
public static Block blockRFIDDetector;
//ITEMS
public static Item itemRFIDTag;
@PreInit
public void preInit(FMLPreInitializationEvent event) {}
@Init
public void Init(FMLInitializationEvent event) {
NetworkRegistry.instance().registerGuiHandler(this, guiHandler);
GameRegistry.registerTileEntity(TileEntityRFIDDetector.class, "rfidDetector");
//Initializes rendering and textures
proxy.initRenderingAndTextures();
itemRFIDTag = new ItemRFIDTag(3500).setItemName("itemRFIDTag");
blockRFIDDetector = new BlockRFIDDetector(3501, Material.iron).setBlockName("blockRFIDDetector");
GameRegistry.registerBlock(blockRFIDDetector);
LanguageRegistry.addName(blockRFIDDetector, "RFID Detector");
LanguageRegistry.addName(itemRFIDTag, "RFID Tag");
GameRegistry.addRecipe(new ItemStack(itemRFIDTag, 1), new Object[] {"IRI", "ILI", "IRI", 'I', Item.ingotIron, 'R', Item.redstone, 'L', Item.goldNugget});
}
}
Custom GUI Handler:
package dmillerw.mods.rfidtags;
import cpw.mods.fml.common.network.IGuiHandler;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import dmillerw.mods.rfidtags.client.GuiRFIDTag;
public class CustomGuiHandler implements IGuiHandler {
@Override
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {
return null;
}
@Override
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
System.out.println("Does this file even load");
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof TileEntityRFIDDetector){
return new GuiRFIDTag((TileEntityRFIDDetector) tileEntity);
}
return null;
}
}
Block File:
package dmillerw.mods.rfidtags;
import java.util.Random;
import net.minecraft.src.BlockContainer;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.Material;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
public class BlockRFIDDetector extends BlockContainer {
protected BlockRFIDDetector(int par1, Material par2Material) {
super(par1, par2Material);
this.setCreativeTab(CreativeTabs.tabRedstone);
this.setTickRandomly(true);
}
@Override
public TileEntity createNewTileEntity(World var1) {
return new TileEntityRFIDDetector();
}
public int tickRate()
{
return 2;
}
public boolean onBlockActivated(World par1World, int par2, int par3, int par4, EntityPlayer par5EntityPlayer, int par6, float par7, float par8, float par9)
{
TileEntityRFIDDetector tileEntity = (TileEntityRFIDDetector) par1World.getBlockTileEntity(par2, par3, par4);
if (par1World.isRemote)
{
return true;
}
else
{
if (!par5EntityPlayer.isSneaking()) {
System.out.println("Does this file even load BLOCK");
par5EntityPlayer.openGui(RFIDMainFile.instance, 0, par1World, par2, par3, par4);
return true;
} else {
return true;
}
}
}
public boolean isPoweringTo(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
{
TileEntityRFIDDetector tileEntity = (TileEntityRFIDDetector) par1IBlockAccess.getBlockTileEntity(par2, par3, par4);
int metadata = par1IBlockAccess.getBlockMetadata(par2, par3, par4);
if (metadata == 1) {
return true;
} else {
return false;
}
}
/**
* Is this block indirectly powering the block on the specified side
*/
public boolean isIndirectlyPoweringTo(World par1World, int par2, int par3, int par4, int par5)
{
TileEntityRFIDDetector tileEntity = (TileEntityRFIDDetector) par1World.getBlockTileEntity(par2, par3, par4);
int metadata = par1World.getBlockMetadata(par2, par3, par4);
if (metadata == 1) {
return true;
} else {
return false;
}
}
public void onBlockDestroyedByPlayer(World world, int i, int j, int k, int l)
{
notifyNeighbors(world, i, j, k);
}
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
{
super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
}
public void updateTick(World world, int i, int j, int k, Random random) {
super.updateTick(world, i, j, k, random);
world.scheduleBlockUpdate(i, j, k, this.blockID, this.tickRate());
notifyNeighbors(world, i, j, k);
}
public void notifyNeighbors(World world, int i, int j, int k)
{
world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
world.notifyBlocksOfNeighborChange(i, j + 1, k, blockID);
world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
}
/**
* Can this block provide power. Only wire currently seems to have this change based on its state.
*/
public boolean canProvidePower()
{
return true;
}
}
Turns out the container code is running, and returning null, but it isn't touching the client code at all. I'm going to take a guess and assume that the server side code needs to return something before the client side code will run.
Turns out the container code is running, and returning null, but it isn't touching the client code at all. I'm going to take a guess and assume that the server side code needs to return something before the client side code will run.
Main File:
Custom GUI Handler:
Block File:
Try this way, it just simply only passes through a new instance of the file rather than passing a variable
It might not fully load since you haven't filled the getServerGuiElement method
probably
Anyone know?
[mod=1.0.0]224151-mob-stats[/mod]
[mod=1.1.1]223742-hearts[/mod]
[mod=1.0.0]224161-common-sense-food[/mod/