Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CustomPig extends EntityPig/*Changer le type d'animal Ex: EntityCow, EntityHorse*/{
- private float speed = 0.1F;/*Vitesse de déplacement*/
- public CustomPig(World world) {
- super(world);
- }
- @Override
- public void g(float sideMot, float forMot) {
- if (this.passenger != null && this.passenger instanceof EntityHuman) {
- this.lastYaw = this.yaw = this.passenger.yaw;
- this.pitch = this.passenger.pitch * 0.5F;
- this.setYawPitch(this.yaw, this.pitch);
- this.aI = this.aG = this.yaw;
- sideMot = ((EntityLiving) this.passenger).aZ * 0.5F;
- forMot = ((EntityLiving) this.passenger).ba;
- if (forMot <= 0.0F) {
- forMot *= 0.25F;
- }
- Field jump = null;
- try {
- jump = EntityLiving.class.getDeclaredField("aY");
- } catch (NoSuchFieldException e1) {
- e1.printStackTrace();
- } catch (SecurityException e1) {
- e1.printStackTrace();
- }
- jump.setAccessible(true);
- if (jump != null && this.onGround) {
- try {
- if (jump.getBoolean(this.passenger)) {
- double jumpHeight = 0.5D;/*Hauteur du saut*/
- this.motY = jumpHeight;
- }
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- }
- this.S = 1.0F;
- this.aK = this.bI() * 0.1F;
- if (!this.world.isClientSide) {
- this.k(speed); //Ou n'importe quel float, sa controle la vitesse de déplacement.
- super.g(sideMot, forMot);
- }
- this.ay = this.az;//Some extra things
- double d0 = this.locX - this.lastX;
- double d1 = this.locZ - this.lastZ;
- float f4 = MathHelper.sqrt(d0 * d0 + d1 * d1) * 4.0F;
- if (f4 > 1.0F) {
- f4 = 1.0F;
- }
- this.az += (f4 - this.az) * 0.4F;
- this.aA += this.az;
- } else {
- this.S = 0.5F;
- this.aK = 0.02F;
- super.g(sideMot, forMot);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment