Blast modifier support for permafrost, plus various fixes and an attempt at slipperiness
This commit is contained in:
@@ -4,14 +4,15 @@ import electroblob.wizardry.registry.Spells;
|
|||||||
import electroblob.wizardry.registry.WizardryPotions;
|
import electroblob.wizardry.registry.WizardryPotions;
|
||||||
import electroblob.wizardry.spell.Spell;
|
import electroblob.wizardry.spell.Spell;
|
||||||
import electroblob.wizardry.util.EntityUtils;
|
import electroblob.wizardry.util.EntityUtils;
|
||||||
|
import net.minecraft.block.state.BlockFaceShape;
|
||||||
import net.minecraft.block.state.IBlockState;
|
import net.minecraft.block.state.IBlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.potion.PotionEffect;
|
import net.minecraft.potion.PotionEffect;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.MathHelper;
|
|
||||||
import net.minecraft.world.IBlockAccess;
|
import net.minecraft.world.IBlockAccess;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
@@ -43,6 +44,16 @@ public class BlockPermafrost extends BlockDryFrostedIce {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isNormalCube(IBlockState state){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockFaceShape getBlockFaceShape(IBlockAccess world, IBlockState state, BlockPos pos, EnumFacing face){
|
||||||
|
return face == EnumFacing.DOWN ? BlockFaceShape.SOLID : BlockFaceShape.UNDEFINED;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollision(World world, BlockPos pos, IBlockState state, Entity entity){
|
public void onEntityCollision(World world, BlockPos pos, IBlockState state, Entity entity){
|
||||||
|
|
||||||
@@ -53,5 +64,28 @@ public class BlockPermafrost extends BlockDryFrostedIce {
|
|||||||
int amplifier = Spells.permafrost.getProperty(Spell.EFFECT_STRENGTH).intValue();
|
int amplifier = Spells.permafrost.getProperty(Spell.EFFECT_STRENGTH).intValue();
|
||||||
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(WizardryPotions.frost, duration, amplifier));
|
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(WizardryPotions.frost, duration, amplifier));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EntityLivingBase's slipperiness code doesn't get the block below it properly so slipperiness only works for
|
||||||
|
// full blocks...
|
||||||
|
if(entity.onGround){
|
||||||
|
|
||||||
|
// Not brilliant but it's about the best I can do
|
||||||
|
entity.motionX *= 1.12 - entity.motionX * entity.motionX;
|
||||||
|
entity.motionZ *= 1.12 - entity.motionZ * entity.motionZ;
|
||||||
|
|
||||||
|
// if(entity instanceof EntityLivingBase){
|
||||||
|
// double maxVel = 0.8;
|
||||||
|
// double x = entity.motionX;
|
||||||
|
// double y = entity.motionY;
|
||||||
|
// double z = entity.motionZ;
|
||||||
|
// double vel = MathHelper.sqrt(x*x + y*y + z*z);
|
||||||
|
// double m = vel / maxVel;
|
||||||
|
// if(m > 1){
|
||||||
|
// entity.motionX /= m;
|
||||||
|
// entity.motionZ /= m;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package electroblob.wizardry.spell;
|
package electroblob.wizardry.spell;
|
||||||
|
|
||||||
|
import electroblob.wizardry.constants.Constants;
|
||||||
import electroblob.wizardry.item.SpellActions;
|
import electroblob.wizardry.item.SpellActions;
|
||||||
import electroblob.wizardry.registry.WizardryBlocks;
|
import electroblob.wizardry.registry.WizardryBlocks;
|
||||||
import electroblob.wizardry.registry.WizardryItems;
|
import electroblob.wizardry.registry.WizardryItems;
|
||||||
@@ -10,10 +11,13 @@ import electroblob.wizardry.util.SpellModifiers;
|
|||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.SoundEvent;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class Permafrost extends SpellRay {
|
public class Permafrost extends SpellRay {
|
||||||
|
|
||||||
public Permafrost(){
|
public Permafrost(){
|
||||||
@@ -25,6 +29,21 @@ public class Permafrost extends SpellRay {
|
|||||||
this.ignoreLivingEntities(true);
|
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
|
@Override
|
||||||
protected boolean onEntityHit(World world, Entity target, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){
|
protected boolean onEntityHit(World world, Entity target, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){
|
||||||
return false;
|
return false;
|
||||||
@@ -33,17 +52,42 @@ public class Permafrost extends SpellRay {
|
|||||||
@Override
|
@Override
|
||||||
protected boolean onBlockHit(World world, BlockPos pos, EnumFacing side, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){
|
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)
|
boolean flag = false;
|
||||||
&& BlockUtils.canBlockBeReplaced(world, pos.up())){
|
|
||||||
|
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));
|
int duration = (int)(getProperty(DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade));
|
||||||
|
|
||||||
if(!world.isRemote && BlockUtils.canPlaceBlock(caster, world, pos.up())){
|
List<BlockPos> sphere = BlockUtils.getBlockSphere(pos.up(), radius);
|
||||||
world.setBlockState(pos.up(), WizardryBlocks.permafrost.getDefaultState());
|
|
||||||
world.scheduleUpdate(pos.up().toImmutable(), WizardryBlocks.permafrost, duration);
|
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;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user