Skip to content

Commit

Permalink
Added Night Vision Lens.
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinSVK12 committed Feb 5, 2024
1 parent 363a84c commit 2dca9f7
Show file tree
Hide file tree
Showing 12 changed files with 168 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -786,12 +786,13 @@ public class SignalIndustries implements ModInitializer, GameStartEntrypoint {
public static final ItemSignalumPowerSuit signalumPowerSuitBoots = (ItemSignalumPowerSuit) ItemHelper.createItem(MOD_ID,new ItemSignalumPowerSuit("reinforced.signalumpowersuit.boots",config.getInt("ItemIDs.signalumPowerSuitBoots"),armorSignalumPowerSuit,3,Tier.REINFORCED),"signalumpowersuit_boots.png");

//public static final Item testingAttachment = ItemHelper.createItem(MOD_ID,new ItemAttachment(config.getInt("ItemIDs.testingAttachment"), listOf(AttachmentPoint.ANY)),"attachment.testingAttachment","energyorb.png");
public static final Item pulsarAttachment = ItemHelper.createItem(MOD_ID,new ItemPulsarAttachment("reinforced.attachment.pulsar",config.getInt("ItemIDs.pulsarAttachment"), listOf(AttachmentPoint.ARM_FRONT), Tier.REINFORCED),"pulsar_attachment.png").setMaxStackSize(1);
public static final Item extendedEnergyPack = ItemHelper.createItem(MOD_ID,new ItemTieredAttachment("reinforced.attachment.extendedEnergyPack",config.getInt("ItemIDs.extendedEnergyPack"), listOf(AttachmentPoint.CORE_BACK), Tier.REINFORCED),"extended_energy_pack.png").setMaxStackSize(1);
public static final Item crystalWings = ItemHelper.createItem(MOD_ID,new ItemWingsAttachment("reinforced.attachment.wings",config.getInt("ItemIDs.crystalWings"), listOf(AttachmentPoint.CORE_BACK), Tier.REINFORCED),"wings.png").setMaxStackSize(1);
public static final Item basicBackpack = ItemHelper.createItem(MOD_ID,new ItemBackpackAttachment("basic.attachment.backpack",config.getInt("ItemIDs.basicBackpack"), listOf(AttachmentPoint.CORE_BACK), Tier.BASIC),"basic_backpack.png").setMaxStackSize(1);
public static final Item reinforcedBackpack = ItemHelper.createItem(MOD_ID,new ItemBackpackAttachment("reinforced.attachment.backpack",config.getInt("ItemIDs.reinforcedBackpack"), listOf(AttachmentPoint.CORE_BACK), Tier.REINFORCED),"reinforced_backpack.png").setMaxStackSize(1);;

//implicit max stack size of 1 (defined in ItemAttachment)
public static final Item pulsarAttachment = ItemHelper.createItem(MOD_ID,new ItemPulsarAttachment("reinforced.attachment.pulsar",config.getInt("ItemIDs.pulsarAttachment"), listOf(AttachmentPoint.ARM_FRONT), Tier.REINFORCED),"pulsar_attachment.png");
public static final Item extendedEnergyPack = ItemHelper.createItem(MOD_ID,new ItemTieredAttachment("reinforced.attachment.extendedEnergyPack",config.getInt("ItemIDs.extendedEnergyPack"), listOf(AttachmentPoint.CORE_BACK), Tier.REINFORCED),"extended_energy_pack.png");
public static final Item crystalWings = ItemHelper.createItem(MOD_ID,new ItemWingsAttachment("reinforced.attachment.wings",config.getInt("ItemIDs.crystalWings"), listOf(AttachmentPoint.CORE_BACK), Tier.REINFORCED),"wings.png");
public static final Item basicBackpack = ItemHelper.createItem(MOD_ID,new ItemBackpackAttachment("basic.attachment.backpack",config.getInt("ItemIDs.basicBackpack"), listOf(AttachmentPoint.CORE_BACK), Tier.BASIC),"basic_backpack.png");
public static final Item reinforcedBackpack = ItemHelper.createItem(MOD_ID,new ItemBackpackAttachment("reinforced.attachment.backpack",config.getInt("ItemIDs.reinforcedBackpack"), listOf(AttachmentPoint.CORE_BACK), Tier.REINFORCED),"reinforced_backpack.png");
public static final Item nightVisionLens = ItemHelper.createItem(MOD_ID,new ItemNVGAttachment("reinforced.attachment.nightVisionLens",config.getInt("ItemIDs.nightVisionLens"), listOf(AttachmentPoint.HEAD_TOP), Tier.REINFORCED),"night_vision_goggles.png");

public static final SuitBaseAbility testAbility = new TestingAbility();
public static final SuitBaseEffectAbility testEffectAbility = new TestingEffectAbility();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class ItemAttachment extends Item implements IAttachment, ICustomDescript
public ItemAttachment(String name, int id, List<AttachmentPoint> attachmentPoints) {
super(name, id);
this.attachmentPoints = attachmentPoints;
setMaxStackSize(1);
}

/*public ItemAttachment(int i, List<AttachmentPoint> attachmentPoints) {
Expand Down
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);
}
}
}
}
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);
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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;
}
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;
}
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);
}
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;
}
4 changes: 3 additions & 1 deletion src/main/resources/lang/signalindustries/en_US.lang
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ item.signalindustries.reinforced.pulsar.desc=Multifunctional gadget. It's main a

item.signalindustries.reinforced.signalumSaber.name=Signalum Saber
item.signalindustries.reinforced.signalumSaber.desc=A heated blade capable of cutting almost anything if powered.
item.signalindustries.awakened.sunriseDawn.name=Sunrise Dawn
item.signalindustries.awakened.sunriseDawn.desc=Allows you to summon a destructive beam of light anywhere near the range of any [Satellite].

item.signalindustries.basic.signalumDrill.name=Basic Signalum Drill
item.signalindustries.basic.signalumDrill.desc=A heavy-duty drill powered by Signalum Energy. Will not break when it runs out of energy.
Expand Down Expand Up @@ -578,7 +580,7 @@ achievement.signalindustries.gate.desc=Construct a Warp Gate to link any two poi
achievement.signalindustries.wings=Better than Icarus
achievement.signalindustries.wings.desc=Attach a pair of Signalum Wings to your suit and reach for the stars.
achievement.signalindustries.orbitalWeapon=3000 Orbital Weapons of Signal Industries
achievement.signalindustries.orbitalWeapon.desc=<todo>
achievement.signalindustries.orbitalWeapon.desc=Cast your divine fury upon your enemies and have them experience the unmatched power of the Sun.

achievement.signalindustries.completed=Signal Industries
achievement.signalindustries.completed=Activate the Awakened Signalum Ignition Facility for the first time reaching the end of your adventure. Thank you for playing!
Expand Down

0 comments on commit 2dca9f7

Please sign in to comment.