particles still dont work on farbc
This commit is contained in:
parent
153b2b9667
commit
918abb89de
7 changed files with 82 additions and 14 deletions
|
@ -2,6 +2,7 @@ package at.petrak.hexcasting.client.particles;
|
|||
|
||||
import at.petrak.hexcasting.api.HexAPI;
|
||||
import at.petrak.hexcasting.common.particles.ConjureParticleOptions;
|
||||
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.BufferBuilder;
|
||||
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
|
||||
|
@ -93,12 +94,8 @@ public class ConjureParticle extends TextureSheetParticle {
|
|||
}
|
||||
}
|
||||
|
||||
// pretty sure this prevents the gross culling
|
||||
// https://github.com/VazkiiMods/Psi/blob/1.18/src/main/java/vazkii/psi/client/fx/FXWisp.java
|
||||
// https://github.com/VazkiiMods/Botania/blob/db85d778ab23f44c11181209319066d1f04a9e3d/Xplat/src/main/java/vazkii/botania/client/fx/FXWisp.java
|
||||
private record ConjureRenderType(boolean light) implements ParticleRenderType {
|
||||
private static boolean prevBlur;
|
||||
private static boolean prevMipmap;
|
||||
|
||||
@Override
|
||||
public void begin(BufferBuilder buf, TextureManager texMan) {
|
||||
Minecraft.getInstance().gameRenderer.lightTexture().turnOnLightLayer();
|
||||
|
@ -108,18 +105,17 @@ public class ConjureParticle extends TextureSheetParticle {
|
|||
RenderSystem.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE);
|
||||
|
||||
RenderSystem.setShaderTexture(0, TextureAtlas.LOCATION_PARTICLES);
|
||||
texMan.bindForSetup(TextureAtlas.LOCATION_PARTICLES);
|
||||
texMan.getTexture(TextureAtlas.LOCATION_PARTICLES).setFilter(this.light, false);
|
||||
var tex = texMan.getTexture(TextureAtlas.LOCATION_PARTICLES);
|
||||
IClientXplatAbstractions.INSTANCE.setFilterSave(tex, this.light, false);
|
||||
buf.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void end(Tesselator tess) {
|
||||
tess.end();
|
||||
// Minecraft.getInstance()
|
||||
// .getTextureManager()
|
||||
// .getTexture(TextureAtlas.LOCATION_PARTICLES)
|
||||
// .restoreLastBlurMipmap();
|
||||
IClientXplatAbstractions.INSTANCE.restoreLastFilter(
|
||||
Minecraft.getInstance().getTextureManager().getTexture(TextureAtlas.LOCATION_PARTICLES)
|
||||
);
|
||||
RenderSystem.disableBlend();
|
||||
RenderSystem.depthMask(true);
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import net.minecraft.client.particle.SpriteSet;
|
|||
import net.minecraft.client.renderer.RenderType;
|
||||
import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
||||
import net.minecraft.client.renderer.item.ItemPropertyFunction;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -35,6 +36,11 @@ public interface IClientXplatAbstractions {
|
|||
|
||||
void registerItemProperty(Item item, ResourceLocation id, ItemPropertyFunction func);
|
||||
|
||||
// On Forge, these are already exposed; on Farbc we do a mixin
|
||||
void setFilterSave(AbstractTexture texture, boolean filter, boolean mipmap);
|
||||
|
||||
void restoreLastFilter(AbstractTexture texture);
|
||||
|
||||
IClientXplatAbstractions INSTANCE = find();
|
||||
|
||||
private static IClientXplatAbstractions find() {
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package at.petrak.hexcasting.fabric.client;
|
||||
|
||||
// https://github.com/VazkiiMods/Botania/blob/db85d778ab23f44c11181209319066d1f04a9e3d/Fabric/src/main/java/vazkii/botania/fabric/client/ExtendedTexture.java
|
||||
public interface ExtendedTexture {
|
||||
void setFilterSave(boolean bilinear, boolean mipmap);
|
||||
|
||||
void restoreLastFilter();
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package at.petrak.hexcasting.fabric.mixin.client;
|
||||
|
||||
import at.petrak.hexcasting.fabric.client.ExtendedTexture;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
import org.spongepowered.asm.mixin.Unique;
|
||||
|
||||
@Mixin(AbstractTexture.class)
|
||||
public abstract class FabricAbstractTextureMixin implements ExtendedTexture {
|
||||
@Shadow
|
||||
protected boolean blur;
|
||||
|
||||
@Shadow
|
||||
protected boolean mipmap;
|
||||
|
||||
@Shadow
|
||||
public abstract void setFilter(boolean bilinear, boolean mipmap);
|
||||
|
||||
@Unique
|
||||
private boolean lastBilinear;
|
||||
|
||||
@Unique
|
||||
private boolean lastMipmap;
|
||||
|
||||
@Override
|
||||
public void setFilterSave(boolean bilinear, boolean mipmap) {
|
||||
this.lastBilinear = this.blur;
|
||||
this.lastMipmap = this.mipmap;
|
||||
setFilter(bilinear, mipmap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreLastFilter() {
|
||||
setFilter(this.lastBilinear, this.lastMipmap);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package at.petrak.hexcasting.fabric.xplat;
|
||||
|
||||
import at.petrak.hexcasting.common.network.IMessage;
|
||||
import at.petrak.hexcasting.fabric.client.ExtendedTexture;
|
||||
import at.petrak.hexcasting.xplat.IClientXplatAbstractions;
|
||||
import net.fabricmc.fabric.api.blockrenderlayer.v1.BlockRenderLayerMap;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
|
@ -16,6 +17,7 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|||
import net.minecraft.client.renderer.item.ClampedItemPropertyFunction;
|
||||
import net.minecraft.client.renderer.item.ItemProperties;
|
||||
import net.minecraft.client.renderer.item.ItemPropertyFunction;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -81,4 +83,14 @@ public class FabricClientXplatImpl implements IClientXplatAbstractions {
|
|||
public void registerItemProperty(Item item, ResourceLocation id, ItemPropertyFunction func) {
|
||||
ItemProperties.register(item, id, new UnclampedClampedItemPropFunc(func));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilterSave(AbstractTexture texture, boolean filter, boolean mipmap) {
|
||||
((ExtendedTexture) texture).setFilterSave(filter, mipmap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreLastFilter(AbstractTexture texture) {
|
||||
((ExtendedTexture) texture).restoreLastFilter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,5 @@
|
|||
"FabricItemEntityMixin",
|
||||
"FabricVillagerTurnIntoWitchMixin"
|
||||
],
|
||||
"client": [
|
||||
"client.FabricMouseHandlerMixin"
|
||||
]
|
||||
"client": ["client.FabricAbstractTextureMixin", "client.FabricMouseHandlerMixin"]
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ import net.minecraft.client.renderer.entity.EntityRendererProvider;
|
|||
import net.minecraft.client.renderer.entity.EntityRenderers;
|
||||
import net.minecraft.client.renderer.item.ItemProperties;
|
||||
import net.minecraft.client.renderer.item.ItemPropertyFunction;
|
||||
import net.minecraft.client.renderer.texture.AbstractTexture;
|
||||
import net.minecraft.core.particles.ParticleOptions;
|
||||
import net.minecraft.core.particles.ParticleType;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
|
@ -57,4 +58,14 @@ public class ForgeClientXplatImpl implements IClientXplatAbstractions {
|
|||
public void registerItemProperty(Item item, ResourceLocation id, ItemPropertyFunction func) {
|
||||
ItemProperties.register(item, id, func);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFilterSave(AbstractTexture texture, boolean filter, boolean mipmap) {
|
||||
texture.setBlurMipmap(filter, mipmap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreLastFilter(AbstractTexture texture) {
|
||||
texture.restoreLastBlurMipmap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue