Blossom berry

This commit is contained in:
paulevsGitch 2021-01-06 16:05:20 +03:00
parent 2a2641eea3
commit ca769ebc66
30 changed files with 257 additions and 36 deletions

View file

@ -8,12 +8,12 @@ import net.minecraft.util.math.Direction;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.FurBlock;
import ru.betterend.blocks.basis.PlantWithAgeBlock;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class BlueVineSeedBlock extends PlantWithAgeBlock {
public class BlueVineSeedBlock extends EndPlantWithAgeBlock {
@Override
public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {
int height = MHelper.randRange(2, 5, random);

View file

@ -8,12 +8,12 @@ import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.WorldView;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.PlantWithAgeBlock;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndTags;
import ru.betterend.util.BlocksHelper;
public class BulbVineSeedBlock extends PlantWithAgeBlock {
public class BulbVineSeedBlock extends EndPlantWithAgeBlock {
@Override
public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) {
BlockState up = world.getBlockState(pos.up());

View file

@ -13,12 +13,12 @@ import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.Direction;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties.TripleShape;
import ru.betterend.blocks.basis.PlantWithAgeBlock;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class GlowingPillarSeedBlock extends PlantWithAgeBlock {
public class GlowingPillarSeedBlock extends EndPlantWithAgeBlock {
public GlowingPillarSeedBlock() {
super(FabricBlockSettings.of(Material.PLANT)
.luminance((state) -> { return state.get(AGE) * 3 + 3; })

View file

@ -8,12 +8,12 @@ import net.minecraft.util.math.BlockPos.Mutable;
import net.minecraft.util.math.Direction;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.BlockProperties.PentaShape;
import ru.betterend.blocks.basis.PlantWithAgeBlock;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class LanceleafSeedBlock extends PlantWithAgeBlock {
public class LanceleafSeedBlock extends EndPlantWithAgeBlock {
@Override
public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) {
int height = MHelper.randRange(4, 6, random);

View file

@ -16,12 +16,12 @@ import net.minecraft.util.shape.VoxelShape;
import net.minecraft.world.BlockView;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.World;
import ru.betterend.blocks.basis.PlantWithAgeBlock;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.registry.EndItems;
import ru.betterend.util.MHelper;
public class ShadowBerryBlock extends PlantWithAgeBlock {
public class ShadowBerryBlock extends EndPlantWithAgeBlock {
private static final VoxelShape SHAPE = Block.createCuboidShape(1, 0, 1, 15, 8, 15);
@Override

View file

@ -0,0 +1,114 @@
package ru.betterend.blocks.basis;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import com.google.common.collect.Lists;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.AbstractBlock;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.server.world.ServerWorld;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.BlockView;
import net.minecraft.world.World;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
public class EndCropBlock extends EndPlantBlock {
public static final IntProperty AGE = IntProperty.of("age", 0, 3);
private final Block[] terrain;
private final Item drop;
public EndCropBlock(Item drop, Block... terrain) {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.HOES)
.sounds(BlockSoundGroup.GRASS)
.breakByHand(true)
.ticksRandomly()
.noCollision());
this.drop = drop;
this.terrain = terrain;
this.setDefaultState(getDefaultState().with(AGE, 0));
}
@Override
protected void appendProperties(StateManager.Builder<Block, BlockState> stateManager) {
stateManager.add(AGE);
}
@Override
protected boolean isTerrain(BlockState state) {
for (Block block: terrain) {
if (state.isOf(block)) {
return true;
}
}
return false;
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
if (state.get(AGE) < 3) {
return Collections.singletonList(new ItemStack(this));
}
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.isEffectiveOn(state)) {
int enchantment = EnchantmentHelper.getLevel(Enchantments.FORTUNE, tool);
if (enchantment > 0) {
int countSeeds = MHelper.randRange(MathHelper.clamp(1 + enchantment, 1, 3), 3, MHelper.RANDOM);
int countDrops = MHelper.randRange(MathHelper.clamp(1 + enchantment, 1, 2), 2, MHelper.RANDOM);
return Lists.newArrayList(new ItemStack(this, countSeeds), new ItemStack(drop, countDrops));
}
}
int countSeeds = MHelper.randRange(1, 3, MHelper.RANDOM);
int countDrops = MHelper.randRange(1, 2, MHelper.RANDOM);
return Lists.newArrayList(new ItemStack(this, countSeeds), new ItemStack(drop, countDrops));
}
@Override
public AbstractBlock.OffsetType getOffsetType() {
return AbstractBlock.OffsetType.NONE;
}
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
int age = state.get(AGE);
if (age < 3) {
BlocksHelper.setWithUpdate(world, pos, state.with(AGE, age + 1));
}
}
@Override
public boolean isFertilizable(BlockView world, BlockPos pos, BlockState state, boolean isClient) {
return state.get(AGE) < 3;
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
return random.nextInt(8) == 0 && state.get(AGE) < 3;
}
@Override
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random random) {
super.scheduledTick(state, world, pos, random);
if (canGrow(world, random, pos, state)) {
grow(world, random, pos, state);
}
}
}

View file

@ -13,11 +13,12 @@ import net.minecraft.state.StateManager;
import net.minecraft.state.property.IntProperty;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import net.minecraft.world.World;
public abstract class PlantWithAgeBlock extends EndPlantBlock {
public abstract class EndPlantWithAgeBlock extends EndPlantBlock {
public static final IntProperty AGE = IntProperty.of("age", 0, 3);
public PlantWithAgeBlock() {
public EndPlantWithAgeBlock() {
this(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.GRASS)
@ -26,7 +27,7 @@ public abstract class PlantWithAgeBlock extends EndPlantBlock {
.noCollision());
}
public PlantWithAgeBlock(FabricBlockSettings settings) {
public EndPlantWithAgeBlock(FabricBlockSettings settings) {
super(settings);
}
@ -39,7 +40,6 @@ public abstract class PlantWithAgeBlock extends EndPlantBlock {
@Override
public void grow(ServerWorld world, Random random, BlockPos pos, BlockState state) {
if (random.nextInt(4) == 0) {
int age = state.get(AGE);
if (age < 3) {
world.setBlockState(pos, state.with(AGE, age + 1));
@ -48,6 +48,10 @@ public abstract class PlantWithAgeBlock extends EndPlantBlock {
growAdult(world, random, pos);
}
}
@Override
public boolean canGrow(World world, Random random, BlockPos pos, BlockState state) {
return random.nextInt(8) == 0;
}
@Override

View file

@ -86,6 +86,7 @@ import ru.betterend.blocks.PedestalVanilla;
import ru.betterend.blocks.RunedFlavolite;
import ru.betterend.blocks.TerminiteBlock;
import ru.betterend.blocks.basis.FurBlock;
import ru.betterend.blocks.basis.EndCropBlock;
import ru.betterend.blocks.basis.EndLeavesBlock;
import ru.betterend.blocks.basis.EndOreBlock;
import ru.betterend.blocks.basis.SimpleLeavesBlock;
@ -220,6 +221,9 @@ public class EndBlocks {
public static final Block SMALL_JELLYSHROOM = registerBlock("small_jellyshroom", new SmallJellyshroomBlock());
// Crops
public static final Block BLOSSOM_BERRY = registerBlock("blossom_berry_seed", new EndCropBlock(EndItems.BLOSSOM_BERRY, PINK_MOSS));
// Water plants
public static final Block BUBBLE_CORAL = registerBlock("bubble_coral", new BubbleCoralBlock());
public static final Block MENGER_SPONGE = registerBlock("menger_sponge", new MengerSpongeBlock());

View file

@ -111,6 +111,10 @@ public class EndItems {
public final static Item BUCKET_END_FISH = registerItem("bucket_end_fish", new FishBucketItem(EndEntities.END_FISH, Fluids.WATER, makeItemSettings().maxCount(1)));
public final static Item SWEET_BERRY_JELLY = registerFood("sweet_berry_jelly", 3, 0.75F);
public final static Item SHADOW_BERRY_JELLY = registerFood("shadow_berry_jelly", 4, 0.75F, new StatusEffectInstance(StatusEffects.NIGHT_VISION, 400));
public final static Item BLOSSOM_BERRY = registerFood("blossom_berry", FoodComponents.APPLE);
// Drinks
public final static Item UMBRELLA_CLUSTER_JUICE = registerDrink("umbrella_cluster_juice");
// Toolparts //
public final static Item AETERNIUM_SHOVEL_HEAD = registerItem("aeternium_shovel_head");
@ -121,9 +125,6 @@ public class EndItems {
public final static Item AETERNIUM_SWORD_BLADE = registerItem("aeternium_sword_blade");
public final static Item AETERNIUM_SWORD_HANDLE = registerItem("aeternium_sword_handle");
// Drinks
public final static Item UMBRELLA_CLUSTER_JUICE = registerDrink("umbrella_cluster_juice");
protected static Item registerItem(String name) {
return registerItem(BetterEnd.makeID(name), new PatternedItem(makeItemSettings()));
}

View file

@ -4,7 +4,7 @@ import java.util.Random;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.basis.PlantWithAgeBlock;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
import ru.betterend.util.BlocksHelper;
import ru.betterend.util.MHelper;
@ -26,10 +26,10 @@ public class BlueVineFeature extends ScatterFeature {
@Override
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
if (small) {
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.BLUE_VINE_SEED.getDefaultState().with(PlantWithAgeBlock.AGE, random.nextInt(4)));
BlocksHelper.setWithoutUpdate(world, blockPos, EndBlocks.BLUE_VINE_SEED.getDefaultState().with(EndPlantWithAgeBlock.AGE, random.nextInt(4)));
}
else {
PlantWithAgeBlock seed = ((PlantWithAgeBlock) EndBlocks.BLUE_VINE_SEED);
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.BLUE_VINE_SEED);
seed.growAdult(world, random, blockPos);
}
}

View file

@ -4,7 +4,7 @@ import java.util.Random;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.basis.PlantWithAgeBlock;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
public class GlowPillarFeature extends ScatterFeature {
@ -19,7 +19,7 @@ public class GlowPillarFeature extends ScatterFeature {
@Override
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
PlantWithAgeBlock seed = ((PlantWithAgeBlock) EndBlocks.GLOWING_PILLAR_SEED);
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.GLOWING_PILLAR_SEED);
seed.growAdult(world, random, blockPos);
}

View file

@ -4,7 +4,7 @@ import java.util.Random;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.basis.PlantWithAgeBlock;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.registry.EndBlocks;
public class LanceleafFeature extends ScatterFeature {
@ -19,7 +19,7 @@ public class LanceleafFeature extends ScatterFeature {
@Override
public void generate(StructureWorldAccess world, Random random, BlockPos blockPos) {
PlantWithAgeBlock seed = ((PlantWithAgeBlock) EndBlocks.LANCELEAF_SEED);
EndPlantWithAgeBlock seed = ((EndPlantWithAgeBlock) EndBlocks.LANCELEAF_SEED);
seed.growAdult(world, random, blockPos);
}

View file

@ -7,7 +7,7 @@ import net.minecraft.block.BlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.StructureWorldAccess;
import ru.betterend.blocks.basis.DoublePlantBlock;
import ru.betterend.blocks.basis.PlantWithAgeBlock;
import ru.betterend.blocks.basis.EndPlantWithAgeBlock;
import ru.betterend.util.BlocksHelper;
public class SinglePlantFeature extends ScatterFeature {
@ -56,9 +56,9 @@ public class SinglePlantFeature extends ScatterFeature {
BlocksHelper.setWithoutUpdate(world, blockPos, state);
BlocksHelper.setWithoutUpdate(world, blockPos.up(), state.with(DoublePlantBlock.TOP, true));
}
else if (plant instanceof PlantWithAgeBlock) {
else if (plant instanceof EndPlantWithAgeBlock) {
int age = random.nextInt(4);
BlockState state = plant.getDefaultState().with(PlantWithAgeBlock.AGE, age);
BlockState state = plant.getDefaultState().with(EndPlantWithAgeBlock.AGE, age);
BlocksHelper.setWithoutUpdate(world, blockPos, state);
}
else {

View file

@ -0,0 +1,8 @@
{
"variants": {
"age=0": { "model": "betterend:block/blossom_berry_seed_0" },
"age=1": { "model": "betterend:block/blossom_berry_seed_1" },
"age=2": { "model": "betterend:block/blossom_berry_seed_2" },
"age=3": { "model": "betterend:block/blossom_berry" }
}
}

View file

@ -550,5 +550,7 @@
"biome.betterend.eterial_grove": "Eterial Grove",
"block.betterend.umbrella_tree_sapling": "Umbrella Tree Sapling",
"item.betterend.umbrella_cluster_juice": "Umbrella Cluster Juice"
"item.betterend.umbrella_cluster_juice": "Umbrella Cluster Juice",
"block.betterend.blossom_berry_seed": "Blossom Berry Seed",
"item.betterend.blossom_berry": "Blossom Berry"
}

View file

@ -552,5 +552,7 @@
"biome.betterend.eterial_grove": "Эфирная роща",
"block.betterend.umbrella_tree_sapling": "Саженец зонтичного дерева",
"item.betterend.umbrella_cluster_juice": "Сок зонтичного кластера"
"item.betterend.umbrella_cluster_juice": "Сок зонтичного кластера",
"block.betterend.blossom_berry_seed": "Семя цветущей ягоды",
"item.betterend.blossom_berry": "Цветущая ягода"
}

View file

@ -0,0 +1,56 @@
{
"__comment": "Designed by Paulevs with Cubik Studio - https://cubik.studio",
"textures": {
"particle": "betterend:block/blossom_berry_flower",
"stem": "betterend:block/blossom_berry_stem",
"flower": "betterend:block/blossom_berry_flower",
"texture": "betterend:block/blossom_berry_fruit"
},
"elements": [
{
"__comment": "PlaneX1",
"from": [ 2.25, 0, 2.25 ],
"to": [ 2.251, 16, 18.25 ],
"rotation": { "origin": [ 2.25, 0, 2.25 ], "axis": "y", "angle": 45 },
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#stem" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#stem" }
}
},
{
"__comment": "PlaneX1",
"from": [ 13.75, 0, 2.25 ],
"to": [ 13.751, 16, 18.25 ],
"rotation": { "origin": [ 13.75, 0, 2.25 ], "axis": "y", "angle": -45 },
"shade": false,
"faces": {
"west": { "uv": [ 0, 0, 16, 16 ], "texture": "#stem" },
"east": { "uv": [ 0, 0, 16, 16 ], "texture": "#stem" }
}
},
{
"__comment": "PlaneY3",
"from": [ 0, 12, 0 ],
"to": [ 16, 12.001, 16 ],
"shade": false,
"faces": {
"down": { "uv": [ 0, 0, 16, 16 ], "texture": "#flower" },
"up": { "uv": [ 0, 0, 16, 16 ], "texture": "#flower" }
}
},
{
"__comment": "Box4",
"from": [ 5, 11, 5 ],
"to": [ 11, 17, 11 ],
"faces": {
"down": { "uv": [ 0, 0, 6, 6 ], "texture": "#texture" },
"up": { "uv": [ 0, 0, 6, 6 ], "texture": "#texture" },
"north": { "uv": [ 0, 0, 6, 6 ], "texture": "#texture" },
"south": { "uv": [ 0, 0, 6, 6 ], "texture": "#texture" },
"west": { "uv": [ 0, 0, 6, 6 ], "texture": "#texture" },
"east": { "uv": [ 0, 0, 6, 6 ], "texture": "#texture" }
}
}
]
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/cross_no_distortion",
"textures": {
"texture": "betterend:block/blossom_berry_seed_0"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/cross_no_distortion",
"textures": {
"texture": "betterend:block/blossom_berry_seed_1"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "betterend:block/cross_no_distortion",
"textures": {
"texture": "betterend:block/blossom_berry_seed_2"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "betterend:item/blossom_berry"
}
}

View file

@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "betterend:item/blossom_berry_seed"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 407 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 304 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B