Added gold root

This commit is contained in:
Sollace 2024-01-04 22:41:27 +01:00
parent 073d411e90
commit e572c2c1ea
No known key found for this signature in database
GPG key ID: E52FACE7B5C773DB
17 changed files with 138 additions and 7 deletions

View file

@ -42,6 +42,7 @@ public interface UTags {
TagKey<Block> CRYSTAL_HEART_BASE = block("crystal_heart_base"); TagKey<Block> CRYSTAL_HEART_BASE = block("crystal_heart_base");
TagKey<Block> CRYSTAL_HEART_ORNAMENT = block("crystal_heart_ornament"); TagKey<Block> CRYSTAL_HEART_ORNAMENT = block("crystal_heart_ornament");
TagKey<Block> UNAFFECTED_BY_GROW_ABILITY = block("unaffected_by_grow_ability");
TagKey<Block> POLEARM_MINEABLE = block("mineable/polearm"); TagKey<Block> POLEARM_MINEABLE = block("mineable/polearm");

View file

@ -1,22 +1,31 @@
package com.minelittlepony.unicopia.ability; package com.minelittlepony.unicopia.ability;
import java.util.Optional; import java.util.Optional;
import java.util.function.DoubleSupplier;
import java.util.function.Supplier;
import com.minelittlepony.unicopia.Race; import com.minelittlepony.unicopia.Race;
import com.minelittlepony.unicopia.UTags;
import com.minelittlepony.unicopia.ability.data.Hit; import com.minelittlepony.unicopia.ability.data.Hit;
import com.minelittlepony.unicopia.ability.data.Pos; import com.minelittlepony.unicopia.ability.data.Pos;
import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.block.UBlocks;
import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.entity.player.Pony;
import com.minelittlepony.unicopia.particle.MagicParticleEffect; import com.minelittlepony.unicopia.particle.MagicParticleEffect;
import com.minelittlepony.unicopia.particle.ParticleUtils;
import com.minelittlepony.unicopia.util.TraceHelper; import com.minelittlepony.unicopia.util.TraceHelper;
import com.minelittlepony.unicopia.util.VecHelper;
import net.minecraft.block.BlockState; import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks; import net.minecraft.block.Blocks;
import net.minecraft.block.CarrotsBlock;
import net.minecraft.block.FarmlandBlock; import net.minecraft.block.FarmlandBlock;
import net.minecraft.item.BoneMealItem; import net.minecraft.item.BoneMealItem;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items; import net.minecraft.item.Items;
import net.minecraft.particle.ParticleTypes;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction; import net.minecraft.util.math.Direction;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
/** /**
@ -61,7 +70,7 @@ public class EarthPonyGrowAbility implements Ability<Pos> {
for (BlockPos pos : BlockPos.iterate( for (BlockPos pos : BlockPos.iterate(
data.pos().add(-2, -2, -2), data.pos().add(-2, -2, -2),
data.pos().add( 2, 2, 2))) { data.pos().add( 2, 2, 2))) {
count += applySingle(player.asWorld(), player.asWorld().getBlockState(pos), pos); count += applySingle(player, player.asWorld(), player.asWorld().getBlockState(pos), pos);
} }
if (count > 0) { if (count > 0) {
@ -70,7 +79,7 @@ public class EarthPonyGrowAbility implements Ability<Pos> {
return true; return true;
} }
protected int applySingle(World w, BlockState state, BlockPos pos) { protected int applySingle(Pony player, World w, BlockState state, BlockPos pos) {
ItemStack stack = new ItemStack(Items.BONE_MEAL); ItemStack stack = new ItemStack(Items.BONE_MEAL);
@ -78,14 +87,35 @@ public class EarthPonyGrowAbility implements Ability<Pos> {
return growable.grow(w, state, pos) ? 1 : 0; return growable.grow(w, state, pos) ? 1 : 0;
} }
if (w.getBlockState(pos).isOf(Blocks.GRASS_BLOCK)) { if (state.isOf(Blocks.CARROTS)) {
if (state.get(CarrotsBlock.AGE) == CarrotsBlock.MAX_AGE) {
boolean transform = w.random.nextInt(3) == 0;
DoubleSupplier vecComponentFactory = () -> w.random.nextTriangular(0, 0.5);
Supplier<Vec3d> posSupplier = () -> pos.toCenterPos().add(VecHelper.supply(vecComponentFactory));
for (int i = 0; i < 25; i++) {
ParticleUtils.spawnParticle(w, new MagicParticleEffect(0xFFFF00), posSupplier.get(), Vec3d.ZERO);
if (transform) {
ParticleUtils.spawnParticle(w, ParticleTypes.CLOUD, posSupplier.get(), Vec3d.ZERO);
}
}
if (transform) {
w.setBlockState(pos, UBlocks.GOLD_ROOT.getDefaultState().with(CarrotsBlock.AGE, CarrotsBlock.MAX_AGE));
}
return 5;
}
}
if (w.getBlockState(pos).isIn(UTags.UNAFFECTED_BY_GROW_ABILITY)) {
return 0; return 0;
} }
if (BoneMealItem.useOnFertilizable(stack, w, pos)) { if (BoneMealItem.useOnFertilizable(stack, w, pos)) {
if (w.random.nextInt(350) == 0) { if (w.random.nextInt(350) == 0) {
if (w.getBlockState(pos.down()).isOf(Blocks.FARMLAND)) { if (w.getBlockState(pos.down()).isOf(Blocks.FARMLAND)) {
w.setBlockState(pos.down(), Blocks.DIRT.getDefaultState()); FarmlandBlock.setToDirt(null, state, w, pos.down());
} }
w.setBlockState(pos, UBlocks.PLUNDER_VINE_BUD.getDefaultState()); w.setBlockState(pos, UBlocks.PLUNDER_VINE_BUD.getDefaultState());
} else if (w.random.nextInt(5000) == 0) { } else if (w.random.nextInt(5000) == 0) {

View file

@ -140,6 +140,12 @@ 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 = 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 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()));
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))); 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 GOLD_ROOT = register("gold_root", new CarrotsBlock(AbstractBlock.Settings.create().mapColor(MapColor.GOLD).noCollision().ticksRandomly().breakInstantly().sounds(BlockSoundGroup.CROP).pistonBehavior(PistonBehavior.DESTROY)) {
@Override
protected ItemConvertible getSeedsItem() {
return Items.GOLDEN_CARROT;
}
});
Block CHITIN = register("chitin", new SnowyBlock(Settings.create().mapColor(MapColor.PALE_PURPLE).hardness(5).requiresTool().ticksRandomly().sounds(BlockSoundGroup.CORAL)), 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 SURFACE_CHITIN = register("surface_chitin", new GrowableBlock(Settings.copy(CHITIN), () -> CHITIN), ItemGroups.NATURAL);

View file

@ -19,7 +19,6 @@ import net.minecraft.item.ItemStack;
import net.minecraft.server.world.ServerWorld; import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.SoundCategory; import net.minecraft.sound.SoundCategory;
import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World; import net.minecraft.world.World;
public class ConsumptionEnchantment extends SimpleEnchantment { public class ConsumptionEnchantment extends SimpleEnchantment {
@ -44,7 +43,7 @@ public class ConsumptionEnchantment extends SimpleEnchantment {
Block.getDroppedStacks(state, world, pos, blockEntity, entity, tool).forEach(s -> { Block.getDroppedStacks(state, world, pos, blockEntity, entity, tool).forEach(s -> {
world.playSound(null, pos, USounds.ENCHANTMENT_CONSUMPTION_CONSUME, SoundCategory.BLOCKS, 0.05F, (float)world.random.nextTriangular(0.6F, 0.2F)); world.playSound(null, pos, USounds.ENCHANTMENT_CONSUMPTION_CONSUME, SoundCategory.BLOCKS, 0.05F, (float)world.random.nextTriangular(0.6F, 0.2F));
ExperienceOrbEntity.spawn(world, Vec3d.ofCenter(pos).add(VecHelper.supply(vecComponentFactory)), s.getCount()); ExperienceOrbEntity.spawn(world, pos.toCenterPos().add(VecHelper.supply(vecComponentFactory)), s.getCount());
UCriteria.USE_CONSUMPTION.trigger(entity); UCriteria.USE_CONSUMPTION.trigger(entity);
}); });
state.onStacksDropped(world, pos, tool, true); state.onStacksDropped(world, pos, tool, true);

View file

@ -0,0 +1,12 @@
{
"variants": {
"age=0": { "model": "unicopia:block/gold_root_stage0" },
"age=1": { "model": "unicopia:block/gold_root_stage0" },
"age=2": { "model": "unicopia:block/gold_root_stage1" },
"age=3": { "model": "unicopia:block/gold_root_stage1" },
"age=4": { "model": "unicopia:block/gold_root_stage2" },
"age=5": { "model": "unicopia:block/gold_root_stage2" },
"age=6": { "model": "unicopia:block/gold_root_stage2" },
"age=7": { "model": "unicopia:block/gold_root_stage3" }
}
}

View file

@ -247,6 +247,7 @@
"block.unicopia.apple_pie": "Apple Pie", "block.unicopia.apple_pie": "Apple Pie",
"block.unicopia.weather_vane": "Weather Vane", "block.unicopia.weather_vane": "Weather Vane",
"block.unicopia.curing_joke": "Curing Joke", "block.unicopia.curing_joke": "Curing Joke",
"block.unicopia.gold_root": "Gold Root",
"block.unicopia.mango": "Mango", "block.unicopia.mango": "Mango",
"block.unicopia.mango_leaves": "Mango Leaves", "block.unicopia.mango_leaves": "Mango Leaves",
"block.unicopia.mango_sapling": "Mango Sapling", "block.unicopia.mango_sapling": "Mango Sapling",

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/crop",
"textures": {
"crop": "unicopia:block/gold_root_stage0"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/crop",
"textures": {
"crop": "unicopia:block/gold_root_stage1"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/crop",
"textures": {
"crop": "unicopia:block/gold_root_stage2"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "minecraft:block/crop",
"textures": {
"crop": "unicopia:block/gold_root_stage3"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

View file

@ -7,6 +7,7 @@
"unicopia:oats_stem", "unicopia:oats_stem",
"unicopia:green_apple_sprout", "unicopia:green_apple_sprout",
"unicopia:sweet_apple_sprout", "unicopia:sweet_apple_sprout",
"unicopia:sour_apple_sprout" "unicopia:sour_apple_sprout",
"unicopia:gold_root"
] ]
} }

View file

@ -0,0 +1,51 @@
{
"type": "minecraft:block",
"functions": [
{
"function": "minecraft:explosion_decay"
}
],
"pools": [
{
"bonus_rolls": 0.0,
"entries": [
{
"type": "minecraft:item",
"name": "minecraft:golden_carrot"
}
],
"rolls": 1.0
},
{
"bonus_rolls": 0.0,
"conditions": [
{
"block": "unicopia:gold_root",
"condition": "minecraft:block_state_property",
"properties": {
"age": "7"
}
}
],
"entries": [
{
"type": "minecraft:item",
"functions": [
{
"enchantment": "minecraft:fortune",
"formula": "minecraft:binomial_with_bonus_count",
"function": "minecraft:apply_bonus",
"parameters": {
"extra": 3,
"probability": 0.5714286
}
}
],
"name": "minecraft:golden_carrot"
}
],
"rolls": 1.0
}
],
"random_sequence": "minecraft:blocks/carrots"
}

View file

@ -0,0 +1,6 @@
{
"replace": false,
"values": [
"minecraft:grass_block"
]
}