use of net.minecraft.client.renderer.BlockModelShapes in project EnderIO by SleepyTrousers.
the class QuadCollector method addFriendlyBlockStates.
/**
* Adds the baked model(s) of the given block states to the quad lists for the given block layer. The models are expected to behave. The block layer will be
* NOT set when the models are asked for their quads.
*/
public void addFriendlyBlockStates(BlockRenderLayer pass, List<IBlockState> states) {
if (states == null || states.isEmpty()) {
return;
}
BlockModelShapes modelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
for (IBlockState state : states) {
if (state != null) {
IBakedModel model = modelShapes.getModelForState(state);
List<BakedQuad> generalQuads = model.getQuads(state, null, 0);
if (!generalQuads.isEmpty()) {
addQuads(null, pass, generalQuads);
}
for (EnumFacing face : EnumFacing.values()) {
List<BakedQuad> faceQuads = model.getQuads(state, face, 0);
if (!faceQuads.isEmpty()) {
addQuads(face, pass, faceQuads);
}
}
}
}
}
use of net.minecraft.client.renderer.BlockModelShapes in project ForestryMC by ForestryMC.
the class CamouflageHandlerBlock method getModel.
@SideOnly(Side.CLIENT)
@Override
public Pair<IBlockState, IBakedModel> getModel(ItemStack stack) {
Preconditions.checkArgument(!stack.isEmpty(), "Stack cannot be empty");
BlockRendererDispatcher rendererDispatcher = Minecraft.getMinecraft().getBlockRendererDispatcher();
BlockModelShapes modelShapes = rendererDispatcher.getBlockModelShapes();
Block block = Block.getBlockFromItem(stack.getItem());
Preconditions.checkArgument(block != Blocks.AIR, "Block cannot be AIR");
IBlockState state = block.getStateFromMeta(stack.getItemDamage());
return Pair.of(state, modelShapes.getModelForState(state));
}
use of net.minecraft.client.renderer.BlockModelShapes in project FoamFix by asiekierka.
the class FoamFixModelRegistryDuplicateWipe method onTextureStitchPost.
@SubscribeEvent
public void onTextureStitchPost(TextureStitchEvent.Post event) {
ItemModelMesher imm = Minecraft.getMinecraft().getRenderItem().getItemModelMesher();
BlockModelShapes bms = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
ModelManager mgr = bms.getModelManager();
Field f = ReflectionHelper.findField(ModelManager.class, "modelRegistry", "field_174958_a");
try {
IRegistry<ModelResourceLocation, IBakedModel> registry = (IRegistry<ModelResourceLocation, IBakedModel>) f.get(mgr);
FoamFix.logger.info("Clearing unnecessary model registry of size " + registry.getKeys().size() + ".");
for (ModelResourceLocation l : registry.getKeys()) {
registry.putObject(l, ProxyClient.DUMMY_MODEL);
}
} catch (Exception e) {
e.printStackTrace();
}
f = ReflectionHelper.findField(BlockModelShapes.class, "bakedModelStore", "field_178129_a");
try {
Map<IBlockState, IBakedModel> modelStore = (Map<IBlockState, IBakedModel>) f.get(bms);
FoamFix.logger.info("Clearing unnecessary model store of size " + modelStore.size() + ".");
modelStore.clear();
} catch (Exception e) {
e.printStackTrace();
}
if (imm instanceof ItemModelMesherForge) {
f = ReflectionHelper.findField(ItemModelMesherForge.class, "models");
try {
Map<IRegistryDelegate<Item>, TIntObjectHashMap<IBakedModel>> modelStore = (Map<IRegistryDelegate<Item>, TIntObjectHashMap<IBakedModel>>) f.get(imm);
FoamFix.logger.info("Clearing unnecessary item shapes cache of size " + modelStore.size() + ".");
modelStore.clear();
} catch (Exception e) {
e.printStackTrace();
}
}
}
use of net.minecraft.client.renderer.BlockModelShapes in project pnc-repressurized by TeamPneumatic.
the class CamoModel method handleBlockState.
private IBakedModel handleBlockState(IBlockState state) {
if (state instanceof IExtendedBlockState) {
IExtendedBlockState ext = (IExtendedBlockState) state;
IBlockState camoState = ext.getValue(BlockPneumaticCraftCamo.CAMO_STATE);
if (camoState != null && !(camoState.getBlock() instanceof BlockPneumaticCraftCamo)) {
BlockModelShapes blockModelShapes = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes();
return blockModelShapes.getModelForState(camoState);
}
}
return originalModel;
}
Aggregations