diff --git a/src/main/java/com/minelittlepony/unicopia/UTags.java b/src/main/java/com/minelittlepony/unicopia/UTags.java index 91b4fcae..9d4a460b 100644 --- a/src/main/java/com/minelittlepony/unicopia/UTags.java +++ b/src/main/java/com/minelittlepony/unicopia/UTags.java @@ -42,6 +42,7 @@ public interface UTags { TagKey CRYSTAL_HEART_BASE = block("crystal_heart_base"); TagKey CRYSTAL_HEART_ORNAMENT = block("crystal_heart_ornament"); + TagKey UNAFFECTED_BY_GROW_ABILITY = block("unaffected_by_grow_ability"); TagKey POLEARM_MINEABLE = block("mineable/polearm"); diff --git a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java index c7e6493b..b69ebae4 100644 --- a/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java +++ b/src/main/java/com/minelittlepony/unicopia/ability/EarthPonyGrowAbility.java @@ -1,22 +1,31 @@ package com.minelittlepony.unicopia.ability; import java.util.Optional; +import java.util.function.DoubleSupplier; +import java.util.function.Supplier; import com.minelittlepony.unicopia.Race; +import com.minelittlepony.unicopia.UTags; 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.player.Pony; import com.minelittlepony.unicopia.particle.MagicParticleEffect; +import com.minelittlepony.unicopia.particle.ParticleUtils; import com.minelittlepony.unicopia.util.TraceHelper; +import com.minelittlepony.unicopia.util.VecHelper; + import net.minecraft.block.BlockState; import net.minecraft.block.Blocks; +import net.minecraft.block.CarrotsBlock; import net.minecraft.block.FarmlandBlock; import net.minecraft.item.BoneMealItem; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; +import net.minecraft.particle.ParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.Direction; +import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; /** @@ -61,7 +70,7 @@ public class EarthPonyGrowAbility implements Ability { for (BlockPos pos : BlockPos.iterate( 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) { @@ -70,7 +79,7 @@ public class EarthPonyGrowAbility implements Ability { 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); @@ -78,14 +87,35 @@ public class EarthPonyGrowAbility implements Ability { 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 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; } if (BoneMealItem.useOnFertilizable(stack, w, pos)) { if (w.random.nextInt(350) == 0) { 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()); } else if (w.random.nextInt(5000) == 0) { diff --git a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java index cd8284da..ca6726e9 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java @@ -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_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))); + 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 SURFACE_CHITIN = register("surface_chitin", new GrowableBlock(Settings.copy(CHITIN), () -> CHITIN), ItemGroups.NATURAL); diff --git a/src/main/java/com/minelittlepony/unicopia/item/enchantment/ConsumptionEnchantment.java b/src/main/java/com/minelittlepony/unicopia/item/enchantment/ConsumptionEnchantment.java index 547710c0..9976f03b 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/enchantment/ConsumptionEnchantment.java +++ b/src/main/java/com/minelittlepony/unicopia/item/enchantment/ConsumptionEnchantment.java @@ -19,7 +19,6 @@ import net.minecraft.item.ItemStack; import net.minecraft.server.world.ServerWorld; import net.minecraft.sound.SoundCategory; import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; public class ConsumptionEnchantment extends SimpleEnchantment { @@ -44,7 +43,7 @@ public class ConsumptionEnchantment extends SimpleEnchantment { 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)); - 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); }); state.onStacksDropped(world, pos, tool, true); diff --git a/src/main/resources/assets/unicopia/blockstates/gold_root.json b/src/main/resources/assets/unicopia/blockstates/gold_root.json new file mode 100644 index 00000000..6791a03a --- /dev/null +++ b/src/main/resources/assets/unicopia/blockstates/gold_root.json @@ -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" } + } +} diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index fe458ff4..3dc63351 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -247,6 +247,7 @@ "block.unicopia.apple_pie": "Apple Pie", "block.unicopia.weather_vane": "Weather Vane", "block.unicopia.curing_joke": "Curing Joke", + "block.unicopia.gold_root": "Gold Root", "block.unicopia.mango": "Mango", "block.unicopia.mango_leaves": "Mango Leaves", "block.unicopia.mango_sapling": "Mango Sapling", diff --git a/src/main/resources/assets/unicopia/models/block/gold_root_stage0.json b/src/main/resources/assets/unicopia/models/block/gold_root_stage0.json new file mode 100644 index 00000000..8f0b22cd --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/gold_root_stage0.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/crop", + "textures": { + "crop": "unicopia:block/gold_root_stage0" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/unicopia/models/block/gold_root_stage1.json b/src/main/resources/assets/unicopia/models/block/gold_root_stage1.json new file mode 100644 index 00000000..5315c2b8 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/gold_root_stage1.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/crop", + "textures": { + "crop": "unicopia:block/gold_root_stage1" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/unicopia/models/block/gold_root_stage2.json b/src/main/resources/assets/unicopia/models/block/gold_root_stage2.json new file mode 100644 index 00000000..cf262db5 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/gold_root_stage2.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/crop", + "textures": { + "crop": "unicopia:block/gold_root_stage2" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/unicopia/models/block/gold_root_stage3.json b/src/main/resources/assets/unicopia/models/block/gold_root_stage3.json new file mode 100644 index 00000000..790fd135 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/gold_root_stage3.json @@ -0,0 +1,6 @@ +{ + "parent": "minecraft:block/crop", + "textures": { + "crop": "unicopia:block/gold_root_stage3" + } +} \ No newline at end of file diff --git a/src/main/resources/assets/unicopia/textures/block/gold_root_stage0.png b/src/main/resources/assets/unicopia/textures/block/gold_root_stage0.png new file mode 100644 index 00000000..54ec7e1c Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/block/gold_root_stage0.png differ diff --git a/src/main/resources/assets/unicopia/textures/block/gold_root_stage1.png b/src/main/resources/assets/unicopia/textures/block/gold_root_stage1.png new file mode 100644 index 00000000..ad9dbea7 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/block/gold_root_stage1.png differ diff --git a/src/main/resources/assets/unicopia/textures/block/gold_root_stage2.png b/src/main/resources/assets/unicopia/textures/block/gold_root_stage2.png new file mode 100644 index 00000000..af5f7f91 Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/block/gold_root_stage2.png differ diff --git a/src/main/resources/assets/unicopia/textures/block/gold_root_stage3.png b/src/main/resources/assets/unicopia/textures/block/gold_root_stage3.png new file mode 100644 index 00000000..970f559f Binary files /dev/null and b/src/main/resources/assets/unicopia/textures/block/gold_root_stage3.png differ diff --git a/src/main/resources/data/minecraft/tags/blocks/maintains_farmland.json b/src/main/resources/data/minecraft/tags/blocks/maintains_farmland.json index b8408162..0e142e00 100644 --- a/src/main/resources/data/minecraft/tags/blocks/maintains_farmland.json +++ b/src/main/resources/data/minecraft/tags/blocks/maintains_farmland.json @@ -7,6 +7,7 @@ "unicopia:oats_stem", "unicopia:green_apple_sprout", "unicopia:sweet_apple_sprout", - "unicopia:sour_apple_sprout" + "unicopia:sour_apple_sprout", + "unicopia:gold_root" ] } \ No newline at end of file diff --git a/src/main/resources/data/unicopia/loot_tables/blocks/gold_root.json b/src/main/resources/data/unicopia/loot_tables/blocks/gold_root.json new file mode 100644 index 00000000..6bfe9e77 --- /dev/null +++ b/src/main/resources/data/unicopia/loot_tables/blocks/gold_root.json @@ -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" +} diff --git a/src/main/resources/data/unicopia/tags/blocks/unaffected_by_grow_ability.json b/src/main/resources/data/unicopia/tags/blocks/unaffected_by_grow_ability.json new file mode 100644 index 00000000..06c918c6 --- /dev/null +++ b/src/main/resources/data/unicopia/tags/blocks/unaffected_by_grow_ability.json @@ -0,0 +1,6 @@ +{ + "replace": false, + "values": [ + "minecraft:grass_block" + ] +}