Jump to content

Recommended Posts

Posted

I have been trying to create a furnace which has 9 crafting inputs, at the moment i am just trying to get the gui to open.

 

TileEntityAngellicInfuser

 

package net.mymod.mod.TileEntity;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.IInventory;

import net.minecraft.item.ItemStack;

import net.minecraft.tileentity.TileEntity;

 

public class TileEntityAngellicInfuser extends TileEntity implements IInventory {

 

private ItemStack slots[];

 

public int dualPower;

public int dualCookTime;

 

private String customName;

 

public TileEntityAngellicInfuser() {

slots = new ItemStack[11];

}

 

@Override

public int getSizeInventory() {

// TODO Auto-generated method stub

return 0;

}

 

@Override

public ItemStack getStackInSlot(int var1) {

// TODO Auto-generated method stub

return null;

}

 

@Override

public ItemStack decrStackSize(int var1, int var2) {

// TODO Auto-generated method stub

return null;

}

 

@Override

public ItemStack getStackInSlotOnClosing(int var1) {

// TODO Auto-generated method stub

return null;

}

 

@Override

public void setInventorySlotContents(int var1, ItemStack var2) {

// TODO Auto-generated method stub

 

}

 

@Override

public String getInventoryName() {

return this.hasCustomInventoryName() ? this.customName : "container.AngellicInfuser";

}

 

@Override

public boolean hasCustomInventoryName() {

return this.customName != null && this.customName.length() > 0;

 

}

 

@Override

public int getInventoryStackLimit() {

// TODO Auto-generated method stub

return 0;

}

 

@Override

public boolean isUseableByPlayer(EntityPlayer player) {

if (worldObj.getTileEntity(xCoord, yCoord, zCoord) != this) {

return false;

}else{

return player.getDistanceSq((double)xCoord + 0.5D ,(double)yCoord + 0.5D, (double)zCoord + 0.5D) <= 64;

}

}

 

@Override

public void openInventory() {

// TODO Auto-generated method stub

 

}

 

@Override

public void closeInventory() {

// TODO Auto-generated method stub

 

}

 

@Override

public boolean isItemValidForSlot(int var1, ItemStack var2) {

// TODO Auto-generated method stub

return false;

}

}

 

(block) Angellic Infuser

 

package net.mymod.mod.blocks;

 

import java.util.Random;

 

import cpw.mods.fml.common.network.internal.FMLNetworkHandler;

import cpw.mods.fml.relauncher.Side;

import cpw.mods.fml.relauncher.SideOnly;

import net.minecraft.block.Block;

import net.minecraft.block.BlockContainer;

import net.minecraft.block.material.Material;

import net.minecraft.client.renderer.texture.IIconRegister;

import net.minecraft.entity.EntityLivingBase;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.item.ItemStack;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.util.IIcon;

import net.minecraft.util.MathHelper;

import net.minecraft.world.World;

import net.mymod.mod.mymod;

import net.mymod.mod.TileEntity.TileEntityAngellicInfuser;

 

public class AngellicInfuser extends BlockContainer {

 

private Random rand;

private final boolean isActive;

private static boolean keepInventory = false;

 

@SideOnly(Side.CLIENT)

private IIcon iconFront;

private IIcon iconTop;

 

public AngellicInfuser(boolean blockState) {

super(Material.iron);

rand = new Random();

isActive = blockState;

}

 

@SideOnly(Side.CLIENT)

public void registerBlockIcons(IIconRegister iconRegister) {

this.iconFront = iconRegister.registerIcon(mymod.modid + ":" + (this.isActive ? "Angellic Infuser Front Active" : "Angellic Infuser Front Idle"));

this.blockIcon = iconRegister.registerIcon(mymod.modid + ":" + "Angellic Infuser Side");

this.iconTop = iconRegister.registerIcon(mymod.modid + ":" + "Angellic Infuser Top");

 

}

 

@SideOnly(Side.CLIENT)

public IIcon getIcon(int side, int metadata) {

return metadata == 0 && side == 3 ? this.iconFront : (side == metadata ? this.iconFront : this.blockIcon);

}

 

public void onBlockAdded(World world, int x, int y, int z) {

super.onBlockAdded(world, x, y, z);

this.setDefaultDirection(world, x, y, z);

}

 

private void setDefaultDirection(World world, int x, int y, int z) {

 

if(!world.isRemote) {

Block b1 = world.getBlock(x, y, z - 1);

Block b2 = world.getBlock(x, y, z + 1);

Block b3 = world.getBlock(x - 1, y, z);

Block b4 = world.getBlock(x + 1, y, z);

 

byte b0 = 3;

 

if(b1.func_149730_j() && !b2.func_149730_j()) {

b0 = 3;

}

if(b1.func_149730_j() && !b1.func_149730_j()) {

b0 = 2;

}

if(b1.func_149730_j() && !b4.func_149730_j()) {

b0 = 5;

}

if(b1.func_149730_j() && !b3.func_149730_j()) {

b0 = 4;

}

world.setBlockMetadataWithNotify(x, y, z, b0, 2);

}

}

 

public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entityPlayer, ItemStack itemstack) {

int i = MathHelper.floor_double((double)(entityPlayer.rotationYaw * 4.0F / 360F) +0.50) & 3;

 

if (i == 0) {

world.setBlockMetadataWithNotify(x, y, z, 2, 2);

}

if (i == 1) {

world.setBlockMetadataWithNotify(x, y, z, 5, 2);

}

if (i == 2) {

world.setBlockMetadataWithNotify(x, y, z, 3, 2);

}

if (i == 3) {

world.setBlockMetadataWithNotify(x, y, z, 4, 2);

}

 

if(itemstack.hasDisplayName()) {

//((TileEntityAngellicIfuser)world.getTileEntity(x, y, z)).setCustomName(itemstack.getDisplayName());

}

}

 

public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {

if (world.isRemote) {

return true;

}else if (!player.isSneaking()) {

TileEntityAngellicInfuser entity = (TileEntityAngellicInfuser) world.getTileEntity(x, y, z);

if (entity != null) {

FMLNetworkHandler.openGui(player, mymod.instance, mymod.guiIdAngelicInfuser, world, x, y, z);

}

return true;

}else{

return false;

}

 

}

 

@Override

public TileEntity createNewTileEntity(World var1, int var2) {

return new TileEntityAngellicInfuser();

}

 

}

 

ContainerAngellicInfuser

 

package net.mymod.mod.container;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.inventory.Container;

import net.minecraft.inventory.Slot;

import net.mymod.mod.TileEntity.TileEntityAngellicInfuser;

import net.mymod.mod.slot.SlotAngellicInfuser;

 

public class ContainerAngellicInfuser extends Container {

 

private TileEntityAngellicInfuser Infuser;

private int dualCookTime;

private int dualPower;

private int lastItemBurnTime;

 

 

public ContainerAngellicInfuser(InventoryPlayer invPlayer, TileEntityAngellicInfuser TEAngellicInfuser) {

dualCookTime = 0;

dualPower = 0;

lastItemBurnTime = 0;

 

 

Infuser = TEAngellicInfuser;

 

this.addSlotToContainer(new Slot(TEAngellicInfuser, 0, 48, 16));

this.addSlotToContainer(new Slot(TEAngellicInfuser, 1, 48, 34));

this.addSlotToContainer(new Slot(TEAngellicInfuser, 2, 48, 52));

this.addSlotToContainer(new Slot(TEAngellicInfuser, 3, 66, 16));

this.addSlotToContainer(new Slot(TEAngellicInfuser, 4, 66, 34));

this.addSlotToContainer(new Slot(TEAngellicInfuser, 5, 66, 52));

this.addSlotToContainer(new Slot(TEAngellicInfuser, 6, 84, 16));

this.addSlotToContainer(new Slot(TEAngellicInfuser, 7, 84, 34));

this.addSlotToContainer(new Slot(TEAngellicInfuser, 8, 84, 52));

this.addSlotToContainer(new Slot(TEAngellicInfuser, 9, 6, 39));

this.addSlotToContainer(new SlotAngellicInfuser(invPlayer.player, TEAngellicInfuser, 10, 138, 30));

 

//Inventory

for(int i = 0; i < 3; i++) {

for(int j = 0; j < 9; j++) {

this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));

}

}

 

//ActionBar

for(int i = 0; i < 9; i++) {

this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 142));

}

}

@Override

public boolean canInteractWith(EntityPlayer player) {

return Infuser.isUseableByPlayer(player);

}

 

}

 

guiAngelicInfuser

 

package net.mymod.mod.gui;

 

import org.lwjgl.opengl.GL11;

 

import net.minecraft.client.Minecraft;

import net.minecraft.client.gui.inventory.GuiContainer;

import net.minecraft.client.resources.I18n;

import net.minecraft.entity.player.InventoryPlayer;

import net.minecraft.inventory.Container;

import net.minecraft.util.ResourceLocation;

import net.mymod.mod.mymod;

import net.mymod.mod.TileEntity.TileEntityAngellicInfuser;

import net.mymod.mod.container.ContainerAngellicInfuser;

 

public class guiAngelicInfuser extends GuiContainer {

 

private ResourceLocation texture = new ResourceLocation(mymod.modid + ":" + "/textures/gui/AngellicInfuserGUI.png");

    private TileEntityAngellicInfuser AngellicInfuser;

   

   

public guiAngelicInfuser(InventoryPlayer invPlayer, TileEntityAngellicInfuser TEAngellicInfuser) {

super(new ContainerAngellicInfuser(invPlayer, TEAngellicInfuser));

AngellicInfuser = TEAngellicInfuser;

 

this.xSize = 176;

this.ySize = 166;

}

 

protected void drawGuiContainerForegroundLayer(int i, int j) {

String name = this.AngellicInfuser.hasCustomInventoryName() ? this.AngellicInfuser.getInventoryName() : I18n.format(this.AngellicInfuser.getInventoryName());

 

this.fontRendererObj.drawString(name,  this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);

this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 5, 4210752);

}

 

@Override

protected void drawGuiContainerBackgroundLayer(float var1, int var2, int var3) {

GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

Minecraft.getMinecraft().getTextureManager().bindTexture(texture);

drawTexturedModalRect(guiLeft,guiTop, 0,0 , xSize, ySize);

 

//power

 

//progress bar

}

 

}

 

GUIHandler

 

package net.mymod.Handler;

 

import cpw.mods.fml.common.network.IGuiHandler;

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.tileentity.TileEntity;

import net.minecraft.world.World;

import net.mymod.mod.mymod;

import net.mymod.mod.TileEntity.TileEntityAngellicInfuser;

import net.mymod.mod.container.ContainerAngellicInfuser;

import net.mymod.mod.gui.guiAngelicInfuser;

 

 

public class GUIHandler implements IGuiHandler {

 

@Override

public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {

TileEntity entity = world.getTileEntity(x, y, z);

 

if(entity != null) {

switch(ID) {

 

case mymod.guiIdAngelicInfuser:

if (entity instanceof TileEntityAngellicInfuser) {

return new ContainerAngellicInfuser(player.inventory, (TileEntityAngellicInfuser) entity);

}

 

}

}

return null;

 

}

 

@Override

public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z) {

TileEntity entity = world.getTileEntity(x, y, z);

 

if(entity != null) {

switch(ID) {

case mymod.guiIdAngelicInfuser:

if (entity instanceof TileEntityAngellicInfuser) {

return new guiAngelicInfuser(player.inventory, (TileEntityAngellicInfuser) entity);

}

 

}

}

return null;

 

}

 

 

 

}

 

 

slotAngellicInfuser

 

package net.mymod.mod.slot;

 

import net.minecraft.entity.player.EntityPlayer;

import net.minecraft.inventory.IInventory;

import net.minecraft.inventory.Slot;

import net.minecraft.item.ItemStack;

 

public class SlotAngellicInfuser extends Slot {

 

public SlotAngellicInfuser(EntityPlayer player, IInventory iInventory, int i, int j, int k) {

super(iInventory, i, j, k);

// TODO Auto-generated constructor stub

}

 

 

 

}

 

 

main modding class

 

public static Block blockAngellicInfuserIdle;

public static Block blockAngellicInfuserActive;

public static final int guiIdAngelicInfuser = 1;

 

@EventHandler

public void PreInit(FMLPreInitializationEvent preEvent){

 

blockAngellicInfuserIdle = new AngellicInfuser(false).setBlockName("Angellic Infuser Idle").setCreativeTab(mymod.SatangelicaTab).setHardness(3.5F);

GameRegistry.registerBlock(blockAngellicInfuserIdle, "Angellic Infuser Idle");

blockAngellicInfuserActive = new AngellicInfuser(true).setBlockName("Angellic Infuser Active").setHardness(3.5F);

GameRegistry.registerBlock(blockAngellicInfuserActive, "Angellic Infuser Active");

GameRegistry.registerTileEntity(TileEntityAngellicInfuser.class, "TEAngellicInfuser");

 

 

 

 

 

 

i believe that that is everything relevant to it aside from the textures, which are all named properly.

 

Posted

I hate to be that guy but:

Where is your problem?

And please surround your Code with

[code]

[/code]

because it is much easier to read...

PM's regarding modding questions should belong in the Modder Support sub-forum and won't be answered.

Posted

i have no errors, but I have been following a tutorial, and by this point i should be able to open the gui, but i cant. if it had showed up, i would have been able to look up the error, but i cannot see it.

 

(also i didn't know about the surrounding it with code, but i will in the future)

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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