Add permafrost spell and fix dry frosted ice not being very icy

This commit is contained in:
Electroblob77
2020-10-23 01:22:28 +01:00
parent e530695f54
commit 29617451d8
14 changed files with 209 additions and 7 deletions
@@ -1,6 +1,8 @@
package electroblob.wizardry.block;
import net.minecraft.block.BlockFrostedIce;
import net.minecraft.block.SoundType;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
@@ -12,6 +14,17 @@ import java.util.Random;
* disappears instead of turning to water. */
public class BlockDryFrostedIce extends BlockFrostedIce {
public BlockDryFrostedIce(){
super();
setDefaultSlipperiness(0.98f); // For some strange reason BlockFrostedIce overrides BlockIce's icy-ness...
setSoundType(SoundType.GLASS);
}
@Override
public Material getMaterial(IBlockState state){
return Material.ICE; // For goodness sake
}
@Override
protected void turnIntoWater(World world, BlockPos pos){
world.destroyBlock(pos, false);
@@ -1,22 +1,57 @@
package electroblob.wizardry.block;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import electroblob.wizardry.registry.Spells;
import electroblob.wizardry.registry.WizardryPotions;
import electroblob.wizardry.spell.Spell;
import electroblob.wizardry.util.EntityUtils;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.DamageSource;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import javax.annotation.Nullable;
public class BlockPermafrost extends Block {
public class BlockPermafrost extends BlockDryFrostedIce {
public BlockPermafrost(){
super(Material.ICE);
protected static final AxisAlignedBB BOUNDING_BOX = new AxisAlignedBB(0, 0, 0, 1, 0, 1);
protected static final AxisAlignedBB SELECTION_BOUNDING_BOX = new AxisAlignedBB(0, 0, 0, 1, 0.125, 1);
@Override
public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos){
return BOUNDING_BOX;
}
@Override
public float getSlipperiness(IBlockState state, IBlockAccess world, BlockPos pos, @Nullable Entity entity){
return super.getSlipperiness(state, world, pos, entity);
public AxisAlignedBB getSelectedBoundingBox(IBlockState state, World worldIn, BlockPos pos){
return SELECTION_BOUNDING_BOX;
}
@Nullable
@Override
public AxisAlignedBB getCollisionBoundingBox(IBlockState blockState, IBlockAccess worldIn, BlockPos pos){
return super.getCollisionBoundingBox(blockState, worldIn, pos);
}
@Override
public boolean isFullCube(IBlockState state){
return false;
}
@Override
public void onEntityCollision(World world, BlockPos pos, IBlockState state, Entity entity){
if(EntityUtils.isLiving(entity) && entity.ticksExisted % 30 == 0){
// Can't make it player damage unless we make this block a tile entity, but there will be too many for that
entity.attackEntityFrom(DamageSource.MAGIC, Spells.permafrost.getProperty(Spell.DAMAGE).floatValue());
int duration = Spells.permafrost.getProperty(Spell.EFFECT_DURATION).intValue();
int amplifier = Spells.permafrost.getProperty(Spell.EFFECT_STRENGTH).intValue();
((EntityLivingBase)entity).addPotionEffect(new PotionEffect(WizardryPotions.frost, duration, amplifier));
}
}
}