Static Entity
This commit is contained in:
parent
11bee7b00c
commit
a0911892f5
7 changed files with 127 additions and 2 deletions
|
@ -16,4 +16,14 @@ public class ModShaders {
|
|||
public static Shader getDimensionalPortal() {
|
||||
return DIMENSIONAL_PORTAL;
|
||||
}
|
||||
|
||||
private static Shader STATIC = null;
|
||||
|
||||
public static void setStaticShader(Shader dimensionalPortal) {
|
||||
STATIC = dimensionalPortal;
|
||||
}
|
||||
|
||||
public static Shader getStaticShader() {
|
||||
return STATIC;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,17 @@ public class MyRenderLayer extends RenderLayer {
|
|||
.build(false)
|
||||
);
|
||||
|
||||
public static RenderLayer STATIC = RenderLayerFactory.create(
|
||||
"static",
|
||||
VertexFormats.POSITION_TEXTURE,
|
||||
VertexFormat.DrawMode.QUADS,
|
||||
2097152,
|
||||
true,
|
||||
false,
|
||||
RenderLayer.MultiPhaseParameters.builder()
|
||||
.shader(new Shader(ModShaders::getStaticShader))
|
||||
.build(true));
|
||||
|
||||
public static RenderLayer getMonolith(Identifier texture) {
|
||||
RenderLayer.MultiPhaseParameters multiPhaseParameters = RenderLayer.MultiPhaseParameters.builder().texture(new RenderPhase.Texture(texture, false, false)).shader(new Shader(GameRenderer::getRenderTypeEntityTranslucentShader)).transparency(RenderPhase.TRANSLUCENT_TRANSPARENCY).cull(DISABLE_CULLING).lightmap(ENABLE_LIGHTMAP).depthTest(RenderPhase.ALWAYS_DEPTH_TEST).overlay(ENABLE_OVERLAY_COLOR).build(false);
|
||||
return RenderLayerFactory.create("monolith", VertexFormats.POSITION_COLOR_TEXTURE_OVERLAY_LIGHT_NORMAL, VertexFormat.DrawMode.QUADS, 256, true, true, multiPhaseParameters);
|
||||
|
|
|
@ -32,5 +32,6 @@ public abstract class GameRendererMixin {
|
|||
@Inject(method = "loadShaders", at = @At(value = "INVOKE", shift = At.Shift.AFTER, ordinal = 1, target = "java/util/List.add(Ljava/lang/Object;)Z"), locals = LocalCapture.CAPTURE_FAILSOFT)
|
||||
public void onReload(ResourceManager manager, CallbackInfo ci, List list, List list2) throws IOException {
|
||||
list2.add(Pair.of(new Shader(manager, "dimensional_portal", VertexFormats.POSITION), (Consumer<Shader>) ModShaders::setDimensionalPortal));
|
||||
list2.add(Pair.of(new Shader(manager, "static", VertexFormats.POSITION), (Consumer<Shader>) ModShaders::setStaticShader));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
package org.dimdev.dimdoors.mixin.client;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import net.minecraft.client.render.*;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
import org.dimdev.dimdoors.ModConfig;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
|
|
@ -3,12 +3,18 @@ package org.dimdev.dimdoors.mixin.client;
|
|||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.gl.JsonEffectGlShader;
|
||||
import net.minecraft.client.gl.PostProcessShader;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.LivingEntity;
|
||||
import net.minecraft.entity.player.PlayerEntity;
|
||||
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
|
||||
import org.dimdev.dimdoors.DimensionalDoorsInitializer;
|
||||
import org.dimdev.dimdoors.ModConfig;
|
||||
import org.dimdev.dimdoors.entity.MaskEntity;
|
||||
import org.dimdev.dimdoors.entity.ModEntityTypes;
|
||||
import org.dimdev.dimdoors.entity.MonolithEntity;
|
||||
import org.dimdev.dimdoors.world.ModDimensions;
|
||||
import org.spongepowered.asm.mixin.Final;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.Shadow;
|
||||
|
@ -21,9 +27,32 @@ public class PostProcessShaderMixin {
|
|||
|
||||
@Shadow @Final private JsonEffectGlShader program;
|
||||
|
||||
private static float overlayOpacity = 0.0F;
|
||||
|
||||
@Inject(method = "render(F)V", at = @At("HEAD"), cancellable = true)
|
||||
public void render(float time, CallbackInfo cir) {
|
||||
program.getUniformByNameOrDummy("GameTime").set(RenderSystem.getShaderGameTime());
|
||||
if(program.getName().equals("static")) {
|
||||
System.out.println("Static");
|
||||
if (MinecraftClient.getInstance().getCameraEntity() instanceof LivingEntity livingEntity) {
|
||||
System.out.println("Living Entity");
|
||||
if(!(livingEntity instanceof PlayerEntity || livingEntity instanceof MonolithEntity || livingEntity instanceof MaskEntity)) {
|
||||
while (ModDimensions.isLimboDimension(livingEntity.world)) {
|
||||
System.out.println("Limbo");
|
||||
for (int i = 0; i < 20; i++) {
|
||||
overlayOpacity += 0.1F;
|
||||
program.getUniformByNameOrDummy("StaticIntensity" + i).set(overlayOpacity);
|
||||
if(overlayOpacity == 1.0F) {
|
||||
livingEntity.getEntityWorld().spawnEntity(new MonolithEntity(ModEntityTypes.MONOLITH, livingEntity.getEntityWorld()));
|
||||
livingEntity.remove(Entity.RemovalReason.KILLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
program.getUniformByNameOrDummy("StaticIntensity").set(0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private PlayerEntity getCameraPlayer() {
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
"uniforms": [
|
||||
{ "name": "ModelViewMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "ProjMat", "type": "matrix4x4", "count": 16, "values": [ 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0 ] },
|
||||
{ "name": "GameTime", "type": "float", "count": 1, "values": [ 0.0 ] }
|
||||
{ "name": "GameTime", "type": "float", "count": 1, "values": [ 0.0 ] },
|
||||
{ "name": "OutSize", "type": "float", "count": 2, "values": [ 1.0, 1.0 ] },
|
||||
{ "name": "StaticIntensity", "type": "float", "count": 1, "values": [ 0.1 ] }
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
{
|
||||
"targets": [
|
||||
"water",
|
||||
"translucent",
|
||||
"itemEntity",
|
||||
"particles",
|
||||
"clouds",
|
||||
"weather",
|
||||
"final"
|
||||
],
|
||||
"passes": [
|
||||
{
|
||||
"name": "transparency",
|
||||
"intarget": "minecraft:main",
|
||||
"outtarget": "final",
|
||||
"auxtargets": [
|
||||
{
|
||||
"name": "DiffuseDepthSampler",
|
||||
"id": "minecraft:main:depth"
|
||||
},
|
||||
{
|
||||
"name": "TranslucentSampler",
|
||||
"id": "translucent"
|
||||
},
|
||||
{
|
||||
"name": "TranslucentDepthSampler",
|
||||
"id": "translucent:depth"
|
||||
},
|
||||
{
|
||||
"name": "ItemEntitySampler",
|
||||
"id": "itemEntity"
|
||||
},
|
||||
{
|
||||
"name": "ItemEntityDepthSampler",
|
||||
"id": "itemEntity:depth"
|
||||
},
|
||||
{
|
||||
"name": "ParticlesSampler",
|
||||
"id": "particles"
|
||||
},
|
||||
{
|
||||
"name": "ParticlesDepthSampler",
|
||||
"id": "particles:depth"
|
||||
},
|
||||
{
|
||||
"name": "CloudsSampler",
|
||||
"id": "clouds"
|
||||
},
|
||||
{
|
||||
"name": "CloudsDepthSampler",
|
||||
"id": "clouds:depth"
|
||||
},
|
||||
{
|
||||
"name": "WeatherSampler",
|
||||
"id": "weather"
|
||||
},
|
||||
{
|
||||
"name": "WeatherDepthSampler",
|
||||
"id": "weather:depth"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "static",
|
||||
"intarget": "final",
|
||||
"outtarget": "minecraft:main"
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in a new issue