net.minecraft.client.particle.Particle Java Examples

The following examples show how to use net.minecraft.client.particle.Particle. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EntityWitherCat.java    From EnderZoo with Creative Commons Zero v1.0 Universal 6 votes vote down vote up
private void spawnParticles() {
  double startX = posX;
  double startY = posY;
  double startZ = posZ;
  double offsetScale = 0.8 * getScale();
  for (int i = 0; i < 2; i++) {
    double xOffset = offsetScale - rand.nextFloat() * offsetScale * 2;
    double yOffset = offsetScale / 3 + rand.nextFloat() * offsetScale / 3 * 2F;
    double zOffset = offsetScale - rand.nextFloat() * offsetScale * 2;
    Particle fx = Minecraft.getMinecraft().effectRenderer.spawnEffectParticle(EnumParticleTypes.SPELL.getParticleID(), startX + xOffset, startY + yOffset,
        startZ + zOffset, 0.0D, 0.0D, 0.0D);
    if (fx != null) {
      fx.setRBGColorF(0.8f, 0.2f, 0.2f);       
    }
  }
}
 
Example #2
Source File: EntityNewYearsCow.java    From Moo-Fluids with GNU General Public License v3.0 6 votes vote down vote up
@SideOnly(Side.CLIENT)
private void spawnParticle() {
  final Minecraft minecraft = Minecraft.getMinecraft();
  if (minecraft.gameSettings.particleSetting != 2) {
    final ParticleFirework.Factory particleFireworkFactory = new ParticleFirework.Factory();
    final Particle particle =
        particleFireworkFactory.createParticle(1, world,
                                               posX, posY + 1D, posZ,
                                               rand.nextGaussian() * 0.15D,
                                               -motionY * 0.5D,
                                               rand.nextGaussian() * 0.15D);

    particle.setRBGColorF(rand.nextFloat(), rand.nextFloat(), rand.nextFloat());
    minecraft.effectRenderer.addEffect(particle);
  }
}
 
Example #3
Source File: ClientProxy.java    From NOVA-Core with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Entity spawnParticle(net.minecraft.world.World world, Entity entity) {
	//Backward entity particle unwrapper
	if (entity instanceof BWParticle) {
		Particle particle = ((BWParticle) entity).createParticle(world);
		Vector3D position = entity.position();
		particle.posX = position.getX();
		particle.posY = position.getY();
		particle.posZ = position.getZ();
		FMLClientHandler.instance().getClient().effectRenderer.addEffect(particle);
		return Game.natives().toNova(particle);
	} else {
		FWParticle bwEntityFX = new FWParticle(world, entity);
		FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX);
		return bwEntityFX.wrapped;
	}
}
 
Example #4
Source File: ArmorLogicRebreather.java    From GregTech with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
    IElectricItem electricItem = itemStack.getCapability(GregtechCapabilities.CAPABILITY_ELECTRIC_ITEM, null);
    if (electricItem.getCharge() >= energyUsagePerTick) {
        if (player.isInsideOfMaterial(Material.WATER) && world.isRemote && world.getTotalWorldTime() % 20 == 0L) {
            Vec3d pos = player.getPositionVector().add(new Vec3d(0.0, player.getEyeHeight(), 0.0));
            Particle particle = new ParticleBubble.Factory().createParticle(0, world, pos.x, pos.y, pos.z, 0.0, 0.0, 0.0);
            particle.setMaxAge(Integer.MAX_VALUE);
            Minecraft.getMinecraft().effectRenderer.addEffect(particle);
        }
        if (player.isInsideOfMaterial(Material.WATER) && !player.isPotionActive(MobEffects.WATER_BREATHING)) {
            if (player.getAir() < 300 && drainActivationEnergy(electricItem)) {
                player.setAir(Math.min(player.getAir() + 1, 300));
            }
        }
    }
}
 
Example #5
Source File: ClientProxy.java    From Sakura_mod with MIT License 5 votes vote down vote up
@Override
 public void spawnParticle(SakuraParticleType particleType, double x, double y, double z, double velX, double velY, double velZ) {
     Minecraft mc = Minecraft.getMinecraft();
     World world = mc.world;
     if (world == null) return;
     
     if (mc.effectRenderer != null) {
         int i = mc.gameSettings.particleSetting;
         if (i == 1 && world.rand.nextInt(3) == 0) i = 2;
         Particle particle = null;
         switch (particleType) {
         case MAPLERED:
             particle = new ParticleMapleRedLeaf(world, x, y, z, velX, velY, velZ);
             break;
case MAPLEGREEN:
	particle = new ParticleMapleGreenLeaf(world, x, y, z, velX, velY, velZ);
	break;
case MAPLEORANGE:
	particle = new ParticleMapleOrangeLeaf(world, x, y, z, velX, velY, velZ);
	break;
case MAPLEYELLOW:
	particle = new ParticleMapleYellowLeaf(world, x, y, z, velX, velY, velZ);
	break;
case LEAVESSAKURA:
	particle = new ParticleSakuraLeaf(world, x, y, z, velX, velY, velZ);
	break;
case SYRUPDROP:
	particle = new ParticleSyrupDrop(world, x, y, z, velX, velY, velZ);
	break;
default:
	break;

         }

         if (particle != null) {
             mc.effectRenderer.addEffect(particle);
         }

     }
 }
 
Example #6
Source File: BlockEnderCharge.java    From EnderZoo with Creative Commons Zero v1.0 Universal 5 votes vote down vote up
@SideOnly(Side.CLIENT)
public static void doTeleportEffect(World world, double x, double y, double z) {
  Random random = world.rand;
  for (int i = 0; i < 100; ++i) {
    double d = random.nextDouble() * 2D;
    double mag = 2;
    double motionX = (0.5 - random.nextDouble()) * mag * d;
    double motionY = (0.5 - random.nextDouble()) * mag;
    double motionZ = (0.5 - random.nextDouble()) * mag * d;
    Particle entityfx = new ParticlePortal.Factory().createParticle
        (i, world, x + motionX * 0.1, y + motionY * 0.1, z + motionZ * 0.1, motionX, motionY,
        motionZ, (int[])null);
    Minecraft.getMinecraft().effectRenderer.addEffect(entityfx);
  }
}
 
Example #7
Source File: EntityValentinesCow.java    From Moo-Fluids with GNU General Public License v3.0 5 votes vote down vote up
@SideOnly(Side.CLIENT)
private void spawnParticle() {
  final Minecraft minecraft = Minecraft.getMinecraft();
  if (minecraft.gameSettings.particleSetting != 2) {
    final ParticleHeart.Factory particleHeartFactory = new ParticleHeart.Factory();
    final Particle particle =
        particleHeartFactory.createParticle(1, world,
                                            posX + rand.nextDouble(),
                                            posY + rand.nextDouble(),
                                            posZ + rand.nextDouble(),
                                            rand.nextGaussian() * 0.30D, -motionY * 0.5D,
                                            rand.nextGaussian() * 0.30D);
    minecraft.effectRenderer.addEffect(particle);
  }
}
 
Example #8
Source File: ClientProxy.java    From NOVA-Core with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Entity spawnParticle(net.minecraft.world.World world, EntityFactory factory) {
	//Backward entity particle unwrapper
	Entity build = factory.build();
	if (build instanceof BWParticle) {
		Particle particle = ((BWParticle) build).createParticle(world);
		FMLClientHandler.instance().getClient().effectRenderer.addEffect(particle);
		return Game.natives().toNova(particle);
	} else {
		FWParticle bwEntityFX = new FWParticle(world, factory);
		FMLClientHandler.instance().getClient().effectRenderer.addEffect(bwEntityFX);
		return bwEntityFX.wrapped;
	}
}
 
Example #9
Source File: MixinParticleManager.java    From Valkyrien-Skies with Apache License 2.0 5 votes vote down vote up
@Inject(method = "addEffect", at = @At("HEAD"), cancellable = true)
    public void preAddEffect(Particle effect, CallbackInfo callbackInfoReturnable) {
        if (effect == null) {
            callbackInfoReturnable.cancel();
            return;
        }

        BlockPos pos = new BlockPos(effect.posX, effect.posY, effect.posZ);
        Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysicsObject(effect.world, pos);
        if (physicsObject.isPresent()) {
            Vector posVec = new Vector(effect.posX, effect.posY, effect.posZ);
            Vector velocity = new Vector(effect.motionX, effect.motionY, effect.motionZ);
            physicsObject.get()
                .getShipTransformationManager()
                .fromLocalToGlobal(posVec);
//            RotationMatrices.doRotationOnly(wrapper.wrapping.coordTransform.lToWTransform, velocity);
            physicsObject.get()
                .getShipTransformationManager()
                .getCurrentTickTransform()
                .rotate(velocity, TransformType.SUBSPACE_TO_GLOBAL);
            effect.setPosition(posVec.X, posVec.Y, posVec.Z);
            effect.motionX = velocity.X;
            effect.motionY = velocity.Y;
            effect.motionZ = velocity.Z;
        }
        //vanilla code follows
    }
 
Example #10
Source File: MixinParticleManager.java    From multiconnect with MIT License 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Inject(method = "createParticle", at = @At("HEAD"), cancellable = true)
private <T extends ParticleEffect> void onCreateParticle(T effect, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed, CallbackInfoReturnable<Particle> ci) {
    ParticleFactory<T> customFactory = (ParticleFactory<T>) customFactories.get(Registry.PARTICLE_TYPE.getId(effect.getType()));
    if (customFactory != null)
        ci.setReturnValue(customFactory.createParticle(effect, world, x, y, z, xSpeed, ySpeed, zSpeed));
}
 
Example #11
Source File: Dabify.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@SubscribeEvent
public static void clientTick(ClientTickEvent event) {
	EntityPlayer e = Minecraft.getMinecraft().player;
	if(e != null && e.world != null && !Minecraft.getMinecraft().isGamePaused()) {
		Particle particle = new ParticleBasic(e.world, e.posX + (Math.random() - 0.5F), e.posY + 3, e.posZ + (Math.random() - 0.5F), 0.0F, 1000.0F, 0.0F, DabSquirrels.dab, 1F);
		Minecraft.getMinecraft().effectRenderer.addEffect(particle);
	}
}
 
Example #12
Source File: ClientProxy.java    From TofuCraftReload with MIT License 5 votes vote down vote up
@Override
public void spawnParticle(World world, TofuParticleType particleType, double x, double y, double z, double velX, double velY, double velZ) {
    Minecraft mc = Minecraft.getMinecraft();
    Entity entity = mc.getRenderViewEntity();
    // ignore the passed-in world, since on SP we get the integrated server world, which is not really what we want
    world = this.getClientWorld();
    if (entity != null && mc.effectRenderer != null) {
        int i = mc.gameSettings.particleSetting;
        if (i == 1 && world.rand.nextInt(3) == 0) {
            i = 2;
        }
        double d0 = entity.posX - x;
        double d1 = entity.posY - y;
        double d2 = entity.posZ - z;
        if (d0 * d0 + d1 * d1 + d2 * d2 <= 1024D && i <= 1) {
            Particle particle = null;
            switch (particleType) {
                case TOFUPORTAL:
                    particle = new ParticleTofuPortal(world, x, y, z, velX, velY, velZ);
                    break;
                case ZUNDAPOWDER:
                    particle = new ParticleZundaPowder(world, x, y, z, velX, velY, velZ);
                    break;
            }
            if (particle != null) {
                mc.effectRenderer.addEffect(particle);
            }
        }
    }
}
 
Example #13
Source File: PlayerParticleType.java    From MiningGadgets with MIT License 4 votes vote down vote up
@Override
public Particle makeParticle(PlayerParticleData data, World world, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
    return new PlayerParticle(world, x, y, z, data.targetX, data.targetY, data.targetZ, xSpeed, ySpeed, zSpeed, data.size, data.r, data.g, data.b, data.depthTest, data.maxAgeMul, data.partType, this.sprites);
}
 
Example #14
Source File: ParticleRenderer.java    From Logistics-Pipes-2 with MIT License 4 votes vote down vote up
public void renderParticles(EntityPlayer aPlayer, float pTicks) {
	float f = ActiveRenderInfo.getRotationX();
       float f1 = ActiveRenderInfo.getRotationZ();
       float f2 = ActiveRenderInfo.getRotationYZ();
       float f3 = ActiveRenderInfo.getRotationXY();
       float f4 = ActiveRenderInfo.getRotationXZ();
       EntityPlayer player = Minecraft.getMinecraft().player;
       if(player!=null) {
       	Particle.interpPosX = player.lastTickPosX + (player.posX - player.lastTickPosX) * pTicks;
        Particle.interpPosY = player.lastTickPosY + (player.posY - player.lastTickPosY) * pTicks;
        Particle.interpPosZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * pTicks;
        Particle.cameraViewDir = player.getLook(pTicks);
        GlStateManager.enableAlpha();
        GlStateManager.enableBlend();
        GlStateManager.alphaFunc(516, 0.003921569F);
           GlStateManager.disableCull();
           
           GlStateManager.depthMask(false);
           
           Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
		Tessellator tess = Tessellator.getInstance();
		VertexBuffer buffer = tess.getBuffer();
		
		GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
			buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
			for(int i = 0; i < particles.size(); i ++) {
				if(!((ILP2Particle) particles.get(i)).isAdditive()) {
					particles.get(i).renderParticle(buffer, player, pTicks, f, f4, f1, f2, f3);
				}
			}
			tess.draw();
		
		GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
			buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.PARTICLE_POSITION_TEX_COLOR_LMAP);
			for(int i = 0; i < particles.size(); i ++) {
				if(((ILP2Particle) particles.get(i)).isAdditive()) {
					particles.get(i).renderParticle(buffer, player, pTicks, f, f4, f1, f2, f3);
				}
			}
			tess.draw();
		
		GlStateManager.enableCull();
           GlStateManager.depthMask(true);
        GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
        GlStateManager.disableBlend();
        GlStateManager.alphaFunc(516, 0.1F);
       }
}
 
Example #15
Source File: ParticleRenderer.java    From Logistics-Pipes-2 with MIT License 4 votes vote down vote up
public void addParticle(Particle part) {
	particles.add(part);
}
 
Example #16
Source File: LightParticleType.java    From MiningGadgets with MIT License 4 votes vote down vote up
public Particle makeParticle(BasicParticleType typeIn, World worldIn, double x, double y, double z, double xSpeed, double ySpeed, double zSpeed) {
    LightParticle particle = new LightParticle(worldIn, x, y, z, xSpeed, ySpeed, zSpeed);
    particle.selectSpriteRandomly(this.spriteSet);
    particle.setColor(.1F, .5f, .5F);
    return particle;
}
 
Example #17
Source File: BWParticle.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Particle createParticle(net.minecraft.world.World world) {
	//Look up for particle factory and pass it into BWParticle
	IParticleFactory particleFactory = FMLClientHandler.instance().getClient().effectRenderer.particleTypes.get(particleID);
	Particle particle = particleFactory.createParticle(0, world, 0, 0, 0, 0, 0, 0, 0);
	return particle;
}
 
Example #18
Source File: MCParticleTransform.java    From NOVA-Core with GNU Lesser General Public License v3.0 4 votes vote down vote up
public MCParticleTransform(Particle wrapper) {
	this.wrapper = wrapper;
	this.setPivot(Vector3D.ZERO);
}
 
Example #19
Source File: RenderLaser.java    From AdvancedRocketry with MIT License 4 votes vote down vote up
public void doRender(Particle entity, double x, double y, double z,
		float f, float f1) {

	GL11.glPushMatrix();
	GL11.glTranslated(x, y, z);
	BufferBuilder buffer = Tessellator.getInstance().getBuffer();
	GL11.glDisable(GL11.GL_LIGHTING);
	GL11.glDisable(GL11.GL_FOG);
	GL11.glEnable(GL11.GL_BLEND);
	GL11.glDepthMask(false);
	GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

	Minecraft.getMinecraft().renderEngine.bindTexture(flare);
	//bindTexture(flare);

	buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_TEX);

	GlStateManager.color(flareColor[0],flareColor[1],flareColor[2],flareColor[3]);

	for(int i = 0; i < 4; i++) {
		RenderHelper.renderBottomFaceWithUV(buffer, -y + 200, -(i*6) - x, -(i*6) - z, (i*6) - x, (i*6) - z, 0, 1, 0, 1);
	}

	Tessellator.getInstance().draw();

	GL11.glDisable(GL11.GL_TEXTURE_2D);
	OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE, 0, 0);
	//GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);

	buffer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION);
	GlStateManager.color(color[0], color[1], color[2], color[3]);//0.9F, 0.2F, 0.3F, 0.5F);

	for(float radius = 0.25F; radius < size; radius += .25F) {

		for(double i = 0; i < 2*Math.PI; i += Math.PI) {
			buffer.pos(- x , -y + 200,  - z).endVertex();
			buffer.pos(- x, -y + 200, - z).endVertex();
			buffer.pos(- (radius* Math.cos(i)) + 0.5F, 0,- (radius* Math.sin(i)) + 0.5F).endVertex();
			buffer.pos(+ (radius* Math.sin(i)) + 0.5F, 0, (radius* Math.cos(i)) + 0.5F).endVertex();
		}

		for(double i = 0; i < 2*Math.PI; i += Math.PI) {
			buffer.pos(- x, -y + 200,- z).endVertex();
			buffer.pos(- x, -y + 200, - z).endVertex();
			buffer.pos(+ (radius* Math.sin(i)) + 0.5F, 0, -(radius* Math.cos(i)) + 0.5F).endVertex();
			buffer.pos(- (radius* Math.cos(i)) + 0.5F, 0,(radius* Math.sin(i)) + 0.5F).endVertex();
		}
	}

	Tessellator.getInstance().draw();

	GL11.glDisable(GL11.GL_BLEND);
	GL11.glEnable(GL11.GL_LIGHTING);
	GL11.glEnable(GL11.GL_TEXTURE_2D);
	GL11.glEnable(GL11.GL_FOG);
	GL11.glDepthMask(true);
	GL11.glPopMatrix();
	
	GlStateManager.color(1f, 1f, 1f,1f);
	//Clean up and make player not transparent
	OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, 0, 0);

}
 
Example #20
Source File: EntityDabSquirrel.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
@SideOnly(Side.CLIENT)
protected void spawnParticle() {
	Particle particle = new ParticleBasic(this.world, this.posX + Math.random(), this.posY + 4.5, this.posZ + Math.random(), 0.0F, 0.0F, 0.0F, DabSquirrels.dab, 10F);
	Minecraft.getMinecraft().effectRenderer.addEffect(particle);
}
 
Example #21
Source File: ParticlePortal.java    From CommunityMod with GNU Lesser General Public License v2.1 4 votes vote down vote up
public Particle createParticle(int particleID, World worldIn, double xCoordIn, double yCoordIn, double zCoordIn, double xSpeedIn, double ySpeedIn, double zSpeedIn, int... p_178902_15_)
{
    return new ParticlePortal(worldIn, xCoordIn, yCoordIn, zCoordIn, xSpeedIn, ySpeedIn, zSpeedIn, 1F, 1F, 1F);
}