1.0.14
SorceryCraft/pipeline/head This commit looks good Details

Update Spell API
This commit is contained in:
TheBrokenRail 2020-03-08 12:06:43 -04:00
parent 8cf31594e0
commit 27cdf09bc2
11 changed files with 23 additions and 17 deletions

View File

@ -1,5 +1,8 @@
### Changelog
**1.0.14**
* Update Spell API
**1.0.13**
* Rename ```SpellRegistry.registerSpell``` to ```SpellRegistry.register```

View File

@ -10,7 +10,7 @@ org.gradle.jvmargs = -Xmx1G
loader_version = 0.7.8+build.186
# Mod Properties
mod_version = 1.0.13
mod_version = 1.0.14
maven_group = com.thebrokenrail
archives_base_name = sorcerycraft

View File

@ -57,17 +57,17 @@ public class SpellEntity extends ThrownItemEntity {
if (success) {
if (hitResult.getType() == HitResult.Type.BLOCK) {
BlockHitResult blockHitResult = (BlockHitResult) hitResult;
spell.execute(getEntityWorld(), blockHitResult);
spell.execute(getEntityWorld(), this, getOwner(), blockHitResult);
} else if (hitResult.getType() == HitResult.Type.ENTITY) {
Entity entity = ((EntityHitResult) hitResult).getEntity();
spell.execute(entity, this, getOwner());
spell.execute(world, this, getOwner(), entity);
}
} else if (getOwner() != null) {
if (getOwner() instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) getOwner();
player.playSound(SoundEvents.ENCHANT_THORNS_HIT, SoundCategory.PLAYERS, 1.0f, 1.0f);
}
spell.execute(getOwner(), this, getOwner());
spell.execute(world, this, getOwner(), getOwner());
}
}
}
@ -88,7 +88,7 @@ public class SpellEntity extends ThrownItemEntity {
Spell spell = SpellRegistry.getSpell(entry);
if (spell != null) {
if (success) {
spell.execute(getOwner(), this, getOwner());
spell.execute(world, this, getOwner(), getOwner());
} else if (getOwner() instanceof PlayerEntity) {
PlayerEntity player = (PlayerEntity) getOwner();
player.playSound(SoundEvents.ENCHANT_THORNS_HIT, SoundCategory.PLAYERS, 1.0f, 1.0f);

View File

@ -16,12 +16,12 @@ public class CoolingSpell extends Spell {
}
@Override
public void execute(Entity target, Entity source, Entity attacker) {
public void execute(World world, Entity source, Entity attacker, Entity target) {
target.setFireTicks(0);
}
@Override
public void execute(World world, BlockHitResult hitResult) {
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
BlockPos blockPos = hitResult.getBlockPos();
if (world.getBlockState(blockPos).matches(BlockTags.FIRE)) {
world.removeBlock(blockPos, false);

View File

@ -7,6 +7,7 @@ import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
public class DamageSpell extends Spell {
public DamageSpell(Identifier id, int level) {
@ -14,7 +15,7 @@ public class DamageSpell extends Spell {
}
@Override
public void execute(Entity target, Entity source, Entity attacker) {
public void execute(World world, Entity source, Entity attacker, Entity target) {
if (target instanceof LivingEntity) {
StatusEffects.INSTANT_DAMAGE.applyInstantEffect(source, attacker, (LivingEntity) target, getLevel(), 1.0d);
}

View File

@ -6,6 +6,7 @@ import net.minecraft.entity.LivingEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
public class DissolveSpell extends Spell {
public DissolveSpell(Identifier id, int level) {
@ -13,7 +14,7 @@ public class DissolveSpell extends Spell {
}
@Override
public void execute(Entity target, Entity source, Entity attacker) {
public void execute(World world, Entity source, Entity attacker, Entity target) {
if (target instanceof LivingEntity) {
((LivingEntity) target).clearStatusEffects();
}

View File

@ -16,12 +16,12 @@ public class FlameSpell extends Spell {
}
@Override
public void execute(Entity target, Entity source, Entity attacker) {
public void execute(World world, Entity source, Entity attacker, Entity target) {
target.setFireTicks(400 + (getLevel() * 200));
}
@Override
public void execute(World world, BlockHitResult hitResult) {
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
BlockPos blockPos = hitResult.getBlockPos().offset(hitResult.getSide());
if (world.isAir(blockPos)) {
world.setBlockState(blockPos, AbstractFireBlock.getState(world, blockPos));

View File

@ -7,6 +7,7 @@ import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
public class HealSpell extends Spell {
public HealSpell(Identifier id, int level) {
@ -14,7 +15,7 @@ public class HealSpell extends Spell {
}
@Override
public void execute(Entity target, Entity source, Entity attacker) {
public void execute(World world, Entity source, Entity attacker, Entity target) {
if (target instanceof LivingEntity) {
StatusEffects.INSTANT_HEALTH.applyInstantEffect(source, attacker, (LivingEntity) target, getLevel(), 1.0d);
}

View File

@ -8,6 +8,7 @@ import net.minecraft.entity.effect.StatusEffects;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.Identifier;
import net.minecraft.world.World;
public class LevitateSpell extends Spell {
public LevitateSpell(Identifier id, int level) {
@ -15,7 +16,7 @@ public class LevitateSpell extends Spell {
}
@Override
public void execute(Entity target, Entity source, Entity attacker) {
public void execute(World world, Entity source, Entity attacker, Entity target) {
if (target instanceof LivingEntity) {
((LivingEntity) target).addStatusEffect(new StatusEffectInstance(StatusEffects.LEVITATION, 400 + (getLevel() * 160)));
}

View File

@ -21,8 +21,7 @@ public class TeleportSpell extends Spell {
}
@Override
public void execute(Entity target, Entity source, Entity attacker) {
World world = target.getEntityWorld();
public void execute(World world, Entity source, Entity attacker, Entity target) {
int range = 16 + (8 * getLevel());
if (target instanceof LivingEntity) {
LivingEntity user = (LivingEntity) target;

View File

@ -23,11 +23,11 @@ public abstract class Spell {
return level;
}
public void execute(Entity target, Entity source, Entity attacker) {
public void execute(World world, Entity source, Entity attacker, Entity target) {
// NOOP
}
public void execute(World world , BlockHitResult hitResult) {
public void execute(World world, Entity source, Entity attacker, BlockHitResult hitResult) {
// NOOP
}