From 29617451d8838873c207932743ce7cab8d87f7b0 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Fri, 23 Oct 2020 01:22:28 +0100 Subject: [PATCH] Add permafrost spell and fix dry frosted ice not being very icy --- .../wizardry/block/BlockDryFrostedIce.java | 13 ++++ .../wizardry/block/BlockPermafrost.java | 49 ++++++++++++-- .../electroblob/wizardry/registry/Spells.java | 2 + .../wizardry/registry/WizardryBlocks.java | 2 + .../wizardry/spell/Permafrost.java | 65 +++++++++++++++++++ .../ebwizardry/blockstates/permafrost.json | 9 +++ .../assets/ebwizardry/lang/en_gb.lang | 3 + .../assets/ebwizardry/lang/en_us.lang | 3 + .../ebwizardry/models/block/permafrost_0.json | 20 ++++++ .../ebwizardry/models/block/permafrost_1.json | 7 ++ .../ebwizardry/models/block/permafrost_2.json | 7 ++ .../ebwizardry/models/block/permafrost_3.json | 7 ++ .../resources/assets/ebwizardry/sounds.json | 3 + .../assets/ebwizardry/spells/permafrost.json | 26 ++++++++ 14 files changed, 209 insertions(+), 7 deletions(-) create mode 100644 src/main/java/electroblob/wizardry/spell/Permafrost.java create mode 100644 src/main/resources/assets/ebwizardry/blockstates/permafrost.json create mode 100644 src/main/resources/assets/ebwizardry/models/block/permafrost_0.json create mode 100644 src/main/resources/assets/ebwizardry/models/block/permafrost_1.json create mode 100644 src/main/resources/assets/ebwizardry/models/block/permafrost_2.json create mode 100644 src/main/resources/assets/ebwizardry/models/block/permafrost_3.json create mode 100644 src/main/resources/assets/ebwizardry/spells/permafrost.json diff --git a/src/main/java/electroblob/wizardry/block/BlockDryFrostedIce.java b/src/main/java/electroblob/wizardry/block/BlockDryFrostedIce.java index 8e80b5ae..88782a8d 100644 --- a/src/main/java/electroblob/wizardry/block/BlockDryFrostedIce.java +++ b/src/main/java/electroblob/wizardry/block/BlockDryFrostedIce.java @@ -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); diff --git a/src/main/java/electroblob/wizardry/block/BlockPermafrost.java b/src/main/java/electroblob/wizardry/block/BlockPermafrost.java index fb221cd0..6d3da942 100644 --- a/src/main/java/electroblob/wizardry/block/BlockPermafrost.java +++ b/src/main/java/electroblob/wizardry/block/BlockPermafrost.java @@ -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)); + } } } diff --git a/src/main/java/electroblob/wizardry/registry/Spells.java b/src/main/java/electroblob/wizardry/registry/Spells.java index 116c0c67..3f1afe3e 100644 --- a/src/main/java/electroblob/wizardry/registry/Spells.java +++ b/src/main/java/electroblob/wizardry/registry/Spells.java @@ -245,6 +245,7 @@ public final class Spells { public static final Spell enrage = placeholder(); public static final Spell mark_sacrifice = placeholder(); + public static final Spell permafrost = placeholder(); public static final Spell stormcloud = placeholder(); public static final Spell withering_totem = placeholder(); public static final Spell fangs = placeholder(); @@ -464,6 +465,7 @@ public final class Spells { registry.register(new Enrage()); registry.register(new MarkSacrifice()); + registry.register(new Permafrost()); registry.register(new Stormcloud()); registry.register(new WitheringTotem()); registry.register(new Fangs()); diff --git a/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java b/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java index 9d9451bc..3933afb0 100644 --- a/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java +++ b/src/main/java/electroblob/wizardry/registry/WizardryBlocks.java @@ -56,6 +56,7 @@ public final class WizardryBlocks { public static final Block obsidian_crust = placeholder(); public static final Block dry_frosted_ice = placeholder(); public static final Block crystal_flower_pot = placeholder(); + public static final Block permafrost = placeholder(); public static final Block runestone = placeholder(); public static final Block runestone_pedestal = placeholder(); @@ -120,6 +121,7 @@ public final class WizardryBlocks { registerBlock(registry, "obsidian_crust", new BlockObsidianCrust()); registerBlock(registry, "dry_frosted_ice", new BlockDryFrostedIce()); registerBlock(registry, "crystal_flower_pot", new BlockCrystalFlowerPot()); + registerBlock(registry, "permafrost", new BlockPermafrost()); registerBlock(registry, "runestone", new BlockRunestone(Material.ROCK)); registerBlock(registry, "runestone_pedestal", new BlockPedestal(Material.ROCK)); diff --git a/src/main/java/electroblob/wizardry/spell/Permafrost.java b/src/main/java/electroblob/wizardry/spell/Permafrost.java new file mode 100644 index 00000000..6176f46a --- /dev/null +++ b/src/main/java/electroblob/wizardry/spell/Permafrost.java @@ -0,0 +1,65 @@ +package electroblob.wizardry.spell; + +import electroblob.wizardry.item.SpellActions; +import electroblob.wizardry.registry.WizardryBlocks; +import electroblob.wizardry.registry.WizardryItems; +import electroblob.wizardry.util.BlockUtils; +import electroblob.wizardry.util.ParticleBuilder; +import electroblob.wizardry.util.ParticleBuilder.Type; +import electroblob.wizardry.util.SpellModifiers; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +public class Permafrost extends SpellRay { + + public Permafrost(){ + super("permafrost", SpellActions.POINT, true); + this.particleVelocity(1); + this.particleSpacing(0.5); + soundValues(0.5f, 1, 0); + addProperties(DURATION, DAMAGE, EFFECT_DURATION, EFFECT_STRENGTH); + this.ignoreLivingEntities(true); + } + + @Override + protected boolean onEntityHit(World world, Entity target, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){ + return false; + } + + @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())){ + + 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); + } + + return true; + } + + return false; + } + + @Override + protected boolean onMiss(World world, EntityLivingBase caster, Vec3d origin, Vec3d direction, int ticksInUse, SpellModifiers modifiers){ + return true; + } + + @Override + protected void spawnParticle(World world, double x, double y, double z, double vx, double vy, double vz){ + float brightness = world.rand.nextFloat(); + ParticleBuilder.create(Type.DUST).pos(x, y, z).vel(vx, vy, vz).time(8 + world.rand.nextInt(12)) + .clr(0.4f + 0.6f * brightness, 0.6f + 0.4f*brightness, 1).spawn(world); + ParticleBuilder.create(Type.SNOW).pos(x, y, z).vel(vx, vy, vz).time(8 + world.rand.nextInt(12)).spawn(world); + } + +} diff --git a/src/main/resources/assets/ebwizardry/blockstates/permafrost.json b/src/main/resources/assets/ebwizardry/blockstates/permafrost.json new file mode 100644 index 00000000..50446ad0 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/blockstates/permafrost.json @@ -0,0 +1,9 @@ +{ + "forge_marker": 1, + "variants": { + "age=0": { "model": "ebwizardry:permafrost_0" }, + "age=1": { "model": "ebwizardry:permafrost_1" }, + "age=2": { "model": "ebwizardry:permafrost_2" }, + "age=3": { "model": "ebwizardry:permafrost_3" } + } +} diff --git a/src/main/resources/assets/ebwizardry/lang/en_gb.lang b/src/main/resources/assets/ebwizardry/lang/en_gb.lang index 0e8d0898..f635d8ee 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_gb.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_gb.lang @@ -17,6 +17,7 @@ tile.ebwizardry\:thorns.name=Thorns tile.ebwizardry\:obsidian_crust.name=Obsidian Crust tile.ebwizardry\:dry_frosted_ice.name=Dry Frosted Ice tile.ebwizardry\:crystal_flower_pot.name=Flower Pot +tile.ebwizardry\:permafrost.name=Permafrost tile.ebwizardry\:magic_crystal_block.name=Block of Crystal tile.ebwizardry\:fire_crystal_block.name=Block of Fiery Crystal @@ -899,6 +900,7 @@ spell.ebwizardry\:muffle=Muffle spell.ebwizardry\:none=[Empty Slot] spell.ebwizardry\:oakflesh=Oakflesh spell.ebwizardry\:paralysis=Paralysis +spell.ebwizardry\:permafrost=Permafrost spell.ebwizardry\:petrify=Petrify spell.ebwizardry\:phase_step=Phase Step spell.ebwizardry\:plague_of_darkness=Plague of Darkness @@ -1088,6 +1090,7 @@ spell.ebwizardry\:muffle.desc=Silences any sounds made by the caster for 30 seco spell.ebwizardry\:none.desc=To get a spell book with the /give command, use id\: /give [player] ebwizardry\:spell_book 1 [spell id] (if you found this book in a chest, some other mod has messed things up). spell.ebwizardry\:oakflesh.desc=Improves the caster's damage resistance for 30 seconds. spell.ebwizardry\:paralysis.desc=Delivers a powerful lightning bolt that paralyses targets for 5 seconds. Paralysed creatures cannot move and will still take damage - but too much will snap the creature out of paralysis. +spell.ebwizardry\:permafrost.desc=Spreads a layer of slippery ice on the ground where you are pointing, the extreme cold of which causes creatures to slowly take damage. spell.ebwizardry\:petrify.desc=Turns the target to stone until broken out, with a chance for it to break out when it is dark. The target cannot move or do anything while petrified but is also impervious to all damage. spell.ebwizardry\:phase_step.desc=Teleports the caster a short distance in front of them, including through walls. Range upgrades will increase the wall thickness you can teleport through. spell.ebwizardry\:plague_of_darkness.desc=The darkness will consume them all... diff --git a/src/main/resources/assets/ebwizardry/lang/en_us.lang b/src/main/resources/assets/ebwizardry/lang/en_us.lang index b7533fe4..26921378 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_us.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_us.lang @@ -17,6 +17,7 @@ tile.ebwizardry\:thorns.name=Thorns tile.ebwizardry\:obsidian_crust.name=Obsidian Crust tile.ebwizardry\:dry_frosted_ice.name=Dry Frosted Ice tile.ebwizardry\:crystal_flower_pot.name=Flower Pot +tile.ebwizardry\:permafrost.name=Permafrost tile.ebwizardry\:magic_crystal_block.name=Block of Crystal tile.ebwizardry\:fire_crystal_block.name=Block of Fiery Crystal @@ -899,6 +900,7 @@ spell.ebwizardry\:muffle=Muffle spell.ebwizardry\:none=[Empty Slot] spell.ebwizardry\:oakflesh=Oakflesh spell.ebwizardry\:paralysis=Paralysis +spell.ebwizardry\:permafrost=Permafrost spell.ebwizardry\:petrify=Petrify spell.ebwizardry\:phase_step=Phase Step spell.ebwizardry\:plague_of_darkness=Plague of Darkness @@ -1088,6 +1090,7 @@ spell.ebwizardry\:muffle.desc=Silences any sounds made by the caster for 30 seco spell.ebwizardry\:none.desc=To get a spell book with the /give command, use id\: /give [player] ebwizardry\:spell_book 1 [spell id] (if you found this book in a chest, some other mod has messed things up). spell.ebwizardry\:oakflesh.desc=Improves the caster's damage resistance for 30 seconds. spell.ebwizardry\:paralysis.desc=Delivers a powerful lightning bolt that paralyses targets for 5 seconds. Paralysed creatures cannot move and will still take damage - but too much will snap the creature out of paralysis. +spell.ebwizardry\:permafrost.desc=Spreads a layer of slippery ice on the ground where you are pointing, the extreme cold of which causes creatures to slowly take damage. spell.ebwizardry\:petrify.desc=Turns the target to stone until broken out, with a chance for it to break out when it is dark. The target cannot move or do anything while petrified but is also impervious to all damage. spell.ebwizardry\:phase_step.desc=Teleports the caster a short distance in front of them, including through walls. Range upgrades will increase the wall thickness you can teleport through. spell.ebwizardry\:plague_of_darkness.desc=The darkness will consume them all... diff --git a/src/main/resources/assets/ebwizardry/models/block/permafrost_0.json b/src/main/resources/assets/ebwizardry/models/block/permafrost_0.json new file mode 100644 index 00000000..c400d5d1 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/models/block/permafrost_0.json @@ -0,0 +1,20 @@ +{ + "parent": "block/thin_block", + "textures": { + "particle": "blocks/frosted_ice_0", + "texture": "blocks/frosted_ice_0" + }, + "elements": [ + { "from": [ 0, 0, 0 ], + "to": [ 16, 1, 16 ], + "faces": { + "down": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture", "cullface": "down" }, + "up": { "uv": [ 0, 0, 16, 16 ], "texture": "#texture" }, + "north": { "uv": [ 0, 15, 16, 16 ], "texture": "#texture", "cullface": "north" }, + "south": { "uv": [ 0, 15, 16, 16 ], "texture": "#texture", "cullface": "south" }, + "west": { "uv": [ 0, 15, 16, 16 ], "texture": "#texture", "cullface": "west" }, + "east": { "uv": [ 0, 15, 16, 16 ], "texture": "#texture", "cullface": "east" } + } + } + ] +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/models/block/permafrost_1.json b/src/main/resources/assets/ebwizardry/models/block/permafrost_1.json new file mode 100644 index 00000000..9f15c160 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/models/block/permafrost_1.json @@ -0,0 +1,7 @@ +{ + "parent": "ebwizardry:block/permafrost_0", + "textures": { + "particle": "blocks/frosted_ice_1", + "texture": "blocks/frosted_ice_1" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/models/block/permafrost_2.json b/src/main/resources/assets/ebwizardry/models/block/permafrost_2.json new file mode 100644 index 00000000..06ddcdb0 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/models/block/permafrost_2.json @@ -0,0 +1,7 @@ +{ + "parent": "ebwizardry:block/permafrost_0", + "textures": { + "particle": "blocks/frosted_ice_2", + "texture": "blocks/frosted_ice_2" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/models/block/permafrost_3.json b/src/main/resources/assets/ebwizardry/models/block/permafrost_3.json new file mode 100644 index 00000000..c57a8c4c --- /dev/null +++ b/src/main/resources/assets/ebwizardry/models/block/permafrost_3.json @@ -0,0 +1,7 @@ +{ + "parent": "ebwizardry:block/permafrost_0", + "textures": { + "particle": "blocks/frosted_ice_3", + "texture": "blocks/frosted_ice_3" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/ebwizardry/sounds.json b/src/main/resources/assets/ebwizardry/sounds.json index 92d3bc4c..da8d9c34 100644 --- a/src/main/resources/assets/ebwizardry/sounds.json +++ b/src/main/resources/assets/ebwizardry/sounds.json @@ -277,6 +277,9 @@ "spell.none": {"category": "spells", "sounds": []}, "spell.oakflesh": {"category": "spells", "sounds": ["ebwizardry:buff"]}, "spell.paralysis": {"category": "spells", "sounds": ["ebwizardry:shockwave"]}, + "spell.permafrost.start": {"category": "spells", "sounds": ["ebwizardry:frost_start"]}, + "spell.permafrost.loop": {"category": "spells", "sounds": ["ebwizardry:frost_loop"]}, + "spell.permafrost.end": {"category": "spells", "sounds": ["ebwizardry:frost_end"]}, "spell.petrify": {"category": "spells", "sounds": ["mob/wither/spawn"]}, "spell.phase_step": {"category": "spells", "sounds": ["mob/endermen/portal", "mob/endermen/portal2"]}, "spell.plague_of_darkness": {"category": "spells", "sounds": ["mob/wither/death"]}, diff --git a/src/main/resources/assets/ebwizardry/spells/permafrost.json b/src/main/resources/assets/ebwizardry/spells/permafrost.json new file mode 100644 index 00000000..0fc7bb15 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/spells/permafrost.json @@ -0,0 +1,26 @@ +{ + "enabled": { + "book": true, + "scroll": true, + "wands": true, + "npcs": true, + "dispensers": true, + "commands": true, + "treasure": true, + "trades": true, + "looting": true + }, + "tier": "advanced", + "element": "ice", + "type": "alteration", + "cost": 10, + "chargeup": 10, + "cooldown": 40, + "base_properties": { + "range": 10, + "duration": 600, + "damage": 3, + "effect_duration": 100, + "effect_strength": 0 + } +} \ No newline at end of file