Merci à plagueZ !
Et vu que je suis gentil 😄 voici le code:
EntityFuse:
public class EntityFuse extends EntityHorse
{
private static boolean isLaunched = false;
public EntityFuse(World worldIn)
{
super(worldIn);
}
public EntityFuse(World worldIn, double x, double y, double z)
{
super(worldIn);
this.setPosition(x, y, z);
}
@Override
public boolean processInteract(EntityPlayer player, EnumHand hand)
{
ItemStack itemstack = player.getHeldItem(hand);
boolean flag = !itemstack.isEmpty();
if (!this.isChild())
{
if (this.isBeingRidden())
{
return super.processInteract(player, hand);
}
}
if (flag)
{
if (itemstack.interactWithEntity(player, this, hand))
{
return true;
}
}
if(!this.isChild())
{
this.mount(player);
this.playSound(SoundsHandler.FUSE_LAUNCH, 9.0F, 0);
}
else
{
return super.processInteract(player, hand);
}
return true;
}
@Override
protected ResourceLocation getLootTable()
{
// TODO Auto-generated method stub
return LootTableHandler.FUSE;
}
private void mount(EntityPlayer player)
{
this.setRearing(false);
if (!world.isRemote)
{
player.startRiding(this);
}
isLaunched = true;
}
protected void entityInit()
{
super.entityInit();
}
protected SoundEvent getAmbientSound()
{
return SoundsHandler.IDLE_FUSE;
}
protected SoundEvent getDeathSound()
{
return SoundsHandler.IDLE_FUSE;
}
protected SoundEvent getHurtSound(DamageSource damageSourceIn)
{
return SoundsHandler.IDLE_FUSE;
}
protected SoundEvent getAngrySound()
{
return SoundsHandler.IDLE_FUSE;
}
@Override
public void writeEntityToNBT(NBTTagCompound compound)
{
}
@Override
public void readEntityFromNBT(NBTTagCompound compound)
{
}
@Override
public boolean isAIDisabled()
{
// TODO Auto-generated method stub
return true;
}
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
super.onUpdate();
if (this.world.isRemote && this.dataManager.isDirty())
{
this.dataManager.setClean();
}
if(isLaunched)
{
this.addVelocity(0, 1, 0);
}
world.spawnParticle(EnumParticleTypes.FLAME, this.posX, this.posY, this.posZ, this.motionX, this.motionY, this.motionZ, 0);
}
@Override
public boolean attackable()
{
// TODO Auto-generated method stub
return false;
}
@Override
public boolean canBeAttackedWithItem()
{
// TODO Auto-generated method stub
return false;
}
}
ModelFuse:
public class ModelFuse extends ModelBase
{
private final ModelRenderer bone;
public ModelFuse()
{
textureWidth = 64;
textureHeight = 64;
bone = new ModelRenderer(this);
bone.setRotationPoint(0.0F, 24.0F, -8.0F);
bone.cubeList.add(new ModelBox(bone, 0, 29, -3.0F, -29.0F, 5.0F, 6, 29, 6, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 24, 59, -2.0F, -30.0F, 6.0F, 4, 1, 4, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 24, 55, -1.0F, -32.0F, 7.0F, 2, 2, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 56, 48, -1.0F, -25.0F, 11.0F, 2, 13, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 48, 36, -1.0F, -23.0F, 1.0F, 2, 10, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 48, 36, -1.0F, -21.0F, -1.0F, 2, 10, 2, 0.0F, true));
bone.cubeList.add(new ModelBox(bone, 48, 48, -1.0F, -25.0F, 3.0F, 2, 13, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 56, 36, -1.0F, -23.0F, 13.0F, 2, 10, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 56, 36, -1.0F, -21.0F, 15.0F, 2, 10, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 2, 2, 3.0F, -25.0F, 7.0F, 2, 13, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 56, 12, -7.0F, -23.0F, 7.0F, 2, 10, 2, 0.0F, true));
bone.cubeList.add(new ModelBox(bone, 56, 0, -9.0F, -21.0F, 7.0F, 2, 10, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 2, 2, -5.0F, -25.0F, 7.0F, 2, 13, 2, 0.0F, true));
bone.cubeList.add(new ModelBox(bone, 56, 24, 7.0F, -21.0F, 7.0F, 2, 10, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 56, 12, 5.0F, -23.0F, 7.0F, 2, 10, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 40, 58, 3.0F, -6.0F, 7.0F, 2, 4, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 40, 52, -7.0F, -4.0F, 7.0F, 2, 4, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 40, 58, -5.0F, -6.0F, 7.0F, 2, 4, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 40, 52, 5.0F, -4.0F, 7.0F, 2, 4, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 40, 58, -1.0F, -6.0F, 3.0F, 2, 4, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 40, 52, -1.0F, -4.0F, 1.0F, 2, 4, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 40, 58, -1.0F, -6.0F, 11.0F, 2, 4, 2, 0.0F, false));
bone.cubeList.add(new ModelBox(bone, 40, 52, -1.0F, -4.0F, 13.0F, 2, 4, 2, 0.0F, false));
}
@Override
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
{
bone.render(f5);
}
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z)
{
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
RenderFuse:
public class RenderFuse extends RenderLiving<EntityFuse>
{
protected static ModelBase modelFuse = new ModelFuse();
public static final ResourceLocation TEXTURES = new ResourceLocation(Reference.MODID + ":textures/entity/fuse.png");
public RenderFuse(RenderManager renderManager)
{
super(renderManager, modelFuse, 0.5f);
bindTexture(TEXTURES);
}
@Override
protected ResourceLocation getEntityTexture(EntityFuse entity)
{
return TEXTURES;
}
}
Events:
@SubscribeEvent
public static void playerTickEvent(PlayerTickEvent e)
{
if(e.player.dimension == 2)
{
e.player.addVelocity(0, 0.02754375, 0);
if(e.player.getPosition().getY() >= 299 && !e.player.world.isRemote && e.player.getRidingEntity() instanceof EntityFuse)
{
e.player.dismountRidingEntity();
if(e.player.world.isRemote)
{
e.player.sendMessage(new TextComponentString("Copyright: DrasticLp :D"));
}
CustomTeleporter.teleportToDimension(e.player, 0, 0, 150, 0);
}
}
if(e.player.dimension == 0)
{
if(e.player.getPosition().getY() >= 299 && !e.player.world.isRemote && e.player.getRidingEntity() instanceof EntityFuse)
{
e.player.dismountRidingEntity();
if(e.player.world.isRemote)
{
e.player.sendMessage(new TextComponentString("Copyright: DrasticLp :D"));
}
CustomTeleporter.teleportToDimension(e.player, Reference.MOON, 0, 150, 0);
}
}
}
@SubscribeEvent
public static void killFuse(LivingUpdateEvent e)
{
if(e.getEntityLiving().getPosition().getY()>= 298D)
{
//System.out.println("Pos");
if(!e.getEntityLiving().world.isRemote)
{
//System.out.println("world");
if(e.getEntityLiving() instanceof EntityFuse)
{
//System.out.println("fuse");
e.getEntityLiving().addPotionEffect(new PotionEffect(MobEffects.INSTANT_DAMAGE, 20, 20));
}
}
}
}
Texture :fuse.png