Как добавить obj блоку разные расположения к игроку?

Версия Minecraft
1.7.10
API
Forge
У меня есть блок,но он ставится только в одну сторону из ещё 3 доступных,как сделать так чтоб блок ставился в 4 разных позициях?Были 2 попытки,но они не увенчались успехом(2022-07-17_21.55.32.png2022-07-17_21.55.37.png
 
Решение
Render:
private void render(TileEntityObj09 tile, double x, double y, double z, float f) {
        GL11.glPushMatrix();
        bindTexture(texture);
        GL11.glTranslated(x, y, z);
        GL11.glTranslatef(0.5F, 0.0F, 0.5F);
        GL11.glTranslatef(0, 0, 1);
        GL11.glRotatef(90f, 0.1f, 0.1f, 1.0f);
        if (tile != null) {
            GL11.glRotatef(tile.getBlockMetadata()*90, 0f, 1f, 0f);
        }
        GL11.glCallList(ProxyClient.displayList[8]);
        GL11.glPopMatrix();
    }
63
1
5
Java:
public void renderTileEntity(TileEntity tile , double x, double y, double z, float f)
{
    if (tile != null)
    {
        switch(tile.getBlockMetadata())
        {
            case 0:GL11.glRotatef(360F + 90F, 0.0F, 1.0F, 0.0F);break;
            case 1:GL11.glRotatef(0F, 0.0F, 1.0F, 0.0F);break;
            case 2:GL11.glRotatef(180F + 90F, 0.0F, 1.0F, 0.0F);break;
            case 3:GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);break;
        }
    }
}
 
Java:
public void renderTileEntity(TileEntity tile , double x, double y, double z, float f)
{
    if (tile != null)
    {
        switch(tile.getBlockMetadata())
        {
            case 0:GL11.glRotatef(360F + 90F, 0.0F, 1.0F, 0.0F);break;
            case 1:GL11.glRotatef(0F, 0.0F, 1.0F, 0.0F);break;
            case 2:GL11.glRotatef(180F + 90F, 0.0F, 1.0F, 0.0F);break;
            case 3:GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F);break;
        }
    }
}
модель пропадает если ставишь больше одной
 
это тайтл ентити
package sub_mod.obj_block.client.render.tile;

import org.lwjgl.opengl.GL11;

import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ResourceLocation;

import sub_mod.obj_block.ModBlockObj;
import sub_mod.obj_block.client.ProxyClient;
import sub_mod.obj_block.tile_entity.TileEntityObj09;

public class RenderTileEntityObj09 extends TileEntitySpecialRenderer {

public static final ResourceLocation texture = new ResourceLocation(ModBlockObj.MODID, "textures/blocks/block9.png");

@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float f) {
render((TileEntityObj09)tile, x, y, z, f);
}





private void render(TileEntityObj09 tile, double x, double y, double z, float f) {
GL11.glPushMatrix();
GL11.glTranslated(x, y, z);
GL11.glTranslatef(0.5F, 0.0F, 0.5F);
bindTexture(texture);
GL11.glCallList(ProxyClient.displayList[8]);
GL11.glPushMatrix();
GL11.glTranslatef(0,0,1);
GL11.glRotatef(90f, 0.1f, 0.1f, 1.0f);
GL11.glPopMatrix();
{
if (tile != null)
{
switch(tile.getBlockMetadata())
{
case 0:GL11.glRotatef(0.0F, 0.0F, 1.0F, 0.0F);break;
case 1:GL11.glRotatef(90.0F, 0.0F, 1.0F, 0.0F);break;
case 2:GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);break;
case 3:GL11.glRotatef(270.0F, 0.0F, 1.0F, 0.0F);break;
}
}


}

}

}
 
Неправильное оформление кода
это сам блок
package sub_mod.obj_block.block;

import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import sub_mod.obj_block.ModBlockObj;
import sub_mod.obj_block.tile_entity.TileEntityObj09;

public class BlockObj09 extends Block implements ITileEntityProvider {

public BlockObj09() {
super(Material.circuits);
setCreativeTab(CreativeTabs.tabBlock);
setHardness(2F);
setStepSound(soundTypeMetal);
setBlockTextureName("iron_block");
setBlockName(ModBlockObj.MODID + ".block_obj09");

this.setBlockBounds(00, 00, 00, 01, 02, 01);
}
public boolean getRenderBoundingBox() {
this.setSize(1, 2, 1);
return blockConstructorCalled;
}
private void setSize(int i, int j, int k) {
// TODO Auto-generated method stub

}

@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase entity, ItemStack stack) {
int l = MathHelper.floor_double((double)(entity.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
world.setBlockMetadataWithNotify(x, y, z, l, 2);
}

@Override
public TileEntity createNewTileEntity(World world, int metadata) {
return new TileEntityObj09();
}

public int getRenderType() {
return -200;
}

public boolean isOpaqueCube() {
return false;
}

public boolean renderAsNormalBlock() {
return false;





}

}
 
175
14
25
Render:
private void render(TileEntityObj09 tile, double x, double y, double z, float f) {
        GL11.glPushMatrix();
        bindTexture(texture);
        GL11.glTranslated(x, y, z);
        GL11.glTranslatef(0.5F, 0.0F, 0.5F);
        GL11.glTranslatef(0, 0, 1);
        GL11.glRotatef(90f, 0.1f, 0.1f, 1.0f);
        if (tile != null) {
            GL11.glRotatef(tile.getBlockMetadata()*90, 0f, 1f, 0f);
        }
        GL11.glCallList(ProxyClient.displayList[8]);
        GL11.glPopMatrix();
    }
 
Последнее редактирование:
Сверху