use of pl.asie.charset.lib.render.model.IStateParticleBakedModel in project Charset by CharsetMC.
the class BlockBase method addDestroyEffects.
@Override
@SideOnly(Side.CLIENT)
public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager manager) {
IBlockState state = world.getBlockState(pos);
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
if (model instanceof IStateParticleBakedModel) {
state = getExtendedState(state.getActualState(world, pos), world, pos);
TextureAtlasSprite sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, null);
if (sprite != null) {
for (int j = 0; j < 4; ++j) {
for (int k = 0; k < 4; ++k) {
for (int l = 0; l < 4; ++l) {
double d0 = ((double) j + 0.5D) / 4.0D;
double d1 = ((double) k + 0.5D) / 4.0D;
double d2 = ((double) l + 0.5D) / 4.0D;
manager.addEffect(new ParticleDiggingCharset(world, (double) pos.getX() + d0, (double) pos.getY() + d1, (double) pos.getZ() + d2, d0 - 0.5D, d1 - 0.5D, d2 - 0.5D, state, pos, sprite, getParticleTintIndex()));
}
}
}
return true;
}
}
return false;
}
use of pl.asie.charset.lib.render.model.IStateParticleBakedModel 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 pl.asie.charset.lib.render.model.IStateParticleBakedModel 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 pl.asie.charset.lib.render.model.IStateParticleBakedModel in project Charset by CharsetMC.
the class BlockBase method addHitEffects.
@Override
@SideOnly(Side.CLIENT)
public boolean addHitEffects(IBlockState state, World world, RayTraceResult target, ParticleManager manager) {
IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getModelForState(state);
if (model instanceof IStateParticleBakedModel) {
BlockPos pos = target.getBlockPos();
EnumFacing side = target.sideHit;
state = getExtendedState(state.getActualState(world, pos), world, pos);
TextureAtlasSprite sprite = ((IStateParticleBakedModel) model).getParticleTexture(state, side);
if (sprite != null) {
int i = pos.getX();
int j = pos.getY();
int k = pos.getZ();
AxisAlignedBB axisalignedbb = state.getBoundingBox(world, pos);
double d0 = (double) i + RANDOM.nextDouble() * (axisalignedbb.maxX - axisalignedbb.minX - 0.20000000298023224D) + 0.10000000149011612D + axisalignedbb.minX;
double d1 = (double) j + RANDOM.nextDouble() * (axisalignedbb.maxY - axisalignedbb.minY - 0.20000000298023224D) + 0.10000000149011612D + axisalignedbb.minY;
double d2 = (double) k + RANDOM.nextDouble() * (axisalignedbb.maxZ - axisalignedbb.minZ - 0.20000000298023224D) + 0.10000000149011612D + axisalignedbb.minZ;
if (side == EnumFacing.DOWN) {
d1 = (double) j + axisalignedbb.minY - 0.10000000149011612D;
}
if (side == EnumFacing.UP) {
d1 = (double) j + axisalignedbb.maxY + 0.10000000149011612D;
}
if (side == EnumFacing.NORTH) {
d2 = (double) k + axisalignedbb.minZ - 0.10000000149011612D;
}
if (side == EnumFacing.SOUTH) {
d2 = (double) k + axisalignedbb.maxZ + 0.10000000149011612D;
}
if (side == EnumFacing.WEST) {
d0 = (double) i + axisalignedbb.minX - 0.10000000149011612D;
}
if (side == EnumFacing.EAST) {
d0 = (double) i + axisalignedbb.maxX + 0.10000000149011612D;
}
Particle particle = new ParticleDiggingCharset(world, d0, d1, d2, 0.0D, 0.0D, 0.0D, state, pos, sprite, getParticleTintIndex()).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F);
manager.addEffect(particle);
return true;
}
}
return false;
}
Aggregations