Jump to content

[Solved]Problems with custom model render. (I guess so)


bormoshka

Recommended Posts

Hello. I have a problem with custom model render - no any errors, but in game i can't see my block model(it works fine, but block is invisible) only cubic frame. It's not a missing texture file. I'm looking for solution for a second day, you my last chance.

 

And if anyone knows about good manual about classes and methods in minecraft, please give me a link, thank you.

 

Here is my source:

mod class

 

 


package ru.ulmc.ulex;

import java.util.logging.Level;
import cpw.mods.fml.common.FMLLog;
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.PostInit;
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.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.src.Block;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraftforge.common.Configuration;
import ru.ulmc.ulex.CommonProxy;

@Mod(modid = "UltimateExtender", name = "Ultimate Extender", version = "In-Dev 1.0")
@NetworkMod(
        channels = { "UltimateExtender" },
        clientSideRequired = true,
        serverSideRequired = false,
        packetHandler = PacketHandler.class)
public class UltimateExtender
{

    @Instance
    public static UltimateExtender instance;
    @SidedProxy(clientSide = "ru.ulmc.ulex.ClientProxy", serverSide = "ru.ulmc.ulex.CommonProxy")
    public static CommonProxy proxy;
    // Blocks here
    [b]public static BlockBones blockBones;[/b]
    // Items here
    public static ItemSkull itemSkull; // Череп

    // Configuration Values
    private int blockBonesID;
    @PreInit
    public void preInit(FMLPreInitializationEvent event)
    {
        // Loading in Configuration Data
        Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
        ModLoader.registerTileEntity(TileEntityBones.class, "TileEntityBones", new RenderBones());
        EntityRegistry.registerModEntity(EntityExplosiveStick.class, "EntityExplosiveStick", EntityRegistry.findGlobalUniqueEntityId(), this, 200, 30, false);
        try
        {
            cfg.load();
            // Load Block IDs
            //blockBonesID = cfg.getOrCreateBlockIdProperty("Bones", 1400).getInt(1400);
            blockBonesID = 1400;
            blockReinforcedConcreteID =  cfg.getOrCreateBlockIdProperty("Reinforced Concrete", 1401).getInt(1401);
            // Load Item IDs NOT!

        }
        catch (Exception e)
        {
            FMLLog.log(Level.SEVERE, e, "UltimateExtender's configuration failed to load.");
        }
        finally
        {
            cfg.save();
        }
    }
    @Init
    public void init(FMLInitializationEvent evt)
    {
        // Initialize Blocks !
        blockBones = new BlockBones(blockBonesID, TileEntityBones.class);

       //Initialize Items part 1
      itemSkull = new ItemSkull(2600, blockBones);


        //Creating Items
       this.CreateItem(itemSkull, 0, "Skull", "Череп", "Skull");
                 //Add Localization Data
        this.PrepareBlock(blockBones, "Груда костей", "Pile of bones");
        // Register Blocks Recipes
            --- тут были рецепты ---
        // Register Rendering Information
        proxy.registerTileEntitySpecialRenderer(TileEntityBones.class, "TileEntityBones");
        proxy.registerRenderInformation();

    }

    @PostInit
    public void postInit(FMLPostInitializationEvent evt)
    {
        // TODO: Add Post-Initialization code such as mod hooks
    }

     private void CreateItem(Item anItem, int index, String name, String ru, String en)
    {
     anItem.setIconIndex(index);
     anItem.setItemName(name);
     anItem.setTextureFile("/ru/ulmc/png/ulmcitems.png");
     LanguageRegistry.instance().addStringLocalization(anItem.getItemName() + ".name", "ru_RU", ru);
     LanguageRegistry.instance().addStringLocalization(anItem.getItemName() + ".name", "en_US", en);
    
    }
    private void PrepareBlock(Block aBlock, String ru, String en)
    {
     // Register Blocks
     GameRegistry.registerBlock(aBlock);
     //Localization
     LanguageRegistry.instance().addStringLocalization(aBlock.getBlockName() + ".name", "ru_RU", ru);
     LanguageRegistry.instance().addStringLocalization(aBlock.getBlockName() + ".name", "en_US", en);
    
    }
}

 

 

BonesBlock.java

 

 

package ru.ulmc.ulex;
import java.util.Random;
import net.minecraft.src.AxisAlignedBB;
import net.minecraft.src.Block;
import net.minecraft.src.IBlockAccess;
import net.minecraft.src.Material;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
public class BlockBones extends Block
{
private Class bonesEntityClass;
    public BlockBones(int i, Class class1)
    {
            super(i, Material.wood);
            bonesEntityClass = class1;
            setHardness(2.0F);
            setResistance(1.0F);
            setStepSound(Block.soundWoodFootstep);
            setBlockName("BlockBones");
           // this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
            this.blockIndexInTexture = 1;
    }
    //Указывает TileEntity для блока
    public TileEntity getBlockEntity()
    {
            try
            {
                    return (TileEntity)bonesEntityClass.newInstance();
            }
            catch (Exception exception)
            {
                    throw new RuntimeException(exception);
            }
    }
    //TileEntity? Это объект на карте? Ну ок, вообще вроде нужен для более серьёзных устройств.
    public TileEntity createNewTileEntity(World var1)
    {
        return new TileEntityBones();
    }
    public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess)
    {
        this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    }
    //проходим сквозь блок
    public AxisAlignedBB getCollisionBoundingBoxFromPool(World par1World, int par2, int par3, int par4)
    {
        return null;
    }
    //проверяет на что может быть поставлен блок скопипащщено с торча. Подредактировано, чтоб не лепить на стены.
    private boolean canPlaceBonesOn(World par1World, int par2, int par3, int par4)
    {
        if (par1World.doesBlockHaveSolidTopSurface(par2, par3, par4))
        {
            return true;
        }
        else
        {
            int var5 = par1World.getBlockId(par2, par3, par4);
            return (Block.blocksList[var5] != null && Block.blocksList[var5].canPlaceTorchOnTop(par1World, par2, par3, par4));
        }
    }
    public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
    {
        return canPlaceBonesOn(par1World, par2, par3 - 1, par4);
    }
    //непосредственно
    private boolean dropBonesIfCantStay(World par1World, int par2, int par3, int par4)
    {
        if (!this.canPlaceBlockAt(par1World, par2, par3, par4))
        {
            if (par1World.getBlockId(par2, par3, par4) == this.blockID)
            {
                this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
                par1World.setBlockWithNotify(par2, par3, par4, 0);
            }
            return false;
        }
        else
        {
            return true;
        }
    }
    // Прослушиваем изменения вокруг, если блок под нами сломан - разрушаемся и дропаем итем.
    public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
    {
        if (this.dropBonesIfCantStay(par1World, par2, par3, par4))
        {
            int var6 = par1World.getBlockMetadata(par2, par3, par4);
            if (!this.canPlaceBonesOn(par1World, par2, par3 - 1, par4) && var6 == 5)
            {
             this.dropBlockAsItem(par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
                par1World.setBlockWithNotify(par2, par3, par4, 0);
            }
        }
    }
    //Тут указываем итем, который дропается при уничтожении блока. Указываем итем-заменитель!
    public int idDropped(int i, Random random, int j)
    {
            return UltimateExtender.itemSkull.shiftedIndex;
    }
    //Количество дропа
    public int quantityDropped(Random random)
    {
            return 1;
    }
    //Тип рендера для блока (используется кейс для передачи рендеру?)
    // If i change it to 0/1/2 etc. it will render.
    public int getRenderType()
    {
            return -1;
    }
    @Override
    public String getTextureFile()
    {
        return "/ru/ulmc/png/bones.png";
    }
    //Прозрачный ли блок?
    public boolean isOpaqueCube()
    {
            return false;
    }
    //Рендерить как куб?
    public boolean renderAsNormalBlock()
    {
            return false;
    }
}

 

 

 

RenderBones.java

 

 



package ru.ulmc.ulex;

import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11;

public class RenderBones extends TileEntitySpecialRenderer
{
   private ModelBones model;

   public RenderBones()
   {
       model = new ModelBones();
   }
   //Метод взаимодействия с OpenGL.
   public void renderModel(TileEntityBones tileEntityBones, double d, double d1, double d2, float f)
   {
            GL11.glPushMatrix();
            GL11.glTranslatef((float)d, (float)d1, (float)d2);
            GL11.glRotatef(0F, 0.0F, 1.0F, 0.0F);
            bindTextureByName("/ru/ulmc/png/bones.png");
            GL11.glPushMatrix();
            model.render(0.0625F);
            GL11.glPopMatrix();
            GL11.glPopMatrix();
   }

   @Override
   public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
   {
       this.renderModel((TileEntityBones)tileEntity,var2, var4, var6, var8);
   }

}

 

 

TileEntityBones.java

 

 


package ru.ulmc.ulex;

import net.minecraft.src.TileEntity;

public class TileEntityBones extends TileEntity
{
public TileEntityBones()
     {
      //Это пустой объект. 
     }

}

 

 

CommonProxy.java - don't really need

 

 

 

package ru.ulmc.ulex;

import net.minecraft.src.EntityPlayer;
import net.minecraft.src.TileEntitySpecialRenderer;
import net.minecraft.src.World;
import cpw.mods.fml.common.network.IGuiHandler;
import cpw.mods.fml.common.registry.GameRegistry;

public class CommonProxy implements IGuiHandler
{
    public void registerRenderInformation()
    {
    
    }

public void registerTileEntitySpecialRenderer(Class tileEntityClass, String str)
    {
    //GameRegistry.registerTileEntity(tileEntityClass, str);
    }

    @Override
    public Object getClientGuiElement(int ID, EntityPlayer player, World world,
            int x, int y, int z)
    {
        return null;
    }

    @Override
    public Object getServerGuiElement(int ID, EntityPlayer player, World world,
            int x, int y, int z)
    {
        return null;
    }

    public World getClientWorld()
    {
        return null;
    }
}

 

 

ClientProxy.java - don't really need

 

 


package ru.ulmc.ulex;

import ru.ulmc.ulex.CommonProxy;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import net.minecraft.src.World;
import net.minecraftforge.client.MinecraftForgeClient;

public class ClientProxy extends CommonProxy
{
    @Override
    public void registerRenderInformation()
    {
     MinecraftForgeClient.preloadTexture("/ru/ulmc/png/UltimateExtender.png");
     MinecraftForgeClient.preloadTexture("/ru/ulmc/png/ulmcitems.png");
     MinecraftForgeClient.preloadTexture("/ru/ulmc/png/bones.png");
    }
    @Override
    public void registerTileEntitySpecialRenderer(Class tileEntityClass, String str)
    {
     //по сто раз тут всё менял уже запутался. [url="http://www.minecraftforge.net/wiki/Tutorials/Upgrading_To_Forge_for_1.3.1"]http://www.minecraft...Forge_for_1.3.1[/url]
     //RenderBones renderBones = new RenderBones();
    // ClientRegistry.registerTileEntity(tileEntityClass, str, renderBones);
     //ClientRegistry.bindTileEntitySpecialRenderer(tileEntityClass, renderBones);
    }

    @Override
    public World getClientWorld()
    {
        return FMLClientHandler.instance().getClient().theWorld;
    }
}

 

 

Link to comment
Share on other sites

Register the tileentity in your mod-file, and renderstuff in your clientproxy.

 

And this belongs in your clientproxy too:

  private void CreateItem(Item anItem, int index, String name, String ru, String en)
    {
     anItem.setIconIndex(index);
     anItem.setItemName(name);
     anItem.setTextureFile("/ru/ulmc/png/ulmcitems.png");
     LanguageRegistry.instance().addStringLocalization(anItem.getItemName() + ".name", "ru_RU", ru);
     LanguageRegistry.instance().addStringLocalization(anItem.getItemName() + ".name", "en_US", en);
    
    }
    private void PrepareBlock(Block aBlock, String ru, String en)
    {
     // Register Blocks
     GameRegistry.registerBlock(aBlock);
     //Localization
     LanguageRegistry.instance().addStringLocalization(aBlock.getBlockName() + ".name", "ru_RU", ru);
     LanguageRegistry.instance().addStringLocalization(aBlock.getBlockName() + ".name", "en_US", en);
    
    }

 

Example:

 

Mod-file:

package TF2.Teleporter.common;

import java.util.EnumSet;
import java.util.logging.Level;

import net.minecraft.src.Block;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraftforge.common.Configuration;
import net.minecraftforge.common.Property;
import cpw.mods.fml.common.FMLLog;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.Init;
import cpw.mods.fml.common.Mod.PostInit;
import cpw.mods.fml.common.Mod.PreInit;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.TickType;
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.registry.GameRegistry;
import cpw.mods.fml.common.registry.TickRegistry;


/**
* @author pitman-87
* 
*/

@Mod(modid = "pitman-87_TF2_Teleporter", name = "TF2 Teleporter", version = "1.3.2")
@NetworkMod(channels = {"TF2_Teleporter_C","TF2_Teleporter_S"},clientSideRequired = true, serverSideRequired = true,
packetHandler = PacketHandler.class)


public class TF2TeleporterMod
{

@SidedProxy(clientSide = "TF2.Teleporter.client.ClientProxy", serverSide = "TF2.Teleporter.common.CommonProxy")
public static CommonProxy proxy;

public static int blockIDblue = 233;
public static int blockIDred = 234;
public static int itemIDBlue = 2813;
public static int itemIDRed = 2816;
public static int itemIDBase = 2814;
public static int itemIDPropeller = 2815;

public static float teleportVolume = 0.2F;
public static float spinVolume = 0.05F;

public static Block teleporterBlockBlue;
public static Block teleporterBlockRed;

public static Item teleporterItemBlue;
public static Item teleporterItemRed;
public static Item teleporterBase;
public static Item teleporterPropeller;

public static boolean teamsEnabled = false;
public static String itemsPath = "/TF2/Teleporter/sprites/TF2Items.png";

@PreInit
public void preInit(FMLPreInitializationEvent event)
{
	proxy.preInit();

	Configuration configuration = new Configuration(event.getSuggestedConfigurationFile());
	try
	{
		configuration.load();
		Property prop;
		prop = configuration.getOrCreateBlockIdProperty("blockIDblue", 233);
		blockIDblue = prop.getInt(233);
		prop = configuration.getOrCreateBlockIdProperty("blockIDred", 234);
		blockIDred = prop.getInt(234);

		prop = configuration.getOrCreateIntProperty("itemIDBlue", configuration.CATEGORY_ITEM, 2813);
		itemIDBlue = prop.getInt(2813);
		prop = configuration.getOrCreateIntProperty("itemIDRed", configuration.CATEGORY_ITEM, 2816);
		itemIDRed = prop.getInt(2816);
		prop = configuration.getOrCreateIntProperty("itemIDBase", configuration.CATEGORY_ITEM, 2814);
		itemIDBase = prop.getInt(2814);
		prop = configuration.getOrCreateIntProperty("itemIDPropeller", configuration.CATEGORY_ITEM, 2815);
		itemIDPropeller = prop.getInt(2815);

		prop = configuration.getOrCreateProperty("teleportVolume", configuration.CATEGORY_GENERAL, "0.2");
		prop.comment = "min: 0.0	max 1.0";
		teleportVolume = Float.valueOf(prop.value).floatValue();
		prop = configuration.getOrCreateProperty("spinVolume", configuration.CATEGORY_GENERAL, "0.05");
		prop.comment = "min: 0.0	max 1.0";
		spinVolume = Float.valueOf(prop.value).floatValue();
	} catch (Exception e)
	{
		FMLLog.log(Level.SEVERE, e, "TF2 Sentry has a problem loading it's configuration");
		FMLLog.severe(e.getMessage());

	} finally
	{
		configuration.save();
	}
}

@Init
public void load(FMLInitializationEvent evt)
{



	teleporterBlockBlue = new BlockTF2TeleporterBlue(blockIDblue).setHardness(0.5F).setResistance(2000F).setStepSound(Block.soundWoodFootstep).setBlockName("TF2 Teleporter");
	teleporterBlockRed = new BlockTF2TeleporterRed(blockIDred).setHardness(0.5F).setResistance(2000F).setStepSound(Block.soundWoodFootstep).setBlockName("TF2 Teleporter");

	teleporterItemBlue = new ItemTF2Teleporter(itemIDBlue).setItemName("TF2 Teleporter");
	teleporterItemRed = new ItemTF2Teleporter(itemIDRed).setItemName("TF2 Teleporter");
	teleporterBase = new ItemTF2TeleporterPiece(itemIDBase).setItemName("Teleporter Base");
	teleporterPropeller = new ItemTF2TeleporterPiece(itemIDPropeller).setItemName("Teleporter Propeller");

	proxy.load();
	GameRegistry.registerBlock(teleporterBlockBlue);
	GameRegistry.registerBlock(teleporterBlockRed);
	GameRegistry.registerTileEntity(TileEntityTF2Teleporter.class, "TF2 Teleporter");

	TickRegistry.registerTickHandler(new ServerTickHandler(EnumSet.of(TickType.SERVER)), Side.SERVER);

	GameRegistry.addRecipe(new ItemStack(teleporterBase, 1), new Object[]
	{ "X X", "XXX", "X X", Character.valueOf('X'), Item.ingotIron });
	GameRegistry.addRecipe(new ItemStack(teleporterPropeller, 1), new Object[]
	{ "#Y#", "YYY", "XXX", Character.valueOf('X'), Item.ingotIron, Character.valueOf('Y'), Item.redstone, Character.valueOf('#'), Block.torchRedstoneActive });
	GameRegistry.addRecipe(new ItemStack(teleporterItemBlue, 1), new Object[]
	{ "#", "X", "Y", Character.valueOf('X'), teleporterPropeller, Character.valueOf('Y'), teleporterBase, Character.valueOf('#'), new ItemStack(Item.dyePowder, 1, 4) });
	GameRegistry.addRecipe(new ItemStack(teleporterItemRed, 1), new Object[]
	{ "#", "X", "Y", Character.valueOf('X'), teleporterPropeller, Character.valueOf('Y'), teleporterBase, Character.valueOf('#'), new ItemStack(Item.dyePowder, 1, 1) });
	GameRegistry.addRecipe(new ItemStack(teleporterItemRed, 1), new Object[]
	{ "X", "Y", Character.valueOf('Y'), teleporterItemBlue, Character.valueOf('X'), new ItemStack(Item.dyePowder, 1, 1) });
	GameRegistry.addRecipe(new ItemStack(teleporterItemBlue, 1), new Object[]
	{ "X", "Y", Character.valueOf('Y'), teleporterItemRed, Character.valueOf('X'), new ItemStack(Item.dyePowder, 1, 4) });

}

@PostInit
public void modsLoaded(FMLPostInitializationEvent evt)
{

}


}

 

clientproxy:

package TF2.Teleporter.client;

import java.util.EnumSet;

import net.minecraft.src.EntityPlayer;
import net.minecraft.src.SoundManager;
import net.minecraft.src.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.client.event.sound.SoundLoadEvent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.ForgeSubscribe;
import TF2.Teleporter.common.CommonProxy;
import TF2.Teleporter.common.TF2TeleporterMod;
import TF2.Teleporter.common.TileEntityTF2Teleporter;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.TickType;
import cpw.mods.fml.common.registry.LanguageRegistry;
import cpw.mods.fml.common.registry.TickRegistry;

public class ClientProxy extends CommonProxy
{

@Override
public void preInit()
{
	MinecraftForgeClient.preloadTexture(TF2TeleporterMod.itemsPath);
	MinecraftForge.EVENT_BUS.register(this);
}

@Override
public void load()
{
	TickRegistry.registerTickHandler(new ClientTickHandler(EnumSet.of(TickType.CLIENT)), Side.CLIENT);

	LanguageRegistry.instance().addNameForObject(TF2TeleporterMod.teleporterBase, "en_US", "Teleporter Base");
	LanguageRegistry.instance().addNameForObject(TF2TeleporterMod.teleporterPropeller, "en_US", "Teleporter Propeller");
	LanguageRegistry.instance().addNameForObject(TF2TeleporterMod.teleporterItemBlue, "en_US", "Blue Teleporter");
	LanguageRegistry.instance().addNameForObject(TF2TeleporterMod.teleporterItemRed, "en_US", "Red Teleporter");

	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityTF2Teleporter.class, new TileEntityTF2TeleporterRenderer());

}

@ForgeSubscribe
public void onSoundsLoaded(SoundLoadEvent event)
{
	SoundManager manager = event.manager;
	String[] soundFiles =
	{ "spin.ogg", "teleport.ogg" };
	for (int i = 0; i < soundFiles.length; i++)
	{
		manager.soundPoolSounds.addSound(soundFiles[i], this.getClass().getResource("/TF2/Teleporter/Sounds/" + soundFiles[i]));
	}
}

@Override
public void openGui(EntityPlayer entityplayer, TileEntityTF2Teleporter tileentity)
{
	FMLClientHandler.instance().displayGuiScreen(entityplayer, new GuiTF2Teleporter(tileentity));
}


@Override
public boolean isTeleporterActive(int xCoord, int yCoord, int zCoord)
{

	return TF2TeleporterDBClient.isActive(xCoord, yCoord, zCoord);
}

@Override
public void initDB()
{
	TF2TeleporterDBClient.init();
}

@Override
public World getClientWorld()
{
	return FMLClientHandler.instance().getClient().theWorld;
}

@Override
public void addToDB(int f, int x, int y, int z)
{
	TF2TeleporterDBClient.add(f, x, y, z);
}
}

 

 

Link to comment
Share on other sites

Register the tileentity in your mod-file, and renderstuff in your clientproxy.

 

And this belongs in your clientproxy too:

Maybe i missed something, but:

pic.png

main file

package ru.ulmc.ulex;

import java.util.logging.Level;
import cpw.mods.fml.common.FMLLog;
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.PostInit;
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.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.EntityRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.ModLoader;
import net.minecraftforge.common.Configuration;
import ru.ulmc.ulex.CommonProxy;

@Mod(modid = "UltimateExtender", name = "Ultimate Extender", version = "In-Dev 1.0")
@NetworkMod(
        channels = { "UltimateExtender" },
        clientSideRequired = true,
        serverSideRequired = false,
        packetHandler = PacketHandler.class)
public class UltimateExtender
{

    @Instance
    public static UltimateExtender instance;
    @SidedProxy(clientSide = "ru.ulmc.ulex.ClientProxy", serverSide = "ru.ulmc.ulex.CommonProxy")
    public static CommonProxy proxy;
    // Blocks here
    public static BlockBones blockBones;
    // Items here
    public static ItemSkull itemSkull; // Череп
     // Configuration Values
    private int blockBonesID;
    @PreInit
    public void preInit(FMLPreInitializationEvent event)
    {
        // Loading in Configuration Data
        Configuration cfg = new Configuration(event.getSuggestedConfigurationFile());
        proxy.registerRenderInformation(); //You have to call the methods in your proxy class
        try
        {
            cfg.load();
            // Load Block IDs
            blockBonesID = cfg.getOrCreateBlockIdProperty("Bones", 1400).getInt(1400);
            // Load Item IDs NOT!

        }
        catch (Exception e)
        {
            FMLLog.log(Level.SEVERE, e, "UltimateExtender's configuration failed to load.");
        }
        finally
        {
            cfg.save();
        }
    }

    @Init
    public void init(FMLInitializationEvent evt)
    {
        // Initialize Blocks !
        blockBones = new BlockBones(blockBonesID, TileEntityBones.class);
        //Initialize Items part 1
       itemSkull = new ItemSkull(2600, blockBones);
       //Creating Items
       proxy.CreateItem(itemSkull, 0, "Skull", "Череп", "Skull");
       //Add Localization Data
       proxy.PrepareBlock(blockBones, "Груда костей", "Pile of bones");
       // Register Blocks Recipes
       // registring blocks
        GameRegistry.registerBlock(blockBones);
      // Register Rendering Information
          GameRegistry.registerTileEntity(TileEntityBones.class, "TileEntityBones");
          EntityRegistry.registerModEntity(EntityExplosiveStick.class, "EntityExplosiveStick", EntityRegistry.findGlobalUniqueEntityId(), this, 200, 30, false);
         proxy.registerTileEntitySpecialRenderer();
        
       
    }

    @PostInit
    public void postInit(FMLPostInitializationEvent evt)
    {
        // TODO: Add Post-Initialization code such as mod hooks
    }
}

 

ClientProxy

package ru.ulmc.ulex;

import ru.ulmc.ulex.CommonProxy;
import cpw.mods.fml.client.FMLClientHandler;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.Item;
import net.minecraft.src.World;
import net.minecraftforge.client.MinecraftForgeClient;
import net.minecraftforge.common.MinecraftForge;

public class ClientProxy extends CommonProxy
{
@Override
    public void preInit()
    {
    	MinecraftForgeClient.preloadTexture("/ru/ulmc/png/UltimateExtender.png");
    	MinecraftForgeClient.preloadTexture("/ru/ulmc/png/ulmcitems.png");
    	MinecraftForgeClient.preloadTexture("/ru/ulmc/png/bones.png");
    	MinecraftForge.EVENT_BUS.register(this); // Just in case. I don't know what it is.
    	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBones.class, new RenderBones());
    }
    @Override
    public void registerTileEntitySpecialRenderer()
    {
    	ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBones.class, new RenderBones());
    }

    @Override
    public World getClientWorld()
    {
        return FMLClientHandler.instance().getClient().theWorld;
    }
    @Override
    public void CreateItem(Item anItem, int index, String name, String ru, String en)
    {
    	anItem.setTabToDisplayOn(CreativeTabs.tabTransport);
    	anItem.setIconIndex(index);
    	anItem.setItemName(name);
    	anItem.setTextureFile("/ru/ulmc/png/ulmcitems.png");
    	LanguageRegistry.instance().addStringLocalization(anItem.getItemName() + ".name", "ru_RU", ru);
    	LanguageRegistry.instance().addStringLocalization(anItem.getItemName() + ".name", "en_US", en);
    	
    }
    @Override
    public void PrepareBlock(Block aBlock, String ru, String en)
    {
    	// Register Blocks
    	//Localization
    	LanguageRegistry.instance().addStringLocalization(aBlock.getBlockName() + ".name", "ru_RU", ru);
    	LanguageRegistry.instance().addStringLocalization(aBlock.getBlockName() + ".name", "en_US", en);
    	
    }
}

Link to comment
Share on other sites

Forgot to attach Model file.

ModelBones.java

package ru.ulmc.ulex;

import net.minecraft.src.Entity;
import net.minecraft.src.ModelBase;
import net.minecraft.src.ModelRenderer;

public class ModelBones extends ModelBase
{
//fields
    ModelRenderer bone1;
    ModelRenderer skull;
    ModelRenderer bone2;
    ModelRenderer bone3;
    ModelRenderer bone5;
    ModelRenderer goldcoin;
    ModelRenderer backbone1;
    ModelRenderer verticalbone;
  
  public ModelBones()
  {
    textureWidth = 32;
    textureHeight = 16;
    
      bone1 = new ModelRenderer(this, 0, 14);
      bone1.addBox(0F, 0F, 0F, 9, 1, 1);
      bone1.setRotationPoint(-2F, 23F, -6F);
      bone1.setTextureSize(32, 16);
      bone1.mirror = true;
      setRotation(bone1, 0F, -0.2602503F, 0F);
      skull = new ModelRenderer(this, 0, 0);
      skull.addBox(0F, -6F, -3F, 6, 6, 6);
      skull.setRotationPoint(-3F, 23F, 0F);
      skull.setTextureSize(32, 16);
      skull.mirror = true;
      setRotation(skull, 0.1115358F, -0.2602503F, -0.3346075F);
      bone2 = new ModelRenderer(this, 0, 14);
      bone2.addBox(-5F, 0F, 0F, 10, 1, 1);
      bone2.setRotationPoint(0F, 23F, 5F);
      bone2.setTextureSize(32, 16);
      bone2.mirror = true;
      setRotation(bone2, 0F, 0.2602503F, 0F);
      bone3 = new ModelRenderer(this, 27, 0);
      bone3.addBox(0F, -7F, 0F, 1, 9, 1);
      bone3.setRotationPoint(1.866667F, 22.66667F, -1.333333F);
      bone3.setTextureSize(32, 16);
      bone3.mirror = true;
      setRotation(bone3, -1.449966F, 0F, 0F);
      bone5 = new ModelRenderer(this, 27, 0);
      bone5.addBox(0F, -10F, 0F, 1, 10, 1);
      bone5.setRotationPoint(-2F, 22F, 5F);
      bone5.setTextureSize(32, 16);
      bone5.mirror = true;
      setRotation(bone5, 0.1858931F, 1.115358F, 1.635859F);
      goldcoin = new ModelRenderer(this, 24, 13);
      goldcoin.addBox(0F, 0F, 0F, 2, 1, 2);
      goldcoin.setRotationPoint(4F, 23F, 3F);
      goldcoin.setTextureSize(32, 16);
      goldcoin.mirror = true;
      setRotation(goldcoin, 0F, 1.003822F, 0F);
      backbone1 = new ModelRenderer(this, 0, 14);
      backbone1.addBox(-6F, 0F, 0F, 9, 1, 1);
      backbone1.setRotationPoint(-4.6F, 23.26667F, -4.666667F);
      backbone1.setTextureSize(32, 16);
      backbone1.mirror = true;
      setRotation(backbone1, 1.245484F, 1.189716F, 0F);
      verticalbone = new ModelRenderer(this, 27, 0);
      verticalbone.addBox(0F, 0F, 0F, 1, 6, 1);
      verticalbone.setRotationPoint(-4.666667F, 18F, 3.866667F);
      verticalbone.setTextureSize(32, 16);
      verticalbone.mirror = true;
      setRotation(verticalbone, -0.0743572F, 0.4089647F, 0.1858931F);
  }
  
  public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.render(entity, f, f1, f2, f3, f4, f5);
    setRotationAngles(f, f1, f2, f3, f4, f5);
    bone1.render(f5);
    skull.render(f5);
    bone2.render(f5);
    bone3.render(f5);
    bone5.render(f5);
    goldcoin.render(f5);
    backbone1.render(f5);
    verticalbone.render(f5);
  }
  public void render(float f5)
  {

    bone1.render(f5);
    skull.render(f5);
    bone2.render(f5);
    bone3.render(f5);
    bone5.render(f5);
    goldcoin.render(f5);
    backbone1.render(f5);
    verticalbone.render(f5);
  }
  
  private void setRotation(ModelRenderer model, float x, float y, float z)
  {
    model.rotateAngleX = x;
    model.rotateAngleY = y;
    model.rotateAngleZ = z;
  }
  
  public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
  {
    super.setRotationAngles(f, f1, f2, f3, f4, f5);
  }
  }


Link to comment
Share on other sites

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.