Made curing joke obtainable by earth ponies

This commit is contained in:
Sollace 2024-01-03 23:01:04 +01:00
parent 19831a635f
commit 5196c9bf17
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
5 changed files with 68 additions and 10 deletions

View file

@ -6,7 +6,6 @@ import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.data.Pos;
import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.entity.mob.TentacleEntity;
import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.util.TraceHelper;
@ -85,14 +84,11 @@ public class EarthPonyGrowAbility implements Ability<Pos> {
w.setBlockState(pos.down(), Blocks.DIRT.getDefaultState());
}
w.setBlockState(pos, UBlocks.PLUNDER_VINE_BUD.getDefaultState());
} else if (w.random.nextInt(5000) == 0 || w.getBlockState(pos).isOf(UBlocks.CURING_JOKE)) {
} else if (w.random.nextInt(5000) == 0) {
if (w.getBlockState(pos.down()).isOf(Blocks.FARMLAND)) {
FarmlandBlock.setToDirt(null, state, w, pos.down());
}
w.breakBlock(pos, false);
TentacleEntity tentacle = new TentacleEntity(w, pos);
tentacle.updatePositionAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0);
w.spawnEntity(tentacle);
UBlocks.CURING_JOKE.grow(w, state, pos);
}
return 1;
}

View file

@ -1,16 +1,20 @@
package com.minelittlepony.unicopia.block;
import com.minelittlepony.unicopia.ability.EarthPonyGrowAbility.Growable;
import com.minelittlepony.unicopia.entity.mob.IgnimeousBulbEntity;
import com.minelittlepony.unicopia.entity.mob.TentacleEntity;
import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import net.minecraft.block.BlockState;
import net.minecraft.block.FlowerBlock;
import net.minecraft.client.util.ParticleUtil;
import net.minecraft.entity.Dismounting;
import net.minecraft.entity.effect.StatusEffect;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.random.Random;
import net.minecraft.world.World;
class CuringJokeBlock extends FlowerBlock {
public class CuringJokeBlock extends FlowerBlock implements Growable {
public CuringJokeBlock(StatusEffect suspiciousStewEffect, int effectDuration, Settings settings) {
super(suspiciousStewEffect, effectDuration, settings);
}
@ -21,4 +25,29 @@ class CuringJokeBlock extends FlowerBlock {
ParticleUtil.spawnParticle(world, pos, random, new MagicParticleEffect(0x3388EE));
}
}
@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();
if (otherFlowers.size() >= 8) {
IgnimeousBulbEntity bulb = new IgnimeousBulbEntity(world);
bulb.updatePositionAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0);
if (Dismounting.canPlaceEntityAt(world, bulb, bulb.getBoundingBox())) {
otherFlowers.forEach(p -> world.removeBlock(p, false));
world.spawnEntity(bulb);
return true;
}
}
world.removeBlock(pos, false);
TentacleEntity tentacle = new TentacleEntity(world, pos);
tentacle.updatePositionAndAngles(pos.getX() + 0.5, pos.getY(), pos.getZ() + 0.5, 0, 0);
world.spawnEntity(tentacle);
return true;
}
}

View file

@ -139,7 +139,7 @@ public interface UBlocks {
Block PLUNDER_VINE = register("plunder_vine", new ThornBlock(Settings.create().mapColor(MapColor.DARK_CRIMSON).hardness(1).ticksRandomly().sounds(BlockSoundGroup.WOOD).pistonBehavior(PistonBehavior.DESTROY), () -> UBlocks.PLUNDER_VINE_BUD));
Block PLUNDER_VINE_BUD = register("plunder_vine_bud", new ThornBudBlock(Settings.create().mapColor(MapColor.DARK_CRIMSON).hardness(1).nonOpaque().ticksRandomly().sounds(BlockSoundGroup.GRASS).pistonBehavior(PistonBehavior.DESTROY), PLUNDER_VINE.getDefaultState()));
Block CURING_JOKE = register("curing_joke", new CuringJokeBlock(UEffects.BUTTER_FINGERS, 7, AbstractBlock.Settings.create().mapColor(MapColor.PALE_PURPLE).noCollision().breakInstantly().sounds(BlockSoundGroup.GRASS).offset(AbstractBlock.OffsetType.XZ).pistonBehavior(PistonBehavior.DESTROY)));
CuringJokeBlock CURING_JOKE = register("curing_joke", new CuringJokeBlock(UEffects.BUTTER_FINGERS, 7, AbstractBlock.Settings.create().mapColor(MapColor.PALE_PURPLE).noCollision().breakInstantly().sounds(BlockSoundGroup.GRASS).offset(AbstractBlock.OffsetType.XZ).pistonBehavior(PistonBehavior.DESTROY)));
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);

View file

@ -11,6 +11,7 @@ import org.jetbrains.annotations.Nullable;
import com.minelittlepony.unicopia.USounds;
import com.minelittlepony.unicopia.entity.player.Pony;
import net.minecraft.block.BlockState;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.LivingEntity;
import net.minecraft.entity.MovementType;
@ -120,15 +121,27 @@ public class IgnimeousBulbEntity extends MobEntity {
World w = getWorld();
mutable.set(getBlockPos());
mutable.move(offset);
while (w.isAir(mutable.down()) && w.isInBuildLimit(mutable)) {
while (isSpace(w, mutable.down()) && w.isInBuildLimit(mutable)) {
mutable.move(Direction.DOWN);
}
while (!w.isAir(mutable) && w.isInBuildLimit(mutable)) {
while (!isPosValid(w, mutable) && w.isInBuildLimit(mutable)) {
mutable.move(Direction.UP);
}
if (w.getBlockState(mutable).isReplaceable()) {
w.breakBlock(mutable, true);
}
return mutable.toImmutable();
}
private boolean isPosValid(World w, BlockPos pos) {
return w.isTopSolid(pos.down(), this) && isSpace(w, pos);
}
private boolean isSpace(World w, BlockPos pos) {
BlockState state = w.getBlockState(pos);
return state.isAir() || state.isReplaceable();
}
@Override
public void remove(RemovalReason reason) {
super.remove(reason);

View file

@ -0,0 +1,20 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1.0,
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "unicopia:curing_joke"
}
],
"conditions": [
{
"condition": "minecraft:survives_explosion"
}
]
}
]
}