Création tnt
-
@‘robin4002’:
Supprimes également les lignes :
private static final String __OBFID = “CL_xxxxxxx”;
Sinon tu vas avoir des problèmes lors de la compilation.Oups j’en ai plein x)
-
Dans ta classe ExplosionCustom, essaie de modifier ton constructeur :
public ExplosionCustom(World p_i1948_1_, Entity p_i1948_2_, double p_i1948_3_, double p_i1948_5_, double p_i1948_7_, float p_i1948_9_) { super(p_i1948_1_, p_i1948_2_, p_i1948_3_, p_i1948_5_, p_i1948_7_, p_i1948_9_); this.worldObj = p_i1948_1_; this.exploder = p_i1948_2_; this.explosionX = p_i1948_3_; this.explosionY = p_i1948_5_; this.explosionZ = p_i1948_7_; this.explosionSize = p_i1948_9_; } -
C’est bon ça marche merci beaucoup !!
J’ai plus que le soucis de la tnt qui disparait quand elle est désactivé.
J’ai fait ceci pour register mon Entité : EntityRegistry.registerModEntity(EntityTNTCustom.class, “EntityTNTCustom”, 30, Main.MODID, 80, 3, true);
Est-bon ? -
Le problème ne vient pas de la déclaration mais plutot du block :
Par exemple, la méthodepublic void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_) { if (p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_)) { this.onBlockDestroyedByPlayer(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, 1); p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_); } }va détecter un changement des blocs à coté de ta TNTCustome. Et si ce block active ta TNT (genre red torch etc…), alors un block d’air est placé à la place de ton block, il faut donc modifier cette ligne
-
Ah, il faut aussi enregistrer le rendu de l’entity comme celle de n’importe quelle entité.
Pour le rendu tu peux reprendre le même code que le rendu de la tnt vanilla (RenderTNTPrimed) -
Ma classe EntityTNTCustom correspond exactement au même code que la classe RenderTNTPrimed pourtant

-
Non, ta classe EntityTNTCustom correspond à EntityTNTPrimed.
Maintenant il faut en plus faire un rendu. -
Ah oui autant pour moi.
J’ai donc créé ma classe mais aucun changement. Ai-je oublié quelque chose ?
Voici mon code :package com.sebenforce; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderTNTPrimed extends Render { private RenderBlocks blockRenderer = new RenderBlocks(); public RenderTNTPrimed() { this.shadowSize = 0.5F; } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(EntityTNTCustom p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { GL11.glPushMatrix(); GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_); float f2; if ((float)p_76986_1_.fuse - p_76986_9_ + 1.0F < 10.0F) { f2 = 1.0F - ((float)p_76986_1_.fuse - p_76986_9_ + 1.0F) / 10.0F; if (f2 < 0.0F) { f2 = 0.0F; } if (f2 > 1.0F) { f2 = 1.0F; } f2 *= f2; f2 *= f2; float f3 = 1.0F + f2 * 0.3F; GL11.glScalef(f3, f3, f3); } f2 = (1.0F - ((float)p_76986_1_.fuse - p_76986_9_ + 1.0F) / 100.0F) * 0.8F; this.bindEntityTexture(p_76986_1_); this.blockRenderer.renderBlockAsItem(Main.tntZenodium, 0, p_76986_1_.getBrightness(p_76986_9_)); if (p_76986_1_.fuse / 5 % 2 == 0) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, f2); this.blockRenderer.renderBlockAsItem(Main.tntZenodium, 0, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_TEXTURE_2D); } GL11.glPopMatrix(); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityTNTCustom p_110775_1_) { return TextureMap.locationBlocksTexture; } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity p_110775_1_) { return this.getEntityTexture((EntityTNTCustom)p_110775_1_); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { this.doRender((EntityTNTCustom)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } } ```</t></t> -
As-tu enregistré cette classe ?
RenderingRegistry.registerEntityRenderingHandler(EntityTNTCustom.class, new RenderTNTPrimed());
dans la classe client proxy -
Oui ici :
package com.sebenforce; import cpw.mods.fml.client.registry.RenderingRegistry; public class ClientProxy extends CommonProxy { @Override public void registerRender() { RenderingRegistry.registerEntityRenderingHandler(EntityTNTCustom.class, new RenderTNTPrimed()); } } -
Et toujours pas de rendu ?
-
Faut que tu fasses attention aux imports, à prendre le bon RenderTNTPrimed.
-
Sa viendrai pas de la texture ? car je c’est que si on mais pas de texture au mob l’entity est invisible c’est pas pareil pour la TNT ?
protected ResourceLocation getEntityTexture(EntityTntObsi p_110775_1_) { return TextureMap.locationBlocksTexture; } -
La texture c’est bon, TextureMap.locationBlocksTexture c’est le fichier de texture des blocs.
C’est ce qu’il faut utiliser pour avoir la texture d’un bloc dans une entité.
Le problème ne vient pas de là. -
@‘robin4002’:
Et toujours pas de rendu ?
Si j’ai crée la classe RenderTntPrimed :
package com.sebenforce; import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.entity.Render; import net.minecraft.client.renderer.texture.TextureMap; import net.minecraft.entity.Entity; import net.minecraft.init.Blocks; import net.minecraft.util.ResourceLocation; import org.lwjgl.opengl.GL11; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @SideOnly(Side.CLIENT) public class RenderTNTPrimed extends Render { private RenderBlocks blockRenderer = new RenderBlocks(); public RenderTNTPrimed() { this.shadowSize = 0.5F; } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(EntityTNTCustom p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { GL11.glPushMatrix(); GL11.glTranslatef((float)p_76986_2_, (float)p_76986_4_, (float)p_76986_6_); float f2; if ((float)p_76986_1_.fuse - p_76986_9_ + 1.0F < 10.0F) { f2 = 1.0F - ((float)p_76986_1_.fuse - p_76986_9_ + 1.0F) / 10.0F; if (f2 < 0.0F) { f2 = 0.0F; } if (f2 > 1.0F) { f2 = 1.0F; } f2 *= f2; f2 *= f2; float f3 = 1.0F + f2 * 0.3F; GL11.glScalef(f3, f3, f3); } f2 = (1.0F - ((float)p_76986_1_.fuse - p_76986_9_ + 1.0F) / 100.0F) * 0.8F; this.bindEntityTexture(p_76986_1_); this.blockRenderer.renderBlockAsItem(Main.tntZenodium, 0, p_76986_1_.getBrightness(p_76986_9_)); if (p_76986_1_.fuse / 5 % 2 == 0) { GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glDisable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_DST_ALPHA); GL11.glColor4f(1.0F, 1.0F, 1.0F, f2); this.blockRenderer.renderBlockAsItem(Main.tntZenodium, 0, 1.0F); GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(GL11.GL_BLEND); GL11.glEnable(GL11.GL_LIGHTING); GL11.glEnable(GL11.GL_TEXTURE_2D); } GL11.glPopMatrix(); } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(EntityTNTCustom p_110775_1_) { return TextureMap.locationBlocksTexture; } /** * Returns the location of an entity's texture. Doesn't seem to be called unless you call Render.bindEntityTexture. */ protected ResourceLocation getEntityTexture(Entity p_110775_1_) { return this.getEntityTexture((EntityTNTCustom)p_110775_1_); } /** * Actually renders the given argument. This is a synthetic bridge method, always casting down its argument and then * handing it off to a worker function which does the actual work. In all probabilty, the class Render is generic * (Render <t extends="" entity)="" and="" this="" method="" has="" signature="" public="" void="" func_76986_a(t="" entity,="" double="" d,="" d1,<br="">* double d2, float f, float f1). But JAD is pre 1.5 so doesn't do that. */ public void doRender(Entity p_76986_1_, double p_76986_2_, double p_76986_4_, double p_76986_6_, float p_76986_8_, float p_76986_9_) { this.doRender((EntityTNTCustom)p_76986_1_, p_76986_2_, p_76986_4_, p_76986_6_, p_76986_8_, p_76986_9_); } } [java] @'Plaigon': > Faut que tu fasses attention aux imports, à prendre le bon RenderTNTPrimed. En faisant ctrl clique gauche sur le nom ça me redirige bien vers ma classe. @'darkvince37': > Sa viendrai pas de la texture ? car je c'est que si on mais pas de texture au mob l'entity est invisible c'est pas pareil pour la TNT ? > > [java] protected ResourceLocation getEntityTexture(EntityTntObsi p_110775_1_) > { > return TextureMap.locationBlocksTexture; > } > ``` ça y est dans mon rendu du coup.</t></t> -
En cherchant un peut j’ai trouver sa
https://www.minecraftforgefrance.fr/showthread.php?tid=394
en 1.7 sa donne sa
Oublie pas l’implements IEntityAdditionalSpawnData
@Override public void writeSpawnData(ByteBuf buffer) { buffer.writeInt(this.fuse); } @Override public void readSpawnData(ByteBuf additionalData) { this.fuse = additionalData.readInt(); }J’ai tester sa marche
-
Merci, la tnt ne disparais plus !
Par contre c’est un bloc blanc, comment puis-je appliquer une texture ? -
@‘Sebenf0rce’:
Merci, la tnt ne disparais plus !
Par contre c’est un bloc blanc, comment puis-je appliquer une texture ?Bizarre j’ai la texture chez moi
Edit:
J’ai pu constaté que chez moi il crash sur le serveur pareil pour toi ?
-
Blanc ? Tu peux envoyer un screen ?
-
@‘robin4002’:
Blanc ? Tu peux envoyer un screen ?
C’était vraiment tout blanc sans rien dessus x)
Je viens de résoudre le problème. J’ai fait une erreur bête, mauvais lien ici :
@SidedProxy(clientSide = “com.sebenforce.ClientProxy”, serverSide = “com.sebenforce.CommonProxy”)Du coup mon register ne s’appliquait pas.
Merci à tous ceux qui m’ont aidé.