Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.mcreator.thebeginning2;
- import net.minecraftforge.fml.relauncher.SideOnly;
- import net.minecraftforge.fml.relauncher.Side;
- import net.minecraft.world.World;
- import net.minecraft.world.IBlockAccess;
- import net.minecraft.util.math.BlockPos;
- import net.minecraft.util.math.AxisAlignedBB;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.util.BlockRenderLayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.entity.Entity;
- import net.minecraft.creativetab.CreativeTabs;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.block.state.BlockStateContainer;
- import net.minecraft.block.state.BlockFaceShape;
- import net.minecraft.block.properties.PropertyBool;
- import net.minecraft.block.properties.IProperty;
- import net.minecraft.block.material.Material;
- import net.minecraft.block.material.MapColor;
- import net.minecraft.block.SoundType;
- import net.minecraft.block.Block;
- import net.mcreator.thebeginning2.MCreatorIcestone;
- import javax.annotation.Nullable;
- import java.util.List;
- @Elementsthebeginning2.ModElement.Tag
- public class MCreatorDynamicmodel extends Block {
- public static final PropertyBool NORTH = PropertyBool.create("north");
- public static final PropertyBool EAST = PropertyBool.create("east");
- public static final PropertyBool SOUTH = PropertyBool.create("south");
- public static final PropertyBool WEST = PropertyBool.create("west");
- public static final PropertyBool UP = PropertyBool.create("up");
- public static final PropertyBool DOWN = PropertyBool.create("down");
- protected MCreatorDynamicmodel() {
- super(Material.PLANTS, MapColor.PURPLE);
- setRegistryName("dynamicmodel");
- setUnlocalizedName("dynamicmodel");
- setSoundType(SoundType.STONE);
- this.setCreativeTab(CreativeTabs.DECORATIONS);
- this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false))
- .withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)).withProperty(UP, Boolean.valueOf(false))
- .withProperty(DOWN, Boolean.valueOf(false)));
- }
- /**
- * Get the actual Block state of this Block at the given position. This
- * applies properties not visible in the metadata, such as fence
- * connections.
- */
- public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
- Block block = worldIn.getBlockState(pos.down()).getBlock();
- Block block1 = worldIn.getBlockState(pos.up()).getBlock();
- Block block2 = worldIn.getBlockState(pos.north()).getBlock();
- Block block3 = worldIn.getBlockState(pos.east()).getBlock();
- Block block4 = worldIn.getBlockState(pos.south()).getBlock();
- Block block5 = worldIn.getBlockState(pos.west()).getBlock();
- return state.withProperty(DOWN, Boolean.valueOf(block == this || block == Blocks.CHORUS_FLOWER || block == Blocks.END_STONE || block == MCreatorIcestone.block))
- .withProperty(UP, Boolean.valueOf(block1 == this || block1 == Blocks.CHORUS_FLOWER || block1 == MCreatorIcestone.block))
- .withProperty(NORTH, Boolean.valueOf(block2 == this || block2 == Blocks.CHORUS_FLOWER || block2 == MCreatorIcestone.block))
- .withProperty(EAST, Boolean.valueOf(block3 == this || block3 == Blocks.CHORUS_FLOWER || block3 == MCreatorIcestone.block))
- .withProperty(SOUTH, Boolean.valueOf(block4 == this || block4 == Blocks.CHORUS_FLOWER || block4 == MCreatorIcestone.block))
- .withProperty(WEST, Boolean.valueOf(block5 == this || block5 == Blocks.CHORUS_FLOWER || block5 == MCreatorIcestone.block));
- }
- public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
- state = state.getActualState(source, pos);
- float f = 0.1875F;
- float f1 = ((Boolean) state.getValue(WEST)).booleanValue() ? 0.0F : 0.375F;
- float f2 = ((Boolean) state.getValue(DOWN)).booleanValue() ? 0.0F : 0.375F;
- float f3 = ((Boolean) state.getValue(NORTH)).booleanValue() ? 0.0F : 0.375F;
- float f4 = ((Boolean) state.getValue(EAST)).booleanValue() ? 1.0F : 0.625F;
- float f5 = ((Boolean) state.getValue(UP)).booleanValue() ? 1.0F : 0.625F;
- float f6 = ((Boolean) state.getValue(SOUTH)).booleanValue() ? 1.0F : 0.625F;
- return new AxisAlignedBB((double) f1, (double) f2, (double) f3, (double) f4, (double) f5, (double) f6);
- }
- public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes,
- @Nullable Entity entityIn, boolean isActualState) {
- if (!isActualState) {
- state = state.getActualState(worldIn, pos);
- }
- float f = 0.375F;
- float f1 = 0.625F;
- addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.375D, 0.375D, 0.375D, 0.625D, 0.625D, 0.625D));
- if (((Boolean) state.getValue(WEST)).booleanValue()) {
- addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.0D, 0.375D, 0.375D, 0.375D, 0.625D, 0.625D));
- }
- if (((Boolean) state.getValue(EAST)).booleanValue()) {
- addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.625D, 0.375D, 0.375D, 1.0D, 0.625D, 0.625D));
- }
- if (((Boolean) state.getValue(UP)).booleanValue()) {
- addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.375D, 0.625D, 0.375D, 0.625D, 1.0D, 0.625D));
- }
- if (((Boolean) state.getValue(DOWN)).booleanValue()) {
- addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 0.375D, 0.625D));
- }
- if (((Boolean) state.getValue(NORTH)).booleanValue()) {
- addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.375D, 0.375D, 0.0D, 0.625D, 0.625D, 0.375D));
- }
- if (((Boolean) state.getValue(SOUTH)).booleanValue()) {
- addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.375D, 0.375D, 0.625D, 0.625D, 0.625D, 1.0D));
- }
- }
- public int getMetaFromState(IBlockState state) {
- return 0;
- }
- public boolean isFullCube(IBlockState state) {
- return false;
- }
- public boolean isOpaqueCube(IBlockState state) {
- return false;
- }
- @SideOnly(Side.CLIENT)
- public BlockRenderLayer getBlockLayer() {
- return BlockRenderLayer.CUTOUT;
- }
- protected BlockStateContainer createBlockState() {
- return new BlockStateContainer(this, new IProperty[]{NORTH, EAST, SOUTH, WEST, UP, DOWN});
- }
- @SideOnly(Side.CLIENT)
- public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
- Block block = blockAccess.getBlockState(pos.offset(side)).getBlock();
- return block != this && block != Blocks.CHORUS_FLOWER && (side != EnumFacing.DOWN || block != Blocks.END_STONE);
- }
- public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
- return BlockFaceShape.UNDEFINED;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement