-
-
Save UltraTechX/ed19605d8b0b241ff1e7 to your computer and use it in GitHub Desktop.
the minecraft code that crashed:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package tutorial.generic; | |
import net.minecraft.block.Block; | |
import net.minecraft.block.BlockRail; | |
import net.minecraft.block.BlockRailBase; | |
import net.minecraft.block.ITileEntityProvider; | |
import net.minecraft.block.material.Material; | |
import net.minecraft.block.properties.IProperty; | |
import net.minecraft.block.properties.PropertyEnum; | |
import net.minecraft.block.state.BlockState; | |
import net.minecraft.block.state.IBlockState; | |
import net.minecraft.creativetab.CreativeTabs; | |
import net.minecraft.entity.EntityLivingBase; | |
import net.minecraft.item.ItemStack; | |
import net.minecraft.tileentity.TileEntity; | |
import net.minecraft.util.AxisAlignedBB; | |
import net.minecraft.util.BlockPos; | |
import net.minecraft.util.IStringSerializable; | |
import net.minecraft.world.IBlockAccess; | |
import net.minecraft.world.World; | |
import net.minecraftforge.fml.common.registry.GameRegistry; | |
import net.minecraftforge.fml.relauncher.Side; | |
import net.minecraftforge.fml.relauncher.SideOnly; | |
public class railControlBlock extends BlockRail implements ITileEntityProvider { | |
public static final PropertyEnum PART = PropertyEnum.create("part", EnumPartType.class); | |
public static final PropertyEnum SHAPE = PropertyEnum.create("shape", BlockRailBase.EnumRailDirection.class); | |
private static String name = "railControlBlock"; | |
private int part; | |
public railControlBlock(int pnum) { | |
super(); | |
GameRegistry.registerTileEntity(railControl.class, name); | |
if(pnum == 0) { | |
setDefaultState(this.blockState.getBaseState().withProperty(PART, EnumPartType.MIDDLE).withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH)); | |
this.part = 0; | |
}else if(pnum == 1){ | |
setDefaultState(this.blockState.getBaseState().withProperty(PART, EnumPartType.LEFT).withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH)); | |
}else if(pnum == 2){ | |
setDefaultState(this.blockState.getBaseState().withProperty(PART, EnumPartType.RIGHT).withProperty(SHAPE, BlockRailBase.EnumRailDirection.NORTH_SOUTH)); | |
} | |
GameRegistry.registerBlock(this, name); | |
this.setCreativeTab(CreativeTabs.tabMisc); | |
this.setUnlocalizedName(name); | |
this.setHardness(2.0f); | |
setBlockBounds(); | |
this.setResistance(6.0f); | |
this.setHarvestLevel("pickaxe", 2); | |
this.isBlockContainer = true; | |
} | |
@Override | |
public String toString() { | |
return getName(); | |
} | |
@Override | |
public TileEntity createNewTileEntity(World worldIn, int meta) { | |
return new railControl(); | |
} | |
public static String getName(){ | |
return name; | |
} | |
@SideOnly(Side.CLIENT) | |
public AxisAlignedBB getSelectedBoundingBox(World worldIn, BlockPos pos) | |
{ | |
setBlockBoundsBasedOnState(worldIn, pos); | |
return super.getSelectedBoundingBox(worldIn, pos); | |
} | |
public IProperty getShapeProperty() | |
{ | |
return SHAPE; | |
} | |
public IProperty getPartProperty() | |
{ | |
return PART; | |
} | |
public IBlockState getStateFromMeta(int meta) | |
{ | |
return getDefaultState().withProperty(PART, EnumPartType.byMetadata(meta)).withProperty(SHAPE, BlockRailBase.EnumRailDirection.byMetadata(meta)); | |
} | |
@Override | |
public void setBlockBoundsBasedOnState(IBlockAccess worldIn, BlockPos pos) | |
{ | |
setBlockBounds(); | |
} | |
private void setBlockBounds() | |
{ | |
setBlockBounds(0F, 0.0F, 0F, 1F, 0.125F, 1F); | |
} | |
public int getMetaFromState(IBlockState state) | |
{ | |
return ((BlockRailBase.EnumRailDirection)state.getValue(SHAPE)).getMetadata(); | |
} | |
@Override | |
public IBlockState getActualState(IBlockState state, IBlockAccess worldIn, BlockPos pos) | |
/* */ { | |
return state.withProperty(PART, this.part); | |
} | |
protected BlockState createBlockState() | |
{ | |
return new BlockState(this, new IProperty[] { PART, SHAPE }); | |
} | |
public boolean isOpaqueCube() | |
{ | |
return false; | |
} | |
/** | |
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc) | |
*/ | |
public boolean renderAsNormalBlock() | |
{ | |
return false; | |
} | |
public int getRenderBlockPass() | |
{ | |
return 1; | |
} | |
protected void onNeighborChangedInternal(World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) | |
{ | |
//whenever the blocks around it change | |
} | |
public static enum EnumPartType | |
implements IStringSerializable | |
{ | |
MIDDLE(0, "middle"), | |
LEFT(1, "left"), | |
RIGHT(2, "right"); | |
private static final EnumPartType[] META_LOOKUP = new EnumPartType[values().length]; | |
private final int meta; | |
private final String name; | |
private EnumPartType(int meta, String name) | |
{ | |
this.meta = meta; | |
this.name = name; | |
} | |
public int getMetadata() | |
{ | |
return this.meta; | |
} | |
public String toString() | |
{ | |
return this.name; | |
} | |
public String getName() | |
{ | |
return this.name; | |
} | |
public static EnumPartType byMetadata(int meta) | |
{ | |
if (meta < 0 || meta >= META_LOOKUP.length) | |
{ | |
meta = 0; | |
} | |
return META_LOOKUP[meta]; | |
} | |
static | |
{ | |
EnumPartType[] var0 = values(); | |
int var1 = var0.length; | |
for (int var2 = 0; var2 < var1; ++var2) | |
{ | |
EnumPartType var3 = var0[var2]; | |
META_LOOKUP[var3.getMetadata()] = var3; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment