From 47af6e960eaf3a07ccebb04df03d369608c5d017 Mon Sep 17 00:00:00 2001 From: ToMe25 <38815969+ToMe25@users.noreply.github.com> Date: Wed, 8 Jan 2020 20:58:37 +0100 Subject: [PATCH] Add snow layering and particles to Snowflake Pendant (#3126) * Add snow layering and particles to Snowflake Pendant Make the Snowflake Pendant leave a trail of snow layers wherever you go while you aren't sneaking. Add snowflake particles to the Snowflake Pendant. * Add information about the snow layering to the... ...Lexica Botania. * disable snow particles while sneaking --- .../item/equipment/bauble/ItemIcePendant.java | 27 ++++++++++++++++++- .../resources/assets/botania/lang/en_us.json | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java index 92a022942..35bc51133 100644 --- a/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java +++ b/src/main/java/vazkii/botania/common/item/equipment/bauble/ItemIcePendant.java @@ -11,6 +11,9 @@ package vazkii.botania.common.item.equipment.bauble; import com.mojang.blaze3d.platform.GlStateManager; + +import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.texture.AtlasTexture; @@ -19,7 +22,10 @@ import net.minecraft.enchantment.FrostWalkerEnchantment; import net.minecraft.entity.LivingEntity; import net.minecraft.inventory.EquipmentSlotType; import net.minecraft.item.ItemStack; +import net.minecraft.particles.BlockParticleData; +import net.minecraft.particles.ParticleTypes; import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.MathHelper; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import vazkii.botania.client.core.handler.MiscellaneousIcons; @@ -33,11 +39,30 @@ public class ItemIcePendant extends ItemBauble { @Override public void onWornTick(ItemStack stack, LivingEntity entity) { - if(!entity.world.isRemote && !entity.isSneaking()) { + if (!entity.world.isRemote && !entity.isSneaking()) { boolean lastOnGround = entity.onGround; entity.onGround = true; FrostWalkerEnchantment.freezeNearby(entity, entity.world, new BlockPos(entity), 8); entity.onGround = lastOnGround; + + int x = MathHelper.floor(entity.posX); + int y = MathHelper.floor(entity.posY); + int z = MathHelper.floor(entity.posZ); + BlockState blockstate = Blocks.SNOW.getDefaultState(); + + for(int l = 0; l < 4; ++l) { + x = MathHelper.floor(entity.posX + (double)((float)(l % 2 * 2 - 1) * 0.25F)); + z = MathHelper.floor(entity.posZ + (double)((float)(l / 2 % 2 * 2 - 1) * 0.25F)); + BlockPos blockpos = new BlockPos(x, y, z); + if (entity.world.isAirBlock(blockpos) && entity.world.getBiome(blockpos).func_225486_c(blockpos) < 0.9F && blockstate.isValidPosition(entity.world, blockpos)) { + entity.world.setBlockState(blockpos, blockstate); + } + } + } + else if (entity.world.isRemote && !entity.isSneaking()) { + if(entity.world.rand.nextFloat() >= 0.25F) { + entity.world.addParticle(new BlockParticleData(ParticleTypes.FALLING_DUST, Blocks.SNOW_BLOCK.getDefaultState()), entity.posX + entity.world.rand.nextFloat() * 0.6 - 0.3, entity.posY + 1.1, entity.posZ + entity.world.rand.nextFloat() * 0.6 - 0.3, 0, -0.15, 0); + } } } diff --git a/src/main/resources/assets/botania/lang/en_us.json b/src/main/resources/assets/botania/lang/en_us.json index 76a4ab0a3..6ff3a83cd 100644 --- a/src/main/resources/assets/botania/lang/en_us.json +++ b/src/main/resources/assets/botania/lang/en_us.json @@ -3003,7 +3003,7 @@ "botania.entry.icePendant": "Snowflake Pendant", "botania.tagline.icePendant": "Frost Walker: Necklace Edition", - "botania.page.icePendant0": "The $(item)Snowflake Pendant$(0) is a $(thing)Trinket$(0) that's saturated with freezing energies. Any nearby still $(item)Water$(0) blocks its wearer's feet will be temporarily frozen into $(item)Ice$(0); said $(item)Ice$(0) will melt shortly after the wearer leaves the area (as if the wearer had $(thing)Frost Walker$(0) boots). This charm will cease its freeze if its wearer is sneaking or fully submerged.", + "botania.page.icePendant0": "The $(item)Snowflake Pendant$(0) is a $(thing)Trinket$(0) that's saturated with freezing energies. Any nearby still $(item)Water$(0) blocks its wearer's feet will be temporarily frozen into $(item)Ice$(0); said $(item)Ice$(0) will melt shortly after the wearer leaves the area (as if the wearer had $(thing)Frost Walker$(0) boots). It will also create a trail of $(item)Snow Layers$(0) in your path. This charm will cease its freeze if its wearer is sneaking or fully submerged.", "botania.page.icePendant1": "Do you want to build a snowman?", "botania.entry.lavaPendant": "Pyroclast Pendant",