That's one heck of a commit you've got there...
I may have got a bit behind with version control. A lot behind, in fact. Maybe I'll go back and split this sometime - then again, I probably won't. But hey, at least it's here!
This commit is contained in:
@@ -1,49 +1,62 @@
|
||||
package electroblob.wizardry.spell;
|
||||
|
||||
import electroblob.wizardry.constants.Element;
|
||||
import electroblob.wizardry.constants.SpellType;
|
||||
import electroblob.wizardry.constants.Tier;
|
||||
import electroblob.wizardry.entity.construct.EntityIceSpike;
|
||||
import electroblob.wizardry.registry.WizardryItems;
|
||||
import electroblob.wizardry.registry.WizardrySounds;
|
||||
import electroblob.wizardry.util.SpellModifiers;
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class IceSpikes extends SpellConstructRanged<EntityIceSpike> {
|
||||
|
||||
private static final int BASE_SPAWN_COUNT = 17; // Was 18, reduced to 17 to account for the extra one in the middle.
|
||||
public static final String ICE_SPIKE_COUNT = "ice_spike_count";
|
||||
|
||||
public IceSpikes(){
|
||||
// Base duration is set to -1 so that the superclass doesn't waste time retrieving the duration multiplier
|
||||
super("ice_spikes", Tier.ADVANCED, Element.ICE, SpellType.ATTACK, 30, 75, EntityIceSpike::new, -1, 20, WizardrySounds.SPELL_ICE);
|
||||
super("ice_spikes", EntityIceSpike::new, true);
|
||||
addProperties(EFFECT_RADIUS, ICE_SPIKE_COUNT, DAMAGE, EFFECT_DURATION, EFFECT_STRENGTH);
|
||||
this.ignoreUncollidables(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean spawnConstruct(World world, double x, double y, double z, EntityLivingBase caster, SpellModifiers modifiers){
|
||||
|
||||
if(world.getBlockState(new BlockPos(x, y, z)).isNormalCube()) return false;
|
||||
protected boolean spawnConstruct(World world, double x, double y, double z, EnumFacing side, EntityLivingBase caster, SpellModifiers modifiers){
|
||||
|
||||
BlockPos blockHit = new BlockPos(x, y, z);
|
||||
if(side != null && side.getAxisDirection() == EnumFacing.AxisDirection.NEGATIVE) blockHit = blockHit.offset(side);
|
||||
|
||||
if(world.getBlockState(blockHit).isNormalCube()) return false;
|
||||
|
||||
Vec3d origin = new Vec3d(x, y, z);
|
||||
|
||||
Vec3d pos = origin.add(new Vec3d(side.getOpposite().getDirectionVec()));
|
||||
|
||||
// Now always spawns a spike exactly at the position aimed at
|
||||
super.spawnConstruct(world, x, y-1, z, caster, modifiers);
|
||||
|
||||
int quantity = (int)(BASE_SPAWN_COUNT * modifiers.get(WizardryItems.blast_upgrade));
|
||||
super.spawnConstruct(world, pos.x, pos.y, pos.z, side, caster, modifiers);
|
||||
// -1 because of the one spawned above
|
||||
int quantity = (int)(getProperty(ICE_SPIKE_COUNT).floatValue() * modifiers.get(WizardryItems.blast_upgrade)) - 1;
|
||||
|
||||
float maxRadius = getProperty(EFFECT_RADIUS).floatValue() * modifiers.get(WizardryItems.blast_upgrade);
|
||||
|
||||
for(int i=0; i<quantity; i++){
|
||||
|
||||
float angle = (float)(world.rand.nextFloat() * Math.PI * 2);
|
||||
double radius = 0.5 + world.rand.nextDouble() * 2 * modifiers.get(WizardryItems.blast_upgrade);
|
||||
|
||||
double x1 = x + radius * MathHelper.sin(angle);
|
||||
double z1 = z + radius * MathHelper.cos(angle);
|
||||
double y1 = WizardryUtilities.getNearestFloorLevel(world,
|
||||
new BlockPos(MathHelper.floor(x1), (int)y, MathHelper.floor(z1)), 2) - 1;
|
||||
double radius = 0.5 + world.rand.nextDouble() * (maxRadius - 0.5);
|
||||
|
||||
if(y1 > -1){
|
||||
super.spawnConstruct(world, x1, y1, z1, caster, modifiers);
|
||||
// First, generate a random vector of length radius with a z component of zero
|
||||
// Then rotate it so that what was south is now the side that was hit
|
||||
Vec3d offset = Vec3d.fromPitchYaw(world.rand.nextFloat() * 180 - 90, world.rand.nextBoolean() ? 0 : 180)
|
||||
.scale(radius).rotateYaw(side.getHorizontalAngle() * (float)Math.PI/180).rotatePitch(WizardryUtilities.getPitch(side) * (float)Math.PI/180);
|
||||
|
||||
if(side.getAxis().isHorizontal()) offset = offset.rotateYaw((float)Math.PI/2);
|
||||
|
||||
Integer surface = WizardryUtilities.getNearestSurface(world, new BlockPos(origin.add(offset)), side,
|
||||
(int)maxRadius, true, WizardryUtilities.SurfaceCriteria.basedOn(World::isBlockFullCube));
|
||||
|
||||
if(surface != null){
|
||||
Vec3d vec = WizardryUtilities.replaceComponent(origin.add(offset), side.getAxis(), surface)
|
||||
.subtract(new Vec3d(side.getDirectionVec()));
|
||||
super.spawnConstruct(world, vec.x, vec.y, vec.z, side, caster, modifiers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,9 +64,10 @@ public class IceSpikes extends SpellConstructRanged<EntityIceSpike> {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addConstructExtras(EntityIceSpike construct, EntityLivingBase caster, SpellModifiers modifiers){
|
||||
protected void addConstructExtras(EntityIceSpike construct, EnumFacing side, EntityLivingBase caster, SpellModifiers modifiers){
|
||||
// In this particular case, lifetime is implemented as a delay instead so is treated differently.
|
||||
construct.lifetime = 30 + construct.world.rand.nextInt(15);
|
||||
construct.setFacing(side);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user