mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Added a new changeling ability and spell
This commit is contained in:
parent
1c4e116ee8
commit
7abb696b76
5 changed files with 155 additions and 3 deletions
|
@ -0,0 +1,68 @@
|
||||||
|
package com.minelittlepony.unicopia.power;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import org.lwjgl.input.Keyboard;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.Race;
|
||||||
|
import com.minelittlepony.unicopia.player.IPlayer;
|
||||||
|
import com.minelittlepony.unicopia.power.data.Hit;
|
||||||
|
import com.minelittlepony.unicopia.spell.ITossedEffect;
|
||||||
|
import com.minelittlepony.unicopia.spell.SpellChangelingTrap;
|
||||||
|
|
||||||
|
public class PowerEngulf implements IPower<Hit> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getKeyName() {
|
||||||
|
return "engulf";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getKeyCode() {
|
||||||
|
return Keyboard.KEY_L;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getWarmupTime(IPlayer player) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getCooldownTime(IPlayer player) {
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canUse(Race playerSpecies) {
|
||||||
|
return playerSpecies == Race.CHANGELING;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Hit tryActivate(IPlayer player) {
|
||||||
|
return new Hit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Hit> getPackageType() {
|
||||||
|
return Hit.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(IPlayer player, Hit data) {
|
||||||
|
ITossedEffect effect = new SpellChangelingTrap();
|
||||||
|
|
||||||
|
effect.toss(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preApply(IPlayer player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void postApply(IPlayer player) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -33,6 +33,7 @@ public class PowersRegistry {
|
||||||
registerPower(new PowerCarry());
|
registerPower(new PowerCarry());
|
||||||
registerPower(new PowerDisguise());
|
registerPower(new PowerDisguise());
|
||||||
registerPower(new PowerCloudBase());
|
registerPower(new PowerCloudBase());
|
||||||
|
registerPower(new PowerEngulf());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasRegisteredPower(int keyCode) {
|
public boolean hasRegisteredPower(int keyCode) {
|
||||||
|
|
|
@ -12,6 +12,12 @@ import net.minecraft.world.World;
|
||||||
|
|
||||||
public interface ITossedEffect extends IMagicEffect, ITossable<ICaster<?>> {
|
public interface ITossedEffect extends IMagicEffect, ITossable<ICaster<?>> {
|
||||||
|
|
||||||
|
default ItemStack getCastAppearance(ICaster<?> caster) {
|
||||||
|
Item item = this.getAffinity() == SpellAffinity.BAD ? UItems.curse : UItems.spell;
|
||||||
|
|
||||||
|
return SpellRegistry.instance().enchantStack(new ItemStack(item), getName());
|
||||||
|
}
|
||||||
|
|
||||||
default void toss(ICaster<?> caster) {
|
default void toss(ICaster<?> caster) {
|
||||||
World world = caster.getWorld();
|
World world = caster.getWorld();
|
||||||
|
|
||||||
|
@ -22,9 +28,7 @@ public interface ITossedEffect extends IMagicEffect, ITossable<ICaster<?>> {
|
||||||
if (!world.isRemote) {
|
if (!world.isRemote) {
|
||||||
EntityProjectile projectile = new EntityProjectile(world, caster.getOwner());
|
EntityProjectile projectile = new EntityProjectile(world, caster.getOwner());
|
||||||
|
|
||||||
Item item = this.getAffinity() == SpellAffinity.BAD ? UItems.curse : UItems.spell;
|
projectile.setItem(getCastAppearance(caster));
|
||||||
|
|
||||||
projectile.setItem(SpellRegistry.instance().enchantStack(new ItemStack(item), getName()));
|
|
||||||
projectile.setThrowDamage(getThrowDamage(caster));
|
projectile.setThrowDamage(getThrowDamage(caster));
|
||||||
projectile.setOwner(caster.getOwner());
|
projectile.setOwner(caster.getOwner());
|
||||||
projectile.setEffect(this);
|
projectile.setEffect(this);
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.minelittlepony.unicopia.spell;
|
||||||
|
|
||||||
|
import com.minelittlepony.unicopia.entity.EntityProjectile;
|
||||||
|
import com.minelittlepony.unicopia.player.IPlayer;
|
||||||
|
import com.minelittlepony.unicopia.player.PlayerSpeciesList;
|
||||||
|
import com.minelittlepony.util.vector.VecHelper;
|
||||||
|
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.util.EnumParticleTypes;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class SpellChangelingTrap extends AbstractSpell implements ITossedEffect {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "changeling_trap";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTint() {
|
||||||
|
return 0x88FF88;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCraftable() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean update(ICaster<?> source) {
|
||||||
|
Entity entity = source.getEntity();
|
||||||
|
|
||||||
|
if (!(entity instanceof EntityProjectile)) {
|
||||||
|
entity.motionX /= 3;
|
||||||
|
entity.motionY /= 3;
|
||||||
|
entity.motionZ /= 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void render(ICaster<?> source) {
|
||||||
|
source.spawnParticles(EnumParticleTypes.DRIP_LAVA.getParticleID(), 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SpellAffinity getAffinity() {
|
||||||
|
return SpellAffinity.BAD;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void enforce() {
|
||||||
|
|
||||||
|
setDirty(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void entrap(IPlayer e) {
|
||||||
|
|
||||||
|
SpellChangelingTrap existing = e.getEffect(SpellChangelingTrap.class, true);
|
||||||
|
|
||||||
|
if (existing == null) {
|
||||||
|
e.setEffect(copy());
|
||||||
|
} else {
|
||||||
|
existing.enforce();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onImpact(World world, BlockPos pos, IBlockState state) {
|
||||||
|
VecHelper.findAllEntitiesInRange(null, world, pos, 5)
|
||||||
|
.filter(e -> e instanceof EntityPlayer)
|
||||||
|
.map(e -> PlayerSpeciesList.instance().getPlayer((EntityPlayer)e))
|
||||||
|
.forEach(this::entrap);
|
||||||
|
}
|
||||||
|
}
|
|
@ -47,6 +47,7 @@ public class SpellRegistry {
|
||||||
registerSpell(SpellFlame::new);
|
registerSpell(SpellFlame::new);
|
||||||
registerSpell(SpellSiphon::new);
|
registerSpell(SpellSiphon::new);
|
||||||
registerSpell(SpellLight::new);
|
registerSpell(SpellLight::new);
|
||||||
|
registerSpell(SpellChangelingTrap::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
Loading…
Reference in a new issue