Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
MehVahdJukaar committed May 28, 2024
1 parent fbb5897 commit ab3ebd4
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 76 deletions.
4 changes: 2 additions & 2 deletions build.properties
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#Tue May 28 12:18:02 UTC 2024
#Tue May 28 12:25:43 UTC 2024
mapping_version=1.20.1
version=4.0
mod_name=Quark
mc_version=1.20.1
mapping_channel=official
mod_id=quark
build_number=447
build_number=448
dir_output=../Build Output/Quark/
Original file line number Diff line number Diff line change
@@ -1,74 +1,75 @@
package org.violetmoon.quark.addons.oddities.client.particle;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
import net.minecraftforge.client.event.RegisterShadersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.violetmoon.quark.addons.oddities.module.MagnetsModule;
import org.violetmoon.quark.base.Quark;

import java.util.function.Supplier;

import static com.mojang.blaze3d.vertex.DefaultVertexFormat.PARTICLE;

// Im putting here some stuff idk where else to put
@Mod.EventBusSubscriber(modid = "quark", value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
public class MagnetParticleRenderType {

//I think this just makes it so stuff with low alpha isn't cutoff
private static Supplier<ShaderInstance> PARTICLE_SHADER = GameRenderer::getParticleShader;

public static final ParticleRenderType ADDITIVE_TRANSLUCENCY = new ParticleRenderType() {
@Override
public void begin(BufferBuilder builder, TextureManager textureManager) {
RenderSystem.setShader(PARTICLE_SHADER);
RenderSystem.depthMask(false);
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES);
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
builder.begin(VertexFormat.Mode.QUADS, PARTICLE);
}

@Override
public void end(Tesselator tesselator) {
tesselator.end();
}

public String toString() {
return "PARTICLE_SHEET_ADDITIVE_TRANSLUCENT";
}
};

// On fabric don't add this if its too much. just leave on forge. Shader just makes particles a tiny bit nicer as it doesnt cut off alpha
@SubscribeEvent
public static void registerShader(RegisterShadersEvent event) {
try {
ShaderInstance translucentParticleShader = new ShaderInstance(event.getResourceProvider(),
Quark.asResource("particle_translucent"), DefaultVertexFormat.POSITION_TEX);

event.registerShader(translucentParticleShader, s -> PARTICLE_SHADER = () -> s);

} catch (Exception e) {
Quark.LOG.error("Failed to parse shader: " + e);
}
}

@SubscribeEvent
public static void registerParticleProviders(RegisterParticleProvidersEvent event) {
event.registerSpriteSet(MagnetsModule.attractorParticle, MagnetParticle.Provider::new);
event.registerSpriteSet(MagnetsModule.repulsorParticle, MagnetParticle.Provider::new);
}

}
package org.violetmoon.quark.addons.oddities.client.particle;

import com.mojang.blaze3d.platform.GlStateManager;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import net.minecraft.client.particle.ParticleRenderType;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.ShaderInstance;
import net.minecraft.client.renderer.texture.TextureAtlas;
import net.minecraft.client.renderer.texture.TextureManager;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.client.event.RegisterParticleProvidersEvent;
import net.minecraftforge.client.event.RegisterShadersEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import org.violetmoon.quark.addons.oddities.module.MagnetsModule;
import org.violetmoon.quark.base.Quark;

import java.util.function.Supplier;

import static com.mojang.blaze3d.vertex.DefaultVertexFormat.PARTICLE;

// Im putting here some stuff idk where else to put
@Mod.EventBusSubscriber(modid = "quark", value = Dist.CLIENT, bus = Mod.EventBusSubscriber.Bus.MOD)
public class MagnetParticleRenderType {

//I think this just makes it so stuff with low alpha isn't cutoff
private static Supplier<ShaderInstance> PARTICLE_SHADER = GameRenderer::getParticleShader;

public static final ParticleRenderType ADDITIVE_TRANSLUCENCY = new ParticleRenderType() {
@Override
public void begin(BufferBuilder builder, TextureManager textureManager) {
RenderSystem.setShader(PARTICLE_SHADER);
RenderSystem.depthMask(false);
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES);
RenderSystem.enableBlend();
RenderSystem.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE);
builder.begin(VertexFormat.Mode.QUADS, PARTICLE);
}

@Override
public void end(Tesselator tesselator) {
tesselator.end();
}

@Override
public String toString() {
return "PARTICLE_SHEET_ADDITIVE_TRANSLUCENT";
}
};

// On fabric don't add this if its too much. just leave on forge. Shader just makes particles a tiny bit nicer as it doesnt cut off alpha
@SubscribeEvent
public static void registerShader(RegisterShadersEvent event) {
try {
ShaderInstance translucentParticleShader = new ShaderInstance(event.getResourceProvider(),
Quark.asResource("particle_translucent"), DefaultVertexFormat.POSITION_TEX);

event.registerShader(translucentParticleShader, s -> PARTICLE_SHADER = () -> s);

} catch (Exception e) {
Quark.LOG.error("Failed to parse shader: " + e);
}
}

@SubscribeEvent
public static void registerParticleProviders(RegisterParticleProvidersEvent event) {
event.registerSpriteSet(MagnetsModule.attractorParticle, MagnetParticle.Provider::new);
event.registerSpriteSet(MagnetsModule.repulsorParticle, MagnetParticle.Provider::new);
}

}

0 comments on commit ab3ebd4

Please sign in to comment.