use of net.minecraft.block.state.IBlockState in project Railcraft by Railcraft.
the class BlockPostMetal method getState.
@Override
public IBlockState getState(@Nullable IVariantEnum variant) {
IBlockState state = getDefaultState();
if (variant != null) {
checkVariant(variant);
state = state.withProperty(COLOR, (EnumColor) variant);
}
return state;
}
use of net.minecraft.block.state.IBlockState in project Railcraft by Railcraft.
the class GeneratorMine method getGen.
@Nullable
private static WorldGenerator getGen(@Nullable IBlockState ore, int density) {
Predicate<IBlockState> genCheck = state -> RailcraftConfig.isWorldGenEnabled("sky") ? GenTools.AIR_STONE.test(state) : GenTools.STONE.test(state);
WorldGenerator gen;
if (ore == null)
gen = null;
else if (density >= 4)
gen = new WorldGenMinable(ore, density, genCheck::test);
else
gen = new WorldGenSmallDeposits(ore, density, genCheck);
return gen;
}
use of net.minecraft.block.state.IBlockState in project Railcraft by Railcraft.
the class IRailcraftItemBlock method getModelLocation.
@SideOnly(Side.CLIENT)
default default ModelResourceLocation getModelLocation(IBlockState state) {
StateMapperBase stateMapper = null;
if (state.getBlock() instanceof IRailcraftBlock)
stateMapper = ((IRailcraftBlock) state.getBlock()).getStateMapper();
if (stateMapper == null)
return new ModelResourceLocation(state.getBlock().getRegistryName(), new DefaultStateMapper().getPropertyString(state.getProperties()));
Map<IBlockState, ModelResourceLocation> stateMap = stateMapper.putStateModelLocations(state.getBlock());
return stateMap.get(state);
}
use of net.minecraft.block.state.IBlockState in project Railcraft by Railcraft.
the class ItemTunnelBore method onItemUse.
@Override
public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
IBlockState existingState = WorldPlugin.getBlockState(world, pos);
if (TrackTools.isRailBlock(existingState)) {
if (Game.isHost(world) && !CartToolsAPI.isMinecartAt(world, pos, 0)) {
BlockRailBase.EnumRailDirection trackShape = TrackTools.getTrackDirection(world, pos, existingState);
if (TrackShapeHelper.isLevelStraight(trackShape)) {
EnumFacing playerFacing = MiscTools.getHorizontalSideFacingPlayer(player).getOpposite();
if (trackShape == BlockRailBase.EnumRailDirection.NORTH_SOUTH) {
if (playerFacing == EnumFacing.WEST)
playerFacing = EnumFacing.NORTH;
else if (playerFacing == EnumFacing.EAST)
playerFacing = EnumFacing.SOUTH;
} else if (trackShape == BlockRailBase.EnumRailDirection.EAST_WEST) {
if (playerFacing == EnumFacing.SOUTH)
playerFacing = EnumFacing.EAST;
else if (playerFacing == EnumFacing.NORTH)
playerFacing = EnumFacing.WEST;
}
// System.out.println("PlayerYaw = " + playerYaw + " Yaw = " + facing + " Meta = " + meta);
EntityMinecart bore = new EntityTunnelBore(world, (float) pos.getX() + 0.5F, (float) pos.getY(), (float) pos.getZ() + 0.5F, playerFacing);
CartToolsAPI.setCartOwner(bore, player);
world.spawnEntityInWorld(bore);
}
}
stack.stackSize--;
return EnumActionResult.SUCCESS;
} else {
return EnumActionResult.FAIL;
}
}
use of net.minecraft.block.state.IBlockState in project Railcraft by Railcraft.
the class TileRockCrusher method placeRockCrusher.
public static void placeRockCrusher(World world, BlockPos pos, int patternIndex, List<ItemStack> input, List<ItemStack> output) {
MultiBlockPattern pattern = TileRockCrusher.patterns.get(patternIndex);
Map<Character, IBlockState> blockMapping = new HashMap<Character, IBlockState>();
IBlockState state = EnumMachineAlpha.ROCK_CRUSHER.getDefaultState();
blockMapping.put('B', state);
blockMapping.put('D', state);
blockMapping.put('a', state);
blockMapping.put('b', state);
blockMapping.put('c', state);
blockMapping.put('d', state);
blockMapping.put('e', state);
blockMapping.put('f', state);
blockMapping.put('h', state);
TileEntity tile = pattern.placeStructure(world, pos, blockMapping);
if (tile instanceof TileRockCrusher) {
TileRockCrusher master = (TileRockCrusher) tile;
for (int slot = 0; slot < 9; slot++) {
if (input != null && slot < input.size())
master.inv.setInventorySlotContents(TileRockCrusher.SLOT_INPUT + slot, input.get(slot));
if (output != null && slot < output.size())
master.inv.setInventorySlotContents(TileRockCrusher.SLOT_OUTPUT + slot, output.get(slot));
}
}
}
Aggregations