Merge pull request #1845 from Agarmal/m1tty-nvg

Fix effect conflicts with Night Vision Goggles in the M1TTY Environment Suit
This commit is contained in:
HbmMods 2025-01-06 18:20:23 +01:00 committed by GitHub
commit 50edd0f04b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 70 additions and 59 deletions

View File

@ -1,13 +1,12 @@
package com.hbm.handler; package com.hbm.handler;
import java.util.UUID;
import com.hbm.items.armor.ItemArmorMod; import com.hbm.items.armor.ItemArmorMod;
import net.minecraft.item.ItemArmor; import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import java.util.UUID;
public class ArmorModHandler { public class ArmorModHandler {
public static final int helmet_only = 0; public static final int helmet_only = 0;
@ -147,6 +146,11 @@ public class ArmorModHandler {
return nbt.hasKey(MOD_COMPOUND_KEY); return nbt.hasKey(MOD_COMPOUND_KEY);
} }
/**
* Gets all the modifications in the provided armor
* @param armor
* @return
*/
public static ItemStack[] pryMods(ItemStack armor) { public static ItemStack[] pryMods(ItemStack armor) {
ItemStack[] slots = new ItemStack[MOD_SLOTS]; ItemStack[] slots = new ItemStack[MOD_SLOTS];

View File

@ -1,11 +1,9 @@
package com.hbm.items.armor; package com.hbm.items.armor;
import java.util.UUID;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import com.hbm.handler.ArmorModHandler;
import com.hbm.items.ModItems; import com.hbm.items.ModItems;
import com.hbm.render.model.ModelArmorEnvsuit; import com.hbm.render.model.ModelArmorEnvsuit;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.model.ModelBiped; import net.minecraft.client.model.ModelBiped;
@ -19,6 +17,8 @@ import net.minecraft.potion.PotionEffect;
import net.minecraft.util.Vec3; import net.minecraft.util.Vec3;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.UUID;
public class ArmorEnvsuit extends ArmorFSBPowered { public class ArmorEnvsuit extends ArmorFSBPowered {
public ArmorEnvsuit(ArmorMaterial material, int slot, String texture, long maxPower, long chargeRate, long consumption, long drain) { public ArmorEnvsuit(ArmorMaterial material, int slot, String texture, long maxPower, long chargeRate, long consumption, long drain) {
@ -78,7 +78,14 @@ public class ArmorEnvsuit extends ArmorFSBPowered {
player.motionY += vec.yCoord; player.motionY += vec.yCoord;
player.motionZ += vec.zCoord; player.motionZ += vec.zCoord;
} else { } else {
if(!world.isRemote) { boolean canRemoveNightVision = true;
ItemStack helmet = player.inventory.armorInventory[3];
ItemStack helmetMod = ArmorModHandler.pryMod(helmet, ArmorModHandler.helmet_only); // Get the modification!
if (helmetMod != null && helmetMod.getItem() instanceof ItemModNightVision) {
canRemoveNightVision = false;
}
if(!world.isRemote && canRemoveNightVision) {
player.removePotionEffect(Potion.nightVision.id); player.removePotionEffect(Potion.nightVision.id);
} }
} }