Résolu Problème block TESR
-
**Version **: 1.7.10
[font=helvetica, arial, sans-serifAPI utilisée(s) :][font=helvetica, arial, sans-serif Forge]
[font=helvetica, arial, sans-serif**Recherche(s) effectuée(s) : **MinecraftForgeFrance, google, etc…][font=helvetica, arial, sans-serif**Explication du problème : **Bonjours la communauté de Minecraft Forge France, aujourd’hui, je fait face a un petit problème, j’ai suivi le tutoriels de robin4002 sur les block TESR mais j’ai un problème, moi block n’apparaît pas. Je crois j’ai du louper quelque chose ou autre mais je fait appel a voir afin de m’aider a trouver mon erreurs. Le but de mon block est un panneaux.]
Je précise que c’est pas mon premier block TESR que je fait, tout les autres blocks ont fonctionner, mais sa faisait depuis 1 mois javais pas modder sous forge donc j’en suis sur c’est juste une petite erreur con de ma part…
[font=helvetica, arial, sans-serifCode(s):]
[font=helvetica, arial, sans-serifMon models :][font=helvetica, arial, sans-serifModelpanneaux.class]
package ca.mathmatboy.PlanetCraft.Block.models; import net.minecraft.client.model.ModelBase; import net.minecraft.client.model.ModelRenderer; public class Modelpanneaux extends ModelBase { ModelRenderer fenetre; ModelRenderer patteGauche; ModelRenderer patteMid; ModelRenderer patteDroit; public Modelpanneaux() { textureWidth = 265; textureHeight = 256; fenetre = new ModelRenderer(this, 0, 0); fenetre.addBox(-40F, 0F, -1F, 80, 39, 3); fenetre.setRotationPoint(0F, -18F, 0F); fenetre.setTextureSize(265, 256); fenetre.mirror = true; setRotation(fenetre, 0F, 0F, 0F); patteGauche = new ModelRenderer(this, 0, 42); patteGauche.addBox(0F, 0F, 0F, 3, 3, 3); patteGauche.setRotationPoint(-34F, 21F, -1F); patteGauche.setTextureSize(265, 256); patteGauche.mirror = true; setRotation(patteGauche, 0F, 0F, 0F); patteMid = new ModelRenderer(this, 0, 42); patteMid.addBox(0F, 0F, 0F, 3, 3, 3); patteMid.setRotationPoint(-1F, 21F, -1F); patteMid.setTextureSize(265, 256); patteMid.mirror = true; setRotation(patteMid, 0F, 0F, 0F); patteDroit = new ModelRenderer(this, 0, 42); patteDroit.addBox(0F, 0F, 0F, 3, 3, 3); patteDroit.setRotationPoint(31F, 21F, -1F); patteDroit.setTextureSize(265, 256); patteDroit.mirror = true; setRotation(patteDroit, 0F, 0F, 0F); } public void renderAll() { fenetre.render(0.0625F); patteGauche.render(0.0625F); patteMid.render(0.0625F); patteDroit.render(0.0625F); } private void setRotation(ModelRenderer model, float x, float y, float z) { model.rotateAngleX = x; model.rotateAngleY = y; model.rotateAngleZ = z; } }
[font=helvetica, arial, sans-serifLa déclaration de mon block :]
PlanetCraft.panneaux = new BlockModPanneaux(Material.wood).setHardness(1.5F).setResistance(10.0F).setBlockName("panneaux").setBlockTextureName(PlanetCraft.MODID + ":panneaux").setCreativeTab(CreativeTabs.tabBlock);
[font=helvetica, arial, sans-serifBlockModPanneaux.class]
package ca.mathmatboy.PlanetCraft.Block.TESR; import ca.mathmatboy.PlanetCraft.Block.TileEntity.TileEntityBlockPanneaux; import ca.mathmatboy.PlanetCraft.proxy.ClientProxy; import net.minecraft.block.Block; import net.minecraft.block.material.Material; 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 net.minecraftforge.common.util.ForgeDirection; public class BlockModPanneaux extends Block{ public BlockModPanneaux(Material material) { super(material); } public boolean hasTileEntity(int metadata) { return true; } public TileEntity createTileEntity(World world, int metadata) { return new TileEntityBlockPanneaux(); } 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 TileEntityBlockPanneaux) { int direction = MathHelper.floor_double((double)(living.rotationYaw * 4.0F / 360.0F) + 2.5D) & 3; ((TileEntityBlockPanneaux)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 TileEntityBlockPanneaux) { TileEntityBlockPanneaux tileDirectional = (TileEntityBlockPanneaux)tile; byte direction = tileDirectional.getDirection(); direction++; if(direction > 3) { direction = 0; } tileDirectional.setDirection(direction); return true; } } return false; } 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; } public boolean isOpaqueCube() { return false; } public boolean renderAsNormalBlock() { return false; } public int getRenderType() { return ClientProxy.tesrRenderId; } }
[font=helvetica, arial, sans-serifTileEntityBlockPanneaux.class]
package ca.mathmatboy.PlanetCraft.Block.TileEntity; 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 TileEntityBlockPanneaux extends TileEntity { private byte direction; @Override public void readFromNBT(NBTTagCompound compound) { super.readFromNBT(compound); this.direction = compound.getByte("Direction"); } @Override public void writeToNBT(NBTTagCompound compound) { super.writeToNBT(compound); compound.setByte("Direction", this.direction); } public byte getDirection() { return direction; } public void setDirection(byte direction) { this.direction = direction; this.worldObj.markBlockForUpdate(this.xCoord, this.yCoord, this.zCoord); } public Packet getDescriptionPacket() { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 0, nbttagcompound); } 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); } }
[font=helvetica, arial, sans-serifTileEntityPanneauxSpecialRenderer.class]
package ca.mathmatboy.PlanetCraft.Block.TileEntity; import org.lwjgl.opengl.GL11; import ca.mathmatboy.PlanetCraft.PlanetCraft; import ca.mathmatboy.PlanetCraft.Block.TESR.BlockModPanneaux; import ca.mathmatboy.PlanetCraft.Block.models.Modelpanneaux; 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 TileEntityPanneauxSpecialRenderer extends TileEntitySpecialRenderer { public static Modelpanneaux model = new Modelpanneaux(); public static ResourceLocation texture = new ResourceLocation(PlanetCraft.MODID, "textures/models/blocks/panneaux.png"); public TileEntityPanneauxSpecialRenderer() { this.func_147497_a(TileEntityRendererDispatcher.instance); } @Override public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float partialRenderTick) { this.renderTileEntityTutorielAt((TileEntityBlockPanneaux)tile, x, y, z, partialRenderTick); } private void renderTileEntityTutorielAt(TileEntityBlockPanneaux tile, double x, double y, double z, float partialRenderTick) { GL11.glPushMatrix(); GL11.glTranslated(x + 0.5D, y + 1.5D, z + 0.5D); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glRotatef((90F * tile.getDirection()) + 180F, 0.0F, 1.0F, 0.0F); this.bindTexture(texture); model.renderAll(); GL11.glPopMatrix(); } }
[font=helvetica, arial, sans-serifTESRInventoryRenderer.class]
package ca.mathmatboy.PlanetCraft.Block.TESR; import org.lwjgl.opengl.GL11; import ca.mathmatboy.PlanetCraft.PlanetCraft; import ca.mathmatboy.PlanetCraft.Block.TileEntity.TileEntityPanneauxSpecialRenderer; import ca.mathmatboy.PlanetCraft.proxy.ClientProxy; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.world.IBlockAccess; import cpw.mods.fml.client.registry.ISimpleBlockRenderingHandler; public class TESRInventoryRenderer implements ISimpleBlockRenderingHandler { @Override public void renderInventoryBlock(Block block, int metadata, int modelId,RenderBlocks renderer) { if(block == PlanetCraft.panneaux && metadata == 0) { GL11.glPushMatrix(); GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F); GL11.glTranslatef(0.0F, -1.0F, 0.0F); GL11.glRotatef(180F, 0.0F, 1.0F, 0.0F); Minecraft.getMinecraft().getTextureManager().bindTexture(TileEntityPanneauxSpecialRenderer.texture); TileEntityPanneauxSpecialRenderer.model.renderAll(); GL11.glPopMatrix(); } } @Override public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) { return false; } @Override public boolean shouldRender3DInInventory(int modelId) { return true; } @Override public int getRenderId() { return ClientProxy.tesrRenderId; } }
[size=smallClientProxy.class]
package ca.mathmatboy.PlanetCraft.proxy; import ca.mathmatboy.PlanetCraft.Block.TESR.TESRInventoryRenderer; import ca.mathmatboy.PlanetCraft.Block.TileEntity.TileEntityBlockPanneaux; import ca.mathmatboy.PlanetCraft.Block.TileEntity.TileEntityPanneauxSpecialRenderer; import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.RenderingRegistry; public class ClientProxy extends CommonProxy{ public static int tesrRenderId; @Override public void registerRender() { System.out.println("méthode côté client"); tesrRenderId = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new TESRInventoryRenderer()); ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBlockPanneaux.class, new TileEntityPanneauxSpecialRenderer()); } }
[font=helvetica, arial, sans-serifCommonProxy.class]
package ca.mathmatboy.PlanetCraft.proxy; public class CommonProxy { public void registerRender(){} }
Screen(s):
Voila a quoi ressemble mon block en jeu, il a juste tout simplement pas la texture et même pas la forme de mon block
[font=helvetica, arial, sans-serifBref, je crois j’ai riens n’oublier, merci d’avance pour l’aide.]
-
Salut,
Dans ta classe principale, dans la fonction init il manque proxy.registerRender()
Enfin c’est la seule explication logique qui correspond au problème. -
Ah bas ouais, c’était sa le problème, merci a toi Robin4002 Sujet Résolu !