Search in sources :

Example 56 with IBlockState

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;
}
Also used : EnumColor(mods.railcraft.common.plugins.color.EnumColor) IBlockState(net.minecraft.block.state.IBlockState)

Example 57 with IBlockState

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;
}
Also used : java.util(java.util) NoiseGenSimplex(mods.railcraft.common.worldgen.NoiseGen.NoiseGenSimplex) World(net.minecraft.world.World) Predicate(java.util.function.Predicate) EventType(net.minecraftforge.event.terraingen.OreGenEvent.GenerateMinable.EventType) Metal(mods.railcraft.common.items.Metal) BlockPos(net.minecraft.util.math.BlockPos) WorldGenMinable(net.minecraft.world.gen.feature.WorldGenMinable) IBlockState(net.minecraft.block.state.IBlockState) WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) BiomeDictionary(net.minecraftforge.common.BiomeDictionary) Type(net.minecraftforge.common.BiomeDictionary.Type) RailcraftConfig(mods.railcraft.common.core.RailcraftConfig) TerrainGen(net.minecraftforge.event.terraingen.TerrainGen) MapMaker(com.google.common.collect.MapMaker) Biome(net.minecraft.world.biome.Biome) Nullable(javax.annotation.Nullable) WorldGenerator(net.minecraft.world.gen.feature.WorldGenerator) IBlockState(net.minecraft.block.state.IBlockState) WorldGenMinable(net.minecraft.world.gen.feature.WorldGenMinable) Nullable(javax.annotation.Nullable)

Example 58 with IBlockState

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);
}
Also used : StateMapperBase(net.minecraft.client.renderer.block.statemap.StateMapperBase) DefaultStateMapper(net.minecraft.client.renderer.block.statemap.DefaultStateMapper) IBlockState(net.minecraft.block.state.IBlockState) ModelResourceLocation(net.minecraft.client.renderer.block.model.ModelResourceLocation) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 59 with IBlockState

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;
    }
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) EnumFacing(net.minecraft.util.EnumFacing) EntityMinecart(net.minecraft.entity.item.EntityMinecart) BlockRailBase(net.minecraft.block.BlockRailBase)

Example 60 with IBlockState

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));
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) MultiBlockPattern(mods.railcraft.common.blocks.machine.MultiBlockPattern)

Aggregations

IBlockState (net.minecraft.block.state.IBlockState)2979 BlockPos (net.minecraft.util.math.BlockPos)1194 Block (net.minecraft.block.Block)797 ItemStack (net.minecraft.item.ItemStack)517 EnumFacing (net.minecraft.util.EnumFacing)420 TileEntity (net.minecraft.tileentity.TileEntity)339 World (net.minecraft.world.World)255 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)171 EntityPlayer (net.minecraft.entity.player.EntityPlayer)136 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)126 ArrayList (java.util.ArrayList)125 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)121 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)95 Entity (net.minecraft.entity.Entity)94 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)93 ItemBlock (net.minecraft.item.ItemBlock)89 BlockPos (net.minecraft.util.BlockPos)84 Random (java.util.Random)82 Vec3d (net.minecraft.util.math.Vec3d)81 RayTraceResult (net.minecraft.util.math.RayTraceResult)76