- 31
- 1
- 1
Здравствуйте,у меня возникла проблема с мобом,а точнее его регистрацией и рендерингом.
Код: Main.class
//proxy-связь;
@Mod.Instance("com.endienasg.shinkansen.Main")
public static com.endienasg.shinkansen.Main instance;
@SidedProxy(clientSide = "ClientProxy.ClientProxy", serverSide = "CommonProxy.CommonProxy")
public static CommonProxy proxy;
//creative Tab
public static final CreativeTabs tabshinkansenMod = new CreativeTabs("tabshinkansenMod"){
public Item getTabIconItem() {
return Item.getItemFromBlock(Blocks.command_block);
}
};
//info
public static final String MODID = "shinkansen";
public static final String MODNAME = "shinkansen Mod";
public static final String VERSION = "0.1.0";
//block
public static Block pipe;
public static Block wood;
//item
public static Item MyPickaxe;
public static Item Myaxe;
public static Item MyShovel;
//Mob|entity
public static void registerEntity(Class entityClass, String name, int primaryColor, int secondaryColor)
{
int entityID = EntityRegistry.findGlobalUniqueEntityId();
long seed = name.hashCode();
EntityRegistry.registerGlobalEntityID(entityClass, name, entityID);
EntityRegistry.registerModEntity(entityClass, name, entityID, instance, 64, 1, true); //эта строка не нужна(зачем она?)
EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, primaryColor, secondaryColor));
}
@EventHandler
public void preLoad(FMLPreInitializationEvent event)
{
System.out.println("Я тут");
registerEntity(E5.class, "E5", 0x00FFFF, 0x00008B);
//block
pipe = new BlockTut(Material.iron, "pipe", "iron");
wood = new BlockWood(Material.wood, "wood", "wood");
//item
MyPickaxe = new MyPickaxe()
.setUnlocalizedName("MyPickaxe");
Myaxe = new Myaxe()
.setUnlocalizedName("Myaxe");
MyShovel = new MyShovel()
.setUnlocalizedName("MyShovel");
proxy.registerRenderers();
//GameRegistry.registerItem
GameRegistry.registerItem( MyShovel, "SilverShovel");
GameRegistry.registerItem( Myaxe, "Silveraxe");
GameRegistry.registerItem( MyPickaxe, "SilverPickaxe");
}
@EventHandler
public void Load(FMLInitializationEvent event)
{
}
@EventHandler
public void postLoad(FMLPostInitializationEvent event)
{
GameRegistry.addRecipe(new ItemStack(Main.MyPickaxe, 1),
new Object[]{
"X#X",
" Y ",
" X ",
('X'),Blocks.diamond_block,
('#'),Items.nether_star,
('Y'),Items.golden_apple
});//end of repice
}
}
Код CommonProxy:
package com.endienasg.proxy;
public class CommonProxy {
public void registerRenderers()
{
}
}
Код ClientProxy
package com.endienasg.proxy;
import com.endienasg.shinkansen.E5;
import com.endienasg.shinkansen.RenderE5;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.model.ModelBiped;
public class ClientProxy extends CommonProxy{
@Override
public void registerRenderers()
{
RenderingRegistry.registerEntityRenderingHandler(E5.class, new RenderE5(new ModelBiped(), 0.5F));
}
}
Код E5.class (сам моб (планируется перенести его из разряда "Моб" -> "Вагонетка и её производные (увы я не знаю как)"
package com.endienasg.shinkansen;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.world.World;
public class E5 extends EntityMob
{
public E5(World par1World)
{
super(par1World);
}
}
Код RenderE5
package com.endienasg.shinkansen;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
public class RenderE5 extends RenderBiped {
private static final ResourceLocation textureLocation = new ResourceLocation("shinkansen:textures/entity/train.png");
public RenderE5(ModelBiped model, float shadowSize)
{
super(model, shadowSize);
}
@Override
protected ResourceLocation getEntityTexture(Entity par1Entity)
{
return textureLocation;
}
}
Код: Main.class
//proxy-связь;
@Mod.Instance("com.endienasg.shinkansen.Main")
public static com.endienasg.shinkansen.Main instance;
@SidedProxy(clientSide = "ClientProxy.ClientProxy", serverSide = "CommonProxy.CommonProxy")
public static CommonProxy proxy;
//creative Tab
public static final CreativeTabs tabshinkansenMod = new CreativeTabs("tabshinkansenMod"){
public Item getTabIconItem() {
return Item.getItemFromBlock(Blocks.command_block);
}
};
//info
public static final String MODID = "shinkansen";
public static final String MODNAME = "shinkansen Mod";
public static final String VERSION = "0.1.0";
//block
public static Block pipe;
public static Block wood;
//item
public static Item MyPickaxe;
public static Item Myaxe;
public static Item MyShovel;
//Mob|entity
public static void registerEntity(Class entityClass, String name, int primaryColor, int secondaryColor)
{
int entityID = EntityRegistry.findGlobalUniqueEntityId();
long seed = name.hashCode();
EntityRegistry.registerGlobalEntityID(entityClass, name, entityID);
EntityRegistry.registerModEntity(entityClass, name, entityID, instance, 64, 1, true); //эта строка не нужна(зачем она?)
EntityList.entityEggs.put(Integer.valueOf(entityID), new EntityList.EntityEggInfo(entityID, primaryColor, secondaryColor));
}
@EventHandler
public void preLoad(FMLPreInitializationEvent event)
{
System.out.println("Я тут");
registerEntity(E5.class, "E5", 0x00FFFF, 0x00008B);
//block
pipe = new BlockTut(Material.iron, "pipe", "iron");
wood = new BlockWood(Material.wood, "wood", "wood");
//item
MyPickaxe = new MyPickaxe()
.setUnlocalizedName("MyPickaxe");
Myaxe = new Myaxe()
.setUnlocalizedName("Myaxe");
MyShovel = new MyShovel()
.setUnlocalizedName("MyShovel");
proxy.registerRenderers();
//GameRegistry.registerItem
GameRegistry.registerItem( MyShovel, "SilverShovel");
GameRegistry.registerItem( Myaxe, "Silveraxe");
GameRegistry.registerItem( MyPickaxe, "SilverPickaxe");
}
@EventHandler
public void Load(FMLInitializationEvent event)
{
}
@EventHandler
public void postLoad(FMLPostInitializationEvent event)
{
GameRegistry.addRecipe(new ItemStack(Main.MyPickaxe, 1),
new Object[]{
"X#X",
" Y ",
" X ",
('X'),Blocks.diamond_block,
('#'),Items.nether_star,
('Y'),Items.golden_apple
});//end of repice
}
}
Код CommonProxy:
package com.endienasg.proxy;
public class CommonProxy {
public void registerRenderers()
{
}
}
Код ClientProxy
package com.endienasg.proxy;
import com.endienasg.shinkansen.E5;
import com.endienasg.shinkansen.RenderE5;
import cpw.mods.fml.client.registry.RenderingRegistry;
import net.minecraft.client.model.ModelBiped;
public class ClientProxy extends CommonProxy{
@Override
public void registerRenderers()
{
RenderingRegistry.registerEntityRenderingHandler(E5.class, new RenderE5(new ModelBiped(), 0.5F));
}
}
Код E5.class (сам моб (планируется перенести его из разряда "Моб" -> "Вагонетка и её производные (увы я не знаю как)"
package com.endienasg.shinkansen;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.world.World;
public class E5 extends EntityMob
{
public E5(World par1World)
{
super(par1World);
}
}
Код RenderE5
package com.endienasg.shinkansen;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.renderer.entity.Render;
import net.minecraft.client.renderer.entity.RenderBiped;
import net.minecraft.entity.Entity;
import net.minecraft.util.ResourceLocation;
public class RenderE5 extends RenderBiped {
private static final ResourceLocation textureLocation = new ResourceLocation("shinkansen:textures/entity/train.png");
public RenderE5(ModelBiped model, float shadowSize)
{
super(model, shadowSize);
}
@Override
protected ResourceLocation getEntityTexture(Entity par1Entity)
{
return textureLocation;
}
}