2024-01-03 21:51:24 +01:00
|
|
|
package com.minelittlepony.unicopia.block;
|
|
|
|
|
2024-01-03 23:01:04 +01:00
|
|
|
import com.minelittlepony.unicopia.ability.EarthPonyGrowAbility.Growable;
|
2024-01-05 18:41:20 +01:00
|
|
|
import com.minelittlepony.unicopia.entity.mob.IgnominiousBulbEntity;
|
2024-01-03 21:51:24 +01:00
|
|
|
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
|
|
|
|
|
|
|
|
import net.minecraft.block.BlockState;
|
|
|
|
import net.minecraft.block.FlowerBlock;
|
|
|
|
import net.minecraft.client.util.ParticleUtil;
|
2024-01-03 23:01:04 +01:00
|
|
|
import net.minecraft.entity.Dismounting;
|
2024-01-03 21:51:24 +01:00
|
|
|
import net.minecraft.entity.effect.StatusEffect;
|
|
|
|
import net.minecraft.util.math.BlockPos;
|
|
|
|
import net.minecraft.util.math.random.Random;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
2024-01-03 23:01:04 +01:00
|
|
|
public class CuringJokeBlock extends FlowerBlock implements Growable {
|
2024-01-03 21:51:24 +01:00
|
|
|
public CuringJokeBlock(StatusEffect suspiciousStewEffect, int effectDuration, Settings settings) {
|
|
|
|
super(suspiciousStewEffect, effectDuration, settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void randomDisplayTick(BlockState state, World world, BlockPos pos, Random random) {
|
|
|
|
for (int i = 0; i < 3; i++) {
|
|
|
|
ParticleUtil.spawnParticle(world, pos, random, new MagicParticleEffect(0x3388EE));
|
|
|
|
}
|
|
|
|
}
|
2024-01-03 23:01:04 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean grow(World world, BlockState state, BlockPos pos) {
|
|
|
|
var otherFlowers = BlockPos.streamOutwards(pos, 16, 16, 16)
|
|
|
|
.filter(p -> world.getBlockState(p).isOf(this))
|
|
|
|
.map(BlockPos::toImmutable)
|
|
|
|
.toList();
|
|
|
|
|
2024-01-15 21:25:07 +01:00
|
|
|
IgnominiousBulbEntity bulb = new IgnominiousBulbEntity(world);
|
|
|
|
bulb.setBaby(true);
|
|
|
|
bulb.updatePositionAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0);
|
2024-01-03 23:01:04 +01:00
|
|
|
|
2024-01-15 21:25:07 +01:00
|
|
|
if (Dismounting.canPlaceEntityAt(world, bulb, bulb.getBoundingBox())) {
|
|
|
|
otherFlowers.forEach(p -> world.breakBlock(p, false));
|
|
|
|
world.spawnEntity(bulb);
|
|
|
|
return true;
|
2024-01-03 23:01:04 +01:00
|
|
|
}
|
|
|
|
|
2024-01-15 21:25:07 +01:00
|
|
|
return false;
|
2024-01-03 23:01:04 +01:00
|
|
|
}
|
2024-01-03 21:51:24 +01:00
|
|
|
}
|