mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
Merge pull request #1928 from Toshayo/master
Night vision toggling with HUD
This commit is contained in:
commit
1a24b8df67
@ -1,5 +1,6 @@
|
||||
## Changed
|
||||
* Particle detectors now print an error for when the recipe could not be completed
|
||||
* Night Vision Goggles toggles with armor HUD
|
||||
* Removed "no ore dict data" line from tooltips with extended view enabled
|
||||
* Added a client config called `GUN_ANIMATION_SPEED` which allows the speed of gun animations to be changed
|
||||
* Mostly for debugging, since it only applies to the bus animation system, things like smoke trails and muzzle flashes are unaffected
|
||||
@ -9,4 +10,4 @@
|
||||
* Fixed packet optimization not allowing packets to be sent when the day night cycle is halted
|
||||
* Fixed particle detectors not always using power when they should
|
||||
* Fixed rotary furnace voiding low pressure steam when dealing with input numbers not divisible by 100
|
||||
* Fixed state leak causing smoke from the right akimbo weapon to glow when the first one is fired
|
||||
* Fixed state leak causing smoke from the right akimbo weapon to glow when the first one is fired
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package com.hbm.items.armor;
|
||||
|
||||
import com.hbm.extprop.HbmPlayerProps;
|
||||
import com.hbm.handler.ArmorModHandler;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
@ -12,6 +14,8 @@ import net.minecraft.util.EnumChatFormatting;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemModNightVision extends ItemArmorMod {
|
||||
private static final String NIGHT_VISION_ACTIVE_NBT_KEY = "ITEM_MOD_NV_ACTIVE";
|
||||
|
||||
public ItemModNightVision() {
|
||||
super(ArmorModHandler.helmet_only, true, false, false, false);
|
||||
}
|
||||
@ -31,10 +35,22 @@ public class ItemModNightVision extends ItemArmorMod {
|
||||
@Override
|
||||
public void modUpdate(EntityLivingBase entity, ItemStack armor) {
|
||||
if(!entity.worldObj.isRemote && entity instanceof EntityPlayer && armor.getItem() instanceof ArmorFSBPowered && ArmorFSBPowered.hasFSBArmor((EntityPlayer) entity)) {
|
||||
entity.addPotionEffect(new PotionEffect(Potion.nightVision.id, 15 * 20, 0));
|
||||
if(HbmPlayerProps.getData(((EntityPlayer) entity)).enableHUD) {
|
||||
// 15 seconds to make less flickering if the client lags
|
||||
entity.addPotionEffect(new PotionEffect(Potion.nightVision.id, 15 * 20, 0));
|
||||
if(!armor.hasTagCompound()) {
|
||||
armor.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
if(!armor.getTagCompound().hasKey(NIGHT_VISION_ACTIVE_NBT_KEY)) {
|
||||
armor.getTagCompound().setBoolean(NIGHT_VISION_ACTIVE_NBT_KEY, true); // Value does not matter, it's just a flag
|
||||
}
|
||||
|
||||
if(entity.getRNG().nextInt(100) == 0) {
|
||||
armor.damageItem(1, entity);
|
||||
if (entity.getRNG().nextInt(100) == 0) {
|
||||
armor.damageItem(1, entity);
|
||||
}
|
||||
} else if(armor.hasTagCompound() && armor.getTagCompound().hasKey(NIGHT_VISION_ACTIVE_NBT_KEY)) { // Disable night vision if it was the armor mod that applied it to avoid removing other night vision sources.
|
||||
entity.removePotionEffect(Potion.nightVision.id);
|
||||
armor.getTagCompound().removeTag(NIGHT_VISION_ACTIVE_NBT_KEY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user