mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-08 14:36:44 +01:00
Change catapult to also push entities forward in the direction you're looking
This commit is contained in:
parent
1b82f7e9b5
commit
2cb57f85f2
1 changed files with 10 additions and 3 deletions
|
@ -22,6 +22,9 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Picks up and throws an entity or block.
|
||||||
|
*/
|
||||||
public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
|
public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
|
||||||
public static final SpellTraits DEFAULT_TRAITS = new SpellTraits.Builder()
|
public static final SpellTraits DEFAULT_TRAITS = new SpellTraits.Builder()
|
||||||
.with(Trait.FOCUS, 50)
|
.with(Trait.FOCUS, 50)
|
||||||
|
@ -63,12 +66,15 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
|
||||||
|
|
||||||
protected void apply(Caster<?> caster, Entity e) {
|
protected void apply(Caster<?> caster, Entity e) {
|
||||||
Vec3d vel = caster.getEntity().getVelocity();
|
Vec3d vel = caster.getEntity().getVelocity();
|
||||||
|
if (Math.abs(e.getVelocity().y) > 0.5) {
|
||||||
|
e.setVelocity(caster.getEntity().getVelocity());
|
||||||
|
} else {
|
||||||
e.addVelocity(
|
e.addVelocity(
|
||||||
((caster.getWorld().random.nextFloat() * HORIZONTAL_VARIANCE) - HORIZONTAL_VARIANCE + vel.x * 0.8F) * 0.1F,
|
((caster.getWorld().random.nextFloat() * HORIZONTAL_VARIANCE) - HORIZONTAL_VARIANCE + vel.x * 0.8F) * 0.1F,
|
||||||
0.1F + (getTraits().get(Trait.STRENGTH, -MAX_STRENGTH, MAX_STRENGTH) - 50) / 16D,
|
0.1F + (getTraits().get(Trait.STRENGTH, -MAX_STRENGTH, MAX_STRENGTH) - 50) / 16D,
|
||||||
((caster.getWorld().random.nextFloat() * HORIZONTAL_VARIANCE) - HORIZONTAL_VARIANCE + vel.z * 0.8F) * 0.1F
|
((caster.getWorld().random.nextFloat() * HORIZONTAL_VARIANCE) - HORIZONTAL_VARIANCE + vel.z * 0.8F) * 0.1F
|
||||||
);
|
);
|
||||||
e.world.spawnEntity(e);
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void getTarget(Caster<?> caster, Consumer<Entity> apply) {
|
protected void getTarget(Caster<?> caster, Consumer<Entity> apply) {
|
||||||
|
@ -94,6 +100,7 @@ public class CatapultSpell extends AbstractSpell implements ProjectileSpell {
|
||||||
world.removeBlock(bpos, true);
|
world.removeBlock(bpos, true);
|
||||||
e.setOnGround(false);
|
e.setOnGround(false);
|
||||||
e.timeFalling = Integer.MIN_VALUE;
|
e.timeFalling = Integer.MIN_VALUE;
|
||||||
|
e.setHurtEntities(1 + (world.random.nextFloat() * 10), 100);
|
||||||
|
|
||||||
apply.accept(e);
|
apply.accept(e);
|
||||||
world.spawnEntity(e);
|
world.spawnEntity(e);
|
||||||
|
|
Loading…
Reference in a new issue