Add particle effects and sound for chitin

This commit is contained in:
Sollace 2023-10-14 02:37:52 +01:00
parent 602e9b7059
commit 4b85a3d331
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
17 changed files with 84 additions and 2 deletions

View file

@ -96,6 +96,8 @@ public interface USounds {
SoundEvent ITEM_BRACELET_SIGN = register("item.bracelet.sign");
SoundEvent ITEM_MAGIC_AURA = register("item.magic.aura");
SoundEvent BLOCK_CHITIN_AMBIENCE = register("block.chitin.ambience");
SoundEvent BLOCK_WEATHER_VANE_ROTATE = BLOCK_LANTERN_STEP;
SoundEvent BLOCK_PIE_SLICE = BLOCK_BEEHIVE_SHEAR;
SoundEvent BLOCK_PIE_SLICE_POP = ENTITY_ITEM_PICKUP;

View file

@ -2,16 +2,21 @@ package com.minelittlepony.unicopia.block;
import java.util.function.Supplier;
import com.minelittlepony.unicopia.USounds;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.SnowBlock;
import net.minecraft.block.SpreadableBlock;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.registry.tag.FluidTags;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
import net.minecraft.world.chunk.light.ChunkLightProvider;
@ -24,6 +29,35 @@ public class GrowableBlock extends SpreadableBlock {
this.dead = converted;
}
@Override
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
super.randomDisplayTick(state, world, pos, random);
if (random.nextInt(2) == 0) {
world.addParticle(ParticleTypes.MYCELIUM, pos.getX() + random.nextDouble(), pos.getY() + 1.1, pos.getZ() + random.nextDouble(), 0, 0, 0);
}
if (random.nextInt(1500) == 0) {
world.playSoundAtBlockCenter(pos, USounds.BLOCK_CHITIN_AMBIENCE, SoundCategory.BLOCKS, 0.13F, 0.2F, true);
for (int i = 0; i < 9; i++) {
world.addParticle(random.nextInt(2) == 0 ? ParticleTypes.SPORE_BLOSSOM_AIR : ParticleTypes.CRIMSON_SPORE,
pos.getX() + random.nextDouble(),
pos.getY() + 1.1, pos.getZ() + random.nextDouble(),
random.nextDouble() - 0.5, 0, random.nextDouble() - 0.5
);
}
}
if (random.nextInt(20) == 0) {
for (int i = 0; i < 9; i++) {
world.addParticle(ParticleTypes.ASH,
pos.getX() + random.nextDouble(),
pos.getY() + 1.1, pos.getZ() + random.nextDouble(),
random.nextDouble() - 0.5, 0, random.nextDouble() - 0.5
);
}
}
}
@Override
public void randomTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
if (!canSurvive(state, world, pos)) {

View file

@ -114,10 +114,10 @@ public interface UBlocks {
() -> UItems.APPLE_PIE_HOOF
));
Block CHITIN = register("chitin", new SnowyBlock(Settings.create().mapColor(MapColor.PALE_PURPLE).hardness(5).requiresTool().ticksRandomly()), ItemGroups.NATURAL);
Block CHITIN = register("chitin", new SnowyBlock(Settings.create().mapColor(MapColor.PALE_PURPLE).hardness(5).requiresTool().ticksRandomly().sounds(BlockSoundGroup.CORAL)), ItemGroups.NATURAL);
Block SURFACE_CHITIN = register("surface_chitin", new GrowableBlock(Settings.copy(CHITIN), () -> CHITIN), ItemGroups.NATURAL);
Block CHITIN_SPIKES = register("chitin_spikes", new SpikesBlock(Settings.copy(CHITIN).noCollision().nonOpaque()), ItemGroups.NATURAL);
Block CHISELLED_CHITIN = register("chiselled_chitin", new Block(Settings.create().mapColor(MapColor.PALE_PURPLE).hardness(5).requiresTool()), ItemGroups.BUILDING_BLOCKS);
Block CHITIN_SPIKES = register("chitin_spikes", new SpikesBlock(Settings.copy(CHISELLED_CHITIN).noCollision().nonOpaque()), ItemGroups.NATURAL);
Block CHISELLED_CHITIN_SLAB = register("chiselled_chitin_slab", new SlabBlock(Settings.copy(CHISELLED_CHITIN)), ItemGroups.BUILDING_BLOCKS);
Block CHISELLED_CHITIN_STAIRS = register("chiselled_chitin_stairs", new StairsBlock(CHISELLED_CHITIN.getDefaultState(), Settings.copy(CHISELLED_CHITIN)), ItemGroups.BUILDING_BLOCKS);
Block CHISELLED_CHITIN_HULL = register("chiselled_chitin_hull", new OrientedBlock(Settings.copy(CHISELLED_CHITIN)), ItemGroups.BUILDING_BLOCKS);

View file

@ -890,6 +890,7 @@
"unicopia.subtitle.item.alicorn_amulet.ambient": "Alicorn Amulet ambient",
"unicopia.subtitle.item.apple.rot": "Apple rots",
"unicopia.subtitle.item.bracelet.sign": "Bracelet signed",
"unicopia.subtitle.block.chitin.ambience": "Scuttering",
"unicopia.subtitle.spell.cast.fail": "Spellcast fails",
"unicopia.subtitle.spell.cast.success": "Spell casts",
"unicopia.subtitle.spell.cast.shoot": "Unicorn shoots",

View file

@ -415,6 +415,23 @@
"subtitle": "unicopia.subtitle.item.bracelet.sign"
},
"block.chitin.ambience": {
"sounds": [
"unicopia:insect/insect_1",
"unicopia:insect/insect_21",
"unicopia:insect/insect_22",
"unicopia:insect/insect_23",
"unicopia:insect/insect_24",
"unicopia:insect/insect_25",
"unicopia:insect/insect_31",
"unicopia:insect/insect_32",
"unicopia:insect/insect_33",
"unicopia:insect/insect_34",
"unicopia:insect/insect_35"
],
"subtitle": "unicopia.subtitle.block.chitin.ambience"
},
"spell.cast.fail": {
"sounds": [
"random/break"

View file

@ -4,6 +4,7 @@
"unicopia:rocks",
"unicopia:frosted_obsidian",
"unicopia:weather_vane",
"unicopia:chitin_spikes",
"unicopia:chiselled_chitin",
"unicopia:chiselled_chitin_slab",
"unicopia:chiselled_chitin_stairs",

View file

@ -0,0 +1,27 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:carapace",
"functions": [
{
"add": false,
"count": 6,
"function": "minecraft:set_count"
}
]
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}