Fixed tomato plants

This commit is contained in:
Sollace 2020-05-19 18:41:01 +02:00
parent 842148fc97
commit cbf541baf4
13 changed files with 298 additions and 398 deletions

View file

@ -1,66 +0,0 @@
package com.minelittlepony.unicopia.block;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.entity.EntityContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.item.LeadItem;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
public class StickBlock extends Block {
static final VoxelShape BOUNDING_BOX = VoxelShapes.cuboid(new Box(
7/16F, -1/16F, 7/16F,
9/16F, 15/16F, 9/16F
));
public StickBlock(Settings settings) {
super(settings);
}
@Deprecated
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) {
Vec3d off = state.getOffsetPos(source, pos);
return BOUNDING_BOX.offset(off.x, off.y, off.z);
}
@Override
public Block.OffsetType getOffsetType() {
return Block.OffsetType.XZ;
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (!world.isClient) {
return LeadItem.attachHeldMobsToBlock(player, world, pos);
}
ItemStack stack = player.getStackInHand(hand);
if (stack.getItem() == Items.LEAD || stack.isEmpty()) {
return ActionResult.SUCCESS;
}
return ActionResult.PASS;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
Block block = state.getBlock();
return block instanceof StickBlock || block instanceof FarmlandBlock;
}
}

View file

@ -0,0 +1,123 @@
package com.minelittlepony.unicopia.block;
import com.minelittlepony.unicopia.gas.CloudFarmlandBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Blocks;
import net.minecraft.block.CropBlock;
import net.minecraft.block.FarmlandBlock;
import net.minecraft.entity.EntityContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemConvertible;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Box;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
public class StickPlantBlock extends CropBlock {
private static final VoxelShape BOUNDING_BOX = VoxelShapes.cuboid(new Box(
7/16F, -1/16F, 7/16F,
9/16F, 15/16F, 9/16F
));
private final ItemConvertible seeds;
private final ItemConvertible crop;
private final ItemConvertible waste;
public StickPlantBlock(Settings settings, ItemConvertible seeds, ItemConvertible crop, ItemConvertible waste) {
super(settings);
this.seeds = seeds;
this.crop = crop;
this.waste = waste;
}
@Deprecated
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) {
Vec3d off = state.getOffsetPos(source, pos);
return BOUNDING_BOX.offset(off.x, off.y, off.z);
}
@Override
public Block.OffsetType getOffsetType() {
return Block.OffsetType.XZ;
}
@Override
public Item getSeedsItem() {
return seeds.asItem();
}
@Override
protected boolean canPlantOnTop(BlockState floor, BlockView view, BlockPos pos) {
Block block = floor.getBlock();
if (seeds.asItem() == Items.AIR) {
return block instanceof StickPlantBlock
|| block == Blocks.GRASS_BLOCK || block == Blocks.DIRT || block == Blocks.COARSE_DIRT
|| block == Blocks.PODZOL || block == Blocks.FARMLAND || block == UBlocks.CLOUD_FARMLAND;
}
return super.canPlantOnTop(floor, view, pos) || block == UBlocks.CLOUD_FARMLAND;
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (hand == Hand.MAIN_HAND && isMature(state)) {
if (player.getStackInHand(hand).isEmpty()) {
int good = getAge(state);
int rotten = world.random.nextInt(good);
good -= rotten;
if (good > 0) {
dropStack(world, pos, new ItemStack(crop.asItem(), good));
}
if (rotten > 0) {
dropStack(world, pos, new ItemStack(waste.asItem(), rotten));
}
world.setBlockState(pos, state.with(getAgeProperty(), 0));
return ActionResult.SUCCESS;
}
}
return ActionResult.PASS;
}
@Override
public void applyGrowth(World world, BlockPos pos, BlockState state) {
int age = Math.min(getAge(state) + getGrowthAmount(world), getMaxAge());
world.setBlockState(pos, state.with(getAgeProperty(), age), 2);
}
@Override
public BlockState getPlacementState(ItemPlacementContext context) {
return getPlacedState(context.getWorld(), context.getBlockPos().down(), context.getWorld().getBlockState(context.getBlockPos().down()));
}
public BlockState getPlacedState(World world, BlockPos pos, BlockState state) {
if (state.getBlock() instanceof CloudFarmlandBlock) {
return UBlocks.CLOUDSDALE_TOMATO_PLANT.getDefaultState();
}
if (state.getBlock() instanceof FarmlandBlock) {
return UBlocks.TOMATO_PLANT.getDefaultState();
}
return getDefaultState();
}
}

View file

@ -1,165 +0,0 @@
package com.minelittlepony.unicopia.block;
import com.minelittlepony.unicopia.gas.CloudFarmlandBlock;
import com.minelittlepony.unicopia.item.UItems;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.CropBlock;
import net.minecraft.entity.EntityContext;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.EnumProperty;
import net.minecraft.util.ActionResult;
import net.minecraft.util.Hand;
import net.minecraft.util.StringIdentifiable;
import net.minecraft.util.hit.BlockHitResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import net.minecraft.world.WorldView;
public class TomatoPlantBlock extends CropBlock {
public static final EnumProperty<Type> TYPE = EnumProperty.of("type", Type.class);
public TomatoPlantBlock(Settings settings) {
super(settings);
setDefaultState(getDefaultState().with(TYPE, Type.NORMAL));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
super.appendProperties(builder);
builder.add(TYPE);
}
@Deprecated
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView source, BlockPos pos, EntityContext context) {
Vec3d off = state.getOffsetPos(source, pos);
return StickBlock.BOUNDING_BOX.offset(off.x, off.y, off.z);
}
@Override
public Block.OffsetType getOffsetType() {
return Block.OffsetType.XZ;
}
@Override
protected Item getSeedsItem() {
return UItems.TOMATO_SEEDS;
}
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
if (world.getBlockState(pos.down()).getBlock() instanceof TomatoPlantBlock) {
return true;
}
return super.canPlaceAt(state, world, pos);
}
@Override
protected boolean canPlantOnTop(BlockState state, BlockView view, BlockPos pos) {
return super.canPlantOnTop(state, view, pos)
|| state.getBlock() == UBlocks.CLOUD_FARMLAND
|| state.getBlock() == UBlocks.TOMATO_PLANT
|| state.getBlock() == UBlocks.STICK;
}
@Override
public ActionResult onUse(BlockState state, World world, BlockPos pos, PlayerEntity player, Hand hand, BlockHitResult hit) {
if (hand == Hand.MAIN_HAND && isMature(state)) {
if (player.getStackInHand(hand).isEmpty()) {
Type type = state.get(TYPE);
int good = getAge(state);
int rotten = world.random.nextInt(good);
good -= rotten;
if (good > 0) {
dropStack(world, pos, new ItemStack(type.getCrop(), good));
}
if (rotten > 0) {
dropStack(world, pos, new ItemStack(type.getWaste(), rotten));
}
world.setBlockState(pos, state.with(getAgeProperty(), 0));
return ActionResult.SUCCESS;
}
}
return ActionResult.PASS;
}
@Override
public void applyGrowth(World world, BlockPos pos, BlockState state) {
int age = Math.min(getAge(state) + getGrowthAmount(world), getMaxAge());
world.setBlockState(pos, state.with(getAgeProperty(), age), 2);
}
public boolean plant(World world, BlockPos pos, BlockState state) {
if (canPlantOnTop(state, world, pos)) {
world.setBlockState(pos, getPlacedState(world, pos, state).with(getAgeProperty(), 1));
BlockSoundGroup sound = getSoundGroup(state);
world.playSound(null, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch() * 2);
return true;
}
return false;
}
public BlockState getPlacedState(World world, BlockPos pos, BlockState state) {
if (state.getBlock() instanceof StickBlock) {
pos = pos.down();
return getPlacedState(world, pos, world.getBlockState(pos));
}
if (state.getBlock() instanceof CloudFarmlandBlock) {
return getDefaultState().with(TYPE, Type.CLOUDSDALE);
}
if (state.getBlock() instanceof TomatoPlantBlock) {
return getDefaultState().with(TYPE, state.get(TYPE));
}
return getDefaultState();
}
public enum Type implements StringIdentifiable {
NORMAL,
CLOUDSDALE;
@Override
public String toString() {
return asString();
}
@Override
public String asString() {
return this == NORMAL ? "normal" : "cloudsdale";
}
public Item getCrop() {
return this == CLOUDSDALE ? UItems.CLOUDSDALE_TOMATO : UItems.TOMATO;
}
public Item getWaste() {
return this == CLOUDSDALE ? UItems.ROTTEN_CLOUDSDALE_TOMATO : UItems.ROTTEN_TOMATO;
}
}
}

View file

@ -25,6 +25,7 @@ import net.minecraft.block.MaterialColor;
import net.minecraft.block.SaplingBlock; import net.minecraft.block.SaplingBlock;
import net.minecraft.block.SlabBlock; import net.minecraft.block.SlabBlock;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
import net.minecraft.sound.BlockSoundGroup; import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.Identifier; import net.minecraft.util.Identifier;
import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.Registry;
@ -94,17 +95,23 @@ public interface UBlocks {
.breakInstantly() .breakInstantly()
.sounds(BlockSoundGroup.CROP).build())); .sounds(BlockSoundGroup.CROP).build()));
StickBlock STICK = register("stick", new StickBlock(FabricBlockSettings.of(Material.WOOD) StickPlantBlock STICK = register("stick", new StickPlantBlock(FabricBlockSettings.of(UMaterials.STICK)
.noCollision() .nonOpaque()
.strength(0.2F, 0.2F) .strength(0.2F, 0.2F)
.build())); .sounds(BlockSoundGroup.WOOD)
TomatoPlantBlock TOMATO_PLANT = register("tomato_plant", new TomatoPlantBlock(FabricBlockSettings.of(Material.PLANT) .build(), Items.AIR, Items.AIR, Items.AIR));
.noCollision() StickPlantBlock TOMATO_PLANT = register("tomato_plant", new StickPlantBlock(FabricBlockSettings.of(UMaterials.STICK)
.nonOpaque()
.strength(0.2F, 0.2F) .strength(0.2F, 0.2F)
.ticksRandomly() .ticksRandomly()
.lightLevel(1)
.sounds(BlockSoundGroup.WOOD) .sounds(BlockSoundGroup.WOOD)
.build())); .build(), () -> UItems.TOMATO_SEEDS, () -> UItems.TOMATO, () -> UItems.ROTTEN_TOMATO));
StickPlantBlock CLOUDSDALE_TOMATO_PLANT = register("cloudsdale_tomato_plant", new StickPlantBlock(FabricBlockSettings.of(UMaterials.STICK)
.nonOpaque()
.strength(0.2F, 0.2F)
.ticksRandomly()
.sounds(BlockSoundGroup.WOOD)
.build(), () -> UItems.TOMATO_SEEDS, () -> UItems.CLOUDSDALE_TOMATO, () -> UItems.ROTTEN_CLOUDSDALE_TOMATO));
HiveWallBlock HIVE_WALL_BLOCK = register("hive_wall_block", new HiveWallBlock(FabricBlockSettings.of(UMaterials.HIVE) HiveWallBlock HIVE_WALL_BLOCK = register("hive_wall_block", new HiveWallBlock(FabricBlockSettings.of(UMaterials.HIVE)
.strength(10, 10) .strength(10, 10)

View file

@ -1,10 +1,12 @@
package com.minelittlepony.unicopia.block; package com.minelittlepony.unicopia.block;
import net.fabricmc.fabric.api.block.FabricMaterialBuilder;
import net.minecraft.block.Material; import net.minecraft.block.Material;
import net.minecraft.block.MaterialColor; import net.minecraft.block.MaterialColor;
public interface UMaterials { public interface UMaterials {
Material CLOUD = new Material.Builder(MaterialColor.WHITE).allowsMovement().build(); Material CLOUD = new FabricMaterialBuilder(MaterialColor.WHITE).allowsMovement().lightPassesThrough().notSolid().build();
Material HIVE = new Material.Builder(MaterialColor.NETHER).build(); Material HIVE = new Material.Builder(MaterialColor.NETHER).build();
Material CHITIN = new Material.Builder(MaterialColor.BLACK).build(); Material CHITIN = new Material.Builder(MaterialColor.BLACK).build();
Material STICK = new FabricMaterialBuilder(MaterialColor.WOOD).allowsMovement().burnable().destroyedByPiston().lightPassesThrough().notSolid().build();
} }

View file

@ -50,25 +50,11 @@ public interface URenderers {
UBlocks.CLOUD_BLOCK, UBlocks.CLOUD_SLAB, UBlocks.CLOUD_STAIRS, UBlocks.CLOUD_BLOCK, UBlocks.CLOUD_SLAB, UBlocks.CLOUD_STAIRS,
UBlocks.ENCHANTED_CLOUD_BLOCK, UBlocks.ENCHANTED_CLOUD_SLAB, UBlocks.ENCHANTED_CLOUD_STAIRS, UBlocks.ENCHANTED_CLOUD_BLOCK, UBlocks.ENCHANTED_CLOUD_SLAB, UBlocks.ENCHANTED_CLOUD_STAIRS,
UBlocks.SLIME_DROP, UBlocks.SLIME_LAYER UBlocks.SLIME_DROP, UBlocks.SLIME_LAYER,
UBlocks.APPLE_SAPLING, UBlocks.TOMATO_PLANT
); );
UScreens.bootstrap(); UScreens.bootstrap();
} }
} }

View file

@ -5,8 +5,10 @@ import javax.annotation.Nullable;
import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.block.UBlocks;
import net.minecraft.advancement.criterion.Criterions; import net.minecraft.advancement.criterion.Criterions;
import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemPlacementContext;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.item.ItemUsageContext; import net.minecraft.item.ItemUsageContext;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
@ -24,7 +26,6 @@ public class StickItem extends Item {
@Override @Override
public ActionResult useOnBlock(ItemUsageContext context) { public ActionResult useOnBlock(ItemUsageContext context) {
World world = context.getWorld(); World world = context.getWorld();
BlockPos pos = context.getBlockPos(); BlockPos pos = context.getBlockPos();
Direction facing = context.getSide(); Direction facing = context.getSide();
@ -34,11 +35,11 @@ public class StickItem extends Item {
if (facing == Direction.UP && world.isAir(pos.up()) && (player == null || world.canPlayerModifyAt(player, pos.offset(facing)))) { if (facing == Direction.UP && world.isAir(pos.up()) && (player == null || world.canPlayerModifyAt(player, pos.offset(facing)))) {
world.setBlockState(pos.up(), UBlocks.STICK.getDefaultState()); BlockState placementState = UBlocks.STICK.getPlacementState(new ItemPlacementContext(context));
BlockSoundGroup sound = world.getBlockState(pos).getSoundGroup(); if (!world.setBlockState(pos.up(), placementState, 11)) {
return ActionResult.FAIL;
world.playSound(null, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, (sound.getVolume() + 1) / 2, sound.getPitch()); }
ItemStack itemstack = context.getStack(); ItemStack itemstack = context.getStack();
@ -46,10 +47,9 @@ public class StickItem extends Item {
Criterions.PLACED_BLOCK.trigger((ServerPlayerEntity)player, pos.up(), itemstack); Criterions.PLACED_BLOCK.trigger((ServerPlayerEntity)player, pos.up(), itemstack);
} }
if (player == null || !player.abilities.creativeMode) { BlockSoundGroup sound = world.getBlockState(pos).getSoundGroup();
itemstack.decrement(1); world.playSound(null, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, (sound.getVolume() + 1) / 2, sound.getPitch());
} itemstack.decrement(1);
return ActionResult.SUCCESS; return ActionResult.SUCCESS;
} }

View file

@ -18,5 +18,4 @@ public class TomatoItem extends Item {
entity.removeStatusEffect(StatusEffects.NAUSEA); entity.removeStatusEffect(StatusEffects.NAUSEA);
return stack; return stack;
} }
} }

View file

@ -1,6 +1,6 @@
package com.minelittlepony.unicopia.item; package com.minelittlepony.unicopia.item;
import com.minelittlepony.unicopia.block.StickBlock; import com.minelittlepony.unicopia.block.StickPlantBlock;
import com.minelittlepony.unicopia.block.UBlocks; import com.minelittlepony.unicopia.block.UBlocks;
import net.minecraft.block.Block; import net.minecraft.block.Block;
@ -8,7 +8,11 @@ import net.minecraft.block.BlockState;
import net.minecraft.entity.player.PlayerEntity; import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.item.Item; import net.minecraft.item.Item;
import net.minecraft.item.ItemUsageContext; import net.minecraft.item.ItemUsageContext;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.sound.SoundCategory;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
public class TomatoSeedsItem extends Item { public class TomatoSeedsItem extends Item {
@ -19,12 +23,20 @@ public class TomatoSeedsItem extends Item {
@Override @Override
public ActionResult useOnBlock(ItemUsageContext context) { public ActionResult useOnBlock(ItemUsageContext context) {
BlockState state = context.getWorld().getBlockState(context.getBlockPos()); World world = context.getWorld();
BlockPos pos = context.getBlockPos();
BlockState state = world.getBlockState(context.getBlockPos());
Block block = state.getBlock(); Block block = state.getBlock();
if (block instanceof StickBlock) { if (block instanceof StickPlantBlock && (block == UBlocks.TOMATO_PLANT || block == UBlocks.CLOUDSDALE_TOMATO_PLANT)) {
if (UBlocks.TOMATO_PLANT.plant(context.getWorld(), context.getBlockPos(), state)) { StickPlantBlock plant = (StickPlantBlock)block;
if (plant.getSeedsItem() == this && state.get(plant.getAgeProperty()) == 0 && world.setBlockState(pos, plant.getPlacedState(world, pos, state).with(plant.getAgeProperty(), 1), 11)) {
BlockSoundGroup sound = block.getSoundGroup(state);
context.getWorld().playSound(null, pos, sound.getPlaceSound(), SoundCategory.BLOCKS, sound.getVolume(), sound.getPitch() * 2);
PlayerEntity player = context.getPlayer(); PlayerEntity player = context.getPlayer();
if (player == null || !player.isCreative()) { if (player == null || !player.isCreative()) {

View file

@ -0,0 +1,12 @@
{
"variants": {
"age=0": { "model": "unicopia:block/tomato_plant/stage0" },
"age=1": { "model": "unicopia:block/tomato_plant/stage1" },
"age=2": { "model": "unicopia:block/tomato_plant/stage1" },
"age=3": { "model": "unicopia:block/tomato_plant/stage2" },
"age=4": { "model": "unicopia:block/tomato_plant/stage2" },
"age=5": { "model": "unicopia:block/tomato_plant/stage3" },
"age=6": { "model": "unicopia:block/tomato_plant/stage4" },
"age=7": { "model": "unicopia:block/tomato_plant/stage4" }
}
}

View file

@ -1,20 +1,12 @@
{ {
"variants": { "variants": {
"age=0,type=normal": { "model": "unicopia:block/tomato_plant/stage0" }, "age=0": { "model": "unicopia:block/tomato_plant/stage0" },
"age=1,type=normal": { "model": "unicopia:block/tomato_plant/stage1" }, "age=1": { "model": "unicopia:block/tomato_plant/stage1" },
"age=2,type=normal": { "model": "unicopia:block/tomato_plant/stage1" }, "age=2": { "model": "unicopia:block/tomato_plant/stage1" },
"age=3,type=normal": { "model": "unicopia:block/tomato_plant/stage2" }, "age=3": { "model": "unicopia:block/tomato_plant/stage2" },
"age=4,type=normal": { "model": "unicopia:block/tomato_plant/stage2" }, "age=4": { "model": "unicopia:block/tomato_plant/stage2" },
"age=5,type=normal": { "model": "unicopia:block/tomato_plant/stage3" }, "age=5": { "model": "unicopia:block/tomato_plant/stage3" },
"age=6,type=normal": { "model": "unicopia:block/tomato_plant/stage4" }, "age=6": { "model": "unicopia:block/tomato_plant/stage4" },
"age=7,type=normal": { "model": "unicopia:block/tomato_plant/stage4" }, "age=7": { "model": "unicopia:block/tomato_plant/stage4" }
"age=0,type=cloudsdale": { "model": "unicopia:block/tomato_plant/stage0" },
"age=1,type=cloudsdale": { "model": "unicopia:block/tomato_plant/stage1" },
"age=2,type=cloudsdale": { "model": "unicopia:block/tomato_plant/stage1" },
"age=3,type=cloudsdale": { "model": "unicopia:block/tomato_plant/stage2" },
"age=4,type=cloudsdale": { "model": "unicopia:block/tomato_plant/stage2" },
"age=5,type=cloudsdale": { "model": "unicopia:block/tomato_plant/stage3" },
"age=6,type=cloudsdale": { "model": "unicopia:block/tomato_plant/stage4" },
"age=7,type=cloudsdale": { "model": "unicopia:block/tomato_plant/stage4" }
} }
} }

View file

@ -0,0 +1,93 @@
{
"type": "minecraft:block",
"pools": [
{
"rolls": 1,
"entries": [
{ "type": "minecraft:item", "name": "minecraft:stick" }
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:alternatives",
"children": [
{
"type": "minecraft:item", "name": "unicopia:cloudsdale_tomato",
"conditions": [
{
"condition": "minecraft:block_state_property",
"block": "unicopia:cloudsdale_tomato_plant",
"properties": { "age": "7" }
}
],
"functions": [
{
"function": "minecraft:set_count",
"count": { "min": 1, "max": 5 }
},
{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count",
"parameters": { "bonusMultiplier": 1 }
},
{
"function": "minecraft:limit_count",
"limit": { "max": 9, "min": 1 }
}
]
},
{
"type": "minecraft:item", "name": "unicopia:rotten_cloudsdale_tomato",
"conditions": [
{
"condition": "minecraft:block_state_property",
"block": "unicopia:cloudsdale_tomato_plant",
"properties": { "age": "7" }
}
],
"functions": [
{ "function": "minecraft:set_count", "count": 2 },
{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count",
"parameters": { "bonusMultiplier": 1 }
}
]
},
{ "type": "minecraft:item", "name": "unicopia:tomato_seeds" }
]
}
]
},
{
"rolls": 1,
"entries": [
{
"type": "minecraft:item", "name": "unicopia:tomato_seeds",
"functions": [
{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:binomial_with_bonus_count",
"parameters": { "extra": 3, "probability": 0.5714286 }
}
]
}
],
"conditions": [
{
"condition": "minecraft:block_state_property",
"block": "unicopia:cloudsdale_tomato_plant",
"properties": { "age": "7" }
}
]
}
],
"functions": [
{ "function": "minecraft:explosion_decay" }
]
}

View file

@ -2,61 +2,45 @@
"type": "minecraft:block", "type": "minecraft:block",
"pools": [ "pools": [
{ {
"rolls": 1.0, "rolls": 1,
"entries": [ "entries": [
{ { "type": "minecraft:item", "name": "minecraft:stick" }
"type": "minecraft:item",
"name": "minecraft:stick"
}
] ]
}, },
{ {
"rolls": 1.0, "rolls": 1,
"entries": [ "entries": [
{ {
"type": "minecraft:alternatives", "type": "minecraft:alternatives",
"children": [ "children": [
{ {
"type": "minecraft:item", "type": "minecraft:item", "name": "unicopia:tomato",
"name": "unicopia:tomato",
"conditions": [ "conditions": [
{ {
"condition": "minecraft:block_state_property", "condition": "minecraft:block_state_property",
"block": "unicopia:tomato_plant", "block": "unicopia:tomato_plant",
"properties": { "properties": { "age": "7" }
"age": "7",
"type": "normal"
}
} }
], ],
"functions": [ "functions": [
{ {
"function": "minecraft:set_count", "function": "minecraft:set_count",
"count": { "count": { "min": 1, "max": 5 }
"min": 1,
"max": 5
}
}, },
{ {
"function": "minecraft:apply_bonus", "function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune", "enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count", "formula": "minecraft:uniform_bonus_count",
"parameters": { "parameters": { "bonusMultiplier": 1 }
"bonusMultiplier": 1
}
}, },
{ {
"function": "minecraft:limit_count", "function": "minecraft:limit_count",
"limit": { "limit": { "max": 9, "min": 1 }
"max": 9,
"min": 1
}
} }
] ]
}, },
{ {
"type": "minecraft:item", "type": "minecraft:item", "name": "unicopia:rotten_tomato",
"name": "unicopia:rotten_tomato",
"conditions": [ "conditions": [
{ {
"condition": "minecraft:block_state_property", "condition": "minecraft:block_state_property",
@ -70,119 +54,40 @@
"function": "minecraft:apply_bonus", "function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune", "enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count", "formula": "minecraft:uniform_bonus_count",
"parameters": { "parameters": { "bonusMultiplier": 1 }
"bonusMultiplier": 1
}
} }
] ]
}, },
{ { "type": "minecraft:item", "name": "unicopia:tomato_seeds" }
"type": "minecraft:item",
"name": "unicopia:cloudsdale_tomato",
"conditions": [
{
"condition": "minecraft:block_state_property",
"block": "unicopia:tomato_plant",
"properties": {
"age": "7",
"type": "cloudsdale"
}
}
],
"functions": [
{
"function": "minecraft:set_count",
"count": {
"min": 1,
"max": 5
}
},
{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count",
"parameters": {
"bonusMultiplier": 1
}
},
{
"function": "minecraft:limit_count",
"limit": {
"max": 9,
"min": 1
}
}
]
},
{
"type": "minecraft:item",
"name": "unicopia:rotten_cloudsdale_tomato",
"conditions": [
{
"condition": "minecraft:block_state_property",
"block": "unicopia:tomato_plant",
"properties": {
"age": "7",
"type": "cloudsdale"
}
}
],
"functions": [
{
"function": "minecraft:set_count",
"count": 2
},
{
"function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune",
"formula": "minecraft:uniform_bonus_count",
"parameters": {
"bonusMultiplier": 1
}
}
]
},
{
"type": "minecraft:item",
"name": "unicopia:tomato_seeds"
}
] ]
} }
] ]
}, },
{ {
"rolls": 1.0, "rolls": 1,
"entries": [ "entries": [
{ {
"type": "minecraft:item", "type": "minecraft:item", "name": "unicopia:tomato_seeds",
"functions": [ "functions": [
{ {
"function": "minecraft:apply_bonus", "function": "minecraft:apply_bonus",
"enchantment": "minecraft:fortune", "enchantment": "minecraft:fortune",
"formula": "minecraft:binomial_with_bonus_count", "formula": "minecraft:binomial_with_bonus_count",
"parameters": { "parameters": { "extra": 3, "probability": 0.5714286 }
"extra": 3,
"probability": 0.5714286
}
} }
], ]
"name": "unicopia:tomato_seeds"
} }
], ],
"conditions": [ "conditions": [
{ {
"condition": "minecraft:block_state_property", "condition": "minecraft:block_state_property",
"block": "unicopia:tomato_plant", "block": "unicopia:tomato_plant",
"properties": { "properties": { "age": "7" }
"age": "7"
}
} }
] ]
} }
], ],
"functions": [ "functions": [
{ { "function": "minecraft:explosion_decay" }
"function": "minecraft:explosion_decay"
}
] ]
} }