• 0

    posted a message on Minecraft mod coder pack adding a dimension

    I have found the solution: the class files that need to be edited are: AnvilSaveHandler, IntegratedServer (for client), DimensionType, MinecraftServer (for a server), and I believe this should be it. Possibly AnvilSaveConverter, but I doubt that, since it converts saves using the old save format..

    Posted in: Modification Development
  • 0

    posted a message on Minecraft mod coder pack adding a dimension

    I just tested some things, and apparently Minecraft limits the dimension count to 3 (overworld, end, and nether) I found this by altering the AnvilSaveHandler class, and adding my dimension, then using double slashes to ignore the nether, and then create a world. My dimension worked fine, I got to it using a nether portal, of course this replaced the nether in a way. Better explanation with the code:



    else if (provider instanceof WorldProviderHell) {
    File file3 = new File(file1, "DIM2");
    file3.mkdirs();
    return new AnvilChunkLoader(file3, this.dataFixer);
    } // this is the code for a dimensions files, I make the if statement test for WorldProviderCustom, my dimension, and used //slashes to make this code be ignored. This in a way replaced the nether, but uses the files I created still. I made my //dimension id -1 which used to be the nethers, and made its id 2 as can be seen above. I tried keeping the nether loaded //with an id of 2, but its files didn't generate, proving there is a limit.

    Posted in: Modification Development
  • 0

    posted a message on Minecraft mod coder pack adding a dimension

    Hello! I am trying to add another dimension to Minecraft using the mod coder pack, but I am having troubles finding out where to initialize/register/etc. the dimension. To explain: I created my own dimension (its a "re-texture" of the nether, with custom generation settings. This is what I wanted, I liked the Nethers generation) and all the class files I needed were created, the dimension does load, I found this out by replacing the nether with my dimension, but I was wondering if anyone knows if it is possible to add a dimension? I'm asking because so far I was unsuccessful in adding a dimension; the dimension I created is only loadable by replacing an existing one. I do not know if it's possible, I have all of the class files, and I have added my dimension to the AnvilSaveHandler and AnvilSaveConverter classes, yet it never generates the file for saving and loading my dimension (DIM2) in the world folder.


    Again, I have all the classes, and so far I added as many instances to load my dimension as I think I need. There may be some class files I do not know about yet that need modification. I can provide the code that I use to make my dimension, although I do not suspect this to cause the problem, when I used my code (the code saying to add another dimension, DIM2) in the AnvilSave class files, and set my dimension to the default Nether dimension (untouched), it still did not generate my dimension files (DIM2)


    I am asking this because firstly I don't even know if it is possible, and secondly I tried looking for any more files that I need to change, but found none. Apologies if this is difficult to understand, it likely will be if you don't have the mod coder pack. Basically I saw the code Minecraft uses to create its dimensions and copied it to make one of mine, all while loading the default client and server (no outside programs, plugins, files apart from the class files I add, or mods)


    tl;dr I made a custom dimension with all class files needed to get to the dimension, and did get to the dimension, within the default game (no mods, plugins, etc etc.), but I cannot add my dimension to the world without replacing an existing dimension. Thank you for any help, I figured this was the best place to put this. I am mostly using the mod coder pack and no outside mods because I want to add this dimension to a server I have, so others can see it as well without needing mods.


    EDIT: If adding the dimension can't be done on the server, but still on the client, please still post what you know to fix this. Even if I cant have it on the server, I would still like to implement it on my client. I can't imagine why it couldn't be done on the client, since if Mojang wanted to add a dimension they would need to do this, but I wouldn't know much about that.


    EDIT #2: Another file I have changed is DimmensionType, but I am not sure if names have any effect on if it can load, will test this out though.

    Posted in: Modification Development
  • 0

    posted a message on How are tickets being sold on ebay

    Minecon 2015 info states:

    Tickets cannot be resold and are non-transferrable, the person whose name is on the ticket at the time of purchase is the person who will be admitted to MINECON

    Is there some way to be able to sell them? Or are the people selling the tickets a scam? Here is one example:

    http://www.ebay.com/itm/Minecon-2015-Tickets-London-July-4th-5th-With-Capes-/161700044692?pt=LH_DefaultDomain_0&hash=item25a612df94


    If they are changeable and able to be resold, they should update that. It is very misleading.

    Posted in: Minecon 2015
  • 0

    posted a message on Player facing detector for command blocks.

    No, facing isn't a coordinate. Facing tag is if the value is 1, it will work wherever the player faces. If it's 0, it will not be where the player. So it would work in a command block. Does that clear things up? If not, we can talk in private if it is that big of an issue.

    Posted in: Suggestions
  • 0

    posted a message on Player facing detector for command blocks.

    I think you don't understand. With this new tag, no matter where you face with only 1 command block it will work in that direction. Other ways use tons of command blocks, this way used 1 for every direction.

    Posted in: Suggestions
  • 0

    posted a message on Player facing detector for command blocks.

    pengowen123

    I know, this method is to make it so wherever you face, without using a ton of command blocks




    CanaryCasserole

    Because i haven't decided when i want it to end. This thread barely has any views yet, i may not even need to make it end.

    Posted in: Suggestions
  • 0

    posted a message on Player facing detector for command blocks.

    There should be a way to have commands like summon work where the player faces. This means that you don't have to have a ton of command blocks testing where a player faces, then have another ton running each command for a specific value. For example, say you want to spawn a arrow forward when you face forwards, instead of testing if the player faces forward and then making it spawn with the velocity making it go forward, use this new method: I suggest it works by a NBT tag. This tag would be Facing:(0-1). If it's 1, the object will be summoned right in front of the player wherever he faces. Another NBT to add on to this would be distance:(0-∞). This makes the object spawn whatever value the distance is farther away. So if it were 3, the object would be 3 blocks away in that direction. The NBT tag names can be changed.This would be very useful for map making and helpful for just random command block builds.

    Posted in: Suggestions
  • 0

    posted a message on 1.7.2 GUI help
    Still need this if i can get help.
    Posted in: Modification Development
  • 0

    posted a message on GUI for a Quiver
    Still need this if anyone can help.
    Posted in: Requests / Ideas For Mods
  • 0

    posted a message on 1.7.2 GUI help
    I found a code but the code does not open anything and i was suggested to post this here.



    BlockTiny:
    package Gui;
    import java.util.Random;
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockContainer;
    import net.minecraft.block.material.Material;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.world.World;
    public class BlockTiny extends BlockContainer {
    protected BlockTiny (int id) {
    super(Material.wood);
    setHardness(2.0F);
    setResistance(5.0F);
    setBlockName("blockTiny");
    setCreativeTab(CreativeTabs.tabDecorations);
    }
    @Override
    public boolean onBlockActivated(World world, int x, int y, int z,
    EntityPlayer player, int metadata, float what, float these, float are) {
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (tileEntity == null || player.isSneaking()) {
    return false;
    }
    //code to open gui explained later
    player.openGui(Tiny.instance, 0, world, x, y, z);
    return true;
    }
    public void breakBlock(World world, int x, int y, int z, Block par5, int par6) {
    dropItems(world, x, y, z);
    super.breakBlock(world, x, y, z, par5, par6);
    }
    private void dropItems(World world, int x, int y, int z){
    Random rand = new Random();
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (!(tileEntity instanceof IInventory)) {
    return;
    }
    IInventory inventory = (IInventory) tileEntity;
    for (int i = 0; i < inventory.getSizeInventory(); i++) {
    ItemStack item = inventory.getStackInSlot(i);
    if (item != null && item.stackSize > 0) {
    float rx = rand.nextFloat() * 0.8F + 0.1F;
    float ry = rand.nextFloat() * 0.8F + 0.1F;
    float rz = rand.nextFloat() * 0.8F + 0.1F;
    EntityItem entityItem = new EntityItem(world,
    x + rx, y + ry, z + rz,
    new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
    if (item.hasTagCompound()) {
    entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
    }
    float factor = 0.05F;
    entityItem.motionX = rand.nextGaussian() * factor;
    entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
    entityItem.motionZ = rand.nextGaussian() * factor;
    world.spawnEntityInWorld(entityItem);
    item.stackSize = 0;
    }
    }
    }
    public TileEntity createNewTileEntity(World world) {
    return new TileEntityTiny();
    }
    @Override
    public TileEntity createNewTileEntity(World var1, int var2) {
    return null;
    }
    }



    ContainerTiny:
    package Gui;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.inventory.Container;
    import net.minecraft.inventory.Slot;
    import net.minecraft.item.ItemStack;
    public class ContainerTiny extends Container {
    protected TileEntityTiny tileEntity;
    public ContainerTiny (InventoryPlayer inventoryPlayer, TileEntityTiny te){
    tileEntity = te;
    //the Slot constructor takes the IInventory and the slot number in that it binds to
    //and the x-y coordinates it resides on-screen
    for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
    addSlotToContainer(new Slot(tileEntity, j + i * 3, 62 + j * 18, 17 + i * 18));
    }
    }
    //commonly used vanilla code that adds the player's inventory
    bindPlayerInventory(inventoryPlayer);
    }
    @Override
    public boolean canInteractWith(EntityPlayer player) {
    return tileEntity.isUseableByPlayer(player);
    }

    protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
    for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 9; j++) {
    addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
    8 + j * 18, 84 + i * 18));
    }
    }
    for (int i = 0; i < 9; i++) {
    addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
    }
    }
    @Override
    public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
    ItemStack stack = null;
    Slot slotObject = (Slot) inventorySlots.get(slot);
    //null checks and checks if the item can be stacked (maxStackSize > 1)
    if (slotObject != null && slotObject.getHasStack()) {
    ItemStack stackInSlot = slotObject.getStack();
    stack = stackInSlot.copy();
    //merges the item into player inventory since its in the tileEntity
    if (slot < 9) {
    if (!this.mergeItemStack(stackInSlot, 0, 35, true)) {
    return null;
    }
    }
    //places it into the tileEntity is possible since its in the player inventory
    else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
    return null;
    }
    if (stackInSlot.stackSize == 0) {
    slotObject.putStack(null);
    } else {
    slotObject.onSlotChanged();
    }
    if (stackInSlot.stackSize == stack.stackSize) {
    return null;
    }
    slotObject.onPickupFromSlot(player, stackInSlot);
    }
    return stack;
    }
    }


    GuiHandler:
    package Gui;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.world.World;
    import cpw.mods.fml.common.network.IGuiHandler;
    public class GuiHandler implements IGuiHandler {
    //returns an instance of the Container you made earlier
    @Override
    public Object getServerGuiElement(int id, EntityPlayer player, World world,
    int x, int y, int z) {
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if(tileEntity instanceof TileEntityTiny){
    return new ContainerTiny(player.inventory, (TileEntityTiny) tileEntity);
    }
    return null;
    }
    //returns an instance of the Gui you made earlier
    @Override
    public Object getClientGuiElement(int id, EntityPlayer player, World world,
    int x, int y, int z) {
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if(tileEntity instanceof TileEntityTiny){
    return new GuiTiny(player.inventory, (TileEntityTiny) tileEntity);
    }
    return null;
    }
    }


    GuiTiny:
    package Gui;
    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.util.StatCollector;
    import org.lwjgl.opengl.GL11;
    import com.tools.toolsmod.Strings;
    public class GuiTiny extends GuiContainer {
    public GuiTiny (InventoryPlayer inventoryPlayer,
    TileEntityTiny tileEntity) {
    //the container is instanciated and passed to the superclass for handling
    super(new ContainerTiny(inventoryPlayer, tileEntity));
    }
    @Override
    protected void drawGuiContainerForegroundLayer(int param1, int param2) {
    //draw text and stuff here
    //the parameters for drawString are: string, x, y, color
    fontRendererObj.drawString("Tiny", 8, 6, 4210752);
    //draws "Inventory" or your regional equivalent
    fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752);
    }
    @Override
    protected void drawGuiContainerBackgroundLayer(float par1, int par2,
    int par3) {
    //draw your Gui here, only thing you need to change is the path
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    final ResourceLocation field_147505_d = new ResourceLocation(Strings.MODID + ":textures/blocks/LargePupletChest");
    int x = (width - xSize) / 2;
    final ResourceLocation field_147504_g = new ResourceLocation(Strings.MODID + ":textures/blocks/PupletChest");
    int y = (height - ySize) / 2;
    this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    }
    }


    TileEntityTiny:
    package Gui;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.nbt.NBTTagList;
    import net.minecraft.tileentity.TileEntity;
    public class TileEntityTiny extends TileEntity implements IInventory {
    private ItemStack[] inv;
    public TileEntityTiny(){
    inv = new ItemStack[9];
    }

    @Override
    public int getSizeInventory() {
    return inv.length;
    }
    @Override
    public ItemStack getStackInSlot(int slot) {
    return inv[slot];
    }

    @Override
    public void setInventorySlotContents(int slot, ItemStack stack) {
    inv[slot] = stack;
    if (stack != null && stack.stackSize > getInventoryStackLimit()) {
    stack.stackSize = getInventoryStackLimit();
    }
    }
    @Override
    public ItemStack decrStackSize(int slot, int amt) {
    ItemStack stack = getStackInSlot(slot);
    if (stack != null) {
    if (stack.stackSize <= amt) {
    setInventorySlotContents(slot, null);
    } else {
    stack = stack.splitStack(amt);
    if (stack.stackSize == 0) {
    setInventorySlotContents(slot, null);
    }
    }
    }
    return stack;
    }
    @Override
    public ItemStack getStackInSlotOnClosing(int slot) {
    ItemStack stack = getStackInSlot(slot);
    if (stack != null) {
    setInventorySlotContents(slot, null);
    }
    return stack;
    }

    @Override
    public int getInventoryStackLimit() {
    return 64;
    }
    @Override
    public boolean isUseableByPlayer(EntityPlayer player) {
    return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this &&
    player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
    }
    public void openChest() {}
    public void closeChest() {}

    @Override
    public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);

    NBTTagList tagList = tagCompound.getTagList("Inventory", blockMetadata);
    for (int i = 0; i < tagList.tagCount(); i++) {
    NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
    byte slot = tag.getByte("Slot");
    if (slot >= 0 && slot < inv.length) {
    inv[slot] = ItemStack.loadItemStackFromNBT(tag);
    }
    }
    }
    @Override
    public void writeToNBT(NBTTagCompound tagCompound) {
    super.writeToNBT(tagCompound);

    NBTTagList itemList = new NBTTagList();
    for (int i = 0; i < inv.length; i++) {
    ItemStack stack = inv;
    if (stack != null) {
    NBTTagCompound tag = new NBTTagCompound();
    tag.setByte("Slot", (byte) i);
    stack.writeToNBT(tag);
    itemList.appendTag(tag);
    }
    }
    tagCompound.setTag("Inventory", itemList);
    }
    public String getInvName() {
    return "tco.tileentitytiny";
    }
    @Override
    public String getInventoryName() {
    return null;
    }
    @Override
    public boolean hasCustomInventoryName() {
    return false;
    }
    @Override
    public void openInventory() {

    }
    @Override
    public void closeInventory() {

    }
    @Override
    public boolean isItemValidForSlot(int var1, ItemStack var2) {
    return false;
    }
    }



    Tiny:
    package Gui;
    import net.minecraft.block.Block;
    import net.minecraft.item.ItemBlock;
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.*;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.network.NetworkRegistry;
    import cpw.mods.fml.common.registry.GameRegistry;
    @Mod(modid="Tiny", name="Tiny", version="1.0")
    public class Tiny {
    @Instance("Tiny")
    public static Tiny instance;

    public static Block blockTiny;
    @EventHandler
    public void init(FMLInitializationEvent event) {
    blockTiny = new BlockTiny(1337);
    GameRegistry.registerBlock(blockTiny, ItemBlock.class, "blockTiny");
    GameRegistry.registerTileEntity(TileEntityTiny.class, "containerTiny");
    NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
    }
    }
    Posted in: Modification Development
  • 0

    posted a message on GUI for a Quiver
    It has already been posted in the development section, i was recommended to move it here. I cannot get that code to work and i don't even know if it can work. I still want someone else to make this for me.
    Posted in: Requests / Ideas For Mods
  • 0

    posted a message on GUI for a Quiver
    Is that for class BlockTiny? That should be a block and i can't find anything for armor, i have a armor class file for example.
    Posted in: Requests / Ideas For Mods
  • 0

    posted a message on GUI for a Quiver
    I will look into this, what/where is the fix? Thanks! (I mean this as i can't find where the armor extension is, as it is not all my code)
    Posted in: Requests / Ideas For Mods
  • 0

    posted a message on GUI for a Quiver
    I took the time to get that GUI code again, like last time nothing happens, there are no errors in the code. Code:

    BlockTiny:
    package Gui;
    import java.util.Random;
    import net.minecraft.block.Block;
    import net.minecraft.block.BlockContainer;
    import net.minecraft.block.material.Material;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.entity.item.EntityItem;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.world.World;
    public class BlockTiny extends BlockContainer {
    protected BlockTiny (int id) {
    super(Material.wood);
    setHardness(2.0F);
    setResistance(5.0F);
    setBlockName("blockTiny");
    setCreativeTab(CreativeTabs.tabDecorations);
    }
    @Override
    public boolean onBlockActivated(World world, int x, int y, int z,
    EntityPlayer player, int metadata, float what, float these, float are) {
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (tileEntity == null || player.isSneaking()) {
    return false;
    }
    //code to open gui explained later
    player.openGui(Tiny.instance, 0, world, x, y, z);
    return true;
    }
    public void breakBlock(World world, int x, int y, int z, Block par5, int par6) {
    dropItems(world, x, y, z);
    super.breakBlock(world, x, y, z, par5, par6);
    }
    private void dropItems(World world, int x, int y, int z){
    Random rand = new Random();
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if (!(tileEntity instanceof IInventory)) {
    return;
    }
    IInventory inventory = (IInventory) tileEntity;
    for (int i = 0; i < inventory.getSizeInventory(); i++) {
    ItemStack item = inventory.getStackInSlot(i);
    if (item != null && item.stackSize > 0) {
    float rx = rand.nextFloat() * 0.8F + 0.1F;
    float ry = rand.nextFloat() * 0.8F + 0.1F;
    float rz = rand.nextFloat() * 0.8F + 0.1F;
    EntityItem entityItem = new EntityItem(world,
    x + rx, y + ry, z + rz,
    new ItemStack(item.getItem(), item.stackSize, item.getItemDamage()));
    if (item.hasTagCompound()) {
    entityItem.getEntityItem().setTagCompound((NBTTagCompound) item.getTagCompound().copy());
    }
    float factor = 0.05F;
    entityItem.motionX = rand.nextGaussian() * factor;
    entityItem.motionY = rand.nextGaussian() * factor + 0.2F;
    entityItem.motionZ = rand.nextGaussian() * factor;
    world.spawnEntityInWorld(entityItem);
    item.stackSize = 0;
    }
    }
    }
    public TileEntity createNewTileEntity(World world) {
    return new TileEntityTiny();
    }
    @Override
    public TileEntity createNewTileEntity(World var1, int var2) {
    return null;
    }
    }


    ContainerTiny:
    package Gui;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.inventory.Container;
    import net.minecraft.inventory.Slot;
    import net.minecraft.item.ItemStack;
    public class ContainerTiny extends Container {
    protected TileEntityTiny tileEntity;
    public ContainerTiny (InventoryPlayer inventoryPlayer, TileEntityTiny te){
    tileEntity = te;
    //the Slot constructor takes the IInventory and the slot number in that it binds to
    //and the x-y coordinates it resides on-screen
    for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
    addSlotToContainer(new Slot(tileEntity, j + i * 3, 62 + j * 18, 17 + i * 18));
    }
    }
    //commonly used vanilla code that adds the player's inventory
    bindPlayerInventory(inventoryPlayer);
    }
    @Override
    public boolean canInteractWith(EntityPlayer player) {
    return tileEntity.isUseableByPlayer(player);
    }

    protected void bindPlayerInventory(InventoryPlayer inventoryPlayer) {
    for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 9; j++) {
    addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
    8 + j * 18, 84 + i * 18));
    }
    }
    for (int i = 0; i < 9; i++) {
    addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
    }
    }
    @Override
    public ItemStack transferStackInSlot(EntityPlayer player, int slot) {
    ItemStack stack = null;
    Slot slotObject = (Slot) inventorySlots.get(slot);
    //null checks and checks if the item can be stacked (maxStackSize > 1)
    if (slotObject != null && slotObject.getHasStack()) {
    ItemStack stackInSlot = slotObject.getStack();
    stack = stackInSlot.copy();
    //merges the item into player inventory since its in the tileEntity
    if (slot < 9) {
    if (!this.mergeItemStack(stackInSlot, 0, 35, true)) {
    return null;
    }
    }
    //places it into the tileEntity is possible since its in the player inventory
    else if (!this.mergeItemStack(stackInSlot, 0, 9, false)) {
    return null;
    }
    if (stackInSlot.stackSize == 0) {
    slotObject.putStack(null);
    } else {
    slotObject.onSlotChanged();
    }
    if (stackInSlot.stackSize == stack.stackSize) {
    return null;
    }
    slotObject.onPickupFromSlot(player, stackInSlot);
    }
    return stack;
    }
    }


    GuiHandler:
    package Gui;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.world.World;
    import cpw.mods.fml.common.network.IGuiHandler;
    public class GuiHandler implements IGuiHandler {
    //returns an instance of the Container you made earlier
    @Override
    public Object getServerGuiElement(int id, EntityPlayer player, World world,
    int x, int y, int z) {
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if(tileEntity instanceof TileEntityTiny){
    return new ContainerTiny(player.inventory, (TileEntityTiny) tileEntity);
    }
    return null;
    }
    //returns an instance of the Gui you made earlier
    @Override
    public Object getClientGuiElement(int id, EntityPlayer player, World world,
    int x, int y, int z) {
    TileEntity tileEntity = world.getTileEntity(x, y, z);
    if(tileEntity instanceof TileEntityTiny){
    return new GuiTiny(player.inventory, (TileEntityTiny) tileEntity);
    }
    return null;
    }
    }


    GuiTiny:
    package Gui;
    import net.minecraft.client.gui.inventory.GuiContainer;
    import net.minecraft.entity.player.InventoryPlayer;
    import net.minecraft.util.ResourceLocation;
    import net.minecraft.util.StatCollector;
    import org.lwjgl.opengl.GL11;
    import com.tools.toolsmod.Strings;
    public class GuiTiny extends GuiContainer {
    public GuiTiny (InventoryPlayer inventoryPlayer,
    TileEntityTiny tileEntity) {
    //the container is instanciated and passed to the superclass for handling
    super(new ContainerTiny(inventoryPlayer, tileEntity));
    }
    @Override
    protected void drawGuiContainerForegroundLayer(int param1, int param2) {
    //draw text and stuff here
    //the parameters for drawString are: string, x, y, color
    fontRendererObj.drawString("Tiny", 8, 6, 4210752);
    //draws "Inventory" or your regional equivalent
    fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, ySize - 96 + 2, 4210752);
    }
    @Override
    protected void drawGuiContainerBackgroundLayer(float par1, int par2,
    int par3) {
    //draw your Gui here, only thing you need to change is the path
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    final ResourceLocation field_147505_d = new ResourceLocation(Strings.MODID + ":textures/blocks/LargePupletChest");
    int x = (width - xSize) / 2;
    final ResourceLocation field_147504_g = new ResourceLocation(Strings.MODID + ":textures/blocks/PupletChest");
    int y = (height - ySize) / 2;
    this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize);
    }
    }

    TileEntityTiny:
    package Gui;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.inventory.IInventory;
    import net.minecraft.item.ItemStack;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.nbt.NBTTagList;
    import net.minecraft.tileentity.TileEntity;
    public class TileEntityTiny extends TileEntity implements IInventory {
    private ItemStack[] inv;
    public TileEntityTiny(){
    inv = new ItemStack[9];
    }

    @Override
    public int getSizeInventory() {
    return inv.length;
    }
    @Override
    public ItemStack getStackInSlot(int slot) {
    return inv[slot];
    }

    @Override
    public void setInventorySlotContents(int slot, ItemStack stack) {
    inv[slot] = stack;
    if (stack != null && stack.stackSize > getInventoryStackLimit()) {
    stack.stackSize = getInventoryStackLimit();
    }
    }
    @Override
    public ItemStack decrStackSize(int slot, int amt) {
    ItemStack stack = getStackInSlot(slot);
    if (stack != null) {
    if (stack.stackSize <= amt) {
    setInventorySlotContents(slot, null);
    } else {
    stack = stack.splitStack(amt);
    if (stack.stackSize == 0) {
    setInventorySlotContents(slot, null);
    }
    }
    }
    return stack;
    }
    @Override
    public ItemStack getStackInSlotOnClosing(int slot) {
    ItemStack stack = getStackInSlot(slot);
    if (stack != null) {
    setInventorySlotContents(slot, null);
    }
    return stack;
    }

    @Override
    public int getInventoryStackLimit() {
    return 64;
    }
    @Override
    public boolean isUseableByPlayer(EntityPlayer player) {
    return worldObj.getTileEntity(xCoord, yCoord, zCoord) == this &&
    player.getDistanceSq(xCoord + 0.5, yCoord + 0.5, zCoord + 0.5) < 64;
    }
    public void openChest() {}
    public void closeChest() {}

    @Override
    public void readFromNBT(NBTTagCompound tagCompound) {
    super.readFromNBT(tagCompound);

    NBTTagList tagList = tagCompound.getTagList("Inventory", blockMetadata);
    for (int i = 0; i < tagList.tagCount(); i++) {
    NBTTagCompound tag = (NBTTagCompound) tagList.getCompoundTagAt(i);
    byte slot = tag.getByte("Slot");
    if (slot >= 0 && slot < inv.length) {
    inv[slot] = ItemStack.loadItemStackFromNBT(tag);
    }
    }
    }
    @Override
    public void writeToNBT(NBTTagCompound tagCompound) {
    super.writeToNBT(tagCompound);

    NBTTagList itemList = new NBTTagList();
    for (int i = 0; i < inv.length; i++) {
    ItemStack stack = inv[i];
    if (stack != null) {
    NBTTagCompound tag = new NBTTagCompound();
    tag.setByte("Slot", (byte) i);
    stack.writeToNBT(tag);
    itemList.appendTag(tag);
    }
    }
    tagCompound.setTag("Inventory", itemList);
    }
    public String getInvName() {
    return "tco.tileentitytiny";
    }
    @Override
    public String getInventoryName() {
    return null;
    }
    @Override
    public boolean hasCustomInventoryName() {
    return false;
    }
    @Override
    public void openInventory() {

    }
    @Override
    public void closeInventory() {

    }
    @Override
    public boolean isItemValidForSlot(int var1, ItemStack var2) {
    return false;
    }
    }


    Tiny:
    package Gui;
    import net.minecraft.block.Block;
    import net.minecraft.item.ItemBlock;
    import cpw.mods.fml.common.Mod;
    import cpw.mods.fml.common.Mod.*;
    import cpw.mods.fml.common.event.FMLInitializationEvent;
    import cpw.mods.fml.common.network.NetworkRegistry;
    import cpw.mods.fml.common.registry.GameRegistry;
    @Mod(modid="Tiny", name="Tiny", version="1.0")
    public class Tiny {
    @Instance("Tiny")
    public static Tiny instance;

    public static Block blockTiny;
    @EventHandler
    public void init(FMLInitializationEvent event) {
    blockTiny = new BlockTiny(1337);
    GameRegistry.registerBlock(blockTiny, ItemBlock.class, "blockTiny");
    GameRegistry.registerTileEntity(TileEntityTiny.class, "containerTiny");
    NetworkRegistry.INSTANCE.registerGuiHandler(this, new GuiHandler());
    }
    }

    Note:It does not matter that it is the same from the tutorial. I will change the name and stuff later.
    Posted in: Requests / Ideas For Mods
  • To post a comment, please or register a new account.