Search in sources :

Example 1 with BlockCompressed

use of gregtech.common.blocks.BlockCompressed in project GregTech by GregTechCEu.

the class CommandRecipeCheck method prettyPrintItemStack.

public String prettyPrintItemStack(ItemStack stack) {
    if (stack.getItem() instanceof MetaItem) {
        MetaItem<?> metaItem = (MetaItem<?>) stack.getItem();
        MetaValueItem metaValueItem = metaItem.getItem(stack);
        if (metaValueItem == null) {
            if (metaItem instanceof MetaPrefixItem) {
                Material material = ((MetaPrefixItem) metaItem).getMaterial(stack);
                OrePrefix orePrefix = ((MetaPrefixItem) metaItem).getOrePrefix();
                return "(MetaItem) OrePrefix: " + orePrefix.name + ", Material: " + material + " * " + stack.getCount();
            }
        } else {
            if (MetaItems.INTEGRATED_CIRCUIT.isItemEqual(stack)) {
                return "Config circuit #" + IntCircuitIngredient.getCircuitConfiguration(stack);
            }
            return "(MetaItem) " + metaValueItem.unlocalizedName + " * " + stack.getCount();
        }
    } else if (stack.getItem() instanceof MachineItemBlock) {
        MetaTileEntity mte = MachineItemBlock.getMetaTileEntity(stack);
        if (mte != null) {
            String id = mte.metaTileEntityId.toString();
            if (mte.metaTileEntityId.getNamespace().equals("gregtech"))
                id = mte.metaTileEntityId.getPath();
            return "(MetaTileEntity) " + id + " * " + stack.getCount();
        }
    } else {
        Block block = Block.getBlockFromItem(stack.getItem());
        String id = null;
        if (block instanceof BlockCompressed) {
            id = "block" + ((BlockCompressed) block).getGtMaterial(stack.getMetadata()).toCamelCaseString();
        } else if (block instanceof BlockFrame) {
            id = "frame" + ((BlockFrame) block).getGtMaterial(stack.getMetadata()).toCamelCaseString();
        } else if (block instanceof BlockMaterialPipe) {
            id = ((BlockMaterialPipe<?, ?, ?>) block).getPrefix().name + ((BlockMaterialPipe<?, ?, ?>) block).getItemMaterial(stack).toCamelCaseString();
        }
        if (id != null) {
            return "(MetaBlock) " + id + " * " + stack.getCount();
        }
    }
    // noinspection ConstantConditions
    return stack.getItem().getRegistryName().toString() + " * " + stack.getCount() + " (Meta " + stack.getItemDamage() + ")";
}
Also used : MetaValueItem(gregtech.api.items.metaitem.MetaItem.MetaValueItem) MetaItem(gregtech.api.items.metaitem.MetaItem) BlockCompressed(gregtech.common.blocks.BlockCompressed) OrePrefix(gregtech.api.unification.ore.OrePrefix) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) Material(gregtech.api.unification.material.Material) BlockMaterialPipe(gregtech.api.pipenet.block.material.BlockMaterialPipe) MetaTileEntity(gregtech.api.metatileentity.MetaTileEntity) Block(net.minecraft.block.Block) MachineItemBlock(gregtech.api.block.machines.MachineItemBlock) MetaPrefixItem(gregtech.api.items.materialitem.MetaPrefixItem) BlockFrame(gregtech.common.blocks.BlockFrame)

Example 2 with BlockCompressed

use of gregtech.common.blocks.BlockCompressed in project GregTech by GregTechCEu.

the class CompressedBlockBakedModel method getQuads.

@Override
@Nonnull
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    List<BakedQuad> quads = new ArrayList<>();
    if (side == null)
        return quads;
    if (state != null) {
        Material material = state.getValue(((BlockCompressed) state.getBlock()).variantProperty);
        Map<EnumFacing, BakedQuad> materialFace = materialFaces.get(material.getMaterialIconSet());
        if (materialFace == null) {
            materialFaces.put(material.getMaterialIconSet(), materialFace = new Object2ObjectOpenHashMap<>());
        }
        BakedQuad materialFaceQuad = materialFace.get(side);
        if (materialFaceQuad == null) {
            materialFace.put(side, materialFaceQuad = ModelFactory.getBakery().makeBakedQuad(new Vector3f(0F, 0F, 0F), new Vector3f(16F, 16F, 16F), new BlockPartFace(side, 1, "", new BlockFaceUV(new float[] { 0.0F, 0.0F, 16.0F, 16.0F, 0.0F, 0.0F, 16.0F, 16.0F }, 0)), ModelLoader.defaultTextureGetter().apply(MaterialIconType.block.getBlockPath(material.getMaterialIconSet())), side, ModelRotation.X0_Y0, null, true, true));
        }
        quads.add(materialFaceQuad);
        particle.set(materialFaceQuad.getSprite());
    } else {
        ItemStack stack = CompressedBlockItemOverride.INSTANCE.stack.get();
        if (!stack.isEmpty()) {
            BlockCompressed compressed = (BlockCompressed) ((ItemBlock) stack.getItem()).getBlock();
            IBlockState compressedState = compressed.getDefaultState().withProperty(compressed.variantProperty, compressed.variantProperty.getAllowedValues().get(stack.getMetadata()));
            for (EnumFacing face : EnumFacing.VALUES) {
                quads.addAll(getQuads(compressedState, face, rand));
            }
        }
    }
    return quads;
}
Also used : IBlockState(net.minecraft.block.state.IBlockState) BlockCompressed(gregtech.common.blocks.BlockCompressed) EnumFacing(net.minecraft.util.EnumFacing) ArrayList(java.util.ArrayList) Material(gregtech.api.unification.material.Material) Object2ObjectOpenHashMap(it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap) Vector3f(org.lwjgl.util.vector.Vector3f) ItemStack(net.minecraft.item.ItemStack) Nonnull(javax.annotation.Nonnull)

Aggregations

Material (gregtech.api.unification.material.Material)2 BlockCompressed (gregtech.common.blocks.BlockCompressed)2 MachineItemBlock (gregtech.api.block.machines.MachineItemBlock)1 MetaPrefixItem (gregtech.api.items.materialitem.MetaPrefixItem)1 MetaItem (gregtech.api.items.metaitem.MetaItem)1 MetaValueItem (gregtech.api.items.metaitem.MetaItem.MetaValueItem)1 MetaTileEntity (gregtech.api.metatileentity.MetaTileEntity)1 BlockMaterialPipe (gregtech.api.pipenet.block.material.BlockMaterialPipe)1 OrePrefix (gregtech.api.unification.ore.OrePrefix)1 BlockFrame (gregtech.common.blocks.BlockFrame)1 Object2ObjectOpenHashMap (it.unimi.dsi.fastutil.objects.Object2ObjectOpenHashMap)1 ArrayList (java.util.ArrayList)1 Nonnull (javax.annotation.Nonnull)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 Vector3f (org.lwjgl.util.vector.Vector3f)1