mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-17 10:24:23 +01:00
Added the Gem of burning
This commit is contained in:
parent
7439352c7c
commit
fba999e0ff
12 changed files with 145 additions and 43 deletions
|
@ -6,11 +6,14 @@ import javax.annotation.Nullable;
|
|||
|
||||
import com.minelittlepony.unicopia.Predicates;
|
||||
import com.minelittlepony.unicopia.entity.EntitySpell;
|
||||
import com.minelittlepony.unicopia.player.IPlayer;
|
||||
import com.minelittlepony.unicopia.player.PlayerSpeciesList;
|
||||
import com.minelittlepony.unicopia.spell.IMagicEffect;
|
||||
import com.minelittlepony.unicopia.spell.IUseAction;
|
||||
import com.minelittlepony.unicopia.spell.SpellAffinity;
|
||||
import com.minelittlepony.unicopia.spell.SpellCastResult;
|
||||
import com.minelittlepony.unicopia.spell.IDispenceable;
|
||||
import com.minelittlepony.unicopia.spell.IHeldEffect;
|
||||
import com.minelittlepony.unicopia.spell.SpellRegistry;
|
||||
import com.minelittlepony.util.lang.ClientLocale;
|
||||
import com.minelittlepony.util.vector.VecHelper;
|
||||
|
@ -80,6 +83,20 @@ public class ItemSpell extends Item implements ICastable {
|
|||
BlockDispenser.DISPENSE_BEHAVIOR_REGISTRY.putObject(this, dispenserBehavior);
|
||||
}
|
||||
|
||||
public void onUpdate(ItemStack stack, World world, Entity entity, int slot, boolean isSelected) {
|
||||
if (isSelected && entity instanceof EntityPlayer) {
|
||||
IPlayer player = PlayerSpeciesList.instance().getPlayer((EntityPlayer)entity);
|
||||
|
||||
if (player.getPlayerSpecies().canCast()) {
|
||||
IHeldEffect effect = SpellRegistry.instance().getHeldFrom(stack);
|
||||
|
||||
if (effect != null) {
|
||||
effect.updateInHand(player, getAffinity(stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Item setTranslationKey(String key) {
|
||||
translationKey = key;
|
||||
return super.setTranslationKey(key);
|
||||
|
@ -120,7 +137,7 @@ public class ItemSpell extends Item implements ICastable {
|
|||
return EnumActionResult.FAIL;
|
||||
}
|
||||
|
||||
IMagicEffect effect = SpellRegistry.instance().getSpellFromItemStack(stack);
|
||||
IMagicEffect effect = SpellRegistry.instance().getSpellFrom(stack);
|
||||
|
||||
if (effect == null) {
|
||||
return EnumActionResult.FAIL;
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.minelittlepony.unicopia.init.UEffects;
|
|||
import com.minelittlepony.unicopia.init.UItems;
|
||||
import com.minelittlepony.unicopia.network.EffectSync;
|
||||
import com.minelittlepony.unicopia.network.MsgPlayerCapabilities;
|
||||
import com.minelittlepony.unicopia.spell.IAttachedEffect;
|
||||
import com.minelittlepony.unicopia.spell.IMagicEffect;
|
||||
import com.minelittlepony.unicopia.spell.SpellAffinity;
|
||||
import com.minelittlepony.unicopia.spell.SpellDisguise;
|
||||
|
@ -210,12 +211,16 @@ class PlayerCapabilities implements IPlayer {
|
|||
gravity.onUpdate();
|
||||
|
||||
if (hasEffect()) {
|
||||
if (entity.getEntityWorld().isRemote) {
|
||||
getEffect().renderOnPerson(this);
|
||||
}
|
||||
IAttachedEffect effect = getEffect(IAttachedEffect.class, true);
|
||||
|
||||
if (!getEffect().updateOnPerson(this)) {
|
||||
setEffect(null);
|
||||
if (effect != null) {
|
||||
if (entity.getEntityWorld().isRemote) {
|
||||
effect.renderOnPerson(this);
|
||||
}
|
||||
|
||||
if (!effect.updateOnPerson(this)) {
|
||||
setEffect(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package com.minelittlepony.unicopia.spell;
|
||||
|
||||
import com.minelittlepony.unicopia.player.IPlayer;
|
||||
|
||||
public interface IAttachedEffect extends IMagicEffect {
|
||||
/**
|
||||
* Called every tick when attached to a player.
|
||||
*
|
||||
* @param source The entity we are currently attached to.
|
||||
* @return true to keep alive
|
||||
*/
|
||||
boolean updateOnPerson(IPlayer caster);
|
||||
|
||||
/**
|
||||
* Called every tick when attached to a player. Used to apply particle effects.
|
||||
* Is only called on the client side.
|
||||
*
|
||||
* @param source The entity we are currently attached to.
|
||||
*/
|
||||
default void renderOnPerson(IPlayer source) {}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.minelittlepony.unicopia.spell;
|
||||
|
||||
import com.minelittlepony.unicopia.player.IPlayer;
|
||||
|
||||
public interface IHeldEffect extends IMagicEffect {
|
||||
/**
|
||||
* Called every tick when held in a player's inventory.
|
||||
*
|
||||
* @param source The entity we are currently attached to.
|
||||
*/
|
||||
void updateInHand(IPlayer caster, SpellAffinity affinity);
|
||||
}
|
|
@ -62,16 +62,6 @@ public interface IMagicEffect extends InbtSerialisable, IAligned {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every tick when attached to a player.
|
||||
*
|
||||
* @param source The entity we are currently attached to.
|
||||
* @return true to keep alive
|
||||
*/
|
||||
default boolean updateOnPerson(ICaster<?> caster) {
|
||||
return update(caster);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every tick when attached to an entity.
|
||||
* Called on both sides.
|
||||
|
@ -80,16 +70,6 @@ public interface IMagicEffect extends InbtSerialisable, IAligned {
|
|||
*/
|
||||
boolean update(ICaster<?> source);
|
||||
|
||||
/**
|
||||
* Called every tick when attached to a player. Used to apply particle effects.
|
||||
* Is only called on the client side.
|
||||
*
|
||||
* @param source The entity we are currently attached to.
|
||||
*/
|
||||
default void renderOnPerson(ICaster<?> source) {
|
||||
render(source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every tick when attached to an entity to produce particle effects.
|
||||
* Is only called on the client side.
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package com.minelittlepony.unicopia.spell;
|
||||
|
||||
import com.minelittlepony.unicopia.player.IPlayer;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.util.DamageSource;
|
||||
|
||||
public class SpellFlame extends AbstractSpell implements IHeldEffect {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "flame";
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpellAffinity getAffinity() {
|
||||
return SpellAffinity.NEUTRAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTint() {
|
||||
return 0xFF5D00;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(ICaster<?> source) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(ICaster<?> source) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateInHand(IPlayer caster, SpellAffinity affinity) {
|
||||
EntityPlayer player = caster.getOwner();
|
||||
|
||||
if (player.ticksExisted % 15 == 0) {
|
||||
player.attackEntityFrom(DamageSource.ON_FIRE, 1);
|
||||
player.playSound(SoundEvents.BLOCK_FIRE_AMBIENT, 0.5F, 1);
|
||||
|
||||
player.setFire(1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -136,11 +136,6 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseAc
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateOnPerson(ICaster<?> caster) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(ICaster<?> source) {
|
||||
if (!source.getWorld().isRemote) {
|
||||
|
@ -153,11 +148,6 @@ public class SpellPortal extends AbstractSpell.RangedAreaSpell implements IUseAc
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderOnPerson(ICaster<?> source) {
|
||||
/*noop*/
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(ICaster<?> source) {
|
||||
source.spawnParticles(getPortalZone(), 10, pos -> {
|
||||
|
|
|
@ -44,6 +44,7 @@ public class SpellRegistry {
|
|||
registerSpell(SpellDrake::new);
|
||||
registerSpell(SpellReveal::new);
|
||||
registerSpell(SpellDarkness::new);
|
||||
registerSpell(SpellFlame::new);
|
||||
registerSpell(GenericSpell.factory("light", 0xF7FACB, SpellAffinity.GOOD));
|
||||
}
|
||||
|
||||
|
@ -98,7 +99,12 @@ public class SpellRegistry {
|
|||
}
|
||||
|
||||
@Nullable
|
||||
public IMagicEffect getSpellFromItemStack(ItemStack stack) {
|
||||
public IHeldEffect getHeldFrom(ItemStack stack) {
|
||||
return getEntryFromStack(stack).map(Entry::holdable).orElse(null);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public IMagicEffect getSpellFrom(ItemStack stack) {
|
||||
return getSpellFromName(getKeyFromStack(stack));
|
||||
}
|
||||
|
||||
|
@ -168,6 +174,7 @@ public class SpellRegistry {
|
|||
|
||||
final boolean canDispense;
|
||||
final boolean canUse;
|
||||
final boolean canHold;
|
||||
|
||||
final SpellAffinity affinity;
|
||||
|
||||
|
@ -178,6 +185,7 @@ public class SpellRegistry {
|
|||
this.color = inst.getTint();
|
||||
this.canDispense = inst instanceof IDispenceable;
|
||||
this.canUse = inst instanceof IUseAction;
|
||||
this.canHold = inst instanceof IHeldEffect;
|
||||
this.affinity = inst.getAffinity();
|
||||
|
||||
if (inst.isCraftable()) {
|
||||
|
@ -197,6 +205,14 @@ public class SpellRegistry {
|
|||
return (IUseAction)create();
|
||||
}
|
||||
|
||||
IHeldEffect holdable() {
|
||||
if (!canHold) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (IHeldEffect)create();
|
||||
}
|
||||
|
||||
IDispenceable dispensable() {
|
||||
if (!canDispense) {
|
||||
return null;
|
||||
|
|
|
@ -16,7 +16,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
|||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
public class SpellShield extends AbstractSpell.RangedAreaSpell {
|
||||
public class SpellShield extends AbstractSpell.RangedAreaSpell implements IAttachedEffect {
|
||||
|
||||
private final ParticleConnection particlEffect = new ParticleConnection();
|
||||
|
||||
|
@ -49,8 +49,8 @@ public class SpellShield extends AbstractSpell.RangedAreaSpell {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean updateOnPerson(ICaster<?> source) {
|
||||
if (super.updateOnPerson(source)) {
|
||||
public boolean updateOnPerson(IPlayer source) {
|
||||
if (update(source)) {
|
||||
if (source.getEntity().getEntityWorld().getWorldTime() % 50 == 0) {
|
||||
double radius = 4 + (source.getCurrentLevel() * 2);
|
||||
if (!IPower.takeFromPlayer((EntityPlayer)source.getOwner(), radius/4)) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"type": "unicopia:crafting_spell",
|
||||
"ingredients": [
|
||||
{ "id": "unicopia:fire" },
|
||||
{ "item": "unicopia:gem", "spell": "flame" },
|
||||
{ "id": "unicopia:fire" },
|
||||
{ "id": "unicopia:fire" }
|
||||
],
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"type": "unicopia:crafting_spell",
|
||||
"ingredients": [
|
||||
{ "id": "unicopia:fire" },
|
||||
{ "id": "unicopia:fire" },
|
||||
{ "id": "unicopia:fire" }
|
||||
],
|
||||
"result": {
|
||||
"item": { "item": "unicopia:gem" },
|
||||
"spell": "fire"
|
||||
}
|
||||
}
|
|
@ -54,8 +54,11 @@ spell.light.tagline=Discovery I
|
|||
spell.reveal.name=Revealing
|
||||
spell.reveal.tagline=Discovery II
|
||||
|
||||
spell.flame.name=Burning
|
||||
spell.flame.tagline=Fire I
|
||||
|
||||
spell.fire.name=Flame
|
||||
spell.fire.tagline=Fire I
|
||||
spell.fire.tagline=Fire II
|
||||
|
||||
spell.vortex.name=Retention
|
||||
spell.vortex.tagline=Containment I
|
||||
|
@ -88,7 +91,7 @@ curse.necromancy.name=Necromancy
|
|||
curse.necromancy.tagline=Resurrection I
|
||||
|
||||
curse.inferno.name=Inferno
|
||||
curse.inferno.tagline=Fire II
|
||||
curse.inferno.tagline=Fire III
|
||||
|
||||
item.spellbook.name=Spellbook
|
||||
item.bag_of_holding.name=Bag of Holding
|
||||
|
|
Loading…
Reference in a new issue