-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
363a84c
commit 2dca9f7
Showing
12 changed files
with
168 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
src/main/java/sunsetsatellite/signalindustries/items/attachments/ItemNVGAttachment.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package sunsetsatellite.signalindustries.items.attachments; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.render.shader.Shaders; | ||
import net.minecraft.client.render.shader.ShadersRenderer; | ||
import net.minecraft.core.entity.player.EntityPlayer; | ||
import net.minecraft.core.item.ItemStack; | ||
import net.minecraft.core.world.World; | ||
import sunsetsatellite.signalindustries.powersuit.SignalumPowerSuit; | ||
import sunsetsatellite.signalindustries.render.ShadersRendererSI; | ||
import sunsetsatellite.signalindustries.util.AttachmentPoint; | ||
import sunsetsatellite.signalindustries.util.Tier; | ||
|
||
import java.util.List; | ||
|
||
public class ItemNVGAttachment extends ItemTieredAttachment { | ||
public ItemNVGAttachment(String name, int id, List<AttachmentPoint> attachmentPoints, Tier tier) { | ||
super(name, id, attachmentPoints, tier); | ||
} | ||
|
||
@Override | ||
public void activate(ItemStack stack, SignalumPowerSuit signalumPowerSuit, EntityPlayer player, World world) { | ||
super.activate(stack, signalumPowerSuit, player, world); | ||
Minecraft mc = Minecraft.getMinecraft(this); | ||
if(Shaders.enableShaders){ | ||
if(mc.render instanceof ShadersRendererSI){ | ||
mc.setRenderer(new ShadersRenderer(mc)); | ||
mc.render.reload(); | ||
mc.fullbright = false; | ||
mc.renderGlobal.loadRenderers(); | ||
} else { | ||
mc.setRenderer(new ShadersRendererSI(mc,"nightvision/",signalumPowerSuit)); | ||
mc.render.reload(); | ||
mc.fullbright = true; | ||
mc.renderGlobal.loadRenderers(); | ||
} | ||
} else { | ||
mc.ingameGUI.addChatMessage("Can't activate: Shaders are disabled."); | ||
} | ||
} | ||
|
||
@Override | ||
public void tick(ItemStack stack, SignalumPowerSuit signalumPowerSuit, EntityPlayer player, World world, int slot) { | ||
super.tick(stack, signalumPowerSuit, player, world, slot); | ||
Minecraft mc = Minecraft.getMinecraft(this); | ||
if(mc.render instanceof ShadersRendererSI){ | ||
if(signalumPowerSuit.getEnergy() < 1 ){ | ||
mc.setRenderer(new ShadersRenderer(mc)); | ||
mc.render.reload(); | ||
mc.fullbright = false; | ||
mc.renderGlobal.loadRenderers(); | ||
} else { | ||
signalumPowerSuit.decrementEnergy(1); | ||
} | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/sunsetsatellite/signalindustries/render/ShadersRendererSI.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package sunsetsatellite.signalindustries.render; | ||
|
||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.render.shader.ShaderProvider; | ||
import net.minecraft.client.render.shader.ShaderProviderInternal; | ||
import net.minecraft.client.render.shader.ShadersRenderer; | ||
import sunsetsatellite.signalindustries.SignalIndustries; | ||
import sunsetsatellite.signalindustries.items.attachments.ItemAttachment; | ||
import sunsetsatellite.signalindustries.powersuit.SignalumPowerSuit; | ||
|
||
public class ShadersRendererSI extends ShadersRenderer { | ||
|
||
public String currentShaderDir; | ||
private final SignalumPowerSuit powerSuit; | ||
|
||
public ShadersRendererSI(Minecraft minecraft, String dir) { | ||
super(minecraft); | ||
this.currentShaderDir = dir; | ||
this.powerSuit = null; | ||
} | ||
|
||
public ShadersRendererSI(Minecraft minecraft, String dir, SignalumPowerSuit powerSuit) { | ||
super(minecraft); | ||
this.currentShaderDir = dir; | ||
this.powerSuit = powerSuit; | ||
} | ||
|
||
@Override | ||
public void beginRenderGame(float partialTicks) { | ||
if(powerSuit != null){ | ||
if(!powerSuit.hasAttachment((ItemAttachment) SignalIndustries.nightVisionLens) || !powerSuit.active){ | ||
mc.setRenderer(new ShadersRenderer(mc)); | ||
mc.render.reload(); | ||
mc.fullbright = false; | ||
mc.renderGlobal.loadRenderers(); | ||
return; | ||
} | ||
} | ||
super.beginRenderGame(partialTicks); | ||
} | ||
|
||
@Override | ||
public ShaderProvider getShader() { | ||
return new ShaderProviderInternal("/assets/signalindustries/shaders/"+currentShaderDir); | ||
} | ||
} |
Binary file modified
BIN
+0 Bytes
(100%)
src/main/resources/assets/signalindustries/block/eternal_tree_log.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+0 Bytes
(100%)
src/main/resources/assets/signalindustries/block/eternal_tree_log_top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+347 Bytes
src/main/resources/assets/signalindustries/item/night_vision_goggles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions
10
src/main/resources/assets/signalindustries/shaders/nightvision/base.fsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#version 120 | ||
|
||
uniform sampler2D colortex0; | ||
|
||
varying vec2 texcoord; | ||
|
||
void main(){ | ||
vec4 color = texture2D(colortex0, texcoord).rgba; | ||
gl_FragColor = color; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/resources/assets/signalindustries/shaders/nightvision/base.vsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#version 120 | ||
|
||
varying vec2 texcoord; | ||
|
||
void main(){ | ||
gl_Position = ftransform(); | ||
|
||
texcoord = gl_MultiTexCoord0.xy; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/resources/assets/signalindustries/shaders/nightvision/post.fsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#version 120 | ||
|
||
uniform sampler2D colortex0; | ||
|
||
uniform float intensity; | ||
|
||
varying vec2 texcoord; | ||
|
||
vec3 toGrayscale(vec3 color) | ||
{ | ||
color.r = color.r * 0.5 + color.g * 0.5 + color.b * 0.5; | ||
color.g = color.r * 0.5 + color.g * 0.5 + color.b * 0.5; | ||
color.b = color.r * 0.5 + color.g * 0.5 + color.b * 0.5; | ||
|
||
return color; | ||
} | ||
|
||
void main() | ||
{ | ||
vec3 color = texture2D(colortex0, texcoord).rgb; | ||
vec3 gs = toGrayscale(color); | ||
|
||
color = mix(gs, gs, intensity); | ||
|
||
gl_FragColor = vec4(color, 1.0); | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/resources/assets/signalindustries/shaders/nightvision/post.vsh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#version 120 | ||
|
||
varying vec2 texcoord; | ||
|
||
void main(){ | ||
gl_Position = ftransform(); | ||
|
||
texcoord = gl_MultiTexCoord0.xy; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters