Search in sources :

Example 1 with BlockOreVanilla

use of com.oitsjustjose.geolosys.blocks.BlockOreVanilla in project Geolosys by oitsjustjose.

the class ItemProPick method onItemUse.

@Override
public EnumActionResult onItemUse(EntityPlayer player, World worldIn, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) {
    if (worldIn.isRemote) {
        player.swingArm(hand);
        return EnumActionResult.PASS;
    }
    int xStart;
    int xEnd;
    int yStart;
    int yEnd;
    int zStart;
    int zEnd;
    int confAmt = Config.getInstance().proPickRange;
    boolean found = false;
    switch(facing) {
        case UP:
            xStart = -(confAmt / 2);
            xEnd = confAmt / 2;
            yStart = -confAmt;
            yEnd = 0;
            zStart = -(confAmt / 2);
            zEnd = (confAmt / 2);
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
        case DOWN:
            xStart = -(confAmt / 2);
            xEnd = confAmt / 2;
            yStart = 0;
            yEnd = confAmt;
            zStart = -(confAmt / 2);
            zEnd = confAmt / 2;
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
        case NORTH:
            xStart = -(confAmt / 2);
            xEnd = confAmt / 2;
            yStart = -(confAmt / 2);
            yEnd = confAmt / 2;
            zStart = 0;
            zEnd = confAmt;
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
        case SOUTH:
            xStart = -(confAmt / 2);
            xEnd = confAmt / 2;
            yStart = -(confAmt / 2);
            yEnd = confAmt / 2;
            zStart = -confAmt;
            zEnd = 0;
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
        case EAST:
            xStart = -(confAmt);
            xEnd = 0;
            yStart = -(confAmt / 2);
            yEnd = confAmt / 2;
            zStart = -(confAmt / 2);
            zEnd = confAmt / 2;
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
        case WEST:
            xStart = 0;
            xEnd = confAmt;
            yStart = -(confAmt / 2);
            yEnd = confAmt / 2;
            zStart = -(confAmt / 2);
            zEnd = confAmt / 2;
            for (int x = xStart; x <= xEnd; x++) {
                for (int y = yStart; y <= yEnd; y++) {
                    for (int z = zStart; z <= zEnd; z++) {
                        IBlockState state = worldIn.getBlockState(pos.add(x, y, z));
                        if (state.getBlock() instanceof BlockOre || state.getBlock() instanceof BlockOreVanilla || Geolosys.getInstance().userStates.contains(state)) {
                            foundMessage(player, state, facing);
                            found = true;
                            break;
                        }
                    }
                }
            }
            break;
    }
    if (!found) {
        player.sendStatusMessage(new TextComponentString("No deposits found"), true);
    }
    player.swingArm(hand);
    return EnumActionResult.SUCCESS;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockOreVanilla(com.oitsjustjose.geolosys.blocks.BlockOreVanilla) BlockOre(com.oitsjustjose.geolosys.blocks.BlockOre) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 2 with BlockOreVanilla

use of com.oitsjustjose.geolosys.blocks.BlockOreVanilla in project Geolosys by oitsjustjose.

the class Geolosys method preInit.

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
    LOGGER = event.getModLog();
    MinecraftForge.EVENT_BUS.register(new Config(event.getSuggestedConfigurationFile()));
    configOres = getOresConfig(event.getModConfigurationDirectory());
    clientRegistry = new ClientRegistry();
    MinecraftForge.EVENT_BUS.register(clientRegistry);
    chunkOreGen = new ChunkData();
    userStates = new ArrayList<>();
    ORE = new BlockOre();
    ORE_VANILLA = new BlockOreVanilla();
    ORE_SAMPLE = new BlockSample();
    ORE_SAMPLE_VANILLA = new BlockSampleVanilla();
    CLUSTER = new ItemCluster();
    ALMANAC = new ItemFieldManual();
    if (Config.getInstance().enableIngots) {
        INGOT = new ItemIngot();
    }
    if (Config.getInstance().enableCoals) {
        COAL = new ItemCoal();
    }
    if (Config.getInstance().enableProPick) {
        PRO_PICK = new ItemProPick();
    }
    registerGeolosysOreGen();
    registerVanillaOreGen();
}
Also used : ChunkData(com.oitsjustjose.geolosys.world.ChunkData) BlockOre(com.oitsjustjose.geolosys.blocks.BlockOre) BlockSample(com.oitsjustjose.geolosys.blocks.BlockSample) BlockOreVanilla(com.oitsjustjose.geolosys.blocks.BlockOreVanilla) BlockSampleVanilla(com.oitsjustjose.geolosys.blocks.BlockSampleVanilla) EventHandler(net.minecraftforge.fml.common.Mod.EventHandler)

Aggregations

BlockOre (com.oitsjustjose.geolosys.blocks.BlockOre)2 BlockOreVanilla (com.oitsjustjose.geolosys.blocks.BlockOreVanilla)2 BlockSample (com.oitsjustjose.geolosys.blocks.BlockSample)1 BlockSampleVanilla (com.oitsjustjose.geolosys.blocks.BlockSampleVanilla)1 ChunkData (com.oitsjustjose.geolosys.world.ChunkData)1 IBlockState (net.minecraft.block.state.IBlockState)1 TextComponentString (net.minecraft.util.text.TextComponentString)1 EventHandler (net.minecraftforge.fml.common.Mod.EventHandler)1