Résolu Rendu TESR à plusieurs textures // Problème de synchro
-
Bonjour, je fais un rendu spécial assez simple, c’est pour afficher des “graffitis” aux murs.
Mon principe est qu’un seul bloc suffit pour l’ensemble des textures, un simple clic droit faisant augmenter la valeur d’un integer et, lors du rendu, la valeur de l’integer détermine quelle texture doit être appliquée.
Le soucis est que visiblement tout ceci ne se passe que côté client et je pensais pourtant qu’avec les nbt et le packet toussah toussah ça aurait pu aller.
Du coup mes classes actuelles:
Le bloc:
package fr.folgansky.powerdeco.common; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import fr.folgansky.powerdeco.client.TileEntityGraffiti; import fr.folgansky.powerdeco.proxy.ClientProxy; import net.minecraft.block.Block; import net.minecraft.block.material.Material; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.MathHelper; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; public class BlockGraffiti extends Block { protected BlockGraffiti(Material mat) { super(mat); } @Override public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityGraffiti) { TileEntityGraffiti tileEntityGraffiti = (TileEntityGraffiti)tile; switch(tileEntityGraffiti.getDirection()) { case 0: this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 0.1F); break; case 1: this.setBlockBounds(0.9F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F); break; case 2: this.setBlockBounds(0.0F, 0.0F, 0.9F, 1.0F, 1.0F, 1.0F); break; case 3: this.setBlockBounds(0.0F, 0.0F, 0.0F, 0.1F, 1.0F, 1.0F); break; } } } @Override public int damageDropped(int metadata) { return metadata; } @Override public boolean hasTileEntity(int metadata) { return true; } @Override public TileEntity createTileEntity(World world, int metadata) { return new TileEntityGraffiti(); } public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) { TileEntity tile = world.getTileEntity(x, y, z); if(tile instanceof TileEntityGraffiti) { if(player.capabilities.isCreativeMode && tile instanceof TileEntityGraffiti) { TileEntityGraffiti tileGraffiti = (TileEntityGraffiti)tile; tileGraffiti.increase(); if(tileGraffiti.getTexture() > 18) { tileGraffiti.reset(); } return true; } return false; } return false; } @Override public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase living, ItemStack stack) { if (stack.getItemDamage() == 0) { TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileEntityGraffiti) { int direction = MathHelper.floor_double(living.rotationYaw * 4.0F / 360.0F + 2.5D) & 3; ((TileEntityGraffiti) tile).setDirection((byte) direction); } } } @Override public boolean rotateBlock(World world, int x, int y, int z, ForgeDirection axis) { if ((axis == ForgeDirection.UP || axis == ForgeDirection.DOWN) && !world.isRemote && world.getBlockMetadata(x, y, z) == 0) { TileEntity tile = world.getTileEntity(x, y, z); if (tile instanceof TileEntityGraffiti) { TileEntityGraffiti tileDirectional = (TileEntityGraffiti) tile; byte direction = tileDirectional.getDirection(); direction++; if (direction > 3) direction = 0; tileDirectional.setDirection(direction); return true; } } return false; } @Override public ForgeDirection[] getValidRotations(World world, int x, int y, int z) { return world.getBlockMetadata(x, y, z) == 0 ? new ForgeDirection[] { ForgeDirection.UP, ForgeDirection.DOWN } : ForgeDirection.VALID_DIRECTIONS; } @Override public boolean isOpaqueCube() { return false; } @Override public boolean renderAsNormalBlock() { return false; } public boolean canBeCollidedWith() { return true; } @Override @SideOnly(Side.CLIENT) public int getRenderType() { return ClientProxy.tesrRenderId; } }
Le TileEntity:
package fr.folgansky.powerdeco.client; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.network.NetworkManager; import net.minecraft.network.Packet; import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.tileentity.TileEntity; public class TileEntityGraffiti extends TileEntity { private byte direction; private int blockType; @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.direction = compound.getByte("Direction"); this.blockType= compound.getInteger("BlockType"); } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setByte("Direction", this.direction); compound.setInteger("BlockType", this.blockType); } public byte getDirection() { return direction; } public void setDirection(byte direction) { this.direction = direction; this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } public int getTexture() { return blockType; } public void increase() { this.blockType ++; } public void decrease() { this.blockType –; } public void reset() { this.blockType = 0; } @Override public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound); } @Override public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity pkt) { this.readFromNBT(pkt.func_148857_g()); this.worldObj.markBlockRangeForRenderUpdate(this.xCoord, this.yCoord, this.zCoord, this.xCoord, this.yCoord, this.zCoord); } }
Et le TESR (très long pour pas grand chose mais il faut tenir compte des blocksbounds qui ne sont pas les mêmes suivant l’orientation du bloc):
package fr.folgansky.powerdeco.client; import org.lwjgl.opengl.GL11; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; public class TileEntityGraffitiSpecialRenderer extends TileEntitySpecialRenderer { public static ModelGraffiti model = new ModelGraffiti(); public static ResourceLocation texture0 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti0.png"); public static ResourceLocation texture1 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti1.png"); public static ResourceLocation texture2 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti2.png"); public static ResourceLocation texture3 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti3.png"); public static ResourceLocation texture4 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti4.png"); public static ResourceLocation texture5 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti5.png"); public static ResourceLocation texture6 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti6.png"); public static ResourceLocation texture7 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti7.png"); public static ResourceLocation texture8 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti8.png"); public static ResourceLocation texture9 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti9.png"); public static ResourceLocation texture10 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti10.png"); public static ResourceLocation texture11 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti11.png"); public static ResourceLocation texture12 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti12.png"); public static ResourceLocation texture13 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti13.png"); public static ResourceLocation texture14 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti14.png"); public static ResourceLocation texture15 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti15.png"); public static ResourceLocation texture16 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti16.png"); public static ResourceLocation texture17 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti17.png"); public static ResourceLocation texture18 = new ResourceLocation("ModPowerDeco:textures/models/blocks/Graffiti18.png"); public TileEntityGraffitiSpecialRenderer() { this.func_147497_a(TileEntityRendererDispatcher.instance); } @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialRenderTick) { this.renderTileEntityGraffitiAt((TileEntityGraffiti) tile, x, y, z, partialRenderTick); } private void renderTileEntityGraffitiAt(TileEntityGraffiti tile, double x, double y, double z, float partialRenderTick) { if(tile.getTexture() == 0) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture0); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture0); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture0); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture0); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 1) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture1); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture1); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture1); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture1); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 2) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture2); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture2); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture2); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture2); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 3) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture3); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture3); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture3); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture3); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 4) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture4); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture4); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture4); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture4); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 5) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture5); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture5); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture5); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture5); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 6) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture6); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture6); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture6); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture6); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 7) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture7); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture7); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture7); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture7); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 8) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture8); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture8); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture8); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture8); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 9) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture9); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture9); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture9); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture9); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 10) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture10); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture10); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture10); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture10); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 11) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture11); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture11); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture11); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture11); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 12) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture12); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture12); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture12); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture12); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 13) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture13); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture13); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture13); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture13); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 14) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture14); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture14); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture14); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture14); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 15) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture15); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture15); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture15); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture15); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 16) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture16); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture16); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture16); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture16); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 17) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture17); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture17); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture17); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture17); model.renderAll(); GL11.glPopMatrix(); break; } } if(tile.getTexture() == 18) { switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture18); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture18); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture18); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture18); model.renderAll(); GL11.glPopMatrix(); break; } } } }
-
Le problème (je pense) que tu as, est que le serveur n’envoit pas le int de l’image quand il est changé, car il ne le sait pas, il faut que tu mettes this.markDirty() à chaque endroit où tu changes le numéro de ta texture (sauf dans readFromNBT).
Et aussi pour ton rendu, tu n’es pas obligé de refaire tout le rendu pour chaque texture, tu peux bind ta texture au tout début de ton render, en fonction de celle indiqué par le tile entity, puis tu fais le rendu en fonction de la face, pas besoin de le copier 18 fois. -
Le markDirty c’est que pour la classe du tileEntity?
Et aussi pour ton explication du fait que j’ai pas besoin de recopier 18 fois, je n’ai pas compris.
Si je le fais 18 fois c’est qu’il y a 18 cas différents -
- Oui.
- Ce que je veux dire, c’est qu’il y a 18 bindTexture() différents, mais pas 18
GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture1); model.renderAll(); GL11.glPopMatrix(); ``` différents, juste 4 si tu mets le "this.bindTexture(texture1);" avant.
-
Normalement this.markDirty() suffit, en revanche je te conseillerais de passer par les metadata du block qui eux se synchronisent très facilement et permettent de ne pas surcharger le monde avec des TileEntity si tu as besoin de seulement 16 textures (tu peux aussi créer plusieurs blocks si 16 ne suffisent pas).
AymericRed disant que tu pouvais enlever les conditions et créer une array de ResourceLocation avec lequel tu pourrais faire this.bindTexture(arrayDeResourceLocations[tonInt]); ce qui raccourcirai grandement le code :
package fr.folgansky.powerdeco.client; import org.lwjgl.opengl.GL11; import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher; import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer; import net.minecraft.tileentity.TileEntity; import net.minecraft.util.ResourceLocation; public class TileEntityGraffitiSpecialRenderer extends TileEntitySpecialRenderer { public static ModelGraffiti model = new ModelGraffiti(); public static ResourceLocation[] textures = new ResourceLocation[]{/*ici tu mets toutes tes textures*/} public TileEntityGraffitiSpecialRenderer() { this.func_147497_a(TileEntityRendererDispatcher.instance); } @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialRenderTick) { this.renderTileEntityGraffitiAt((TileEntityGraffiti) tile, x, y, z, partialRenderTick); } private void renderTileEntityGraffitiAt(TileEntityGraffiti tile, double x, double y, double z, float partialRenderTick) { this.bindTexture(textures[tile.getTexture()]); switch(tile.getDirection()) { case 0: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.26D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture0); model.renderAll(); GL11.glPopMatrix(); break; case 1: GL11.glPushMatrix(); GL11.glTranslated(x + 0.74D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture0); model.renderAll(); GL11.glPopMatrix(); break; case 2: GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.0D, z + 0.74D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture0); model.renderAll(); GL11.glPopMatrix(); break; case 3: GL11.glPushMatrix(); GL11.glTranslated(x + 0.26D, y + 1.0D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); GL11.glScaled(0.5, 0.5, 0.5); this.bindTexture(texture0); model.renderAll(); GL11.glPopMatrix(); break; } } }
-
Ok je teste pour le MarkDirty (je ne sais pas du tout ce que c’est, si c’est compliqué à expliquer j’vous embête pas avec ça, tant que ça fonctionne pour le coup, je ferai pas mon difficile).
Par contre des metadonnées de bloc avec un rendu spécial ça sonne tout nouveau à mes oreilles et j’y aurais pas pensé.
Merci pour le Array, je suis pas familiarisé avec son utilisation. -
Je mettrai plutôt un world.markBlockForUpdate(x, y, z); avant le return true dans onBlockActivated
-
Si je fais les deux, c’est en excès?
Par contre, comme je disais, les Array et moi c’est pas encore ça…
En gros je ne sais pas les remplir, je teste des trucs qui vont sembleront farfelues genre:public static ResourceLocation[] textures = new ResourceLocation[]{"ModPowerDeco:textures/models/blocks/Graffiti0.png", texture1, texture2};
-
Ce n’est pas farfelues c’est presque comme ça.
Le seul soucis c’est que tu remplis un tableau de ResourceLocation avec des String.La bonne syntaxe :
public static ResourceLocation[] textures = new ResourceLocation[]{new ResourceLocation("ModPowerDeco", "textures/models/blocks/Graffiti0.png"), new ResourceLocation(texture1), new ResourceLocation(texture2), etc …};
(oui les tableaux d’objets c’est dégueulasse quand on déclare tout comme ceci).
Après pour faire moins dégueulasse :
public static ResourceLocation[] textures = new ResourceLocation[19]; static { for(int i = 0; i < 19; i++) { textures* = new ResourceLocation("modpowerdeco", "textures/models/blocks/Graffiti" + i + ".png") } }
-
Ok, j’ai pu retester et c’est bon, les textures sont bien actualisées pour tout le monde. (j’ai fais MarkDirty et MarkBlckForUpdate)
Merci pour chaque réponse les gars et merci robin pour ce gros éclairage sur l’array qui me laissait un peu dubitatif.