diff --git a/src/main/java/com/minelittlepony/unicopia/entity/EntityCloud.java b/src/main/java/com/minelittlepony/unicopia/entity/EntityCloud.java index 2d860edb..12d1bcd0 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/EntityCloud.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/EntityCloud.java @@ -167,7 +167,11 @@ public class EntityCloud extends EntityFlying implements IAnimals { @Override protected void collideWithEntity(Entity other) { - if (other instanceof EntityCloud) { + if (other instanceof EntityCloud || other instanceof EntityPlayer) { + if (other.posY > posY) { + return; + } + super.collideWithEntity(other); } } @@ -264,8 +268,15 @@ public class EntityCloud extends EntityFlying implements IAnimals { } if (setRainTimer(getRainTimer() - 1) == 0) { - if (rand.nextInt(20000) == 0) { - setDead(); + if (!getStationary()) { + pomf(); + + if (getCloudSize() > 1) { + setIsRaining(false); + setCloudSize(getCloudSize() - 1); + } else { + setDead(); + } } } } else { @@ -303,11 +314,13 @@ public class EntityCloud extends EntityFlying implements IAnimals { motionZ = 0; } - motionX /= (1 + getCloudSize()); - motionZ /= (1 + getCloudSize()); - super.onUpdate(); + double motionFactor = (1 + getCloudSize() / 4); + + motionX /= motionFactor; + motionZ /= motionFactor; + hurtTime = 0; } @@ -340,38 +353,31 @@ public class EntityCloud extends EntityFlying implements IAnimals { } } } + super.onCollideWithPlayer(player); } @Override protected void updateAITasks() { if (!getStationary()) { - super.updateAITasks(); - if (!isBeingRidden()) { double distance = targetAltitude - posY; + if (targetAltitude < posY && !world.isAirBlock(getPosition())) { + distance = 0; + } + if (Math.abs(distance) < 1 && rand.nextInt(7000) == 0) { targetAltitude = getRandomFlyingHeight(); distance = targetAltitude - posY; } - if (rand.nextInt(7000) == 0) { - directionX = directionX == 0 ? rand.nextInt(3) - 1 : 0; - } - - if (rand.nextInt(7000) == 0) { - directionZ = directionZ == 0 ? rand.nextInt(3) - 1 : 0; - } - if (Math.abs(distance) < 1) { distance = 0; } - motionX -= 0.02; - motionX -= (Math.signum(directionX) * 0.699999988079071D - motionX) * 0.10000000149011612D; + motionX -= 0.002; motionY += (Math.signum(distance) * 0.699999988079071D - motionY) * 0.10000000149011612D; - motionZ -= (Math.signum(directionZ) * 0.699999988079071D - motionZ) * 0.10000000149011612D; } } } @@ -439,6 +445,29 @@ public class EntityCloud extends EntityFlying implements IAnimals { super.handleStatusUpdate(type); } + public void handlePegasusInteration(int interationType) { + if (!world.isRemote) { + switch (interationType) { + case 1: + setIsRaining(!getIsRaining()); + break; + case 2: + spawnThunderbolt(); + break; + } + } + + pomf(); + } + + public void pomf() { + for (int i = 0; i < 50 * getCloudSize(); i++) { + Particles.instance().getEntityEmitter().emitDiggingParticles(this, UBlocks.cloud.getDefaultState()); + } + + playHurtSound(DamageSource.GENERIC); + } + @Override public boolean attackEntityFrom(DamageSource source, float amount) { Entity attacker = source.getImmediateSource(); @@ -515,7 +544,7 @@ public class EntityCloud extends EntityFlying implements IAnimals { } else if (stack != null && stack.getItem() instanceof ItemSpade) { return super.attackEntityFrom(source, amount * 1.5f); } else if (canFly) { - if (player.posY < posY) { + if (player.posY < posY || !world.isAirBlock(getPosition())) { targetAltitude = posY + 5; } else if (player.posY > posY) { targetAltitude = posY - 5; @@ -555,7 +584,6 @@ public class EntityCloud extends EntityFlying implements IAnimals { && Predicates.ITEM_INTERACT_WITH_CLOUDS.test((EntityItem)e); } - @Override protected void dropFewItems(boolean hitByPlayer, int looting) { if (hitByPlayer) { @@ -611,7 +639,7 @@ public class EntityCloud extends EntityFlying implements IAnimals { entity.onGround = true; entity.motionY += (((floatStrength > 2 ? 1 : floatStrength/2) * 0.699999998079071D) - entity.motionY + boundModifier * 0.7) * 0.10000000149011612D; if (!getStationary()) { - entity.motionX -= 0.013; + entity.motionX -= 0.0105; } if (!getStationary() && entity.motionY > 0.4 && world.rand.nextInt(900) == 0) { @@ -632,15 +660,10 @@ public class EntityCloud extends EntityFlying implements IAnimals { return false; } - @Override - protected void doBlockCollisions() { - super.doBlockCollisions(); - } - @Override public void move(MoverType type, double x, double y, double z) { - this.setEntityBoundingBox(this.getEntityBoundingBox().offset(x, y, z)); - this.resetPositionToBB(); + setEntityBoundingBox(getEntityBoundingBox().offset(x, y, z)); + resetPositionToBB(); } public int getFloatStrength(Entity entity) { diff --git a/src/main/java/com/minelittlepony/unicopia/entity/EntityWildCloud.java b/src/main/java/com/minelittlepony/unicopia/entity/EntityWildCloud.java index da8cc581..9558f577 100644 --- a/src/main/java/com/minelittlepony/unicopia/entity/EntityWildCloud.java +++ b/src/main/java/com/minelittlepony/unicopia/entity/EntityWildCloud.java @@ -72,6 +72,8 @@ public class EntityWildCloud extends EntityCloud { @Override public IEntityLivingData onInitialSpawn(DifficultyInstance difficulty, IEntityLivingData pack) { + pack = super.onInitialSpawn(difficulty, pack); + if (!(pack instanceof PackData)) { float minSpawnHeight = getMinimumFlyingHeight(); @@ -84,6 +86,14 @@ public class EntityWildCloud extends EntityCloud { collideWithNearbyEntities(); } + if (world.isRainingAt(getPosition())) { + setIsRaining(true); + } + + if (world.isThundering()) { + setIsThundering(true); + } + pack = new PackData(this); } else { PackData packData = (PackData)pack; @@ -91,11 +101,14 @@ public class EntityWildCloud extends EntityCloud { Vec3d position = packData.getUnOccupiedPosition(getCloudSize()); + setIsRaining(packData.leader.getIsRaining()); + setIsThundering(packData.leader.getIsThundering()); + setLocationAndAngles(position.x, position.y, position.z, packData.leader.rotationYaw, packData.leader.rotationPitch); collideWithNearbyEntities(); } - return super.onInitialSpawn(difficulty, pack); + return pack; } static class PackData implements IEntityLivingData { diff --git a/src/main/java/com/minelittlepony/unicopia/power/PowerCloudBase.java b/src/main/java/com/minelittlepony/unicopia/power/PowerCloudBase.java new file mode 100644 index 00000000..f1fe8a31 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/power/PowerCloudBase.java @@ -0,0 +1,90 @@ +package com.minelittlepony.unicopia.power; + +import org.lwjgl.input.Keyboard; + +import com.minelittlepony.unicopia.Race; +import com.minelittlepony.unicopia.UParticles; +import com.minelittlepony.unicopia.entity.EntityCloud; +import com.minelittlepony.unicopia.player.IPlayer; +import com.minelittlepony.unicopia.power.data.Numeric; +import com.minelittlepony.util.vector.VecHelper; + +public class PowerCloudBase implements IPower { + + @Override + public String getKeyName() { + return "unicopia.power.cloud"; + } + + @Override + public int getKeyCode() { + return Keyboard.KEY_J; + } + + @Override + public int getWarmupTime(IPlayer player) { + return 10; + } + + @Override + public int getCooldownTime(IPlayer player) { + return 5; + } + + @Override + public boolean canUse(Race playerSpecies) { + return playerSpecies.canInteractWithClouds(); + } + + @Override + public Numeric tryActivate(IPlayer player) { + EntityCloud cloud = findTarget(player); + + if (cloud != null) { + Numeric data = new Numeric(player.getOwner().inventory.currentItem + 1); + cloud.handlePegasusInteration(data.type); + + return data; + } + + return null; + } + + @Override + public Class getPackageType() { + return Numeric.class; + } + + @Override + public void apply(IPlayer player, Numeric data) { + EntityCloud cloud = findTarget(player); + + if (cloud != null) { + cloud.handlePegasusInteration(data.type); + } + } + + protected EntityCloud findTarget(IPlayer player) { + if (player.getOwner().isRiding() && player.getOwner().getRidingEntity() instanceof EntityCloud) { + return (EntityCloud)player.getOwner().getRidingEntity(); + } + + Object e = VecHelper.getLookedAtEntity(player.getOwner(), 18); + + if (e instanceof EntityCloud) { + return (EntityCloud)e; + } + + return null; + } + + @Override + public void preApply(IPlayer player) { + IPower.spawnParticles(UParticles.MAGIC_PARTICLE, player, 10); + } + + @Override + public void postApply(IPlayer player) { + IPower.spawnParticles(UParticles.RAIN_PARTICLE, player, 5); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/power/PowersRegistry.java b/src/main/java/com/minelittlepony/unicopia/power/PowersRegistry.java index 620315f1..b63d146b 100644 --- a/src/main/java/com/minelittlepony/unicopia/power/PowersRegistry.java +++ b/src/main/java/com/minelittlepony/unicopia/power/PowersRegistry.java @@ -32,6 +32,7 @@ public class PowersRegistry { registerPower(new PowerFeed()); registerPower(new PowerCarry()); registerPower(new PowerDisguise()); + registerPower(new PowerCloudBase()); } public boolean hasRegisteredPower(int keyCode) { diff --git a/src/main/java/com/minelittlepony/unicopia/power/data/Numeric.java b/src/main/java/com/minelittlepony/unicopia/power/data/Numeric.java new file mode 100644 index 00000000..513bdaf8 --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/power/data/Numeric.java @@ -0,0 +1,14 @@ +package com.minelittlepony.unicopia.power.data; + +import com.google.gson.annotations.Expose; +import com.minelittlepony.unicopia.power.IData; + +public class Numeric implements IData { + + @Expose + public int type; + + public Numeric(int t) { + type = t; + } +} diff --git a/src/main/resources/assets/unicopia/lang/en_US.lang b/src/main/resources/assets/unicopia/lang/en_US.lang index 2a9932b1..c4f4f20b 100644 --- a/src/main/resources/assets/unicopia/lang/en_US.lang +++ b/src/main/resources/assets/unicopia/lang/en_US.lang @@ -176,8 +176,7 @@ unicopia.power.earth=Secondary Earth Pony ability unicopia.power.teleport=Primary Unicorn ability unicopia.power.magic=Secondary Unicorn ability -unicopia.power.rain=Primary Pegasus ability -unicopia.power.thunder=Secondary Pegasus ability +unicopia.power.cloud=Primary Pegasus ability unicopia.power.carry=Pick up & Drop riders unicopia.power.feed=Primary Changeling ability