Blast modifier support for permafrost, plus various fixes and an attempt at slipperiness
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package electroblob.wizardry.spell;
|
||||
|
||||
import electroblob.wizardry.constants.Constants;
|
||||
import electroblob.wizardry.item.SpellActions;
|
||||
import electroblob.wizardry.registry.WizardryBlocks;
|
||||
import electroblob.wizardry.registry.WizardryItems;
|
||||
@@ -10,10 +11,13 @@ import electroblob.wizardry.util.SpellModifiers;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.SoundEvent;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Permafrost extends SpellRay {
|
||||
|
||||
public Permafrost(){
|
||||
@@ -25,6 +29,21 @@ public class Permafrost extends SpellRay {
|
||||
this.ignoreLivingEntities(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SoundEvent[] createSounds(){
|
||||
return this.createContinuousSpellSounds();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void playSound(World world, EntityLivingBase entity, int ticksInUse, int duration, SpellModifiers modifiers, String... sounds){
|
||||
this.playSoundLoop(world, entity, ticksInUse);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void playSound(World world, double x, double y, double z, int ticksInUse, int duration, SpellModifiers modifiers, String... sounds){
|
||||
this.playSoundLoop(world, x, y, z, ticksInUse, duration);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean onEntityHit(World world, Entity target, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){
|
||||
return false;
|
||||
@@ -33,19 +52,44 @@ public class Permafrost extends SpellRay {
|
||||
@Override
|
||||
protected boolean onBlockHit(World world, BlockPos pos, EnumFacing side, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){
|
||||
|
||||
if(side == EnumFacing.UP && world.getBlockState(pos).isSideSolid(world, pos, EnumFacing.UP)
|
||||
&& BlockUtils.canBlockBeReplaced(world, pos.up())){
|
||||
boolean flag = false;
|
||||
|
||||
if(!world.isRemote){
|
||||
|
||||
int blastUpgradeCount = (int)((modifiers.get(WizardryItems.blast_upgrade) - 1) / Constants.BLAST_RADIUS_INCREASE_PER_LEVEL + 0.5f);
|
||||
// Results in the following patterns:
|
||||
// 0 blast upgrades: single block
|
||||
// 1 blast upgrade: 3x3 without corners or edges
|
||||
// 2 blast upgrades: 3x3 with corners
|
||||
// 3 blast upgrades: 5x5 without corners or edges
|
||||
float radius = 0.5f + 0.73f * blastUpgradeCount;
|
||||
|
||||
int duration = (int)(getProperty(DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade));
|
||||
|
||||
if(!world.isRemote && BlockUtils.canPlaceBlock(caster, world, pos.up())){
|
||||
world.setBlockState(pos.up(), WizardryBlocks.permafrost.getDefaultState());
|
||||
world.scheduleUpdate(pos.up().toImmutable(), WizardryBlocks.permafrost, duration);
|
||||
List<BlockPos> sphere = BlockUtils.getBlockSphere(pos.up(), radius);
|
||||
|
||||
for(BlockPos pos1 : sphere){
|
||||
flag |= tryToPlaceIce(world, pos1, caster, duration);
|
||||
}
|
||||
|
||||
return true;
|
||||
return flag;
|
||||
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
private boolean tryToPlaceIce(World world, BlockPos pos, EntityLivingBase caster, int duration){
|
||||
|
||||
if(world.getBlockState(pos.down()).isSideSolid(world, pos.down(), EnumFacing.UP) && BlockUtils.canBlockBeReplaced(world, pos)){
|
||||
if(BlockUtils.canPlaceBlock(caster, world, pos)){
|
||||
world.setBlockState(pos, WizardryBlocks.permafrost.getDefaultState());
|
||||
world.scheduleUpdate(pos.toImmutable(), WizardryBlocks.permafrost, duration);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user