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,163 +1,89 @@
|
||||
package electroblob.wizardry.spell;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import electroblob.wizardry.constants.Element;
|
||||
import electroblob.wizardry.constants.SpellType;
|
||||
import electroblob.wizardry.constants.Tier;
|
||||
import electroblob.wizardry.registry.WizardryAdvancementTriggers;
|
||||
import electroblob.wizardry.block.BlockStatue;
|
||||
import electroblob.wizardry.registry.WizardryBlocks;
|
||||
import electroblob.wizardry.registry.WizardryItems;
|
||||
import electroblob.wizardry.registry.WizardrySounds;
|
||||
import electroblob.wizardry.tileentity.TileEntityStatue;
|
||||
import electroblob.wizardry.util.AllyDesignationSystem;
|
||||
import electroblob.wizardry.util.SpellModifiers;
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
import net.minecraft.entity.EntityLiving;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.monster.EntityBlaze;
|
||||
import net.minecraft.entity.monster.EntityMagmaCube;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class IceAge extends Spell {
|
||||
|
||||
private static final int baseDuration = 1200;
|
||||
|
||||
public IceAge(){
|
||||
super("ice_age", Tier.MASTER, Element.ICE, SpellType.ATTACK, 70, 250, EnumAction.BOW, false);
|
||||
super("ice_age", EnumAction.BOW, false);
|
||||
this.soundValues(0.7f, 1.0f, 0);
|
||||
addProperties(EFFECT_RADIUS, EFFECT_DURATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doesSpellRequirePacket(){
|
||||
public boolean requiresPacket(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
|
||||
|
||||
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(
|
||||
7 * modifiers.get(WizardryItems.blast_upgrade), caster.posX, caster.posY, caster.posZ, world);
|
||||
float radius = getProperty(EFFECT_RADIUS).floatValue() * modifiers.get(WizardryItems.blast_upgrade);
|
||||
|
||||
List<EntityLivingBase> targets = WizardryUtilities.getEntitiesWithinRadius(radius, caster.posX, caster.posY, caster.posZ, world);
|
||||
|
||||
for(EntityLivingBase target : targets){
|
||||
if(WizardryUtilities.isValidTarget(caster, target)){
|
||||
if(AllyDesignationSystem.isValidTarget(caster, target)){
|
||||
if(!world.isRemote){
|
||||
if(target instanceof EntityBlaze || target instanceof EntityMagmaCube){
|
||||
// These have been removed for the time being because they cause the entity to sink into the
|
||||
// floor when it breaks out.
|
||||
// target.attackEntityFrom(WizardryUtilities.causePlayerMagicDamage(entityplayer), 8.0f *
|
||||
// modifiers.get(SpellModifiers.DAMAGE));
|
||||
}else{
|
||||
// target.attackEntityFrom(WizardryUtilities.causePlayerMagicDamage(entityplayer), 4.0f *
|
||||
// modifiers.get(SpellModifiers.DAMAGE));
|
||||
}
|
||||
if(target.isBurning()){
|
||||
target.extinguish();
|
||||
}
|
||||
|
||||
if(target instanceof EntityBlaze) WizardryAdvancementTriggers.freeze_blaze.triggerFor(caster);
|
||||
|
||||
if(target instanceof EntityLiving){
|
||||
|
||||
// Stops the entity looking red while frozen and the resulting z-fighting
|
||||
target.hurtTime = 0;
|
||||
|
||||
BlockPos pos = new BlockPos(target);
|
||||
|
||||
// Short mobs such as spiders and pigs
|
||||
if((target.height < 1.2 || target.isChild())
|
||||
&& WizardryUtilities.canBlockBeReplaced(world, pos)){
|
||||
world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState());
|
||||
if(world.getTileEntity(pos) instanceof TileEntityStatue){
|
||||
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving)target, 1,
|
||||
1);
|
||||
((TileEntityStatue)world.getTileEntity(pos)).setLifetime(
|
||||
(int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
|
||||
}
|
||||
target.setDead();
|
||||
target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
|
||||
}
|
||||
// Normal sized mobs like zombies and skeletons
|
||||
else if(target.height < 2.5 && WizardryUtilities.canBlockBeReplaced(world, pos)
|
||||
&& WizardryUtilities.canBlockBeReplaced(world, pos.up())){
|
||||
world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState());
|
||||
if(world.getTileEntity(pos) instanceof TileEntityStatue){
|
||||
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving)target, 1,
|
||||
2);
|
||||
((TileEntityStatue)world.getTileEntity(pos)).setLifetime(
|
||||
(int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
|
||||
}
|
||||
|
||||
world.setBlockState(pos.up(), WizardryBlocks.ice_statue.getDefaultState());
|
||||
if(world.getTileEntity(pos.up()) instanceof TileEntityStatue){
|
||||
((TileEntityStatue)world.getTileEntity(pos.up()))
|
||||
.setCreatureAndPart((EntityLiving)target, 2, 2);
|
||||
}
|
||||
target.setDead();
|
||||
target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
|
||||
}
|
||||
// Tall mobs like endermen
|
||||
else if(WizardryUtilities.canBlockBeReplaced(world, pos)
|
||||
&& WizardryUtilities.canBlockBeReplaced(world, pos.up())
|
||||
&& WizardryUtilities.canBlockBeReplaced(world, pos.up(2))){
|
||||
world.setBlockState(pos, WizardryBlocks.ice_statue.getDefaultState());
|
||||
if(world.getTileEntity(pos) instanceof TileEntityStatue){
|
||||
((TileEntityStatue)world.getTileEntity(pos)).setCreatureAndPart((EntityLiving)target, 1,
|
||||
3);
|
||||
((TileEntityStatue)world.getTileEntity(pos)).setLifetime(
|
||||
(int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
|
||||
}
|
||||
|
||||
world.setBlockState(pos.up(), WizardryBlocks.ice_statue.getDefaultState());
|
||||
if(world.getTileEntity(pos.up()) instanceof TileEntityStatue){
|
||||
((TileEntityStatue)world.getTileEntity(pos.up()))
|
||||
.setCreatureAndPart((EntityLiving)target, 2, 3);
|
||||
}
|
||||
|
||||
world.setBlockState(pos.up(2), WizardryBlocks.ice_statue.getDefaultState());
|
||||
if(world.getTileEntity(pos.up(2)) instanceof TileEntityStatue){
|
||||
((TileEntityStatue)world.getTileEntity(pos.up(2)))
|
||||
.setCreatureAndPart((EntityLiving)target, 3, 3);
|
||||
}
|
||||
target.setDead();
|
||||
target.playSound(WizardrySounds.SPELL_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
|
||||
if(((BlockStatue)WizardryBlocks.ice_statue).convertToStatue((EntityLiving)target,
|
||||
(int)(getProperty(EFFECT_DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade)))){
|
||||
target.playSound(WizardrySounds.MISC_FREEZE, 1.0F, world.rand.nextFloat() * 0.4F + 0.8F);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!world.isRemote){
|
||||
for(int i = -7; i < 8; i++){
|
||||
for(int j = -7; j < 8; j++){
|
||||
if(!world.isRemote && WizardryUtilities.canDamageBlocks(caster, world)){
|
||||
for(int i = -(int)radius; i < (int)radius + 1; i++){
|
||||
for(int j = -(int)radius; j < (int)radius + 1; j++){
|
||||
|
||||
BlockPos pos = new BlockPos(caster).add(i, 0, j);
|
||||
|
||||
int y = WizardryUtilities.getNearestFloorLevelB(world, new BlockPos(pos), 7);
|
||||
Integer y = WizardryUtilities.getNearestSurface(world, new BlockPos(pos), EnumFacing.UP, (int)radius, true, WizardryUtilities.SurfaceCriteria.BUILDABLE);
|
||||
|
||||
pos = new BlockPos(pos.getX(), y, pos.getZ());
|
||||
if(y != null){
|
||||
|
||||
double dist = caster.getDistance((int)caster.posX + i, y, (int)caster.posZ + j);
|
||||
pos = new BlockPos(pos.getX(), y, pos.getZ());
|
||||
|
||||
// Randomised with weighting so that the nearer the block the more likely it is to be snowed.
|
||||
if(y != -1 && world.rand.nextInt((int)dist * 2 + 1) < 7 && dist < 8){
|
||||
if(world.getBlockState(pos.down()) == Blocks.WATER.getDefaultState()){
|
||||
world.setBlockState(pos.down(), Blocks.ICE.getDefaultState());
|
||||
}else if(world.getBlockState(pos.down()) == Blocks.LAVA.getDefaultState()){
|
||||
world.setBlockState(pos.down(), Blocks.OBSIDIAN.getDefaultState());
|
||||
}else if(world.getBlockState(pos.down()) == Blocks.FLOWING_LAVA.getDefaultState()){
|
||||
world.setBlockState(pos.down(), Blocks.COBBLESTONE.getDefaultState());
|
||||
}else if(Blocks.SNOW_LAYER.canPlaceBlockAt(world, pos)){
|
||||
world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState());
|
||||
double dist = caster.getDistance((int)caster.posX + i, y, (int)caster.posZ + j);
|
||||
|
||||
// Randomised with weighting so that the nearer the block the more likely it is to be snowed.
|
||||
if(y != -1 && world.rand.nextInt((int)dist * 2 + 1) < radius && dist < radius){
|
||||
if(world.getBlockState(pos.down()) == Blocks.WATER.getDefaultState()){
|
||||
world.setBlockState(pos.down(), Blocks.ICE.getDefaultState());
|
||||
}else if(world.getBlockState(pos.down()) == Blocks.LAVA.getDefaultState()){
|
||||
world.setBlockState(pos.down(), Blocks.OBSIDIAN.getDefaultState());
|
||||
}else if(world.getBlockState(pos.down()) == Blocks.FLOWING_LAVA.getDefaultState()){
|
||||
world.setBlockState(pos.down(), Blocks.COBBLESTONE.getDefaultState());
|
||||
}else if(Blocks.SNOW_LAYER.canPlaceBlockAt(world, pos)){
|
||||
world.setBlockState(pos, Blocks.SNOW_LAYER.getDefaultState());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_ICE, 0.7F, 1.0f);
|
||||
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_LOOP_WIND, 1.0F, 1.0f);
|
||||
|
||||
this.playSound(world, caster, ticksInUse, -1, modifiers);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user