Remove unnecessary empty itemstack checks, see comments on d0fda72

This commit is contained in:
Electroblob
2018-02-16 22:28:00 +00:00
parent bec52edce4
commit 3be254a247
11 changed files with 98 additions and 141 deletions
@@ -57,8 +57,7 @@ public class Clairvoyance extends Spell {
if(caster.dimension == properties.getClairvoyanceDimension()){
if(properties.getClairvoyanceLocation() != null){
if(!world.isRemote)
caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.searching"));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.searching"));
EntityZombie arbitraryZombie = new EntityZombie(world){
@Override
@@ -74,14 +73,12 @@ public class Clairvoyance extends Spell {
BlockPos destination = properties.getClairvoyanceLocation();
WizardryPathFinder pathfinder = new WizardryPathFinder(
arbitraryZombie.getNavigator().getNodeProcessor());
WizardryPathFinder pathfinder = new WizardryPathFinder(arbitraryZombie.getNavigator().getNodeProcessor());
Path path = pathfinder.findPath(world, arbitraryZombie, destination,
256 * modifiers.get(WizardryItems.range_upgrade));
Path path = pathfinder.findPath(world, arbitraryZombie, destination, 256 * modifiers.get(WizardryItems.range_upgrade));
if(path != null && path.getFinalPathPoint() != null){
int x = path.getFinalPathPoint().x;
int y = path.getFinalPathPoint().y;
int z = path.getFinalPathPoint().z;
@@ -91,24 +88,21 @@ public class Clairvoyance extends Spell {
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0f, 1.0f);
if(!world.isRemote && caster instanceof EntityPlayerMP){
WizardryPacketHandler.net.sendTo(new PacketClairvoyance.Message(path,
modifiers.get(WizardryItems.duration_upgrade)), (EntityPlayerMP)caster);
WizardryPacketHandler.net.sendTo(new PacketClairvoyance.Message(path, modifiers.get(WizardryItems.duration_upgrade)),
(EntityPlayerMP)caster);
}
return true;
}
}
if(!world.isRemote)
caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.outofrange"));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.outofrange"));
}else{
if(!world.isRemote)
caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.undefined"));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.undefined"));
}
}else{
if(!world.isRemote)
caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.wrongdimension"));
if(!world.isRemote) caster.sendMessage(new TextComponentTranslation("spell.clairvoyance.wrongdimension"));
}
}
@@ -129,11 +123,9 @@ public class Clairvoyance extends Spell {
nextPoint = path.getCurrentPathLength() - path.getCurrentPathIndex() <= 2 ? path.getFinalPathPoint()
: path.getPathPointFromIndex(path.getCurrentPathIndex() + 2);
Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.x + 0.5, point.y + 0.5,
point.z + 0.5, (nextPoint.x - point.x) / (float)PARTICLE_MOVEMENT_INTERVAL,
(nextPoint.y - point.y) / (float)PARTICLE_MOVEMENT_INTERVAL,
(nextPoint.z - point.z) / (float)PARTICLE_MOVEMENT_INTERVAL,
(int)(1800 * durationMultiplier), 0, 1, 0.3f);
Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.x + 0.5, point.y + 0.5, point.z + 0.5,
(nextPoint.x - point.x) / (float)PARTICLE_MOVEMENT_INTERVAL, (nextPoint.y - point.y) / (float)PARTICLE_MOVEMENT_INTERVAL,
(nextPoint.z - point.z) / (float)PARTICLE_MOVEMENT_INTERVAL, (int)(1800 * durationMultiplier), 0, 1, 0.3f);
path.incrementPathIndex();
path.incrementPathIndex();
@@ -141,8 +133,8 @@ public class Clairvoyance extends Spell {
point = path.getFinalPathPoint();
Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.x + 0.5, point.y + 0.5,
point.z + 0.5, 0, 0, 0, (int)(1800 * durationMultiplier), 1, 1, 1);
Wizardry.proxy.spawnParticle(WizardryParticleType.PATH, world, point.x + 0.5, point.y + 0.5, point.z + 0.5, 0, 0, 0,
(int)(1800 * durationMultiplier), 1, 1, 1);
}
@SubscribeEvent
@@ -153,8 +145,7 @@ public class Clairvoyance extends Spell {
// The event now has an ItemStack, which greatly simplifies hand-related stuff.
ItemStack wand = event.getItemStack();
if(!wand.isEmpty() && wand.getItem() instanceof ItemWand
&& WandHelper.getCurrentSpell(wand) instanceof Clairvoyance){
if(wand.getItem() instanceof ItemWand && WandHelper.getCurrentSpell(wand) instanceof Clairvoyance){
WizardData properties = WizardData.get(event.getEntityPlayer());
@@ -165,8 +156,8 @@ public class Clairvoyance extends Spell {
properties.setClairvoyancePoint(pos, event.getWorld().provider.getDimension());
if(!event.getWorld().isRemote){
event.getEntityPlayer().sendMessage(new TextComponentTranslation("spell.clairvoyance.confirm",
Spells.clairvoyance.getNameForTranslationFormatted()));
event.getEntityPlayer().sendMessage(
new TextComponentTranslation("spell.clairvoyance.confirm", Spells.clairvoyance.getNameForTranslationFormatted()));
}
event.setCanceled(true);
@@ -36,8 +36,7 @@ public class ShadowWard extends Spell {
double dx = -1 + 2 * world.rand.nextFloat();
double dy = -1 + world.rand.nextFloat();
double dz = -1 + 2 * world.rand.nextFloat();
world.spawnParticle(EnumParticleTypes.PORTAL, caster.posX, WizardryUtilities.getPlayerEyesPos(caster),
caster.posZ, dx, dy, dz);
world.spawnParticle(EnumParticleTypes.PORTAL, caster.posX, WizardryUtilities.getPlayerEyesPos(caster), caster.posZ, dx, dy, dz);
}
if(ticksInUse % 50 == 0){
@@ -53,19 +52,16 @@ public class ShadowWard extends Spell {
// There used to be a check that the target was a player here, but I don't see any reason for it.
ItemStack wand = event.getEntityLiving().getActiveItemStack();
if(!wand.isEmpty() && wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand
if(wand.getItemDamage() < wand.getMaxDamage() && wand.getItem() instanceof ItemWand
&& WandHelper.getCurrentSpell(wand) instanceof ShadowWard && !event.getSource().isUnblockable()
&& !(event.getSource() instanceof IElementalDamage
&& ((IElementalDamage)event.getSource()).isRetaliatory())){
&& !(event.getSource() instanceof IElementalDamage && ((IElementalDamage)event.getSource()).isRetaliatory())){
event.setCanceled(true);
// Now we can preserve the original daage source (sort of) as long as we make it retaliatory.
event.getEntityLiving().attackEntityFrom(
MagicDamage.causeDirectMagicDamage(event.getSource().getTrueSource(), DamageType.MAGIC, true),
event.getAmount() / 2);
((EntityLivingBase)event.getSource().getTrueSource()).attackEntityFrom(
MagicDamage.causeDirectMagicDamage(event.getEntityLiving(), DamageType.MAGIC, true),
event.getAmount() / 2);
MagicDamage.causeDirectMagicDamage(event.getSource().getTrueSource(), DamageType.MAGIC, true), event.getAmount() / 2);
((EntityLivingBase)event.getSource().getTrueSource())
.attackEntityFrom(MagicDamage.causeDirectMagicDamage(event.getEntityLiving(), DamageType.MAGIC, true), event.getAmount() / 2);
}
}
}