Jellyshroom

This commit is contained in:
paulevsGitch 2020-12-25 11:09:46 +03:00
parent d52371cf97
commit 23a1bbba08
13 changed files with 477 additions and 2 deletions

View file

@ -0,0 +1,70 @@
package ru.betterend.blocks;
import java.util.EnumMap;
import java.util.List;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import net.fabricmc.fabric.api.object.builder.v1.block.FabricBlockSettings;
import net.fabricmc.fabric.api.tool.attribute.v1.FabricToolTags;
import net.minecraft.block.Block;
import net.minecraft.block.BlockState;
import net.minecraft.block.Material;
import net.minecraft.block.ShapeContext;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.loot.context.LootContext;
import net.minecraft.loot.context.LootContextParameters;
import net.minecraft.sound.BlockSoundGroup;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Direction;
import net.minecraft.util.shape.VoxelShape;
import net.minecraft.util.shape.VoxelShapes;
import net.minecraft.world.BlockView;
import ru.betterend.blocks.basis.BlockAttached;
import ru.betterend.client.render.ERenderLayer;
import ru.betterend.interfaces.IRenderTypeable;
public class BlockSmallJellyshroom extends BlockAttached implements IRenderTypeable {
private static final EnumMap<Direction, VoxelShape> BOUNDING_SHAPES = Maps.newEnumMap(Direction.class);
public BlockSmallJellyshroom() {
super(FabricBlockSettings.of(Material.PLANT)
.breakByTool(FabricToolTags.SHEARS)
.sounds(BlockSoundGroup.NETHER_WART)
.breakByHand(true)
.noCollision());
}
@Override
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, ShapeContext ePos) {
return BOUNDING_SHAPES.get(state.get(FACING));
}
@Override
public List<ItemStack> getDroppedStacks(BlockState state, LootContext.Builder builder) {
ItemStack tool = builder.get(LootContextParameters.TOOL);
if (tool != null && tool.getItem().isIn(FabricToolTags.SHEARS) || EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, tool) > 0) {
return Lists.newArrayList(new ItemStack(this));
}
else {
return Lists.newArrayList();
}
}
@Override
public ERenderLayer getRenderLayer() {
return ERenderLayer.CUTOUT;
}
static {
BOUNDING_SHAPES.put(Direction.UP, Block.createCuboidShape(3, 0, 3, 13, 16, 13));
BOUNDING_SHAPES.put(Direction.DOWN, VoxelShapes.cuboid(0.0, 0.5, 0.0, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.NORTH, VoxelShapes.cuboid(0.0, 0.0, 0.5, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.SOUTH, VoxelShapes.cuboid(0.0, 0.0, 0.0, 1.0, 1.0, 0.5));
BOUNDING_SHAPES.put(Direction.WEST, VoxelShapes.cuboid(0.5, 0.0, 0.0, 1.0, 1.0, 1.0));
BOUNDING_SHAPES.put(Direction.EAST, VoxelShapes.cuboid(0.0, 0.0, 0.0, 0.5, 1.0, 1.0));
}
}

View file

@ -58,6 +58,7 @@ import ru.betterend.blocks.BlockRespawnObelisk;
import ru.betterend.blocks.BlockShadowBerry;
import ru.betterend.blocks.BlockShadowGrass;
import ru.betterend.blocks.BlockSilkMothNest;
import ru.betterend.blocks.BlockSmallJellyshroom;
import ru.betterend.blocks.BlockSulphurCrystal;
import ru.betterend.blocks.BlockTenaneaFlowers;
import ru.betterend.blocks.BlockTenaneaSapling;
@ -209,6 +210,9 @@ public class EndBlocks {
public static final Block GLOWING_PILLAR_LUMINOPHOR = registerBlock("glowing_pillar_luminophor", new BlockGlowingPillarLuminophor());
public static final Block GLOWING_PILLAR_LEAVES = registerBlock("glowing_pillar_leaves", new BlockFur(GLOWING_PILLAR_SEED, 15, 3));
public static final Block SMALL_JELLYSHROOM = registerBlock("small_jellyshroom", new BlockSmallJellyshroom());
// Water plants
public static final Block BUBBLE_CORAL = registerBlock("bubble_coral", new BlockBubbleCoral());
public static final Block MENGER_SPONGE = registerBlock("menger_sponge", new BlockMengerSponge());
public static final Block MENGER_SPONGE_WET = registerBlock("menger_sponge_wet", new BlockMengerSpongeWet());