Guest User

Untitled

a guest
Feb 15th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.42 KB | None | 0 0
  1. ackage com.caledios.conveyortubes.block.pipe;
  2.  
  3. import java.io.IOException;
  4. import java.util.List;
  5.  
  6. import net.minecraft.block.Block;
  7. import net.minecraft.block.ITileEntityProvider;
  8. import net.minecraft.block.material.Material;
  9. import net.minecraft.block.properties.IProperty;
  10. import net.minecraft.block.state.BlockState;
  11. import net.minecraft.block.state.IBlockState;
  12. import net.minecraft.creativetab.CreativeTabs;
  13. import net.minecraft.entity.player.EntityPlayer;
  14. import net.minecraft.tileentity.TileEntity;
  15. import net.minecraft.util.BlockPos;
  16. import net.minecraft.util.EnumFacing;
  17. import net.minecraft.util.ResourceLocation;
  18. import net.minecraft.world.IBlockAccess;
  19. import net.minecraft.world.World;
  20. import net.minecraftforge.client.model.IModel;
  21. import net.minecraftforge.client.model.ModelLoaderRegistry;
  22. import net.minecraftforge.client.model.obj.OBJModel;
  23. import net.minecraftforge.client.model.obj.OBJModel.OBJBakedModel;
  24. import net.minecraftforge.common.property.ExtendedBlockState;
  25. import net.minecraftforge.common.property.IExtendedBlockState;
  26. import net.minecraftforge.common.property.IUnlistedProperty;
  27.  
  28. import com.caledios.conveyortubes.ModConveyorTubes;
  29. import com.caledios.conveyortubes.tileentity.TileBasicPipe;
  30. import com.caledios.conveyortubes.util.ClientUtils;
  31. import com.google.common.collect.Lists;
  32.  
  33. public class BlockCTPipe extends Block implements ITileEntityProvider{
  34.    
  35.     public static final String name = "tube_model";
  36.     private ExtendedBlockState state = new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[]{OBJModel.OBJProperty.instance});
  37.  
  38.  
  39.    
  40.     public BlockCTPipe(){
  41.         super(Material.iron);
  42.         this.setUnlocalizedName(ModConveyorTubes.MODID + ":" + name);
  43.         this.setCreativeTab(CreativeTabs.tabBlock);
  44.     }
  45.    
  46.     private List<String> checkConnections(IBlockAccess world, BlockPos pos){
  47.         List<String> connections = Lists.newArrayList("CENTER");
  48.         if (world.getBlockState(pos.north()) != null && !world.isAirBlock(pos.north())) connections.add("NORTH");
  49.         if (world.getBlockState(pos.south()) != null && !world.isAirBlock(pos.south())) connections.add("SOUTH");
  50.         if (world.getBlockState(pos.east()) != null && !world.isAirBlock(pos.east())) connections.add("EAST");
  51.         if (world.getBlockState(pos.west()) != null && !world.isAirBlock(pos.west())) connections.add("WEST");
  52.         if (world.getBlockState(pos.up()) != null && !world.isAirBlock(pos.up())) connections.add("UP");
  53.         if (world.getBlockState(pos.down()) != null && !world.isAirBlock(pos.down())) connections.add("DOWN");
  54.         return connections;
  55.     }
  56.  
  57.     @Override
  58.     public TileEntity createNewTileEntity(World worldIn, int meta) {
  59.         return new TileBasicPipe();
  60.     }
  61.  
  62.     @Override
  63.     public boolean isVisuallyOpaque() {return false;}
  64.  
  65.     @Override
  66.     public boolean isFullCube() {return false;}
  67.    
  68.     @Override
  69.     public boolean isOpaqueCube()  {return false;}
  70.    
  71.     @Override
  72.     public IBlockState getExtendedState(IBlockState state, IBlockAccess world, BlockPos pos){
  73.         OBJModel.OBJState objState = (new OBJModel.OBJState(this.checkConnections(world, pos), true));
  74.         return ((IExtendedBlockState) this.state.getBaseState()).withProperty(OBJModel.OBJProperty.instance, objState);
  75.     }
  76.  
  77.     @Override
  78.     protected BlockState createBlockState() {
  79.         return new ExtendedBlockState(this, new IProperty[0], new IUnlistedProperty[]{OBJModel.OBJProperty.instance});
  80.     }
  81.  
  82.     @Override
  83.     public boolean hasTileEntity(IBlockState state)
  84.     {
  85.         return true;
  86.     }
  87. }
Advertisement
Add Comment
Please, Sign In to add comment