Search in sources :

Example 1 with BlockPanelLighting

use of micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting in project Galacticraft by micdoodle8.

the class BlockPanelLighting method onUseWrench.

@Override
public boolean onUseWrench(World world, BlockPos pos, EntityPlayer entityPlayer, EnumFacing side, float hitX, float hitY, float hitZ) {
    TileEntity tile = world.getTileEntity(pos);
    if (!(tile instanceof TileEntityPanelLight)) {
        return false;
    }
    IBlockState bs = world.getBlockState(pos);
    if (!(bs.getBlock() instanceof BlockPanelLighting)) {
        return false;
    }
    PanelType type = (PanelType) bs.getValue(BlockPanelLighting.TYPE);
    TileEntityPanelLight tilegood = (TileEntityPanelLight) tile;
    int metadata = tilegood.meta;
    if (metadata < 8 && (type == PanelType.LINEAR || type == PanelType.SF) || metadata < 24 && type == PanelType.SFDIAG) {
        tilegood.meta += 8;
        return true;
    }
    int metaDir = ((metadata & 7) + 1) % 6;
    // 0->1 1->2 2->5 3->4 4->0 5->3
    if (// after north
    metaDir == 3) {
        metaDir = 5;
    } else if (metaDir == 0) {
        metaDir = 3;
    } else if (metaDir == 5) {
        metaDir = 0;
    }
    tilegood.meta = metaDir;
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IBlockState(net.minecraft.block.state.IBlockState) TileEntityPanelLight(micdoodle8.mods.galacticraft.core.tile.TileEntityPanelLight)

Example 2 with BlockPanelLighting

use of micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting in project Galacticraft by micdoodle8.

the class ItemBlockPanel method onItemUseFirst.

@Override
public EnumActionResult onItemUseFirst(EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
    if (!player.isSneaking()) {
        return EnumActionResult.PASS;
    }
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock().isOpaqueCube(state) && !(state.getBlock() instanceof BlockPanelLighting)) {
        ItemStack stack;
        if (hand == EnumHand.OFF_HAND) {
            stack = player.inventory.offHandInventory.get(0);
        } else {
            stack = player.inventory.getStackInSlot(player.inventory.currentItem);
        }
        if (stack.getItem() != this) {
            return EnumActionResult.FAIL;
        }
        if (world.isRemote) {
            BlockPanelLighting.updateClient(stack.getItemDamage(), state);
        } else {
            int meta = stack.getItemDamage();
            if (meta >= BlockPanelLighting.PANELTYPES_LENGTH)
                meta = 0;
            GCPlayerStats stats = GCPlayerStats.get(player);
            IBlockState[] panels = stats.getPanelLightingBases();
            panels[meta] = state;
        }
    }
    return EnumActionResult.PASS;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) ItemStack(net.minecraft.item.ItemStack) BlockPanelLighting(micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting)

Example 3 with BlockPanelLighting

use of micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting in project Galacticraft by micdoodle8.

the class ModelPanelLightBase method getQuads.

@Override
public List<BakedQuad> getQuads(IBlockState state, EnumFacing side, long rand) {
    if (state.getBlock() instanceof BlockPanelLighting) {
        IBlockState baseState = ((IExtendedBlockState) state).getValue(BlockPanelLighting.BASE_STATE);
        BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
        if (baseState == null) {
            if (layer == null || layer == BlockRenderLayer.SOLID) {
                return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelManager().getModel(this.callingBlock).getQuads(state, side, rand);
            }
        } else if (layer == null || baseState.getBlock().canRenderInLayer(baseState, layer)) {
            return Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(baseState).getQuads(baseState, side, rand);
        }
    }
    return ImmutableList.of();
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) IExtendedBlockState(net.minecraftforge.common.property.IExtendedBlockState) BlockRenderLayer(net.minecraft.util.BlockRenderLayer) BlockPanelLighting(micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting)

Example 4 with BlockPanelLighting

use of micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting in project Galacticraft by micdoodle8.

the class GCBlocks method initBlocks.

public static void initBlocks() {
    GCBlocks.breatheableAir = new BlockBreathableAir("breatheable_air");
    GCBlocks.brightAir = new BlockBrightAir("bright_air");
    GCBlocks.brightBreatheableAir = new BlockBrightBreathableAir("bright_breathable_air");
    GCBlocks.brightLamp = new BlockBrightLamp("arclamp");
    GCBlocks.treasureChestTier1 = new BlockTier1TreasureChest("treasure_chest");
    GCBlocks.landingPad = new BlockLandingPad("landing_pad");
    GCBlocks.landingPadFull = new BlockLandingPadFull("landing_pad_full");
    GCBlocks.unlitTorch = new BlockUnlitTorch(false, "unlit_torch");
    GCBlocks.unlitTorchLit = new BlockUnlitTorch(true, "unlit_torch_lit");
    GCBlocks.oxygenDistributor = new BlockOxygenDistributor("distributor");
    GCBlocks.oxygenPipe = new BlockFluidPipe("fluid_pipe", BlockFluidPipe.EnumPipeMode.NORMAL);
    GCBlocks.oxygenPipePull = new BlockFluidPipe("fluid_pipe_pull", BlockFluidPipe.EnumPipeMode.PULL);
    GCBlocks.oxygenCollector = new BlockOxygenCollector("collector");
    GCBlocks.nasaWorkbench = new BlockNasaWorkbench("rocket_workbench");
    GCBlocks.fallenMeteor = new BlockFallenMeteor("fallen_meteor");
    GCBlocks.basicBlock = new BlockBasic("basic_block_core");
    GCBlocks.airLockFrame = new BlockAirLockFrame("air_lock_frame");
    GCBlocks.airLockSeal = new BlockAirLockWall("air_lock_seal");
    // These glass types have to be registered as 6 separate blocks, (a) to allow different coloring of each one and (b) because the Forge MultiLayer custom model does not allow for different textures to be set for different variants
    GCBlocks.spaceGlassVanilla = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_vanilla", GlassType.VANILLA, GlassFrame.PLAIN, null).setHardness(0.3F).setResistance(3F);
    GCBlocks.spaceGlassClear = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_clear", GlassType.CLEAR, GlassFrame.PLAIN, null).setHardness(0.3F).setResistance(3F);
    GCBlocks.spaceGlassStrong = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_strong", GlassType.STRONG, GlassFrame.PLAIN, null).setHardness(4F).setResistance(35F);
    GCBlocks.spaceGlassTinVanilla = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_vanilla_tin", GlassType.VANILLA, GlassFrame.TIN_DECO, GCBlocks.spaceGlassVanilla).setHardness(0.3F).setResistance(4F);
    GCBlocks.spaceGlassTinClear = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_clear_tin", GlassType.CLEAR, GlassFrame.TIN_DECO, GCBlocks.spaceGlassClear).setHardness(0.3F).setResistance(4F);
    GCBlocks.spaceGlassTinStrong = (BlockSpaceGlass) new BlockSpaceGlass("space_glass_strong_tin", GlassType.STRONG, GlassFrame.TIN_DECO, GCBlocks.spaceGlassStrong).setHardness(4F).setResistance(35F);
    GCBlocks.crafting = new BlockCrafting("magnetic_table");
    GCBlocks.refinery = new BlockRefinery("refinery");
    GCBlocks.oxygenCompressor = new BlockOxygenCompressor(false, "oxygen_compressor");
    GCBlocks.fuelLoader = new BlockFuelLoader("fuel_loader");
    GCBlocks.spaceStationBase = new BlockSpaceStationBase("space_station_base");
    GCBlocks.fakeBlock = new BlockMulti("block_multi");
    GCBlocks.oxygenSealer = new BlockOxygenSealer("sealer");
    GCBlocks.sealableBlock = new BlockEnclosed("enclosed");
    GCBlocks.oxygenDetector = new BlockOxygenDetector("oxygen_detector");
    GCBlocks.cargoLoader = new BlockCargoLoader("cargo");
    GCBlocks.parachest = new BlockParaChest("parachest");
    GCBlocks.solarPanel = new BlockSolar("solar");
    GCBlocks.radioTelescope = new BlockDish("dishbase");
    GCBlocks.machineBase = new BlockMachine("machine");
    GCBlocks.machineBase2 = new BlockMachine2("machine2");
    GCBlocks.machineBase3 = new BlockMachine3("machine3");
    GCBlocks.machineBase4 = new BlockMachine4("machine4");
    GCBlocks.machineTiered = new BlockMachineTiered("machine_tiered");
    GCBlocks.aluminumWire = new BlockAluminumWire("aluminum_wire");
    GCBlocks.panelLighting = new BlockPanelLighting("panel_lighting");
    GCBlocks.glowstoneTorch = new BlockGlowstoneTorch("glowstone_torch");
    GCBlocks.blockMoon = new BlockBasicMoon("basic_block_moon");
    GCBlocks.cheeseBlock = new BlockCheese("cheese");
    GCBlocks.spinThruster = new BlockSpinThruster("spin_thruster");
    GCBlocks.screen = new BlockScreen("view_screen");
    GCBlocks.telemetry = new BlockTelemetry("telemetry");
    GCBlocks.fluidTank = new BlockFluidTank("fluid_tank");
    GCBlocks.bossSpawner = new BlockBossSpawner("boss_spawner");
    GCBlocks.slabGCHalf = new BlockSlabGC("slab_gc_half", Material.ROCK);
    GCBlocks.slabGCDouble = new BlockDoubleSlabGC("slab_gc_double", Material.ROCK);
    GCBlocks.tinStairs1 = new BlockStairsGC("tin_stairs_1", basicBlock.getDefaultState().withProperty(BlockBasic.BASIC_TYPE, BlockBasic.EnumBlockBasic.ALUMINUM_DECORATION_BLOCK_0)).setHardness(2.0F);
    GCBlocks.tinStairs2 = new BlockStairsGC("tin_stairs_2", basicBlock.getDefaultState().withProperty(BlockBasic.BASIC_TYPE, BlockBasic.EnumBlockBasic.ALUMINUM_DECORATION_BLOCK_1)).setHardness(2.0F);
    GCBlocks.moonStoneStairs = new BlockStairsGC("moon_stairs_stone", blockMoon.getDefaultState().withProperty(BlockBasicMoon.BASIC_TYPE_MOON, BlockBasicMoon.EnumBlockBasicMoon.MOON_STONE)).setHardness(1.5F);
    GCBlocks.moonBricksStairs = new BlockStairsGC("moon_stairs_brick", blockMoon.getDefaultState().withProperty(BlockBasicMoon.BASIC_TYPE_MOON, BlockBasicMoon.EnumBlockBasicMoon.MOON_DUNGEON_BRICK)).setHardness(4.0F);
    GCBlocks.wallGC = new BlockWallGC("wall_gc");
    GCBlocks.concealedRedstone = new BlockConcealedRedstone("concealed_redstone");
    GCBlocks.concealedRepeater_Powered = new BlockConcealedRepeater("concealed_repeater_pow", true);
    GCBlocks.concealedRepeater_Unpowered = new BlockConcealedRepeater("concealed_repeater", false);
    GCBlocks.concealedDetector = new BlockConcealedDetector("concealed_detector");
    GCBlocks.platform = new BlockPlatform("platform");
    GCBlocks.emergencyBox = new BlockEmergencyBox("emergency_box");
    GCBlocks.grating = new BlockGrating("grating", ConfigManagerCore.allowLiquidGratings ? Material.CARPET : Material.IRON);
    GCBlocks.gratingWater = new BlockGrating("grating1", Material.WATER);
    GCBlocks.gratingLava = new BlockGrating("grating2", Material.LAVA).setLightLevel(1.0F);
    // Hide certain items from NEI
    GCBlocks.hiddenBlocks.add(GCBlocks.airLockSeal);
    GCBlocks.hiddenBlocks.add(GCBlocks.oxygenPipePull);
    GCBlocks.hiddenBlocks.add(GCBlocks.unlitTorch);
    GCBlocks.hiddenBlocks.add(GCBlocks.unlitTorchLit);
    GCBlocks.hiddenBlocks.add(GCBlocks.landingPadFull);
    GCBlocks.hiddenBlocks.add(GCBlocks.spaceStationBase);
    GCBlocks.hiddenBlocks.add(GCBlocks.bossSpawner);
    GCBlocks.hiddenBlocks.add(GCBlocks.slabGCDouble);
    GCBlocks.hiddenBlocks.add(GCBlocks.concealedRepeater_Powered);
    // Register blocks before register ores, so that the ItemStack picks up the correct item
    GCBlocks.registerBlocks();
    GCBlocks.setHarvestLevels();
}
Also used : EnumBlockBasicMoon(micdoodle8.mods.galacticraft.core.blocks.BlockBasicMoon.EnumBlockBasicMoon)

Example 5 with BlockPanelLighting

use of micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting in project Galacticraft by micdoodle8.

the class ItemBlockPanel method onItemUseFirst.

@Override
public boolean onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
    if (!player.isSneaking()) {
        return false;
    }
    IBlockState state = world.getBlockState(pos);
    if (state.getBlock().isOpaqueCube() && !(state.getBlock() instanceof BlockPanelLighting)) {
        if (world.isRemote) {
            BlockPanelLighting.updateClient(stack.getItemDamage(), state);
        } else {
            int meta = stack.getItemDamage();
            if (meta >= BlockPanelLighting.PANELTYPES_LENGTH)
                meta = 0;
            GCPlayerStats stats = GCPlayerStats.get(player);
            IBlockState[] panels = stats.getPanelLightingBases();
            panels[meta] = state;
        }
    }
    return false;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) BlockPanelLighting(micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting)

Aggregations

IBlockState (net.minecraft.block.state.IBlockState)5 BlockPanelLighting (micdoodle8.mods.galacticraft.core.blocks.BlockPanelLighting)3 TileEntityPanelLight (micdoodle8.mods.galacticraft.core.tile.TileEntityPanelLight)3 TileEntity (net.minecraft.tileentity.TileEntity)3 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)2 EnumBlockBasicMoon (micdoodle8.mods.galacticraft.core.blocks.BlockBasicMoon.EnumBlockBasicMoon)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 BlockRenderLayer (net.minecraft.util.BlockRenderLayer)1 IExtendedBlockState (net.minecraftforge.common.property.IExtendedBlockState)1