use of gregtech.api.unification.material.type.Material in project GregTech by GregTechCE.
the class MaterialMetaItem method registerOreDict.
public void registerOreDict() {
for (short metaItem : generatedItems) {
OrePrefix prefix = this.orePrefixes[metaItem / 1000];
Material material = Material.MATERIAL_REGISTRY.getObjectById(metaItem % 1000);
OreDictUnifier.registerOre(new ItemStack(this, 1, metaItem), prefix, material);
}
}
use of gregtech.api.unification.material.type.Material in project GregTech by GregTechCE.
the class MaterialMetaItem method addInformation.
// TODO DELETE ON RELEASE
@Override
public void addInformation(ItemStack itemStack, @Nullable World worldIn, List<String> lines, ITooltipFlag tooltipFlag) {
if (itemStack.getMetadata() >= 32000)
return;
OrePrefix prefix = this.orePrefixes[itemStack.getMetadata() / 1000];
Material material = Material.MATERIAL_REGISTRY.getObjectById(itemStack.getMetadata() % 1000);
if (prefix != null) {
lines.add("IconType: " + prefix.materialIconType);
}
if (material != null) {
lines.add("IconSet: " + material.materialIconSet);
}
}
use of gregtech.api.unification.material.type.Material in project GregTech by GregTechCE.
the class ToolMetaItem method onCreated.
@Override
public void onCreated(ItemStack stack, World world, EntityPlayer player) {
T metaToolValueItem = getItem(stack);
if (metaToolValueItem != null) {
IToolStats toolStats = metaToolValueItem.getToolStats();
toolStats.onToolCrafted(stack, player);
ArrayList<EnchantmentData> enchantments = new ArrayList<>(toolStats.getEnchantments(stack));
SolidMaterial material = getPrimaryMaterial(stack);
if (material == null) {
return;
}
for (EnchantmentData enchantmentData : material.toolEnchantments) {
Optional<EnchantmentData> sameEnchantment = enchantments.stream().filter(it -> it.enchantment == enchantmentData.enchantment).findAny();
if (sameEnchantment.isPresent()) {
enchantments.remove(sameEnchantment.get());
int level = Math.min(enchantmentData.level + sameEnchantment.get().level, enchantmentData.enchantment.getMaxLevel());
enchantments.add(new EnchantmentData(enchantmentData.enchantment, level));
} else {
enchantments.add(enchantmentData);
}
}
for (EnchantmentData enchantmentData : enchantments) {
stack.addEnchantment(enchantmentData.enchantment, enchantmentData.level);
}
}
}
use of gregtech.api.unification.material.type.Material in project GregTech by GregTechCE.
the class MetaBlocks method init.
public static void init() {
MACHINE = new BlockMachine();
MACHINE.setRegistryName("machine");
CABLE = new BlockCable(64, 2, 0);
CABLE.setRegistryName("cable");
BOILER_CASING = new BlockBoilerCasing();
BOILER_CASING.setRegistryName("boiler_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");
BLACK_GRANITE = new StoneType(12, "black_granite", OrePrefix.oreBlackgranite, Materials.GraniteBlack, "gregtech:blocks/stones/granite/granite_black_stone", () -> GRANITE.withVariant(GraniteVariant.BLACK_GRANITE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockGranite && ((BlockGranite) state.getBlock()).getVariant(state) == GraniteVariant.BLACK_GRANITE);
RED_GRANITE = new StoneType(13, "red_granite", OrePrefix.oreRedgranite, Materials.GraniteRed, "gregtech:blocks/stones/granite/granite_red_stone", () -> GRANITE.withVariant(GraniteVariant.RED_GRANITE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockGranite && ((BlockGranite) state.getBlock()).getVariant(state) == GraniteVariant.RED_GRANITE);
MINERAL = new BlockMineral();
MINERAL.setRegistryName("mineral");
MARBLE = new StoneType(14, "marble", OrePrefix.oreMarble, Materials.Marble, "gregtech:blocks/stones/marble/marble_stone", () -> MINERAL.withVariant(MineralVariant.MARBLE, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockMineral && ((BlockMineral) state.getBlock()).getVariant(state) == BlockMineral.MineralVariant.MARBLE);
BASALT = new StoneType(15, "basalt", OrePrefix.oreBasalt, Materials.Basalt, "gregtech:blocks/stones/basalt/basalt_stone", () -> MINERAL.withVariant(MineralVariant.BASALT, ChiselingVariant.NORMAL), state -> state.getBlock() instanceof BlockMineral && ((BlockMineral) state.getBlock()).getVariant(state) == BlockMineral.MineralVariant.BASALT);
CONCRETE = new BlockConcrete();
CONCRETE.setRegistryName("concrete");
COMPRESSED = new HashMap<>();
ORES = new ArrayList<>();
StoneType.init();
Material[] materialBuffer = new Material[16];
Arrays.fill(materialBuffer, Materials._NULL);
int generationIndex = 0;
for (Material material : Material.MATERIAL_REGISTRY.getObjectsWithIds()) {
if (material instanceof DustMaterial) {
int id = Material.MATERIAL_REGISTRY.getIDForObject(material);
int index = id / 16;
if (index > generationIndex) {
createCompressedBlock(materialBuffer, generationIndex);
Arrays.fill(materialBuffer, Materials._NULL);
}
if (!OrePrefix.block.isIgnored(material)) {
materialBuffer[id % 16] = material;
generationIndex = index;
}
if (material.hasFlag(DustMaterial.MatFlags.GENERATE_ORE)) {
createOreBlock((DustMaterial) material);
}
}
}
createCompressedBlock(materialBuffer, generationIndex);
}
use of gregtech.api.unification.material.type.Material in project GregTech by GregTechCE.
the class MetaItem1 method onEntityItemUpdate.
@Override
public boolean onEntityItemUpdate(EntityItem itemEntity) {
int damage = itemEntity.getItem().getMetadata();
if (damage < this.metaItemOffset && damage >= 0 && !itemEntity.getEntityWorld().isRemote) {
Material material = Material.MATERIAL_REGISTRY.getObjectById(damage % 1000);
if (material != null) {
int posX = MathHelper.floor(itemEntity.posX);
int posY = MathHelper.floor(itemEntity.posY);
int posZ = MathHelper.floor(itemEntity.posZ);
OrePrefix prefix = this.orePrefixes[(damage / 1000)];
if (prefix == OrePrefix.dustImpure || prefix == OrePrefix.dustPure || prefix == OrePrefix.crushed || prefix == OrePrefix.dust) {
IBlockState blockState = itemEntity.getEntityWorld().getBlockState(new BlockPos(posX, posY, posZ));
if (blockState.getBlock() == Blocks.CAULDRON) {
int waterLevel = blockState.getValue(BlockCauldron.LEVEL);
if (waterLevel > 0) {
boolean waterConsumed = false;
if (prefix == OrePrefix.crushed) {
itemEntity.setItem(OreDictUnifier.get(OrePrefix.crushedPurified, material, itemEntity.getItem().getCount()));
waterConsumed = true;
} else if (prefix == OrePrefix.dustImpure || prefix == OrePrefix.dustPure) {
itemEntity.setItem(OreDictUnifier.get(OrePrefix.dust, material, itemEntity.getItem().getCount()));
waterConsumed = true;
}
if (waterConsumed) {
itemEntity.getEntityWorld().setBlockState(new BlockPos(posX, posY, posZ), blockState.withProperty(BlockCauldron.LEVEL, waterLevel - 1));
}
return true;
}
}
}
}
}
return false;
}
Aggregations