use of gregtech.api.unification.material.info.MaterialIconSet in project GregTech by GregTechCEu.
the class MetaOreDictItem method registerModels.
@Override
@SideOnly(Side.CLIENT)
public void registerModels() {
TIntObjectHashMap<ModelResourceLocation> alreadyRegistered = new TIntObjectHashMap<>();
for (Map.Entry<Short, OreDictValueItem> metaItem : ITEMS.entrySet()) {
OrePrefix prefix = metaItem.getValue().orePrefix;
MaterialIconSet materialIconSet = metaItem.getValue().materialIconSet;
if (prefix.materialIconType == null || DISALLOWED_TYPES.contains(prefix.materialIconType))
continue;
int registrationKey = prefix.id * 1000 + materialIconSet.id;
if (!alreadyRegistered.containsKey(registrationKey)) {
prefix.materialIconType.getItemModelPath(materialIconSet);
ResourceLocation resourceLocation = prefix.materialIconType.getItemModelPath(materialIconSet);
ModelBakery.registerItemVariants(this, resourceLocation);
alreadyRegistered.put(registrationKey, new ModelResourceLocation(resourceLocation, "inventory"));
}
ModelResourceLocation resourceLocation = alreadyRegistered.get(registrationKey);
metaItemsModels.put(metaItem.getKey(), resourceLocation);
}
}
use of gregtech.api.unification.material.info.MaterialIconSet in project GregTech by GregTechCEu.
the class ClientProxy method registerSprites.
@SubscribeEvent
public static void registerSprites(TextureStitchEvent.Pre event) {
for (MaterialIconSet set : MaterialIconSet.ICON_SETS.values()) {
event.getMap().registerSprite(MaterialIconType.ore.getBlockPath(set));
event.getMap().registerSprite(MaterialIconType.block.getBlockPath(set));
}
MetaBlocks.COMPRESSED.values().stream().distinct().forEach(c -> c.onTextureStitch(event));
MetaBlocks.FRAMES.values().stream().distinct().forEach(f -> f.onTextureStitch(event));
MetaBlocks.ORES.forEach(o -> o.onTextureStitch(event));
}
use of gregtech.api.unification.material.info.MaterialIconSet in project GregTech by GregTechCEu.
the class MetaPrefixItem method registerModels.
@Override
@SideOnly(Side.CLIENT)
@SuppressWarnings("ConstantConditions")
public void registerModels() {
TShortObjectHashMap<ModelResourceLocation> alreadyRegistered = new TShortObjectHashMap<>();
for (short metaItem : metaItems.keySet()) {
MaterialIconSet materialIconSet = GregTechAPI.MATERIAL_REGISTRY.getObjectById(metaItem).getMaterialIconSet();
short registrationKey = (short) (prefix.id + materialIconSet.id);
if (!alreadyRegistered.containsKey(registrationKey)) {
ResourceLocation resourceLocation = prefix.materialIconType.getItemModelPath(materialIconSet);
ModelBakery.registerItemVariants(this, resourceLocation);
alreadyRegistered.put(registrationKey, new ModelResourceLocation(resourceLocation, "inventory"));
}
ModelResourceLocation resourceLocation = alreadyRegistered.get(registrationKey);
metaItemsModels.put(metaItem, resourceLocation);
}
// Make some default model for meta prefix items without any materials associated
if (metaItems.keySet().isEmpty()) {
MaterialIconSet defaultIcon = MaterialIconSet.DULL;
ResourceLocation defaultLocation = OrePrefix.ingot.materialIconType.getItemModelPath(defaultIcon);
ModelBakery.registerItemVariants(this, defaultLocation);
}
}
use of gregtech.api.unification.material.info.MaterialIconSet in project GregTech by GregTechCEu.
the class OreBakedModel method getQuads.
@Override
@Nonnull
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
if (state != null) {
BlockOre ore = (BlockOre) state.getBlock();
StoneType stoneType = state.getValue(ore.STONE_TYPE);
MaterialIconSet materialIconSet = ore.material.getMaterialIconSet();
TextureAtlasSprite textureAtlasSprite = stoneTypeModels.computeIfAbsent(stoneType, type -> Minecraft.getMinecraft().blockRenderDispatcher.getModelForState(type.stone.get()).getParticleTexture());
particle.set(textureAtlasSprite);
if (model == null) {
model = new ModelFactory(ModelFactory.ModelTemplate.CUBE_2_LAYER_ALL_TINT_INDEX).bake();
}
BakedQuad bakedQuad = cacheBottom.get(stoneType, side);
if (side == null)
return Collections.emptyList();
if (bakedQuad == null) {
cacheBottom.put(stoneType, side, bakedQuad = new BakedQuadRetextured(model.getQuads(state, side, rand).get(0), textureAtlasSprite));
}
BakedQuad[] bakedQuads = cacheTop.get(materialIconSet, side);
if (bakedQuads == null) {
bakedQuads = new BakedQuad[2];
bakedQuads[0] = new BakedQuadRetextured(model.getQuads(state, side, rand).get(1), ModelLoader.defaultTextureGetter().apply(MaterialIconType.ore.getBlockPath(materialIconSet)));
bakedQuads[1] = CustomTexture.rebake(15, 15, bakedQuads[0]);
cacheTop.put(materialIconSet, side, bakedQuads);
}
BlockRenderLayer layer = MinecraftForgeClient.getRenderLayer();
boolean hasEmissive = ore.material.getProperty(PropertyKey.ORE).isEmissive();
boolean isEmissiveLayer = hasEmissive && (layer == BloomEffectUtil.getRealBloomLayer() || layer == null);
List<BakedQuad> quads = new ArrayList<>();
if (!hasEmissive || !isEmissiveLayer || layer == null) {
quads.add(bakedQuad);
}
if (hasEmissive && isEmissiveLayer) {
quads.add(bakedQuads[1]);
} else {
quads.add(bakedQuads[0]);
}
return quads;
} else {
List<BakedQuad> quads = new ArrayList<>();
ItemStack stack = OreItemOverride.INSTANCE.stack.get();
if (!stack.isEmpty()) {
BlockOre ore = (BlockOre) ((ItemBlock) stack.getItem()).getBlock();
IBlockState oreState = ore.getDefaultState().withProperty(ore.STONE_TYPE, ore.STONE_TYPE.getAllowedValues().get(stack.getMetadata()));
for (EnumFacing face : EnumFacing.VALUES) {
quads.addAll(getQuads(oreState, face, rand));
}
}
return quads;
}
}
Aggregations