Search in sources :

Example 1 with WireProperties

use of gregtech.common.pipelike.cable.WireProperties in project GregTech by GregTechCE.

the class MetaBlocks method init.

public static void init() {
    GregTechAPI.MACHINE = MACHINE = new BlockMachine();
    MACHINE.setRegistryName("machine");
    CABLE = new BlockCable();
    CABLE.setRegistryName("cable");
    FLUID_PIPE = new BlockFluidPipe();
    FLUID_PIPE.setRegistryName("fluid_pipe");
    BOILER_CASING = new BlockBoilerCasing();
    BOILER_CASING.setRegistryName("boiler_casing");
    BOILER_FIREBOX_CASING = new BlockFireboxCasing();
    BOILER_FIREBOX_CASING.setRegistryName("boiler_firebox_casing");
    METAL_CASING = new BlockMetalCasing();
    METAL_CASING.setRegistryName("metal_casing");
    TURBINE_CASING = new BlockTurbineCasing();
    TURBINE_CASING.setRegistryName("turbine_casing");
    MACHINE_CASING = new BlockMachineCasing();
    MACHINE_CASING.setRegistryName("machine_casing");
    MUTLIBLOCK_CASING = new BlockMultiblockCasing();
    MUTLIBLOCK_CASING.setRegistryName("multiblock_casing");
    WIRE_COIL = new BlockWireCoil();
    WIRE_COIL.setRegistryName("wire_coil");
    WARNING_SIGN = new BlockWarningSign();
    WARNING_SIGN.setRegistryName("warning_sign");
    GRANITE = new BlockGranite();
    GRANITE.setRegistryName("granite");
    MINERAL = new BlockMineral();
    MINERAL.setRegistryName("mineral");
    CONCRETE = new BlockConcrete();
    CONCRETE.setRegistryName("concrete");
    FOAM = new BlockFoam(false);
    FOAM.setRegistryName("foam");
    REINFORCED_FOAM = new BlockFoam(true);
    REINFORCED_FOAM.setRegistryName("reinforced_foam");
    PETRIFIED_FOAM = new BlockPetrifiedFoam(false);
    PETRIFIED_FOAM.setRegistryName("petrified_foam");
    REINFORCED_PETRIFIED_FOAM = new BlockPetrifiedFoam(true);
    REINFORCED_PETRIFIED_FOAM.setRegistryName("reinforced_petrified_foam");
    LOG = new BlockGregLog();
    LOG.setRegistryName("log");
    LEAVES = new BlockGregLeaves();
    LEAVES.setRegistryName("leaves");
    SAPLING = new BlockGregSapling();
    SAPLING.setRegistryName("sapling");
    CRUSHER_BLADE = new BlockCrusherBlade();
    CRUSHER_BLADE.setRegistryName("crusher_blade");
    SURFACE_ROCK_NEW = new BlockSurfaceRockNew();
    SURFACE_ROCK_NEW.setRegistryName("surface_rock_new");
    StoneType.init();
    createGeneratedBlock(material -> material instanceof DustMaterial && !OrePrefix.block.isIgnored(material), MetaBlocks::createCompressedBlock);
    createGeneratedBlock(material -> material instanceof IngotMaterial && material.hasFlag(MatFlags.GENERATE_ORE), MetaBlocks::createSurfaceRockBlock);
    for (Material material : Material.MATERIAL_REGISTRY) {
        if (material instanceof DustMaterial && material.hasFlag(DustMaterial.MatFlags.GENERATE_ORE)) {
            createOreBlock((DustMaterial) material);
        }
        if (material instanceof SolidMaterial && material.hasFlag(GENERATE_FRAME)) {
            BlockFrame blockFrame = new BlockFrame((SolidMaterial) material);
            blockFrame.setRegistryName("frame_" + material.toString());
            FRAMES.put((SolidMaterial) material, blockFrame);
        }
        if (material instanceof IngotMaterial) {
            IngotMaterial metalMaterial = (IngotMaterial) material;
            if (metalMaterial.cableProperties != null) {
                CABLE.addCableMaterial(metalMaterial, metalMaterial.cableProperties);
            }
            if (metalMaterial.fluidPipeProperties != null) {
                FLUID_PIPE.addPipeMaterial(metalMaterial, metalMaterial.fluidPipeProperties);
            }
        }
    }
    FLUID_PIPE.addPipeMaterial(Materials.Wood, new FluidPipeProperties(310, 20, false));
    CABLE.addCableMaterial(MarkerMaterials.Tier.Superconductor, new WireProperties(Integer.MAX_VALUE, 4, 0));
    registerTileEntity();
    // not sure if that's a good place for that, but i don't want to make a dedicated method for that
    // could possibly override block methods, but since these props don't depend on state why not just use nice and simple vanilla method
    Blocks.FIRE.setFireInfo(LOG, 5, 5);
    Blocks.FIRE.setFireInfo(LEAVES, 30, 60);
}
Also used : BlockMachine(gregtech.api.block.machines.BlockMachine) BlockPetrifiedFoam(gregtech.common.blocks.foam.BlockPetrifiedFoam) BlockFluidPipe(gregtech.common.pipelike.fluidpipe.BlockFluidPipe) IngotMaterial(gregtech.api.unification.material.type.IngotMaterial) SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) BlockGregSapling(gregtech.common.blocks.wood.BlockGregSapling) BlockGregLog(gregtech.common.blocks.wood.BlockGregLog) FluidPipeProperties(gregtech.common.pipelike.fluidpipe.FluidPipeProperties) BlockSurfaceRockNew(gregtech.common.blocks.surfacerock.BlockSurfaceRockNew) SolidMaterial(gregtech.api.unification.material.type.SolidMaterial) DustMaterial(gregtech.api.unification.material.type.DustMaterial) Material(gregtech.api.unification.material.type.Material) IngotMaterial(gregtech.api.unification.material.type.IngotMaterial) WireProperties(gregtech.common.pipelike.cable.WireProperties) BlockFoam(gregtech.common.blocks.foam.BlockFoam) BlockGregLeaves(gregtech.common.blocks.wood.BlockGregLeaves) DustMaterial(gregtech.api.unification.material.type.DustMaterial) BlockCable(gregtech.common.pipelike.cable.BlockCable)

Example 2 with WireProperties

use of gregtech.common.pipelike.cable.WireProperties in project GregTech by GregTechCE.

the class CableRenderer method handleRenderBlockDamage.

@Override
public void handleRenderBlockDamage(IBlockAccess world, BlockPos pos, IBlockState state, TextureAtlasSprite sprite, BufferBuilder buffer) {
    CCRenderState renderState = CCRenderState.instance();
    renderState.reset();
    renderState.bind(buffer);
    renderState.setPipeline(new Vector3(new Vec3d(pos)).translation(), new IconTransformation(sprite));
    BlockCable blockCable = (BlockCable) state.getBlock();
    IPipeTile<Insulation, WireProperties> tileEntityCable = blockCable.getPipeTileEntity(world, pos);
    if (tileEntityCable == null) {
        return;
    }
    Insulation insulation = tileEntityCable.getPipeType();
    if (insulation == null) {
        return;
    }
    float thickness = insulation.getThickness();
    int connectedSidesMask = blockCable.getActualConnections(tileEntityCable, world);
    Cuboid6 baseBox = BlockCable.getSideBox(null, thickness);
    BlockRenderer.renderCuboid(renderState, baseBox, 0);
    for (EnumFacing renderSide : EnumFacing.VALUES) {
        if ((connectedSidesMask & (1 << renderSide.getIndex())) > 0) {
            Cuboid6 sideBox = BlockCable.getSideBox(renderSide, thickness);
            BlockRenderer.renderCuboid(renderState, sideBox, 0);
        }
    }
}
Also used : Insulation(gregtech.common.pipelike.cable.Insulation) EnumFacing(net.minecraft.util.EnumFacing) Vector3(codechicken.lib.vec.Vector3) WireProperties(gregtech.common.pipelike.cable.WireProperties) CCRenderState(codechicken.lib.render.CCRenderState) ItemBlockCable(gregtech.common.pipelike.cable.ItemBlockCable) BlockCable(gregtech.common.pipelike.cable.BlockCable) Cuboid6(codechicken.lib.vec.Cuboid6) Vec3d(net.minecraft.util.math.Vec3d) IconTransformation(codechicken.lib.vec.uv.IconTransformation)

Example 3 with WireProperties

use of gregtech.common.pipelike.cable.WireProperties in project GregTech by GregTechCE.

the class EnergyNet method computePatches.

public List<RoutePath> computePatches(BlockPos startPos) {
    ArrayList<RoutePath> readyPaths = new ArrayList<>();
    RoutePath currentPath = new RoutePath();
    Node<WireProperties> firstNode = getNodeAt(startPos);
    currentPath.path.put(startPos, firstNode.data);
    readyPaths.add(currentPath.cloneAndCompute(startPos));
    HashSet<BlockPos> observedSet = new HashSet<>();
    observedSet.add(startPos);
    MutableBlockPos currentPos = new MutableBlockPos(startPos);
    Stack<EnumFacing> moveStack = new Stack<>();
    main: while (true) {
        for (EnumFacing facing : EnumFacing.VALUES) {
            currentPos.move(facing);
            Node<WireProperties> secondNode = getNodeAt(currentPos);
            if (secondNode != null && canNodesConnect(firstNode, facing, secondNode, this) && !observedSet.contains(currentPos)) {
                BlockPos immutablePos = currentPos.toImmutable();
                observedSet.add(immutablePos);
                firstNode = secondNode;
                moveStack.push(facing.getOpposite());
                currentPath.path.put(immutablePos, getNodeAt(immutablePos).data);
                if (secondNode.isActive) {
                    // if we are on active node, this is end of our path
                    RoutePath finalizedPath = currentPath.cloneAndCompute(immutablePos);
                    readyPaths.add(finalizedPath);
                }
                continue main;
            } else {
                currentPos.move(facing.getOpposite());
            }
        }
        if (!moveStack.isEmpty()) {
            currentPos.move(moveStack.pop());
            // also remove already visited block from path
            currentPath.path.remove(currentPos);
        } else
            break;
    }
    return readyPaths;
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) Node(gregtech.api.pipenet.Node) ArrayList(java.util.ArrayList) WireProperties(gregtech.common.pipelike.cable.WireProperties) Stack(java.util.Stack) BlockPos(net.minecraft.util.math.BlockPos) MutableBlockPos(net.minecraft.util.math.BlockPos.MutableBlockPos) MutableBlockPos(net.minecraft.util.math.BlockPos.MutableBlockPos) HashSet(java.util.HashSet)

Example 4 with WireProperties

use of gregtech.common.pipelike.cable.WireProperties in project GregTech by GregTechCE.

the class RoutePath method cloneAndCompute.

public RoutePath cloneAndCompute(BlockPos destination) {
    RoutePath newPath = new RoutePath();
    newPath.path = new HashMap<>(path);
    newPath.destination = destination;
    for (WireProperties wireProperties : path.values()) {
        newPath.maxAmperage = Math.min(newPath.maxAmperage, wireProperties.amperage);
        newPath.minVoltage = Math.min(newPath.minVoltage, wireProperties.voltage);
        newPath.totalLoss += wireProperties.lossPerBlock;
    }
    return newPath;
}
Also used : WireProperties(gregtech.common.pipelike.cable.WireProperties)

Example 5 with WireProperties

use of gregtech.common.pipelike.cable.WireProperties in project GregTech by GregTechCE.

the class RoutePath method burnCablesInPath.

public boolean burnCablesInPath(World world, long voltage, long amperage) {
    for (BlockPos blockPos : path.keySet()) {
        WireProperties wireProperties = path.get(blockPos);
        if (voltage > wireProperties.voltage || amperage > wireProperties.amperage) {
            TileEntity tileEntity = world.getTileEntity(blockPos);
            if (tileEntity instanceof TileEntityCable) {
                world.setBlockToAir(blockPos);
                world.setBlockState(blockPos, Blocks.FIRE.getDefaultState());
                if (!world.isRemote) {
                    ((WorldServer) world).spawnParticle(EnumParticleTypes.SMOKE_LARGE, blockPos.getX() + 0.5, blockPos.getY() + 0.5, blockPos.getZ() + 0.5, 5 + world.rand.nextInt(3), 0.0, 0.0, 0.0, 0.1);
                }
            }
        }
    }
    return true;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityCable(gregtech.common.pipelike.cable.tile.TileEntityCable) BlockPos(net.minecraft.util.math.BlockPos) WireProperties(gregtech.common.pipelike.cable.WireProperties) WorldServer(net.minecraft.world.WorldServer)

Aggregations

WireProperties (gregtech.common.pipelike.cable.WireProperties)5 BlockCable (gregtech.common.pipelike.cable.BlockCable)2 EnumFacing (net.minecraft.util.EnumFacing)2 BlockPos (net.minecraft.util.math.BlockPos)2 CCRenderState (codechicken.lib.render.CCRenderState)1 Cuboid6 (codechicken.lib.vec.Cuboid6)1 Vector3 (codechicken.lib.vec.Vector3)1 IconTransformation (codechicken.lib.vec.uv.IconTransformation)1 BlockMachine (gregtech.api.block.machines.BlockMachine)1 Node (gregtech.api.pipenet.Node)1 DustMaterial (gregtech.api.unification.material.type.DustMaterial)1 IngotMaterial (gregtech.api.unification.material.type.IngotMaterial)1 Material (gregtech.api.unification.material.type.Material)1 SolidMaterial (gregtech.api.unification.material.type.SolidMaterial)1 BlockFoam (gregtech.common.blocks.foam.BlockFoam)1 BlockPetrifiedFoam (gregtech.common.blocks.foam.BlockPetrifiedFoam)1 BlockSurfaceRockNew (gregtech.common.blocks.surfacerock.BlockSurfaceRockNew)1 BlockGregLeaves (gregtech.common.blocks.wood.BlockGregLeaves)1 BlockGregLog (gregtech.common.blocks.wood.BlockGregLog)1 BlockGregSapling (gregtech.common.blocks.wood.BlockGregSapling)1