use of gregtech.api.unification.material.Material 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() + ")";
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class BlockFrame method onTextureStitch.
@Override
@SideOnly(Side.CLIENT)
public void onTextureStitch(TextureStitchEvent.Pre event) {
for (IBlockState state : this.getBlockState().getValidStates()) {
Material material = state.getValue(variantProperty);
event.getMap().registerSprite(MaterialIconType.frameGt.getBlockPath(material.getMaterialIconSet()));
}
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class MetaBlocks method createCompressedBlock.
private static void createCompressedBlock(Material[] materials, int index) {
BlockCompressed block = new BlockCompressed(materials);
block.setRegistryName("meta_block_compressed_" + index);
for (Material material : materials) {
COMPRESSED.put(material, block);
}
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class MetaBlocks method createGeneratedBlock.
/**
* Deterministically populates a category of MetaBlocks based on the unique registry ID of each qualifying Material.
*
* @param materialPredicate a filter for determining if a Material qualifies for generation in the category.
* @param blockGenerator a function which accepts a Materials set to pack into a MetaBlock, and the ordinal this
* MetaBlock should have within its category.
*/
protected static void createGeneratedBlock(Predicate<Material> materialPredicate, BiConsumer<Material[], Integer> blockGenerator) {
Map<Integer, Material[]> blocksToGenerate = new TreeMap<>();
for (Material material : GregTechAPI.MATERIAL_REGISTRY) {
if (materialPredicate.test(material)) {
int id = material.getId();
int metaBlockID = id / 16;
int subBlockID = id % 16;
if (!blocksToGenerate.containsKey(metaBlockID)) {
Material[] materials = new Material[16];
Arrays.fill(materials, Materials.NULL);
blocksToGenerate.put(metaBlockID, materials);
}
blocksToGenerate.get(metaBlockID)[subBlockID] = material;
}
}
blocksToGenerate.forEach((key, value) -> blockGenerator.accept(value, key));
}
use of gregtech.api.unification.material.Material in project GregTech by GregTechCEu.
the class BlockCompressed method getHarvestLevel.
@Override
public int getHarvestLevel(IBlockState state) {
Material material = state.getValue(variantProperty);
DustProperty prop = material.getProperty(PropertyKey.DUST);
if (prop != null) {
return material.getHarvestLevel();
}
return 0;
}
Aggregations