Java 类net.minecraft.client.particle.IParticleFactory 实例源码

项目:Alchemy    文件:AlchemyFXType.java   
@Nullable
public static EnumParticleTypes registerParticleTypes(String name, Class factory, boolean ignoreRange) throws Exception {
    AlchemyModLoader.checkState();
    int id = EnumParticleTypes.values().length;
    if (Always.runOnClient())
        if (Tool.isInstance(IParticleFactory.class, factory))
            Minecraft.getMinecraft().effectRenderer.registerParticle(id, (IParticleFactory) factory.newInstance());
        else 
            AlchemyRuntimeException.onException(new RuntimeException(
                    "Class<" + factory.getName() + "> forgot to implement the Interface<" + IParticleFactory.class.getName() + "> ?"));
    EnumParticleTypes type = EnumHelper.addEnum(EnumParticleTypes.class, name,
            new Class[] { String.class, int.class, boolean.class }, name, id, ignoreRange);
    EnumParticleTypes.PARTICLES.put(type.getParticleID(), type);
    EnumParticleTypes.BY_NAME.put(type.getParticleName(), type);
    return type;
}
项目:MobTotems    文件:EntitySpiritWolf.java   
@SideOnly(Side.CLIENT)
private void spawnParticles() {
    IParticleFactory particleFactory = new ModParticles.Factory();

    long worldTime = getEntityWorld().getTotalWorldTime();
    if (worldTime % 8 == 0) {
        double initialYSpeed = 0.05D;

        Vec3d forwardVec = getForward();
        Vec3d speedVec = new Vec3d(0, -forwardVec.y * 0.10 + initialYSpeed, 0);
        float yPos = (float) this.getEntityBoundingBox().minY;

        for (int j = 0; j < 2; ++j) {
            float xPos = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
            float zPos = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width;
            Particle particle = particleFactory.createParticle(ModParticles.WOLF_IDLE_SMOKE, getEntityWorld(), this.posX + (double) xPos, (double) (yPos + 0.1F), this.posZ + (double) zPos, speedVec.x, speedVec.y, speedVec.z);
            Minecraft.getMinecraft().effectRenderer.addEffect(particle);
        }
    }
}
项目:BlazeLoader    文件:ParticlesRegisterClient.java   
/**
 * Initialises particle IDs and loads them into the vanilla registry for external API support.
 * @param mapping   Mapping of pre-registered vanilla Particles
 *
 * @return A new, or previously cached, mapping with all custom particles added.
 */
//FIXME: This has to be linked up at the bottom of EffectRenderer.func_178930_c(). There might be a better place for this method though.
public static Map<Integer, IParticleFactory> syncroniseParticlesRegistry(Map<Integer, IParticleFactory> mapping) {
    if (vanillaRegistry == null || !vanillaRegistry.equals(mapping)) {
        vanillaRegistry = mapping;
        int injected = 0;
        Iterator<IParticle> types = particlesRegistry.iterator();
        for (int i = 0; types.hasNext();) {
            if (mapping.containsKey(i)) {
                i++;
            } else {
                ParticleTypeClient type = (ParticleTypeClient)types.next();
                if (!particleIds.containsValue(type)) {
                    mapping.put(i, type.getFactory());
                    particleIds.put(i, type.setId(i));
                    i++;
                } else {
                    if (!mapping.containsKey(type.getId())) {
                        mapping.put(type.getId(), type.getFactory());
                    }
                }
            }
        }
    }
    return vanillaRegistry;
}
项目:ShearMadness    文件:CustomParticleFactoryBase.java   
@Override
@SideOnly(Side.CLIENT)
public IParticleFactory getParticleFactory() {
    if (factory == null) {
        factory = (particleID, worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, parameters) -> createCustomParticle(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, parameters);
    }
    return factory;
}
项目:NOVA-Core    文件:BWEntityFX.java   
public EntityFX createEntityFX(net.minecraft.world.World world) {
    //Look up for particle factory and pass it into BWEntityFX
    IParticleFactory particleFactory = (IParticleFactory) FMLClientHandler.instance().getClient().effectRenderer.field_178932_g.get(particleID);
    EntityFX entity = particleFactory.getEntityFX(0, world, 0, 0, 0, 0, 0, 0, 0);
    WrapperEvent.BWEntityFXCreate event = new WrapperEvent.BWEntityFXCreate(this, entity);
    Game.events().publish(event);
    return entity;
}
项目:ZeldaSwordSkills    文件:EntityChu.java   
@SideOnly(Side.CLIENT)
private void spawnParticlesOnLanding() {
    int i = getSlimeSize();
    float r = 1.0F, g = 1.0F, b = 1.0F;
    switch(getType()) {
    case RED: r = 0.65F; g = 0.25F; b = 0.3F; break;
    case BLUE: r = 0.25F; g = 0.4F; b = 0.75F; break;
    case YELLOW: g = 0.65F; b = 0.0F; break;
    default:
    }
    for (int j = 0; j < i * 8; ++j) {
        float f = rand.nextFloat() * (float) Math.PI * 2.0F;
        float f1 = rand.nextFloat() * 0.5F + 0.5F;
        float f2 = MathHelper.sin(f) * (float) i * 0.5F * f1;
        float f3 = MathHelper.cos(f) * (float) i * 0.5F * f1;
        // Need to use a factory to return the particle without automatically adding it to the effect renderer
        IParticleFactory factory = ClientProxy.particleFactoryMap.get(EnumParticleTypes.SLIME.getParticleID());
        // Alternate option: EntityBreakingFX.SlimeFactory factory = new EntityBreakingFX.SlimeFactory();
        if (factory != null) {
            EntityFX particle = factory.getEntityFX(EnumParticleTypes.SLIME.getParticleID(), worldObj, posX + (double) f2, getEntityBoundingBox().minY, posZ + (double) f3, 0, 0, 0);
            if (particle != null) {
                particle.setRBGColorF(r, g, b);
                WorldUtils.spawnWorldParticles(worldObj, particle);
            }
        }
    }
}
项目:ZeldaSwordSkills    文件:ClientProxy.java   
@Override
public void init() {
    AntiqueAtlasHelper.registerTextures();
    Object o = ReflectionHelper.getPrivateValue(EffectRenderer.class, Minecraft.getMinecraft().effectRenderer, 6);
    if (o instanceof Map) {
        particleFactoryMap = (Map<Integer, IParticleFactory>) o;
    }
}
项目:BlazeLoader    文件:ParticlesRegisterClient.java   
public void spawnParticle(ParticleData particle, World world) {
    if (particle.getType() == ParticleType.NONE) return;

    Minecraft mc = Minecraft.getMinecraft();
if (mc != null && mc.getRenderViewEntity() != null && mc.effectRenderer != null) {
          int particleSetting = mc.gameSettings.particleSetting;

          if (particleSetting == 1 && mc.theWorld.rand.nextInt(3) == 0) {
            particleSetting = 2;
          }

          IParticleFactory factory = ((ParticleTypeClient)particle.getType()).getFactory();
          try {
           if (particle.getIgnoreDistance()) {
            spawnCustomParticle(particle, factory, world);
           } else {
                double disX = mc.getRenderViewEntity().posX - particle.posX;
                double disY = mc.getRenderViewEntity().posY - particle.posY;
                double disZ = mc.getRenderViewEntity().posZ - particle.posZ;
               if (disX * disX + disY * disY + disZ * disZ <= particle.getMaxRenderDistance() && particleSetting <= 1) {
                spawnCustomParticle(particle, factory, world);
               }
           }
          } catch (Throwable e) {
            reportParticleError(e, factory, particle.getType(), particle.posX, particle.posY, particle.posZ, particle.getArgs());
          }
      }
  }
项目:BlazeLoader    文件:ParticlesRegisterClient.java   
private void reportParticleError(Throwable e, IParticleFactory factory, IParticle particle, final double x, final double y, final double z, int[] args) {
    CrashReport report = CrashReport.makeCrashReport(e, "Exception while adding custom particle");
    CrashReportCategory category = report.makeCategory("Particle being added");
    category.addCrashSection("ID", particle.getId());
    category.addCrashSection("Particle Factory Class", factory == null ? "Null" : factory.getClass().toString());

    if (args != null && args.length > 0) category.addCrashSection("Parameters", args);
    category.addCrashSectionCallable("Position", new Callable() {
        public String call() {
            return CrashReportCategory.getCoordinateInfo(x, y, z);
        }
    });
    throw new ReportedException(report);
}
项目:ShearMadness    文件:ICustomParticleFactory.java   
@SideOnly(Side.CLIENT)
IParticleFactory getParticleFactory();
项目:MobTotems    文件:CarvingKnife.java   
@SideOnly(Side.CLIENT)
private void spawnParticles(ItemStack stack, World world, EntityPlayer player) {
    long worldTime = world.getWorldTime();

    if (spawnParticles) {
        IParticleFactory particleFactory = new ParticleBlockDust.Factory();

        Vec3d posEyes = player.getPositionEyes(1.0f);
        RayTraceResult rayTraceResult = world.rayTraceBlocks(posEyes, posEyes.add(player.getLookVec().scale(3f)));

        if (rayTraceResult != null) {
            BlockPos pos = rayTraceResult.getBlockPos();
            Block targetBlock = BlockUtils.getBlock(world, pos);

            if (targetBlock != null
                    && targetBlock instanceof TotemWoodBlock) {
                IBlockState state = world.getBlockState(pos);
                int i = 4;

                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;

                            double speedX = d0 - 0.5D;
                            double speedY = d1 - 0.5D;
                            double speedZ = d2 - 0.5D;
                            speedX *= 0.2;
                            speedY *= 0.2;
                            speedZ *= 0.2;
                            Minecraft.getMinecraft().effectRenderer.addEffect(
                                    particleFactory.createParticle(EnumParticleTypes.BLOCK_DUST.getParticleID(),
                                            world,
                                            (double) pos.getX() + d0,
                                            (double) pos.getY() + d1,
                                            (double) pos.getZ() + d2,
                                            speedX,
                                            speedY,
                                            speedZ,
                                            new int[]{Block.getStateId(state)}));
                        }
                    }
                }
            }
        }
        spawnParticles = false;
    }
}
项目:BlazeLoader    文件:ParticlesRegisterClient.java   
public IParticle setFactory(IParticle particle, Object factory) {
    return ((ParticleTypeClient)particle).setFactory((IParticleFactory)factory);
}
项目:BlazeLoader    文件:ParticlesRegisterClient.java   
private void spawnCustomParticle(ParticleData particle, IParticleFactory factory, World world) {
    addEffectToRenderer(factory.getEntityFX(particle.getType().getId(), world, particle.posX, particle.posY, particle.posZ, particle.velX, particle.velY, particle.velZ, particle.getArgs()));
}
项目:BlazeLoader    文件:ParticlesRegisterClient.java   
private Map<Integer, IParticleFactory> getVanillaParticleRegistry() {
    return Minecraft.getMinecraft().effectRenderer.particleTypes;
}
项目:BlazeLoader    文件:ParticleTypeClient.java   
protected final ParticleTypeClient setFactory(IParticleFactory factory) {
    if (particleFactory == null) {
        particleFactory = factory;
    }
    return this;
}
项目:BlazeLoader    文件:ApiParticlesClient.java   
/**
 * Registers a custom particle.
 * 
 * @param particle          ParticleType previously created by registering a particle with ApiParticles
 * @param factory           IParticleFactory to generate an EntityFX when needed
 * 
 * @return ParticleType representing your particle. Use this to spawn your particle.
 */
public static IParticle registerParticleFactory(IParticle particle, IParticleFactory factory) {
    return ParticlesRegister.instance().setFactory(particle, factory);
}
项目:BlazeLoader    文件:ParticleTypeClient.java   
/**
 * Gets the factory used to spawn this particle.
 * 
 * @return IParticleFactory
 */
public IParticleFactory getFactory() {
    return particleFactory;
}