- 149
- 1
- 2
Привет. Я сделал 3д рендер для блока, но он опять же не рендерится как броня.
import cool.Mod.MyTestMod;
import cool.Mod.TileEntity.TileEntityComputer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class BlockComputer extends BlockContainer{
public BlockComputer(int par1, Material par2Material) {
super(par1, par2Material);
this.setCreativeTab(CreativeTabs.tabDecorations);
}
public AxisAlignedBB getCollisionBoundingsu_boxFromPool(World par1World, int par2, int par3, int par4){
return null;
}
public boolean isOpaqueCube(){
return false;
}
public boolean renderAsNormalBlock(){
return false;
}
public int getRenderType(){
return -1;
}
@Override
public TileEntity createNewTileEntity(World world) {
return new TileEntityComputer();
}
}
import cool.Mod.TileEntity.TileEntityComputer;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
public class BlockComputer extends BlockContainer{
public BlockComputer(int par1, Material par2Material) {
super(par1, par2Material);
this.setCreativeTab(CreativeTabs.tabDecorations);
}
public AxisAlignedBB getCollisionBoundingsu_boxFromPool(World par1World, int par2, int par3, int par4){
return null;
}
public boolean isOpaqueCube(){
return false;
}
public boolean renderAsNormalBlock(){
return false;
}
public int getRenderType(){
return -1;
}
@Override
public TileEntity createNewTileEntity(World world) {
return new TileEntityComputer();
}
}
import org.lwjgl.opengl.GL11;
import cool.Mod.TileEntity.TileEntityComputer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
public class ModelBarrelRender extends TileEntitySpecialRenderer{
IModelCustom model;
public ModelBarrelRender(){
model = AdvancedModelLoader.loadModel("/cool/Mod/obj/Blocks/barrel.obj");
}
@Override
public void renderTileEntityAt(TileEntity te, double d1, double d2, double d3, float f) {
renderTE((TileEntityComputer)te, d1, d2, d3, f);
}
private void renderTE(TileEntity te, double d1, double d2, double d3, float f) {
bindTexture(new ResourceLocation("testmod", "textures/models/blocks/barrel.png"));
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslatef(0, 0, 0);
GL11.glScalef(5, 5, 5);
GL11.glRotatef(0, 0, 0, 0);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
public void renderTileEntity(TileEntityComputer tileEntity, double d1, double d2, double d3, float f) {
int i = 0;
if (tileEntity.hasWorldObj()) { i = tileEntity.getBlockMetadata(); }
short rotation = 0;
if (i == 1) { rotation = 360; }
if (i == 2) { rotation = 270; }
if (i == 3) { rotation = 180; }
if (i == 4) { rotation = 90; }
GL11.glPushMatrix();
GL11.glTranslatef((float)d1 + 0.1F, (float)d2 + 1.5F, (float)d3 + 0.5F);
if(i == 1) {GL11.glTranslatef(-0.1F, 0.0F, 0.0F); }
if(i == 2) {GL11.glTranslatef(0.4F, 0.0F, -0.5F); }
if(i == 3) {GL11.glTranslatef(0.9F, 0.0F, 0.0F); }
if(i == 4) {GL11.glTranslatef(0.4F, 0.0F, 0.5F); }
GL11.glRotatef(rotation, 0, 1, 0);
GL11.glRotatef(180F, 0, 0, 1);
GL11.glScalef(1F, 1F, 1F);
GL11.glPopMatrix();
}
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
float f = 0.0000F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.0F, f, 0.0F);
}
private void setBlockBounds(float f, float g, float h, float i, float f2, float j) {
// TODO Auto-generated method stub
}
}
import cool.Mod.TileEntity.TileEntityComputer;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
public class ModelBarrelRender extends TileEntitySpecialRenderer{
IModelCustom model;
public ModelBarrelRender(){
model = AdvancedModelLoader.loadModel("/cool/Mod/obj/Blocks/barrel.obj");
}
@Override
public void renderTileEntityAt(TileEntity te, double d1, double d2, double d3, float f) {
renderTE((TileEntityComputer)te, d1, d2, d3, f);
}
private void renderTE(TileEntity te, double d1, double d2, double d3, float f) {
bindTexture(new ResourceLocation("testmod", "textures/models/blocks/barrel.png"));
GL11.glPushMatrix();
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glTranslatef(0, 0, 0);
GL11.glScalef(5, 5, 5);
GL11.glRotatef(0, 0, 0, 0);
GL11.glDisable(GL11.GL_BLEND);
GL11.glPopMatrix();
}
public void renderTileEntity(TileEntityComputer tileEntity, double d1, double d2, double d3, float f) {
int i = 0;
if (tileEntity.hasWorldObj()) { i = tileEntity.getBlockMetadata(); }
short rotation = 0;
if (i == 1) { rotation = 360; }
if (i == 2) { rotation = 270; }
if (i == 3) { rotation = 180; }
if (i == 4) { rotation = 90; }
GL11.glPushMatrix();
GL11.glTranslatef((float)d1 + 0.1F, (float)d2 + 1.5F, (float)d3 + 0.5F);
if(i == 1) {GL11.glTranslatef(-0.1F, 0.0F, 0.0F); }
if(i == 2) {GL11.glTranslatef(0.4F, 0.0F, -0.5F); }
if(i == 3) {GL11.glTranslatef(0.9F, 0.0F, 0.0F); }
if(i == 4) {GL11.glTranslatef(0.4F, 0.0F, 0.5F); }
GL11.glRotatef(rotation, 0, 1, 0);
GL11.glRotatef(180F, 0, 0, 1);
GL11.glScalef(1F, 1F, 1F);
GL11.glPopMatrix();
}
public void setBlockBoundsBasedOnState(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
float f = 0.0000F;
this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.0F, f, 0.0F);
}
private void setBlockBounds(float f, float g, float h, float i, float f2, float j) {
// TODO Auto-generated method stub
}
}