Jump to content

memanlolz

Members
  • Posts

    10
  • Joined

  • Last visited

Posts posted by memanlolz

  1. Okay, i somehow did everything untill now, now i need to know, how do i make it Save the tile entity?

     

    Codes So Far,

    Tile Entity

    package com.yofungate.mods.YellowMech.misc;
    
    import cpw.mods.fml.common.network.IPacketHandler;
    import cpw.mods.fml.common.network.Player;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.network.INetworkManager;
    import net.minecraft.network.packet.Packet;
    import net.minecraft.network.packet.Packet132TileEntityData;
    import net.minecraft.network.packet.Packet250CustomPayload;
    import net.minecraft.tileentity.TileEntity;
    
    public class TileEntityMegaBlock extends TileEntity {
    public static int blockMetadata = -1;
    
    public TileEntityMegaBlock(){
    }
    @Override
    public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    this.blockMetadata = nbt.getInteger("BMD");
    }
    @Override
    public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    nbt.setInteger("BMD", this.blockMetadata);
    }
    public int GetMeta(){
    	return this.blockMetadata;
    }
    public void setMeta(int i) {
    	this.blockMetadata = i;
    }
    public TileEntity returnTE(){
    	return this;
    }
        public Packet getDescriptionPacket()
        {
            NBTTagCompound nbttagcompound = new NBTTagCompound();
            this.writeToNBT(nbttagcompound);
            return new Packet132TileEntityData(this.xCoord, this.yCoord, this.zCoord, 4, nbttagcompound);
        }
    }
    

     

     

    ItemBlock

    package com.yofungate.mods.YellowMech.misc;
    
    import com.yofungate.mods.YellowMech.common.YellowMech;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import net.minecraft.block.Block;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.ItemBlock;
    import net.minecraft.item.ItemStack;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.Icon;
    import net.minecraft.world.World;
    
    public class ItemBlockMegaBlock extends ItemBlock {
        public static String[] IconNames = {"stone","stonebrick","dirt","wood","bedrock","sand","gravel","oreCoal","oreIron","oreGold","oreLapis","oreDiamond","oreRedstone","blockIron","blockGold","blockDiamond","blockLapis","blockRedstone","cloth_0","cloth_1","cloth_2","cloth_3","cloth_4","cloth_5","cloth_6","cloth_7","cloth_8","cloth_9","cloth_10","cloth_11","cloth_12","cloth_13","cloth_14","cloth_15"};
    private static final TileEntity TE = new TileEntityMegaBlock();
    public ItemBlockMegaBlock(int par1) {
    
    	super(par1);
    	this.setMaxDamage(33);
    	this.setHasSubtypes(true);
    }
    @SideOnly(Side.CLIENT)
    
    public Icon getIconFromDamage(int par1) //Gets the texture
    {		 
    	     this.TE.blockMetadata=par1;
             return YellowMech.MegaBlock.getIcon(2, this.TE.blockMetadata);
    }
    public int getMetadata(int par1) //Returns the metadata value
    {
             return this.TE.blockMetadata;
    }
    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10){
    
            if (par7 == 0)
            {
                --par5;
            }
    
            if (par7 == 1)
            {
                ++par5;
            }
    
            if (par7 == 2)
            {
                --par6;
            }
    
            if (par7 == 3)
            {
                ++par6;
            }
    
            if (par7 == 4)
            {
                --par4;
            }
            if (par7 == 5){
            	++par4;
            }
            int x=par4, y=par5, z=par6;
            this.TE.blockMetadata = par1ItemStack.getItemDamage();
    	par3World.setBlock(x, y, z, this.getBlockID());
    	par3World.setBlockTileEntity(x, y, z, this.TE);
    	par3World.getBlockTileEntity(x, y, z).blockMetadata=this.TE.blockMetadata;
    	par3World.getBlockTileEntity(x,y,z).blockMetadata=this.TE.blockMetadata;
    	System.out.println("Placed? meta = "+this.TE.blockMetadata+"Block Meta = "+par3World.getBlockTileEntity(x,y,z).blockMetadata);
            if (par1ItemStack.stackSize == 0)
            {
                return false;
            }
            else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack))
            {
                return false;
            }
    	return true;
    }
        public int damageDropped(int par1)
        {
            return this.TE.blockMetadata;
        }
    public String getItemNameIS(ItemStack is) //Get's the item incode name from an itemstack
    {
    			this.TE.blockMetadata=is.getItemDamage();
             return "YellowMech." + this.IconNames[is.getItemDamage()];
    }
    }
    

     

    Block.

     

    package com.yofungate.mods.YellowMech.misc;
    
    import java.util.List;
    import java.util.Random;
    
    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.IconRegister;
    import net.minecraft.creativetab.CreativeTabs;
    import net.minecraft.item.ItemStack;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.Icon;
    import net.minecraft.world.IBlockAccess;
    import net.minecraft.world.World;
    
    public class BlockMegaBlock extends BlockContainer{
    private static TileEntity TE  = new TileEntityMegaBlock();
    public static Icon[] IconArray;
    public BlockMegaBlock(int par1) {
    	super(par1, Material.ground);
    	this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
    
    }
    public boolean hasTileEntity(int meta){
    	return true;
    }
    public TileEntity createNewTileEntity(World world) {
    	this.TE.blockMetadata = 9;
        	System.out.println("Block Method Recieved. Meta = "+this.TE.blockMetadata);
    	return new TileEntityMegaBlock();
    }
    public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
    {
    	this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
    	float miX,miY,miZ,maX,maY,maZ;
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2-1, par3, par4)){
    			this.setBlockBounds(0, miY, miZ, maX, maY, maZ);
    		}
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2+1, par3, par4)){
    			this.setBlockBounds(miX, miY, miZ, 1, maY, maZ);
    		}
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2, par3-1, par4)){
    			this.setBlockBounds(miX, 0, miZ, maX, maY, maZ);
    		}
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2, par3+1, par4)){
    			this.setBlockBounds(miX, miY, miZ, maX, 1, maZ);
    		}
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2, par3, par4-1)){
    			this.setBlockBounds(miX, miY, 0, maX, maY, maZ);
    		}
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2, par3, par4+1)){
    			this.setBlockBounds(miX, miY, miZ, maX, maY, 1);
    		}
        }
        public void func_82541_d(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
        {
    	this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
    	float miX,miY,miZ,maX,maY,maZ;
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2-1, par3, par4)){
    			this.setBlockBounds(0, miY, miZ, maX, maY, maZ);
    		}
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2+1, par3, par4)){
    			this.setBlockBounds(miX, miY, miZ, 1, maY, maZ);
    		}
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2, par3-1, par4)){
    			this.setBlockBounds(miX, 0, miZ, maX, maY, maZ);
    		}
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2, par3+1, par4)){
    			this.setBlockBounds(miX, miY, miZ, maX, 1, maZ);
    		}
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2, par3, par4-1)){
    			this.setBlockBounds(miX, miY, 0, maX, maY, maZ);
    		}
    	miX = (float)this.getBlockBoundsMinX();miY = (float)this.getBlockBoundsMinY();miZ = (float)this.getBlockBoundsMinZ();maX = (float)this.getBlockBoundsMaxX();maY = (float)this.getBlockBoundsMaxY();maZ = (float)this.getBlockBoundsMaxZ();
    		if(!par1IBlockAccess.isAirBlock(par2, par3, par4+1)){
    			this.setBlockBounds(miX, miY, miZ, maX, maY, 1);
    		}
        }
        public void setBlockBoundsForItemRender()
        {
            	this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
        }
    public boolean isOpaqueCube()
    {
    	 return false;
    }
    public void registerIcons(IconRegister par1IconRegister)
        {
    	this.IconArray = new Icon[itemBlockMegaBlock.IconNames.length];
    	for(int i=0;i<ItemBlockMegaBlock.IconNames.length;i++){
    		this.IconArray[i] = par1IconRegister.registerIcon(ItemBlockMegaBlock.IconNames[i]); 
    	}
        }
     public Icon getBlockTexture(IBlockAccess par1IBlockAccess, int par2, int par3, int par4, int par5)
        {
    	 try{
            return this.getIcon(par5, par1IBlockAccess.getBlockTileEntity(par2,par3,par4).blockMetadata);
    	 }catch(Exception e){
    		return this.getIcon(par5, 0);
    	 }
    	}
    public Icon getIcon(int par1, int par2)
    {
    	return this.IconArray[par2];
        }
    public int idDropped(int par1, Random par2Random, int par3)
        {
    	return this.blockID;
        }
    public int quantityDropped(Random par1Random)
        {
            return 1;
        } 
    public int damageDropped(int i){ //Tells it what block it drops and also for creative mode pick block
    	return this.TE.blockMetadata;
    }
    @SideOnly(Side.CLIENT)
    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) //Adds the metadata blocks to the creative inventory
    {
    	for(int i=0;i<ItemBlockMegaBlock.IconNames.length;i++){
    		par3List.add(new ItemStack(par1, 1, i));
    	}
    }
    }
    

     

  2. i got my ItemBlock with

    package com.yofungate.mods.YellowMech.misc;
    
    import com.yofungate.mods.YellowMech.common.YellowMech;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import net.minecraft.entity.player.EntityPlayer;
    import net.minecraft.item.ItemBlock;
    import net.minecraft.item.ItemStack;
    import net.minecraft.tileentity.TileEntity;
    import net.minecraft.util.Icon;
    import net.minecraft.world.World;
    
    public class ItemBlockMegaBlock extends ItemBlock {
    
    private static final TileEntity TileEntityMegaBlock = new TileEntityMegaBlock();
    public ItemBlockMegaBlock(int par1) {
    
    	super(par1);
    	this.setMaxDamage(0);
    	this.setHasSubtypes(true);
    }
    @SideOnly(Side.CLIENT)
    
    public Icon getIconFromDamage(int par1) //Gets the texture
    {
             return YellowMech.MegaBlock.getIcon(2, par1);
    }
    public int getMetadata(int par1) //Returns the metadata value
    {
             return par1;
    }
    public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10){
    
            if (par7 == 0)
            {
                --par5;
            }
    
            if (par7 == 1)
            {
                ++par5;
            }
    
            if (par7 == 2)
            {
                --par6;
            }
    
            if (par7 == 3)
            {
                ++par6;
            }
    
            if (par7 == 4)
            {
                --par4;
            }
            if (par7 == 5){
            	++par4;
            }
            int x=par4, y=par5, z=par6;
    
    	par3World.setBlock(x, y, z, this.getBlockID());
    	par3World.setBlockTileEntity(x, y, z, TileEntityMegaBlock);
    	par3World.setBlockMetadataWithNotify(x, y, z, par1ItemStack.getItemDamage(), 3);
    	return true;
    }
    public String getItemNameIS(ItemStack is) //Get's the item incode name from an itemstack
    {
             
             return "YellowMech." + BlockMegaBlock.IconNames[is.getItemDamage()];
    }
    }
    

  3. 1.if its some kind of tile entity without any gui, or anything wierd, than nop, i dont think so, (IM NOT SURE >.<)

    2.containers are a wierd & confusing thing, containers probably do something hidden in the background, something that we cant see or value.

  4. i already have an itemblock.

     

    package com.yofungate.mods.YellowMech.misc;
    
    import com.yofungate.mods.YellowMech.common.YellowMech;
    
    import cpw.mods.fml.relauncher.Side;
    import cpw.mods.fml.relauncher.SideOnly;
    import net.minecraft.item.ItemBlock;
    import net.minecraft.item.ItemStack;
    import net.minecraft.util.Icon;
    
    public class ItemBlockMegaBlock extends ItemBlock {
    
    public ItemBlockMegaBlock(int par1) {
    	super(par1);
    	this.setMaxDamage(0);
    	this.setHasSubtypes(true);
    }
    @SideOnly(Side.CLIENT)
    
    public Icon getIconFromDamage(int par1) //Gets the texture
    {
             return YellowMech.MegaBlock.getIcon(2, par1);
    }
    public int getMetadata(int par1) //Returns the metadata value
    {
             return par1;
    }
    public String getItemNameIS(ItemStack is) //Get's the item incode name from an itemstack
    {
             
             return "YellowMech." + BlockMegaBlock.IconNames[is.getItemDamage()];
    }
    }
    

     

  5. Well, i have this block, which i want to have 33 subblocks, and everywhere i look, everyone just says "You need TE". i realise i need a TE... just how the heck do i make one!?

    Code : MetaDataBlock

    private static final TileEntityMegaBlock TileEntityMega = new TileEntityMegaBlock();
    private static final TileEntityMegaBlock TE = TileEntityMega;
    public static Icon[] IconArray;
        public static String[] IconNames = {"stone","stonebrick","dirt","wood","bedrock","sand","gravel","oreCoal","oreIron","oreGold","oreLapis","oreDiamond","oreRedstone","blockIron","blockGold","blockDiamond","blockLapis","blockRedstone","cloth_0","cloth_1","cloth_2","cloth_3","cloth_4","cloth_5","cloth_6","cloth_7","cloth_8","cloth_9","cloth_10","cloth_11","cloth_12","cloth_13","cloth_14","cloth_15"};
    
    public BlockMegaBlock(int par1) {
    	super(par1, Material.ground);
    	this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
    }
    public boolean hasTileEntity(int meta){
    	return true;
    }
    public TileEntity createNewTileEntity(World world, int meta) {
    	return TE;
    }
    @Override
    public void onBlockAdded(World par1World, int par2, int par3, int par4){
    	par1World.setBlockTileEntity(par2, par3, par4, TileEntityMega);
    	this.TE.worldObj.setBlockTileEntity(par2, par3, par4, TileEntityMega);
    	super.onBlockAdded(par1World, par2, par3, par4);
    	par1World.setBlockTileEntity(par2, par3, par4, TileEntityMega);
    	this.TE.worldObj.setBlockTileEntity(par2, par3, par4, TileEntityMega);
    }
    public boolean isOpaqueCube()
    {
    	 return false;
    }
    public void registerIcons(IconRegister par1IconRegister)
        {
    	this.IconArray = new Icon[iconNames.length];
    	for(int i=0;i<IconNames.length;i++){
    		System.out.println("Registered MegaBlock #"+i+" With Image "+this.IconNames[i]);
    		this.IconArray[i] = par1IconRegister.registerIcon(this.IconNames[i]); 
    	}
        }
    public Icon getIcon(int par1, int par2)
        {
    	return this.IconArray[par2];		
        }
    public int idDropped(int par1, Random par2Random, int par3)
        {
    	return this.blockID;
        }
    public int quantityDropped(Random par1Random)
        {
            return 1;
        } 
    public int damageDropped(int i){ //Tells it what block it drops and also for creative mode pick block
    	return i;
    }
    @SideOnly(Side.CLIENT)
    public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List) //Adds the metadata blocks to the creative inventory
    {
    	for(int i=0;i<IconNames.length;i++){
    		par3List.add(new ItemStack(par1, 1, i));
    	}
    }

     

     

    Tile Entity

    package com.yofungate.mods.YellowMech.misc;
    
    import cpw.mods.fml.common.network.IPacketHandler;
    import cpw.mods.fml.common.network.Player;
    import net.minecraft.nbt.NBTTagCompound;
    import net.minecraft.network.INetworkManager;
    import net.minecraft.network.packet.Packet250CustomPayload;
    import net.minecraft.tileentity.TileEntity;
    
    public class TileEntityMegaBlock extends TileEntity {
    public static int blockMetadata = 0;
    @Override
    public void readFromNBT(NBTTagCompound nbt) {
    super.readFromNBT(nbt);
    blockMetadata = nbt.getInteger("BMD") & 0xFF;
    System.out.print(blockMetadata);
    }
    @Override
    public void writeToNBT(NBTTagCompound nbt) {
    super.writeToNBT(nbt);
    System.out.print(blockMetadata);
    nbt.setInteger("BMD", this.blockMetadata);
    }
    public static int GetMeta(){
    	return blockMetadata;
    }
    }
    

     

×
×
  • Create New...

Important Information

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