Advertisement
Shadowmaster435

Untitled

Nov 18th, 2019
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.74 KB | None | 0 0
  1. package net.mcreator.thebeginning2;
  2.  
  3. import net.minecraftforge.fml.relauncher.SideOnly;
  4. import net.minecraftforge.fml.relauncher.Side;
  5.  
  6. import net.minecraft.world.World;
  7. import net.minecraft.world.IBlockAccess;
  8. import net.minecraft.util.math.BlockPos;
  9. import net.minecraft.util.math.AxisAlignedBB;
  10. import net.minecraft.util.EnumFacing;
  11. import net.minecraft.util.BlockRenderLayer;
  12. import net.minecraft.init.Blocks;
  13. import net.minecraft.entity.Entity;
  14. import net.minecraft.creativetab.CreativeTabs;
  15. import net.minecraft.block.state.IBlockState;
  16. import net.minecraft.block.state.BlockStateContainer;
  17. import net.minecraft.block.state.BlockFaceShape;
  18. import net.minecraft.block.properties.PropertyBool;
  19. import net.minecraft.block.properties.IProperty;
  20. import net.minecraft.block.material.Material;
  21. import net.minecraft.block.material.MapColor;
  22. import net.minecraft.block.SoundType;
  23. import net.minecraft.block.Block;
  24. import net.mcreator.thebeginning2.MCreatorIcestone;
  25.  
  26. import javax.annotation.Nullable;
  27.  
  28. import java.util.List;
  29.  
  30. @Elementsthebeginning2.ModElement.Tag
  31. public class MCreatorDynamicmodel extends Block {
  32. public static final PropertyBool NORTH = PropertyBool.create("north");
  33. public static final PropertyBool EAST = PropertyBool.create("east");
  34. public static final PropertyBool SOUTH = PropertyBool.create("south");
  35. public static final PropertyBool WEST = PropertyBool.create("west");
  36. public static final PropertyBool UP = PropertyBool.create("up");
  37. public static final PropertyBool DOWN = PropertyBool.create("down");
  38.  
  39. protected MCreatorDynamicmodel() {
  40. super(Material.PLANTS, MapColor.PURPLE);
  41. setRegistryName("dynamicmodel");
  42. setUnlocalizedName("dynamicmodel");
  43. setSoundType(SoundType.STONE);
  44. this.setCreativeTab(CreativeTabs.DECORATIONS);
  45. this.setDefaultState(this.blockState.getBaseState().withProperty(NORTH, Boolean.valueOf(false)).withProperty(EAST, Boolean.valueOf(false))
  46. .withProperty(SOUTH, Boolean.valueOf(false)).withProperty(WEST, Boolean.valueOf(false)).withProperty(UP, Boolean.valueOf(false))
  47. .withProperty(DOWN, Boolean.valueOf(false)));
  48. }
  49.  
  50. /**
  51. * Get the actual Block state of this Block at the given position. This
  52. * applies properties not visible in the metadata, such as fence
  53. * connections.
  54. */
  55. public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) {
  56. Block block = worldIn.getBlockState(pos.down()).getBlock();
  57. Block block1 = worldIn.getBlockState(pos.up()).getBlock();
  58. Block block2 = worldIn.getBlockState(pos.north()).getBlock();
  59. Block block3 = worldIn.getBlockState(pos.east()).getBlock();
  60. Block block4 = worldIn.getBlockState(pos.south()).getBlock();
  61. Block block5 = worldIn.getBlockState(pos.west()).getBlock();
  62. return state.withProperty(DOWN, Boolean.valueOf(block == this || block == Blocks.CHORUS_FLOWER || block == Blocks.END_STONE || block == MCreatorIcestone.block))
  63. .withProperty(UP, Boolean.valueOf(block1 == this || block1 == Blocks.CHORUS_FLOWER || block1 == MCreatorIcestone.block))
  64. .withProperty(NORTH, Boolean.valueOf(block2 == this || block2 == Blocks.CHORUS_FLOWER || block2 == MCreatorIcestone.block))
  65. .withProperty(EAST, Boolean.valueOf(block3 == this || block3 == Blocks.CHORUS_FLOWER || block3 == MCreatorIcestone.block))
  66. .withProperty(SOUTH, Boolean.valueOf(block4 == this || block4 == Blocks.CHORUS_FLOWER || block4 == MCreatorIcestone.block))
  67. .withProperty(WEST, Boolean.valueOf(block5 == this || block5 == Blocks.CHORUS_FLOWER || block5 == MCreatorIcestone.block));
  68. }
  69.  
  70. public AxisAlignedBB getBoundingBox(IBlockState state, IBlockAccess source, BlockPos pos) {
  71. state = state.getActualState(source, pos);
  72. float f = 0.1875F;
  73. float f1 = ((Boolean) state.getValue(WEST)).booleanValue() ? 0.0F : 0.375F;
  74. float f2 = ((Boolean) state.getValue(DOWN)).booleanValue() ? 0.0F : 0.375F;
  75. float f3 = ((Boolean) state.getValue(NORTH)).booleanValue() ? 0.0F : 0.375F;
  76. float f4 = ((Boolean) state.getValue(EAST)).booleanValue() ? 1.0F : 0.625F;
  77. float f5 = ((Boolean) state.getValue(UP)).booleanValue() ? 1.0F : 0.625F;
  78. float f6 = ((Boolean) state.getValue(SOUTH)).booleanValue() ? 1.0F : 0.625F;
  79. return new AxisAlignedBB((double) f1, (double) f2, (double) f3, (double) f4, (double) f5, (double) f6);
  80. }
  81.  
  82. public void addCollisionBoxToList(IBlockState state, World worldIn, BlockPos pos, AxisAlignedBB entityBox, List<AxisAlignedBB> collidingBoxes,
  83. @Nullable Entity entityIn, boolean isActualState) {
  84. if (!isActualState) {
  85. state = state.getActualState(worldIn, pos);
  86. }
  87. float f = 0.375F;
  88. float f1 = 0.625F;
  89. addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.375D, 0.375D, 0.375D, 0.625D, 0.625D, 0.625D));
  90. if (((Boolean) state.getValue(WEST)).booleanValue()) {
  91. addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.0D, 0.375D, 0.375D, 0.375D, 0.625D, 0.625D));
  92. }
  93. if (((Boolean) state.getValue(EAST)).booleanValue()) {
  94. addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.625D, 0.375D, 0.375D, 1.0D, 0.625D, 0.625D));
  95. }
  96. if (((Boolean) state.getValue(UP)).booleanValue()) {
  97. addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.375D, 0.625D, 0.375D, 0.625D, 1.0D, 0.625D));
  98. }
  99. if (((Boolean) state.getValue(DOWN)).booleanValue()) {
  100. addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.375D, 0.0D, 0.375D, 0.625D, 0.375D, 0.625D));
  101. }
  102. if (((Boolean) state.getValue(NORTH)).booleanValue()) {
  103. addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.375D, 0.375D, 0.0D, 0.625D, 0.625D, 0.375D));
  104. }
  105. if (((Boolean) state.getValue(SOUTH)).booleanValue()) {
  106. addCollisionBoxToList(pos, entityBox, collidingBoxes, new AxisAlignedBB(0.375D, 0.375D, 0.625D, 0.625D, 0.625D, 1.0D));
  107. }
  108. }
  109.  
  110. public int getMetaFromState(IBlockState state) {
  111. return 0;
  112. }
  113.  
  114. public boolean isFullCube(IBlockState state) {
  115. return false;
  116. }
  117.  
  118.  
  119. public boolean isOpaqueCube(IBlockState state) {
  120. return false;
  121. }
  122.  
  123. @SideOnly(Side.CLIENT)
  124. public BlockRenderLayer getBlockLayer() {
  125. return BlockRenderLayer.CUTOUT;
  126. }
  127.  
  128. protected BlockStateContainer createBlockState() {
  129. return new BlockStateContainer(this, new IProperty[]{NORTH, EAST, SOUTH, WEST, UP, DOWN});
  130. }
  131.  
  132. @SideOnly(Side.CLIENT)
  133. public boolean shouldSideBeRendered(IBlockState blockState, IBlockAccess blockAccess, BlockPos pos, EnumFacing side) {
  134. Block block = blockAccess.getBlockState(pos.offset(side)).getBlock();
  135. return block != this && block != Blocks.CHORUS_FLOWER && (side != EnumFacing.DOWN || block != Blocks.END_STONE);
  136. }
  137.  
  138. public BlockFaceShape getBlockFaceShape(IBlockAccess worldIn, IBlockState state, BlockPos pos, EnumFacing face) {
  139. return BlockFaceShape.UNDEFINED;
  140. }
  141. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement