RenderItem
-
Tu m’a envoyer la class RegistryEvent…
Alors que ta class c’est RegisterHandler -
@Asonyx Ah rip
package com.avonia.mod.util.handlers; import com.avonia.mod.Main; import com.avonia.mod.init.BlockInit; import com.avonia.mod.init.EntityInit; import com.avonia.mod.init.ItemInit; import com.avonia.mod.util.IHasModel; import com.avonia.mod.util.Reference; import net.minecraft.block.Block; import net.minecraft.item.Item; import net.minecraft.util.ResourceLocation; import net.minecraftforge.client.event.ModelRegistryEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.fml.client.registry.ClientRegistry; import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.network.NetworkRegistry; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @EventBusSubscriber public class RegistryHandler { @SubscribeEvent public static void onItemRegister(RegistryEvent.Register<Item> event) { event.getRegistry().registerAll(ItemInit.ITEMS.toArray(new Item[0])); } @SubscribeEvent public static void onBlockRegister(RegistryEvent.Register<Block> event) { event.getRegistry().registerAll(BlockInit.BLOCKS.toArray(new Block[0])); TileEntityHandler.registerTileEntities(); } @SubscribeEvent public static void onModelRegister(ModelRegistryEvent event) { for(Item item : ItemInit.ITEMS) { if(item instanceof IHasModel) { ((IHasModel)item).registerModels(); } } for(Block block : BlockInit.BLOCKS) { if(block instanceof IHasModel) { ((IHasModel)block).registerModels(); } } } public static void preInitRegistries() { EntityInit.registerEntities(); RenderHandler.registerEntityRenders(); } public static void initRegistries() { } } -
Les entitées doivent être dans la méthode init, alors que tu l’as mis dans preInit
-
@Asonyx ah ok
-
@Asonyx re, désolé de te redéranger ,mais, je voudrais que l’entité n’explose que si elle atterrit sur un bloc. Comment faire ?
Mercipublic EntityDyna(World worldIn) { super(worldIn); } public EntityDyna(World worldIn, EntityLivingBase throwerIn) { super(worldIn, throwerIn); } public EntityDyna(World worldIn, double x, double y, double z) { super(worldIn, x, y, z); } public static void registerFixesSnowball(DataFixer fixer) { EntityThrowable.registerFixesThrowable(fixer, "Snowball"); } /** * Handler for {@link World#setEntityState} */ @SideOnly(Side.CLIENT) public void handleStatusUpdate(byte id) { if (id == 3) { for (int i = 0; i < 8; ++i) { this.world.spawnParticle(EnumParticleTypes.SNOWBALL, this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D); } } } /** * Called when this EntityThrowable hits a block or entity. */ protected void onImpact(RayTraceResult result) { if (result.entityHit != null) { int i = 0; if (result.entityHit instanceof EntityBlaze) { i = 3; } result.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), (float)i); world.createExplosion(this, this.posX, this.posY, this.posZ, 4.0F, true); this.setDead(); } if (!this.world.isRemote) { this.world.setEntityState(this, (byte)3); this.setDead(); } } -
Normalement, dans onImpact, tu peut utiliser une fonction qui s’appelle je crois isOnGround() qui retourne un boolean (je ne suis pas sûr)
Ou une fontion de result -
@Asonyx yas inGround et onGround mais aucun ne va.
-
Sinon tu vérifie si l’entité touchée est null
-
@Asonyx Comment ca ?
-
Tu fais :
if (result.entityHit == null) { //Le code quand la dynamite touche le sol } -
@Asonyx a dit dans RenderItem :
if (result.entityHit == null) { //Le code quand la dynamite touche le sol }
toujours pas…
if (result.entityHit.equals(null)) { world.createExplosion(this, this.posX, this.posY, this.posZ, 1.5F, true); this.setDead(); } -
Et ça :
if (result.entityHit != null) { } else { //Le code }