Direction de bloc
-
Ha ouai, c’est … pas le résultat voulu x)
Et avec ça ?GL11.glPushMatrix(); GL11.glRotatef(90 * world.getBlockMetadata(x, y, z), 0.0F, 1.0F, 0.0F); GL11.glPopMatrix();
-
je doit le mettre dans mon bloc ou dans le rendu le:
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; world.setBlockMetadataWithNotify(x, y, z, direction, 2); }
?
-
Dans le bloc.
-
cela ne fait strictement rien…
mon rendu:package Portal; import net.minecraft.block.Block; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.Tessellator; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemStack; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import org.lwjgl.opengl.GL11; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class RenderTable implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelID, RenderBlocks renderer) { Tessellator tessellator = Tessellator.instance; renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); // cree un "etage" pour le rendu de l'inventaire this.renderInInventory(tessellator, renderer, block, metadata); // sauvegarde "l'etage" pour le rendu de l'inventaire //etc etc } private void renderInInventory(Tessellator tessellator, RenderBlocks renderer, Block block, int metadata) { tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 1F, 1.0F); renderer.renderFaceYNeg(block, 1.0D, 1.0D, 1.0D, block.getIcon(0, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 1.0F, 1.0F); renderer.renderFaceYPos(block, 1.0D, 1.0D, 1.0D, block.getIcon(1, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 1.0F, 1F); renderer.renderFaceZNeg(block, 1.0D, 1.0D, 1.0D, block.getIcon(2, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 1.0F, 1.0F); renderer.renderFaceZPos(block, 1.0D, 1.0D, 1.0D, block.getIcon(3, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1F, 1.0F, 1.0F); renderer.renderFaceXNeg(block, 1.0D, 1.0D, 1.0D, block.getIcon(4, metadata)); tessellator.draw(); tessellator.startDrawingQuads(); tessellator.setNormal(1.0F, 1.0F, 1.0F); renderer.renderFaceXPos(block, 1.0D, 1.0D, 1.0D, block.getIcon(5, metadata)); tessellator.draw(); GL11.glTranslatef(1F, 1F, 1F); } public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; world.setBlockMetadataWithNotify(x, y, z, direction, 2); } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { GL11.glPushMatrix(); GL11.glRotatef(90 * world.getBlockMetadata(x, y, z), 0.0F, 1.0F, 0.0F); GL11.glPopMatrix(); renderer.setRenderBounds( 0.0F, 0.0F, 0.0F, 3.0F, 3.0F, 1.0F); // cree un "etage" pour le rendu en jeu //renderer.setRenderBounds(minX, minY, minZ, maxX, maxY, maxZ); renderer.renderStandardBlock(block, x, y, z); //sauvegarde "l'etage" pour le rendu en jeu //etc etc return true; } @Override public boolean shouldRender3DInInventory() { return true; } @Override public int getRenderId() { // TODO Auto-generated method stub return ClientProxy.renderTableId; } }
mon bloc:
package Portal.Blocks; import java.util.Iterator; import java.util.List; import java.util.Random; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.entity.Entity; import net.minecraft.util.AxisAlignedBB; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import Portal.ClientProxy; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; public class portalwowe extends Block { public portalwowe(int id) { super(id, Material.portal); this.setCreativeTab(CreativeTabs.tabBlock); } /** * Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two * adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block. */ public boolean isOpaqueCube() { return false; } /** * If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) */ public boolean renderAsNormalBlock() { return false; } public int isProvidingWeakPower(IBlockAccess par1IBlockAccess, int x, int y, int z, int par5) { return this.getPowerSupply(par1IBlockAccess.getBlockMetadata(x, y, z)); } public void breakBlock(World world, int x, int y, int z, int par5, int par6) { if(this.getPowerSupply(par6) > 0) { this.notifyChange(world, x, y, z); } super.breakBlock(world, x, y, z, par5, par6); } protected void notifyChange(World world, int x, int y, int z) { world.notifyBlocksOfNeighborChange(x, y, z, this.blockID); world.notifyBlocksOfNeighborChange(x, y - 1, z, this.blockID); } public void onEntityCollidedWithBlock(World world, int x, int y, int z, Entity entity) { if(!world.isRemote) { int l = this.getPowerSupply(world.getBlockMetadata(x, y, z)); if(l == 0) { this.setStateIfMobInteractsWithPlate(world, x, y, z, l); } } } protected void setStateIfMobInteractsWithPlate(World world, int x, int y, int z, int par5) { int i1 = this.getPlateState(world, x, y, z); boolean flag = par5 > 0; boolean flag1 = i1 > 0; if(par5 != i1) { world.setBlockMetadataWithNotify(x, y, z, this.getMetaFromWeight(i1), 2); this.notifyChange(world, x, y, z); world.markBlockRangeForRenderUpdate(x, y, z, x, y, z); } if(!flag1 && flag) { world.playSoundEffect((double)x + 0.5D, (double)y + 0.1D, (double)z + 0.5D, "random.click", 0.3F, 0.5F); } else if(flag1 && !flag) { world.playSoundEffect((double)x + 0.5D, (double)y + 0.1D, (double)z + 0.5D, "random.click", 0.3F, 0.6F); } if(flag1) { world.scheduleBlockUpdate(x, y, z, this.blockID, this.tickRate(world)); } } public void updateTick(World world, int x, int y, int z, Random rand) { if(!world.isRemote) { int l = this.getPowerSupply(world.getBlockMetadata(x, y, z)); if(l > 0) { this.setStateIfMobInteractsWithPlate(world, x, y, z, l); } } } public int tickRate(World world) { return 20; } public AxisAlignedBB getCollisionBoundingBoxFromPool(World world, int x, int y, int z) { return null; } protected int getPowerSupply(int metadata) { return metadata == 1 ? 15 : 0; } protected int getMetaFromWeight(int metadata) { return metadata > 0 ? 1 : 0; } protected int getPlateState(World world, int x, int y, int z) { List list = world.getEntitiesWithinAABBExcludingEntity((Entity)null, this.getSensitiveAABB(x, y, z)); //List list = world.getEntitiesWithinAABB(EntityLivingBase.class, this.getSensitiveAABB(x, y, z)); //List list = world.getEntitiesWithinAABB(EntityPlayer.class, this.getSensitiveAABB(x, y, z)); if(list != null && !list.isEmpty()) { Iterator iterator = list.iterator(); while(iterator.hasNext()) { Entity entity = (Entity)iterator.next(); if(!entity.doesEntityNotTriggerPressurePlate()) { return 15; } } } return 0; } protected AxisAlignedBB getSensitiveAABB(int x, int y, int z) { float f = 0.125F; return AxisAlignedBB.getAABBPool().getAABB((double)((float)x + f), (double)y, (double)((float)z + f), (double)((float)(x + 1) - f), (double)y + 0.25D, (double)((float)(z + 1) - f)); } public int isProvidingStrongPower(IBlockAccess blockAccess, int x, int y, int z, int side) { return side == 1 ? this.getPowerSupply(blockAccess.getBlockMetadata(x, y, z)) : 0; } @SideOnly(Side.CLIENT) public int getRenderType() { return ClientProxy.renderTableId; } @SideOnly(Side.CLIENT) public boolean shouldSideBeRendered(IBlockAccess blockAccess, int x, int y, int z, int side) { return true; } }