diff --git a/src/main/java/ru/betterend/blocks/BlockBulbVine.java b/src/main/java/ru/betterend/blocks/BlockBulbVine.java new file mode 100644 index 00000000..0d0c470b --- /dev/null +++ b/src/main/java/ru/betterend/blocks/BlockBulbVine.java @@ -0,0 +1,32 @@ +package ru.betterend.blocks; + +import java.util.List; + +import com.google.common.collect.Lists; + +import net.minecraft.block.BlockState; +import net.minecraft.item.ItemStack; +import net.minecraft.loot.context.LootContext; +import ru.betterend.blocks.BlockProperties.TripleShape; +import ru.betterend.blocks.basis.BlockVine; +import ru.betterend.registry.EndItems; +import ru.betterend.util.MHelper; + +public class BlockBulbVine extends BlockVine { + public BlockBulbVine() { + super(15, true); + } + + @Override + public List getDroppedStacks(BlockState state, LootContext.Builder builder) { + if (state.get(SHAPE) == TripleShape.BOTTOM) { + return Lists.newArrayList(new ItemStack(EndItems.GLOWING_BULB)); + } + else if (MHelper.RANDOM.nextInt(8) == 0) { + return Lists.newArrayList(new ItemStack(EndItems.GLOWING_BULB)); + } + else { + return Lists.newArrayList(); + } + } +} diff --git a/src/main/java/ru/betterend/blocks/BlockBulbVineSeed.java b/src/main/java/ru/betterend/blocks/BlockBulbVineSeed.java new file mode 100644 index 00000000..c1b265e5 --- /dev/null +++ b/src/main/java/ru/betterend/blocks/BlockBulbVineSeed.java @@ -0,0 +1,34 @@ +package ru.betterend.blocks; + +import java.util.Random; + +import net.minecraft.block.BlockState; +import net.minecraft.tag.BlockTags; +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.BlockPlantWithAge; +import ru.betterend.registry.EndBlocks; +import ru.betterend.registry.EndTags; +import ru.betterend.util.BlocksHelper; + +public class BlockBulbVineSeed extends BlockPlantWithAge { + @Override + public boolean canPlaceAt(BlockState state, WorldView world, BlockPos pos) { + BlockState up = world.getBlockState(pos.up()); + return up.isIn(EndTags.GEN_TERRAIN) || up.isIn(BlockTags.LOGS) || up.isIn(BlockTags.LEAVES); + } + + @Override + public void growAdult(StructureWorldAccess world, Random random, BlockPos pos) { + int h = BlocksHelper.downRay(world, pos, random.nextInt(24)) - 1; + if (h > 2) { + BlocksHelper.setWithoutUpdate(world, pos, EndBlocks.BULB_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.TOP)); + for (int i = 1; i < h; i++) { + BlocksHelper.setWithoutUpdate(world, pos.down(i), EndBlocks.BULB_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.MIDDLE)); + } + BlocksHelper.setWithoutUpdate(world, pos.down(h), EndBlocks.BULB_VINE.getDefaultState().with(BlockProperties.TRIPLE_SHAPE, TripleShape.BOTTOM)); + } + } +} diff --git a/src/main/java/ru/betterend/registry/EndBlocks.java b/src/main/java/ru/betterend/registry/EndBlocks.java index 35261613..23c0dacc 100644 --- a/src/main/java/ru/betterend/registry/EndBlocks.java +++ b/src/main/java/ru/betterend/registry/EndBlocks.java @@ -15,6 +15,8 @@ import ru.betterend.blocks.BlockBlueVine; import ru.betterend.blocks.BlockBlueVineLantern; import ru.betterend.blocks.BlockBlueVineSeed; import ru.betterend.blocks.BlockBubbleCoral; +import ru.betterend.blocks.BlockBulbVine; +import ru.betterend.blocks.BlockBulbVineSeed; import ru.betterend.blocks.BlockChorusGrass; import ru.betterend.blocks.BlockDragonTreeSapling; import ru.betterend.blocks.BlockEndLily; @@ -164,7 +166,8 @@ public class EndBlocks { // Vines // public static final Block DENSE_VINE = registerBlock("dense_vine", new BlockVine(15, true)); public static final Block TWISTED_VINE = registerBlock("twisted_vine", new BlockVine()); - public static final Block BULB_VINE = registerBlock("bulb_vine", new BlockVine(15, true)); + public static final Block BULB_VINE_SEED = registerBlock("bulb_vine_seed", new BlockBulbVineSeed()); + public static final Block BULB_VINE = registerBlock("bulb_vine", new BlockBulbVine()); // Ores // public static final Block ENDER_ORE = registerBlock("ender_ore", new BlockOre(EndItems.ENDER_DUST, 1, 3, 5)); diff --git a/src/main/java/ru/betterend/registry/EndItems.java b/src/main/java/ru/betterend/registry/EndItems.java index 7aa57c29..fdf46167 100644 --- a/src/main/java/ru/betterend/registry/EndItems.java +++ b/src/main/java/ru/betterend/registry/EndItems.java @@ -57,6 +57,7 @@ public class EndItems { public final static Item CRYSTAL_SHARDS = registerItem("crystal_shards"); public final static Item RAW_AMBER = registerItem("raw_amber"); public final static Item AMBER_GEM = registerItem("amber_gem"); + public final static Item GLOWING_BULB = registerItem("glowing_bulb"); // Armor // public static final Item TERMINITE_HELMET = registerItem("terminite_helmet", new ArmorItem(EndArmorMaterial.TERMINITE, EquipmentSlot.HEAD, makeSettings())); diff --git a/src/main/resources/assets/betterend/materialmaps/block/bulb_vine.json b/src/main/resources/assets/betterend/materialmaps/block/bulb_vine.json index 5f0f0cee..8eddb398 100644 --- a/src/main/resources/assets/betterend/materialmaps/block/bulb_vine.json +++ b/src/main/resources/assets/betterend/materialmaps/block/bulb_vine.json @@ -3,11 +3,15 @@ "spriteMap": [ { "sprite": "betterend:block/bulb_vine", - "material": "betterend:glow_inc" + "material": "betterend:waving_glow_inc" }, { "sprite": "betterend:block/bulb_vine_middle", "material": "betterend:waving" + }, + { + "sprite": "betterend:block/bulb_vine_fur", + "material": "betterend:waving" } ] } diff --git a/src/main/resources/assets/betterend/materials/waving_glow_inc.json b/src/main/resources/assets/betterend/materials/waving_glow_inc.json new file mode 100644 index 00000000..27dea5e5 --- /dev/null +++ b/src/main/resources/assets/betterend/materials/waving_glow_inc.json @@ -0,0 +1,10 @@ +{ + "layers": [ + { + "vertexSource": "betterend:shaders/material/wave.vert", + "fragmentSource": "betterend:shaders/material/glow_inc.frag", + "disableAo": true, + "disableDiffuse": true + } + ] +} diff --git a/src/main/resources/assets/betterend/models/item/glowing_bulb.json b/src/main/resources/assets/betterend/models/item/glowing_bulb.json new file mode 100644 index 00000000..a9f2eace --- /dev/null +++ b/src/main/resources/assets/betterend/models/item/glowing_bulb.json @@ -0,0 +1,6 @@ +{ + "parent": "item/generated", + "textures": { + "layer0": "betterend:item/glowing_bulb" + } +} diff --git a/src/main/resources/assets/betterend/textures/item/glowing_bulb.png b/src/main/resources/assets/betterend/textures/item/glowing_bulb.png new file mode 100644 index 00000000..1b3d0fac Binary files /dev/null and b/src/main/resources/assets/betterend/textures/item/glowing_bulb.png differ