use of net.minecraft.client.renderer.block.model.IBakedModel in project Charset by CharsetMC.
the class UtilProxyClient method addRunningParticles.
@Override
public boolean addRunningParticles(IBlockState state, World world, BlockPos pos, Entity entity) {
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
if (model instanceof IStateParticleBakedModel) {
state = state.getBlock().getExtendedState(state.getActualState(world, pos), world, pos);
TextureAtlasSprite sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, EnumFacing.UP);
Particle particle = new ParticleDiggingCharset(world, entity.posX + ((double) PacketCustomBlockDust.rand.nextFloat() - 0.5D) * (double) entity.width, entity.getEntityBoundingBox().minY + 0.1D, entity.posZ + ((double) PacketCustomBlockDust.rand.nextFloat() - 0.5D) * (double) entity.width, -entity.motionX * 4.0D, 1.5D, -entity.motionZ * 4.0D, state, pos, sprite, ((BlockBase) state.getBlock()).getParticleTintIndex());
Minecraft.getMinecraft().effectRenderer.addEffect(particle);
return true;
} else {
return false;
}
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project Charset by CharsetMC.
the class UtilProxyClient method spawnBlockDustClient.
@Override
public void spawnBlockDustClient(World world, BlockPos pos, Random rand, float posX, float posY, float posZ, int numberOfParticles, float particleSpeed, EnumFacing facing) {
TextureAtlasSprite sprite;
int tintIndex = -1;
IBlockState state = world.getBlockState(pos);
if (state.getBlock() instanceof BlockBase) {
tintIndex = ((BlockBase) state.getBlock()).getParticleTintIndex();
}
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
if (model instanceof IStateParticleBakedModel) {
state = state.getBlock().getExtendedState(state.getActualState(world, pos), world, pos);
sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, facing);
} else {
sprite = model.getParticleTexture();
}
ParticleManager manager = Minecraft.getMinecraft().effectRenderer;
for (int i = 0; i < numberOfParticles; i++) {
double xSpeed = rand.nextGaussian() * particleSpeed;
double ySpeed = rand.nextGaussian() * particleSpeed;
double zSpeed = rand.nextGaussian() * particleSpeed;
try {
Particle particle = new ParticleBlockDustCharset(world, posX, posY, posZ, xSpeed, ySpeed, zSpeed, state, pos, sprite, tintIndex);
manager.addEffect(particle);
} catch (Throwable var16) {
ModCharset.logger.warn("Could not spawn block particle!");
return;
}
}
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ForestryMC by ForestryMC.
the class ProxyArboricultureClient method onModelBake.
@SubscribeEvent
public <T extends Block & IWoodTyped> void onModelBake(ModelBakeEvent event) {
IRegistry<ModelResourceLocation, IBakedModel> registry = event.getModelRegistry();
for (WoodModelEntry<T> entry : woodModelEntrys) {
T woodTyped = entry.woodTyped;
WoodBlockKind woodKind = woodTyped.getBlockKind();
IWoodStateMapper woodMapper = stateMappers.get(woodTyped);
for (IBlockState blockState : woodTyped.getBlockState().getValidStates()) {
IWoodType woodType;
ItemStack itemStack;
if (entry.withVariants) {
int meta = woodTyped.getMetaFromState(blockState);
woodType = woodTyped.getWoodType(meta);
itemStack = new ItemStack(woodTyped, 1, meta);
} else {
woodType = woodTyped.getWoodType(0);
itemStack = new ItemStack(woodTyped);
}
IWoodItemMeshDefinition definition = shapers.get(itemStack.getItem());
ImmutableMap<String, String> textures = WoodTextureManager.getTextures(woodType, woodKind);
if (definition != null) {
retextureItemModel(registry, textures, woodType, woodKind, itemStack, definition);
}
if (woodMapper != null) {
retexturBlockModel(registry, textures, woodType, woodKind, blockState, woodMapper);
}
}
}
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ForestryMC by ForestryMC.
the class MultipartModel method bake.
@Override
public IBakedModel bake(IModelState state, VertexFormat format, Function<ResourceLocation, TextureAtlasSprite> bakedTextureGetter) {
MultipartBakedModel.Builder builder = new MultipartBakedModel.Builder();
for (Selector selector : multipart.getSelectors()) {
IModel model = partModels.get(selector);
IBakedModel bakedModel = model.bake(model.getDefaultState(), format, bakedTextureGetter);
builder.putModel(selector.getPredicate(multipart.getStateContainer()), bakedModel);
}
return builder.makeMultipartModel();
}
use of net.minecraft.client.renderer.block.model.IBakedModel in project ForestryMC by ForestryMC.
the class ModelButterflyItem method bakeModel.
private IBakedModel bakeModel(IAlleleButterflySpecies species, float size) {
ImmutableMap<String, String> textures = ImmutableMap.of("butterfly", species.getItemTexture());
if (modelButterfly == null) {
try {
modelButterfly = ModelLoaderRegistry.getModel(new ResourceLocation(Constants.MOD_ID, "item/butterfly_ge"));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
IModel model = modelButterfly.retexture(textures);
IBakedModel bakedModel = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.ITEM, DefaultTextureGetter.INSTANCE);
float scale = 1F / 16F;
IModelState state = ModelUtil.loadModelState(new ResourceLocation(Constants.MOD_ID, "models/item/butterfly_ge"));
state = new ModelStateComposition(state, new SimpleModelState(getTransformations(size)));
return new PerspectiveMapWrapper(new TRSRBakedModel(bakedModel, -0.03125F, 0.25F - size * 0.37F, -0.03125F + size * scale, size * 1.4F), state);
}
Aggregations