@Override @SideOnly(Side.CLIENT) public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager particleManager) { final IStructureTE te = (IStructureTE) world.getTileEntity(pos); if (te != null) { final StructureBlock block = te.getMasterBlockInstance(); if (block != null) { return block.addDestroyEffects(world, te.getMasterBlockLocation(), particleManager); } } return true; //No Destroy Effects }
@SuppressWarnings({"ReturnOfNull", "ConstantConditions"}) @Override public IMessage onMessage(SpawnCustomParticleMessage message, MessageContext ctx) { final ParticleManager effectRenderer = Minecraft.getMinecraft().effectRenderer; final IForgeRegistry<ICustomParticleFactory> registry = GameRegistry.findRegistry(ICustomParticleFactory.class); final ICustomParticleFactory factory = registry.getValue(message.getParticleResourceLocation()); final Particle particle = factory.getParticleFactory().createParticle(-1, Minecraft.getMinecraft().thePlayer.worldObj, message.getXCoordinate(), message.getYCoordinate(), message.getZCoordinate(), message.getParticleSpeed(), message.getParticleSpeed(), message.getParticleSpeed(), message.getParticleArgs() ); effectRenderer.addEffect(particle); return null; }
/** * {@link Block#addHitEffects} * Provided the model bound is an instance of IModelParticleProvider, you will have landing particles just handled for you. * Use the default PerspectiveModel implementations inside CCL, Destroy effects will just be handled for you. * * @param world The world. * @param pos The position of the block. * @param manager The ParticleManager. * @return True if particles were added, basically just return the result of this method inside {@link Block#addHitEffects} */ @SideOnly (Side.CLIENT) public static boolean handleDestroyEffects(World world, BlockPos pos, ParticleManager manager) { IBlockState state = world.getBlockState(pos); BlockModelShapes modelProvider = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes(); try { state = state.getActualState(world, pos); } catch (Throwable ignored) { } IBakedModel model = modelProvider.getModelForState(state); state = state.getBlock().getExtendedState(state, world, pos); if (model instanceof IModelParticleProvider) { Cuboid6 bounds = new Cuboid6(state.getBoundingBox(world, pos)); Set<TextureAtlasSprite> destroySprites = ((IModelParticleProvider) model).getDestroyEffects(state, world, pos); List<TextureAtlasSprite> sprites = destroySprites.stream().filter(sprite -> !ignoredParticleSprites.contains(sprite)).collect(Collectors.toList()); addBlockDestroyEffects(world, bounds.add(pos), sprites, manager); return true; } return false; }
/** * Spawns the break particles for a block, similarly to the normal block break effect * particle. The intended use of this method is to override the block break effects. * * @param manager The EffectRenderer, used to render the particle effect. * @param state The BlockState for the block to render the breaking effect of. * @param world The World to spawn the particle effect in. * @param pos The position to spawn the particles at. * @return boolean Whether or not the effect actually spawned. */ public static boolean spawnBreakParticles (ParticleManager manager, IBlockState state, World world, BlockPos pos) { if (state.getBlock() != null) { final int multiplier = 4; for (int xOffset = 0; xOffset < multiplier; xOffset++) for (int yOffset = 0; yOffset < multiplier; yOffset++) for (int zOffset = 0; zOffset < multiplier; zOffset++) { final double xPos = pos.getX() + (xOffset + 0.5D) / multiplier; final double yPos = pos.getY() + (yOffset + 0.5D) / multiplier; final double zPos = pos.getZ() + (zOffset + 0.5D) / multiplier; manager.addEffect(new ParticleDiggingOpen(world, xPos, yPos, zPos, xPos - pos.getX() - 0.5D, yPos - pos.getY() - 0.5D, zPos - pos.getZ() - 0.5D, state).setBlockPos(pos)); } return true; } return false; }
/** * Spawns the break particles for a block, similarly to the normal block break effect * particle. The intended use of this method is to override the block break effects. * * @param manager The EffectRenderer, used to render the particle effect. * @param state The BlockState for the block to render the breaking effect of. * @param world The World to spawn the particle effect in. * @param pos The position to spawn the particles at. * @return boolean Whether or not the effect actually spawned. */ @SideOnly(Side.CLIENT) public static boolean spawnBreakParticles (ParticleManager manager, IBlockState state, World world, BlockPos pos) { if (state.getBlock() != null) { final int multiplier = 4; for (int xOffset = 0; xOffset < multiplier; xOffset++) { for (int yOffset = 0; yOffset < multiplier; yOffset++) { for (int zOffset = 0; zOffset < multiplier; zOffset++) { final double xPos = pos.getX() + (xOffset + 0.5D) / multiplier; final double yPos = pos.getY() + (yOffset + 0.5D) / multiplier; final double zPos = pos.getZ() + (zOffset + 0.5D) / multiplier; manager.addEffect(new OpenParticleDigging(world, xPos, yPos, zPos, xPos - pos.getX() - 0.5D, yPos - pos.getY() - 0.5D, zPos - pos.getZ() - 0.5D, state).setBlockPos(pos)); } } } return true; } return false; }
@SideOnly(Side.CLIENT) @Override public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager effectRenderer) { IBlockState state = world.getBlockState(pos); int i = 4; for (int j = 0; j < i; ++j) { for (int k = 0; k < i; ++k) { for (int l = 0; l < i; ++l) { double d0 = (double) pos.getX() + ((double) j + 0.5D) / (double) i; double d1 = (double) pos.getY() + ((double) k + 0.5D) / (double) i; double d2 = (double) pos.getZ() + ((double) l + 0.5D) / (double) i; effectRenderer.addEffect((new EntityDiggingFXMoarSigns(world, d0, d1, d2, d0 - (double) pos.getX() - 0.5D, d1 - (double) pos.getY() - 0.5D, d2 - (double) pos.getZ() - 0.5D, pos, state)).setBlockPos(pos)); } } } return true; }
@SideOnly(Side.CLIENT) private void addBlockHitEffects(@Nonnull World world, @Nonnull ParticleManager effectRenderer, double xCoord, double yCoord, double zCoord, @Nonnull EnumFacing sideEnum, @Nonnull TextureAtlasSprite tex) { double d0 = xCoord; double d1 = yCoord; double d2 = zCoord; if (sideEnum.getAxis() != Axis.X) { d0 += rand.nextDouble() * 0.4 - rand.nextDouble() * 0.4; } if (sideEnum.getAxis() != Axis.Y) { d1 += rand.nextDouble() * 0.4 - rand.nextDouble() * 0.4; } if (sideEnum.getAxis() != Axis.Z) { d2 += rand.nextDouble() * 0.4 - rand.nextDouble() * 0.4; } ParticleDigging digFX = (ParticleDigging) Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(EnumParticleTypes.BLOCK_CRACK.getParticleID(), d0, d1, d2, 0, 0, 0, 0); if (digFX != null) { digFX.init().multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F); digFX.setParticleTexture(tex); } }
@Override public boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager manager) { if(world != null && pos != null) if (world instanceof WorldServer) ((WorldServer)world).spawnParticle(EnumParticleTypes.CLOUD, false, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 20, 0.7, 0.7, 0.7, 0, new int[EnumParticleTypes.CLOUD.getArgumentCount()]); return super.addHitEffects(state, worldObj, target, manager); }
@Override public boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager manager) { if(world != null && pos != null) if (world instanceof WorldServer) ((WorldServer)world).spawnParticle(EnumParticleTypes.CLOUD, false, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 4, 0.7, 0.8, 0.6, 0, new int[EnumParticleTypes.CLOUD.getArgumentCount()]); return super.addHitEffects(state, worldObj, target, manager); }
@Override public boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager manager) { if(world != null && pos != null) if (world instanceof WorldServer) ((WorldServer)world).spawnParticle(EnumParticleTypes.SMOKE_NORMAL, false, pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, 6, 0.5, 0.5, 0.6, 0, new int[EnumParticleTypes.SMOKE_NORMAL.getArgumentCount()]); return super.addHitEffects(state, worldObj, target, manager); }
@Override @SideOnly(Side.CLIENT) public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager particleManager) { final float scaleVec = 0.05f; final TileEntity ute = world.getTileEntity(pos); if (ute instanceof StructureTE) { final StructureTE te = (StructureTE) ute; for (MutableBlockPos local : getPattern().getStructureItr()) { //outward Vector float xSpeed = 0.0f; float ySpeed = 0.0f; float zSpeed = 0.0f; for (EnumFacing d : EnumFacing.VALUES) { if (!getPattern().hasBlockAt(local, d)) { d = localToGlobal(d, te.getOrientation(), te.getMirror()); xSpeed += d.getFrontOffsetX(); ySpeed += d.getFrontOffsetY(); zSpeed += d.getFrontOffsetZ(); } } mutLocalToGlobal(local, pos, te.getOrientation(), te.getMirror(), getPattern().getBlockBounds()); spawnBreakParticle(world, te, local, xSpeed * scaleVec, ySpeed * scaleVec, zSpeed * scaleVec); } } return true; //No Destroy Effects }
@SuppressWarnings("deprecation") @SideOnly(Side.CLIENT) @Override public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager effectRenderer) { IBlockState state = world.getBlockState(pos); if (state == null || state.getBlock() != this) { return false; } state = state.getBlock().getActualState(state, world, pos); int i = 4; TextureAtlasSprite tex = null; TileEntity tile = world.getTileEntity(pos); if(Util.notNullAndInstanceOf(tile, TileEntityPipe.class)){ TileEntityPipe pipe = ((TileEntityPipe)tile); tex = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(pipe.getPipeType().getCoreTexture(pipe)); if(tex == null){ return false; } } for (int j = 0; j < i; ++j) { for (int k = 0; k < i; ++k) { for (int l = 0; l < i; ++l) { double d0 = pos.getX() + (j + 0.5D) / i; double d1 = pos.getY() + (k + 0.5D) / i; double d2 = pos.getZ() + (l + 0.5D) / i; ParticleDigging fx = (ParticleDigging) new ParticleDigging.Factory().createParticle(-1, world, d0, d1, d2, d0 - pos.getX() - 0.5D, d1 - pos.getY() - 0.5D, d2 - pos.getZ() - 0.5D, 0); fx.setBlockPos(pos); fx.setParticleTexture(tex); effectRenderer.addEffect(fx); } } } return true; }
private void spawnTwinkleParticles(ParticleManager renderer, World w, double x, double y, double z) { for(int i = 0; i < 5; i++) { TwinkleFX fx = new TwinkleFX(w, x, y, z, true); fx.setOffset((Math.random() * 0.4) - 0.2, (Math.random() * 0.4) - 0.2, (Math.random() * 0.4) - 0.2); fx.setNoClip(true); fx.multipleParticleScaleBy(0.5F); fx.randomizeSpeed(); fx.multiplyVelocity(0.02F); fx.setAlphaEffect(true); fx.setScaleEffect(true); fx.setMaxAge(20); fx.setAnimationTicks(20); renderer.addEffect(fx); } }
@Deprecated//Use the new particle system. @SideOnly (Side.CLIENT) public static void addHitEffects(IBlockState state, World world, RayTraceResult trace, ParticleManager particleManager, IWorldBlockTextureProvider provider) { TextureAtlasSprite sprite = provider.getTexture(trace.sideHit, state, BlockRenderLayer.SOLID, world, trace.getBlockPos()); Cuboid6 cuboid = new Cuboid6(state.getBoundingBox(world, trace.getBlockPos())).add(trace.getBlockPos()); addBlockHitEffects(world, cuboid, trace.sideHit, sprite, particleManager); }
@Deprecated//Use the new particle system. @SideOnly (Side.CLIENT) public static void addDestroyEffects(World world, BlockPos pos, ParticleManager particleManager, IWorldBlockTextureProvider provider) { TextureAtlasSprite[] sprites = new TextureAtlasSprite[6]; IBlockState state = world.getBlockState(pos); for (EnumFacing face : EnumFacing.VALUES) { sprites[face.ordinal()] = provider.getTexture(face, state, BlockRenderLayer.SOLID, world, pos); } Cuboid6 cuboid = new Cuboid6(state.getBoundingBox(world, pos)).add(pos); addBlockDestroyEffects(world, cuboid, sprites, particleManager); }
@SideOnly (Side.CLIENT) public static void addLandingEffects(World world, BlockPos pos, IBlockState state, Vector3 entityPos, int numParticles) { //Speshal raytrace, from feet to, down. Vector3 start = entityPos.copy(); Vector3 end = start.copy().add(Vector3.down.copy().multiply(4)); RayTraceResult traceResult = world.rayTraceBlocks(start.vec3(), end.vec3(), true, false, true); if (traceResult != null && traceResult.typeOfHit == Type.BLOCK) { ParticleManager manager = Minecraft.getMinecraft().effectRenderer; Random randy = new Random(); BlockModelShapes modelProvider = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes(); try { state = state.getActualState(world, pos); } catch (Throwable ignored) { } IBakedModel model = modelProvider.getModelForState(state); state = state.getBlock().getExtendedState(state, world, pos); if (model instanceof IModelParticleProvider) { Set<TextureAtlasSprite> hitSprites = ((IModelParticleProvider) model).getHitEffects(traceResult, state, world, pos); List<TextureAtlasSprite> sprites = hitSprites.stream().filter(sprite -> !ignoredParticleSprites.contains(sprite)).collect(Collectors.toList()); double speed = 0.15000000596046448D; if (numParticles != 0) { for (int i = 0; i < numParticles; i++) { double mX = randy.nextGaussian() * speed; double mY = randy.nextGaussian() * speed; double mZ = randy.nextGaussian() * speed; manager.addEffect(DigIconParticle.newLandingParticle(world, entityPos.x, entityPos.y, entityPos.z, mX, mY, mZ, sprites.get(randy.nextInt(sprites.size())))); } } } } }
@SideOnly (Side.CLIENT) public static void addBlockHitEffects(World world, Cuboid6 bounds, EnumFacing side, TextureAtlasSprite icon, ParticleManager particleManager) { float border = 0.1F; Vector3 diff = bounds.max.copy().subtract(bounds.min).add(-2 * border); diff.x *= world.rand.nextDouble(); diff.y *= world.rand.nextDouble(); diff.z *= world.rand.nextDouble(); Vector3 pos = diff.add(bounds.min).add(border); if (side == EnumFacing.DOWN) { diff.y = bounds.min.y - border; } if (side == EnumFacing.UP) { diff.y = bounds.max.y + border; } if (side == EnumFacing.NORTH) { diff.z = bounds.min.z - border; } if (side == EnumFacing.SOUTH) { diff.z = bounds.max.z + border; } if (side == EnumFacing.WEST) { diff.x = bounds.min.x - border; } if (side == EnumFacing.EAST) { diff.x = bounds.max.x + border; } particleManager.addEffect(new DigIconParticle(world, pos.x, pos.y, pos.z, 0, 0, 0, icon).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); }
/** * Spawns the digging particles for a block, similarly to the normal block hit effect * particle. The intended use of this method is to override the block hit effects. * * @param manager The EffectRenderer, used to render the particle effect. * @param state The BlockState for the block to render the breaking effect of. * @param world The World to spawn the particle effects in. * @param pos The position to spawn the particles at. * @param side The side offset for the effect. * @return boolean Whether or not the effect actually spawned. */ public static boolean spawnDigParticles (ParticleManager manager, IBlockState state, World world, BlockPos pos, EnumFacing side) { if (state != null && state.getRenderType() != EnumBlockRenderType.INVISIBLE) { final int x = pos.getX(); final int y = pos.getY(); final int z = pos.getZ(); final float offset = 0.1F; final AxisAlignedBB bounds = state.getBoundingBox(world, pos); double xOffset = x + MMDLib.RANDOM.nextDouble() * (bounds.maxX - bounds.minX - offset * 2.0F) + offset + bounds.minX; double yOffset = y + MMDLib.RANDOM.nextDouble() * (bounds.maxY - bounds.minY - offset * 2.0F) + offset + bounds.minY; double zOffset = z + MMDLib.RANDOM.nextDouble() * (bounds.maxZ - bounds.minZ - offset * 2.0F) + offset + bounds.minZ; if (side == EnumFacing.DOWN) yOffset = y + bounds.minY - offset; else if (side == EnumFacing.UP) yOffset = y + bounds.maxY + offset; else if (side == EnumFacing.NORTH) zOffset = z + bounds.minZ - offset; else if (side == EnumFacing.SOUTH) zOffset = z + bounds.maxZ + offset; else if (side == EnumFacing.WEST) xOffset = x + bounds.minX - offset; else if (side == EnumFacing.EAST) xOffset = x + bounds.maxX + offset; manager.addEffect(new ParticleDiggingOpen(world, xOffset, yOffset, zOffset, 0.0D, 0.0D, 0.0D, state).setBlockPos(pos).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); } return false; }
/** * Spawns the digging particles for a block, similarly to the normal block hit effect * particle. The intended use of this method is to override the block hit effects. * * @param manager The EffectRenderer, used to render the particle effect. * @param state The BlockState for the block to render the breaking effect of. * @param world The World to spawn the particle effects in. * @param pos The position to spawn the particles at. * @param side The side offset for the effect. * @return boolean Whether or not the effect actually spawned. */ @SideOnly(Side.CLIENT) public static boolean spawnDigParticles (ParticleManager manager, IBlockState state, World world, BlockPos pos, EnumFacing side) { if (state != null && state.getRenderType() != EnumBlockRenderType.INVISIBLE) { final int x = pos.getX(); final int y = pos.getY(); final int z = pos.getZ(); final float offset = 0.1F; final AxisAlignedBB bounds = state.getBoundingBox(world, pos); double xOffset = x + Constants.RANDOM.nextDouble() * (bounds.maxX - bounds.minX - offset * 2.0F) + offset + bounds.minX; double yOffset = y + Constants.RANDOM.nextDouble() * (bounds.maxY - bounds.minY - offset * 2.0F) + offset + bounds.minY; double zOffset = z + Constants.RANDOM.nextDouble() * (bounds.maxZ - bounds.minZ - offset * 2.0F) + offset + bounds.minZ; if (side == EnumFacing.DOWN) { yOffset = y + bounds.minY - offset; } else if (side == EnumFacing.UP) { yOffset = y + bounds.maxY + offset; } else if (side == EnumFacing.NORTH) { zOffset = z + bounds.minZ - offset; } else if (side == EnumFacing.SOUTH) { zOffset = z + bounds.maxZ + offset; } else if (side == EnumFacing.WEST) { xOffset = x + bounds.minX - offset; } else if (side == EnumFacing.EAST) { xOffset = x + bounds.maxX + offset; } manager.addEffect(new OpenParticleDigging(world, xOffset, yOffset, zOffset, 0.0D, 0.0D, 0.0D, state).setBlockPos(pos).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); } return false; }
@Override @SideOnly(Side.CLIENT) public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager manager) { IBlockState blockState = world.getBlockState(pos); if(blockState.getBlock() != this) { // somehow got called for a different block if(blockState.getBlock() instanceof SuperBlock) { // if the block at given position is somehow also a SuperBlock, call particle handler for it ((SuperBlock)(blockState.getBlock())).addDestroyEffects(world, pos, manager); } else { // handle as a vanilla block return false; } } ModelState modelState = this.getModelStateAssumeStateIsCurrent(world.getBlockState(pos), world, pos, false); 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 ParticleDiggingSuperBlock(world, (double)pos.getX() + d0, (double)pos.getY() + d1, (double)pos.getZ() + d2, d0 - 0.5D, d1 - 0.5D, d2 - 0.5D, blockState, modelState)).setBlockPos(pos)); } } } return true; }
@Override @SideOnly(Side.CLIENT) public void randomDisplayTick(@Nonnull IBlockState bs, @Nonnull World world, @Nonnull BlockPos pos, @Nonnull Random rand) { // Spit some "steam" out the spout TileVat te = getTileEntity(world, pos); if (te != null && te.isActive()) { float pX = pos.getX() + 0.5f; float pY = pos.getY() + 0.7f; float pZ = pos.getZ() + 0.5f; EnumFacing dir = te.getFacing(); pX += 0.6f * dir.getFrontOffsetX(); pZ += 0.6f * dir.getFrontOffsetZ(); double velX = ((rand.nextDouble() * 0.075) + 0.025) * dir.getFrontOffsetX(); double velZ = ((rand.nextDouble() * 0.075) + 0.025) * dir.getFrontOffsetZ(); int num = rand.nextInt(4) + 2; for (int k = 0; k < num; k++) { ParticleManager er = Minecraft.getMinecraft().effectRenderer; Particle fx = er.spawnEffectParticle(EnumParticleTypes.SMOKE_NORMAL.getParticleID(), pX, pY, pZ, 1, 1, 1, 0); if (fx != null) { fx.setRBGColorF(1 - (rand.nextFloat() * 0.2f), 1 - (rand.nextFloat() * 0.1f), 1 - (rand.nextFloat() * 0.2f)); ClientUtil.setParticleVelocity(fx, velX, -0.06, velZ); } } } }
@SideOnly(Side.CLIENT) @Override public boolean addHitEffects(@Nonnull IBlockState state, @Nonnull World world, @Nonnull RayTraceResult target, @Nonnull ParticleManager effectRenderer) { TextureAtlasSprite tex = null; TileConduitBundle cb = getTileEntity(world, target.getBlockPos()); if (cb == null) { return false; } if (YetaUtil.isSolidFacadeRendered(cb, Minecraft.getMinecraft().player)) { IBlockState paintSource = cb.getPaintSource(); if (paintSource != null) { tex = RenderUtil.getTexture(paintSource); } } else if (target.hitInfo instanceof CollidableComponent) { CollidableComponent cc = (CollidableComponent) target.hitInfo; IConduit con = cb.getConduit(cc.conduitType); if (con != null && con instanceof IConduit.WithDefaultRendering) { tex = ((IConduit.WithDefaultRendering) con).getTextureForState(cc); } } if (tex == null) { tex = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(ModObject.block_machine_base.getBlockNN().getDefaultState()); } lastHitIcon = tex; addBlockHitEffects(world, effectRenderer, target.hitVec.xCoord, target.hitVec.yCoord, target.hitVec.zCoord, target.sideHit, tex); return true; }
@SideOnly(Side.CLIENT) @Override public boolean addDestroyEffects(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull ParticleManager effectRenderer) { if (lastHitIcon == null) { lastHitIcon = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes() .getTexture(ModObject.block_machine_base.getBlockNN().getDefaultState()); } IBlockState state = world.getBlockState(pos); TextureAtlasSprite tex = lastHitIcon; if (state.getBlock() != this || tex == null) { return false; } state = state.getActualState(world, pos); int i = 4; for (int j = 0; j < i; ++j) { for (int k = 0; k < i; ++k) { for (int l = 0; l < i; ++l) { double d0 = pos.getX() + (j + 0.5D) / i; double d1 = pos.getY() + (k + 0.5D) / i; double d2 = pos.getZ() + (l + 0.5D) / i; ParticleDigging fx = (ParticleDigging) new ParticleDigging.Factory().createParticle(-1, world, d0, d1, d2, d0 - pos.getX() - 0.5D, d1 - pos.getY() - 0.5D, d2 - pos.getZ() - 0.5D, 0); fx.setBlockPos(pos); fx.setParticleTexture(tex); effectRenderer.addEffect(fx); } } } return true; }
@SideOnly(Side.CLIENT) public static boolean addHitEffects(@Nonnull IBlockState state, @Nonnull World world, @Nonnull RayTraceResult target, @Nonnull ParticleManager effectRenderer) { if (state.getBlock() instanceof IPaintable) { BlockPos pos = target.getBlockPos(); IBlockState paintSource = ((IPaintable) state.getBlock()).getPaintSource(state, world, pos); if (paintSource != null) { addBlockHitEffects(world, state, paintSource, pos, target.sideHit, effectRenderer); lastTexture = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(paintSource); return true; } } return false; }
@SideOnly(Side.CLIENT) public static boolean addDestroyEffects(@Nonnull World world, @Nonnull BlockPos pos, @Nonnull ParticleManager effectRenderer) { TextureAtlasSprite texture = null; IBlockState state = world.getBlockState(pos); if (state.getBlock() instanceof IPaintable) { IBlockState paintSource = ((IPaintable) state.getBlock()).getPaintSource(state, world, pos); if (paintSource != null) { texture = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getTexture(paintSource); } } if (texture == null) { texture = lastTexture; if (texture == null) { return false; } } int i = 4; for (int j = 0; j < i; ++j) { for (int k = 0; k < i; ++k) { for (int l = 0; l < i; ++l) { double d0 = pos.getX() + (j + 0.5D) / i; double d1 = pos.getY() + (k + 0.5D) / i; double d2 = pos.getZ() + (l + 0.5D) / i; ParticleDigging fx = (ParticleDigging) new ParticleDigging.Factory().createParticle(-1, world, d0, d1, d2, d0 - pos.getX() - 0.5D, d1 - pos.getY() - 0.5D, d2 - pos.getZ() - 0.5D, 0); fx.setBlockPos(pos); fx.setParticleTexture(texture); effectRenderer.addEffect(fx); } } } return true; }
@Override public void addDestroyEffects(CuboidRayTraceResult hit, ParticleManager effectRenderer) { IconHitEffects.addDestroyEffects(this, effectRenderer); }
@Override @SideOnly(Side.CLIENT) public void addHitEffects(CuboidRayTraceResult hit, ParticleManager effectRenderer) { IconHitEffects.addHitEffects(this, hit, effectRenderer); }
@SubscribeEvent @SideOnly(Side.CLIENT) public void playerTick(TickEvent.PlayerTickEvent tickEvent) { EntityPlayer entity = tickEvent.player; if (entity == null) return; World world = entity.world; if (world == null || !world.isRemote) return; if (InteractionBWA.OBVIOUS_STORMS) { ParticleManager particleManager = Minecraft.getMinecraft().effectRenderer; Random random = world.rand; BlockPos pos = entity.getPosition(); int radius = 16; //blocks for (int i = 0; i < InteractionBWA.DUST_PARTICLES; i++) { BlockPos posGround = pos.add(random.nextInt(radius * 2 + 1) - radius, random.nextInt(radius * 2 + 1) - radius, random.nextInt(radius * 2 + 1) - radius); if (!shouldStorm(world, posGround)) continue; posGround = world.getHeight(posGround).down(); //Constant access whaaaat??? IBlockState stateGround = world.getBlockState(posGround); Particle particleGround = particleManager.spawnEffectParticle(EnumParticleTypes.BLOCK_DUST.getParticleID(), posGround.getX() + random.nextDouble(), posGround.getY() + 1.2, posGround.getZ() + random.nextDouble(), -0.5 - random.nextDouble() * 0.6, 0.0, 0.0, Block.getStateId(stateGround)); } for (int i = 0; i < InteractionBWA.AIR_PARTICLES; i++) { BlockPos posAir = pos.add(random.nextInt(radius * 2 + 1) - radius, random.nextInt(radius * 2 + 1) - radius, random.nextInt(radius * 2 + 1) - radius); if (world.canSeeSky(posAir) && shouldStorm(world, posAir)) { Particle particleAir = particleManager.spawnEffectParticle(EnumParticleTypes.SMOKE_NORMAL.getParticleID(), posAir.getX() + random.nextDouble(), posAir.getY() + random.nextDouble(), posAir.getZ() + random.nextDouble(), -0.5 - random.nextDouble() * 0.6, 0.0, 0.0); particleAir.setRBGColorF(1.0f, 1.0f, 1.0f); } } } if (InteractionBWA.OBVIOUS_SAND_STORMS) { float epsilon = 0.001f; if (Math.abs(currentDistance - desiredDistance) > epsilon) currentDistance += (desiredDistance - currentDistance) * 0.2; //TODO: We can do better. if (Math.abs(currentDistanceScale - desiredDistanceScale) > epsilon) currentDistanceScale += (desiredDistanceScale - currentDistanceScale) * 0.2; //TODO: We can do better. if (Math.abs(currentRed - desiredRed) > epsilon) currentRed += (desiredRed - currentRed) * 0.2; if (Math.abs(currentGreen - desiredGreen) > epsilon) currentGreen += (desiredGreen - currentGreen) * 0.2; if (Math.abs(currentBlue - desiredBlue) > epsilon) currentBlue += (desiredBlue - currentBlue) * 0.2; } }
@Override @SideOnly(Side.CLIENT) public boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager manager) { return super.addHitEffects(state, worldObj, target, manager); }
@SuppressWarnings("deprecation") @SideOnly(Side.CLIENT) @Override public boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager effectRenderer) { BlockPos pos = target.getBlockPos(); EnumFacing side = target.sideHit; IBlockState iblockstate = worldObj.getBlockState(pos); TextureAtlasSprite sprite = null; TileEntity tile = worldObj.getTileEntity(pos); if(Util.notNullAndInstanceOf(tile, TileEntityPipe.class)){ TileEntityPipe pipe = ((TileEntityPipe)tile); sprite = Minecraft.getMinecraft().getTextureMapBlocks().getAtlasSprite(pipe.getPipeType().getCoreTexture(pipe)); CoverData data = pipe.getCoverData(side); if(data !=null && data.getBlockState() !=null){ if(data.getBlockState().getBlock().addHitEffects(data.getBlockState(), new PipeWorldWrapper(worldObj, pos, side), target, effectRenderer)){ return true; } sprite = RenderUtil.getTexture(data.getBlockState()); } if(sprite == null){ return false; } } if(iblockstate == null)return false; Block block = iblockstate.getBlock(); if (block.getRenderType(iblockstate) != EnumBlockRenderType.INVISIBLE) { AxisAlignedBB blockBounds = block.getBoundingBox(iblockstate, new PipeWorldWrapper(worldObj, pos, side), pos); int i = pos.getX(); int j = pos.getY(); int k = pos.getZ(); float f = 0.1F; double d0 = i + this.rand.nextDouble() * (blockBounds.maxX - blockBounds.minX - f * 2.0F) + f + blockBounds.minX; double d1 = j + this.rand.nextDouble() * (blockBounds.maxY - blockBounds.minY - f * 2.0F) + f + blockBounds.minY; double d2 = k + this.rand.nextDouble() * (blockBounds.maxZ - blockBounds.minZ - f * 2.0F) + f + blockBounds.minZ; if (side == EnumFacing.DOWN) { d1 = j + blockBounds.minY - f; } if (side == EnumFacing.UP) { d1 = j + blockBounds.maxY + f; } if (side == EnumFacing.NORTH) { d2 = k + blockBounds.minZ - f; } if (side == EnumFacing.SOUTH) { d2 = k + blockBounds.maxZ + f; } if (side == EnumFacing.WEST) { d0 = i + blockBounds.minX - f; } if (side == EnumFacing.EAST) { d0 = i + blockBounds.maxX + f; } ParticleDigging fx = (ParticleDigging) Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(EnumParticleTypes.BLOCK_CRACK.getParticleID(), d0, d1, d2, 0, 0, 0, 0); fx.init().multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F); fx.setParticleTexture(sprite); effectRenderer.addEffect(fx); return true; } return super.addHitEffects(state, worldObj, target, effectRenderer); }
@SideOnly (Side.CLIENT) @Deprecated//Remove in 1.13 public static void addBlockDestroyEffects(World world, Cuboid6 bounds, TextureAtlasSprite[] icons, ParticleManager particleManager) { addBlockDestroyEffects(world, bounds, Lists.newArrayList(icons), particleManager); }
public ExParticleFirework_Starter(World world, double x, double y, double z, double mx, double my, double mz, ParticleManager manager, NBTTagCompound nbt) { super(world, x, y, z, mx, my, mz, manager, nbt); itemNbt = nbt; }
public ParticleManagerTransformer() { super(ParticleManager.class); }
@Override public boolean addHitEffects (IBlockState state, World world, RayTraceResult hitPos, ParticleManager renderer) { final TileEntity tile = world.getTileEntity(hitPos.getBlockPos()); if (tile instanceof TileEntitySneaky && !tile.isInvalid()) { final TileEntitySneaky sneaky = (TileEntitySneaky) tile; if (sneaky.heldState != null) { return ParticleUtils.spawnDigParticles(renderer, sneaky.heldState, world, hitPos.getBlockPos(), hitPos.sideHit); } } return false; }
@Override public boolean addDestroyEffects (World world, BlockPos pos, ParticleManager renderer) { final TileEntity tile = world.getTileEntity(pos); if (tile instanceof TileEntitySneaky && !tile.isInvalid()) { final TileEntitySneaky sneaky = (TileEntitySneaky) tile; if (sneaky.heldState != null) { return ParticleUtils.spawnBreakParticles(renderer, sneaky.heldState, world, pos); } } return false; }
@Override public boolean addHitEffects(IBlockState state, World worldObj, RayTraceResult target, ParticleManager manager) { return true; }
@Override public boolean addDestroyEffects(World world, BlockPos pos, ParticleManager manager) { return true; }
@Override @SideOnly(Side.CLIENT) public boolean addHitEffects(IBlockState blockState, World world, RayTraceResult target, ParticleManager manager) { if(blockState.getBlock() != this) { // somehow got called for a different block if(blockState.getBlock() instanceof SuperBlock) { // if the block at given position is somehow also a SuperBlock, call particle handler for it ((SuperBlock)(blockState.getBlock())).addHitEffects(blockState, world, target, manager); } else { // handle as a vanilla block return false; } } BlockPos pos = target.getBlockPos(); ModelState modelState = this.getModelState(world, pos, false); EnumFacing side = target.sideHit; if (blockState.getRenderType() != EnumBlockRenderType.INVISIBLE) { int i = pos.getX(); int j = pos.getY(); int k = pos.getZ(); AxisAlignedBB axisalignedbb = blockState.getBoundingBox(world, pos); double d0 = (double)i + ThreadLocalRandom.current().nextDouble() * (axisalignedbb.maxX - axisalignedbb.minX - 0.20000000298023224D) + 0.10000000149011612D + axisalignedbb.minX; double d1 = (double)j + ThreadLocalRandom.current().nextDouble() * (axisalignedbb.maxY - axisalignedbb.minY - 0.20000000298023224D) + 0.10000000149011612D + axisalignedbb.minY; double d2 = (double)k + ThreadLocalRandom.current().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; } manager.addEffect((new ParticleDiggingSuperBlock(world, d0, d1, d2, 0.0D, 0.0D, 0.0D, blockState, modelState)).setBlockPos(pos).multiplyVelocity(0.2F).multipleParticleScaleBy(0.6F)); } return true; }
@Override public boolean addHitEffects(IBlockState blockState, World world, RayTraceResult target, ParticleManager manager) { // no hit effects for virtual blocks return true; }