aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlkalus <3060479+draknyte1@users.noreply.github.com>2022-02-13 12:57:51 +0000
committerGitHub <noreply@github.com>2022-02-13 13:57:51 +0100
commita92fac98086fcace97af30149148a5a32083e8ca (patch)
tree505f4471983edeb4780560ebf18a99c1a50cce34
parent92780c970591fd7656859e868adc3583ec70011c (diff)
downloadGT5-Unofficial-a92fac98086fcace97af30149148a5a32083e8ca.tar.gz
GT5-Unofficial-a92fac98086fcace97af30149148a5a32083e8ca.tar.bz2
GT5-Unofficial-a92fac98086fcace97af30149148a5a32083e8ca.zip
Fix Wireless Charger. (#121)
Fix Nano Healer.
-rw-r--r--src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java95
-rw-r--r--src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java10
2 files changed, 28 insertions, 77 deletions
diff --git a/src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java b/src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java
index db06af8297..ac7a149f3c 100644
--- a/src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java
+++ b/src/main/java/gtPlusPlus/core/item/general/ItemHealingDevice.java
@@ -6,34 +6,29 @@ import baubles.api.BaubleType;
import baubles.api.IBauble;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
+import gregtech.api.enums.GT_Values;
import gtPlusPlus.api.objects.Logger;
import gtPlusPlus.core.creative.AddToCreativeTab;
import gtPlusPlus.core.lib.CORE;
import gtPlusPlus.core.util.Utils;
import gtPlusPlus.core.util.math.MathUtils;
-import gtPlusPlus.core.util.minecraft.ItemUtils;
import gtPlusPlus.core.util.minecraft.PlayerUtils;
import gtPlusPlus.core.util.sys.KeyboardUtils;
import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper;
-import ic2.api.item.ElectricItem;
-import ic2.api.item.IElectricItem;
-import ic2.api.item.IElectricItemManager;
+import ic2.api.item.*;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
-import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
-import net.minecraft.util.EnumChatFormatting;
-import net.minecraft.util.StatCollector;
+import net.minecraft.util.*;
import net.minecraft.world.World;
@Optional.InterfaceList(value = {@Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles"), @Optional.Interface(iface = "baubles.api.BaubleType", modid = "Baubles")})
public class ItemHealingDevice extends Item implements IElectricItem, IElectricItemManager, IBauble{
private final String unlocalizedName = "personalHealingDevice";
- private final ItemStack thisStack;
private final static int maxValueEU = 1000000000;
protected double chargeEU = 0;
@@ -42,7 +37,6 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI
this.setUnlocalizedName(this.unlocalizedName);
this.setMaxStackSize(1);
this.setTextureName(CORE.MODID + ":" + "personalCloakingDevice");
- this.thisStack = ItemUtils.getSimpleStack(this);
GameRegistry.registerItem(this, this.unlocalizedName);
}
@@ -85,32 +79,30 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI
@Override
public double getTransferLimit(final ItemStack itemStack) {
- return 32784;
+ return GT_Values.V[7];
}
@Override
public String getItemStackDisplayName(final ItemStack p_77653_1_) {
- return (EnumChatFormatting.BLUE+"Personal Healing NanoBooster"+EnumChatFormatting.RESET);
+ return (EnumChatFormatting.BLUE + "Personal Healing NanoBooster" + EnumChatFormatting.RESET);
}
@Override
- public double getDurabilityForDisplay(final ItemStack stack)
- {
- //return 1.0D - getEnergyStored(stack) / this.capacity;
- return 1.0D - (this.getCharge(stack) / this.getMaxCharge(stack));
+ public double getDurabilityForDisplay(final ItemStack stack) {
+ // return 1.0D - getEnergyStored(stack) / this.capacity;
+ return 1.0D - (this.getCharge(stack) / this.getMaxCharge(stack));
}
@Override
- public boolean showDurabilityBar(final ItemStack stack)
- {
+ public boolean showDurabilityBar(final ItemStack stack) {
return true;
}
- public double secondsLeft(final ItemStack stack){
+ public double secondsLeft(final ItemStack stack) {
double r = 0;
- r = this.getCharge(stack)/(1638400/4);
+ r = this.getCharge(stack) / (1638400 / 4);
return (int) r;
}
@@ -282,6 +274,10 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI
//Try Heal
if (this.getCharge(aBaubleStack) > 0){
+ if (!(arg1 instanceof EntityPlayer)) {
+ return;
+ }
+ EntityPlayer g = (EntityPlayer) arg1;
//health Check
float hp = 0;
if (arg1.getHealth() < arg1.getMaxHealth()){
@@ -292,30 +288,18 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI
this.discharge(aBaubleStack, (1638400)*rx, 6, true, true, false);
}
- //Hunger Check
int hunger = 0;
- if (arg1 instanceof EntityPlayerMP) {
- EntityPlayerMP g = (EntityPlayerMP) arg1;
- if (g != null) {
- hunger = 20 - g.getFoodStats().getFoodLevel();
- g.getFoodStats().setFoodLevel(g.getFoodStats().getFoodLevel() + hunger);
- this.discharge(aBaubleStack, (1638400) * hunger, 6, true, true, false);
- }
- }
-
- //Saturation Check
float saturation = 0;
- if (arg1 instanceof EntityPlayerMP) {
- EntityPlayerMP g = (EntityPlayerMP) arg1;
- if (g != null) {
- saturation = 5f - g.getFoodStats().getSaturationLevel();
- g.getFoodStats().setFoodSaturationLevel(g.getFoodStats().getSaturationLevel() + saturation);
- this.discharge(aBaubleStack, (1638400) * saturation, 6, true, true, false);
- }
+ FoodStats aFood = g.getFoodStats();
+ if (aFood != null) {
+ //Hunger Check
+ hunger = 20 - aFood.getFoodLevel();
+ this.discharge(aBaubleStack, (1638400) * hunger, 6, true, true, false);
+ // Saturation Check
+ saturation = 20f - aFood.getSaturationLevel();
+ this.discharge(aBaubleStack, (1638400) * saturation, 6, true, true, false);
+ aFood.addStats(hunger, saturation);
}
-
-
- saturation = (int) saturation;
//Only show Messages if they're enabled.
if (getShowMessages(aBaubleStack)) {
@@ -335,37 +319,11 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI
if (hp > 0 || hunger > 0 || saturation > 0)
PlayerUtils.messagePlayer((EntityPlayer) arg1,
"You check it's remaining uses, it has " + (int) this.secondsLeft(aBaubleStack) + ".");
-
}
-
-
-
-
}
}
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
private static boolean createNBT(ItemStack rStack){
final NBTTagCompound tagMain = new NBTTagCompound();
tagMain.setBoolean("ShowMSG", false);
@@ -424,9 +382,6 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI
@Override
public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) {
return true;
- }
-
-
-
+ }
}
diff --git a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java
index 6f0176da25..665a1f78df 100644
--- a/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java
+++ b/src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/basic/GregtechMetaWirelessCharger.java
@@ -149,14 +149,15 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity {
@Override
public void onScrewdriverRightClick(byte aSide, EntityPlayer aPlayer, float aX, float aY, float aZ) {
- mWirelessChargingMap.clear();
- mLocalChargingMap.clear();
if (aPlayer.isSneaking()) {
mLocked = !mLocked;
PlayerUtils.messagePlayer(aPlayer, mLocked ? "Locked to owner." : "Unlocked.");
+ return;
}
+ mWirelessChargingMap.clear();
+ mLocalChargingMap.clear();
if (!this.getBaseMetaTileEntity().getWorld().playerEntities.isEmpty()){
for (Object mTempPlayer : this.getBaseMetaTileEntity().getWorld().playerEntities){
if (mTempPlayer instanceof EntityPlayer || mTempPlayer instanceof EntityPlayerMP){
@@ -444,11 +445,6 @@ public class GregtechMetaWirelessCharger extends GregtechMetaTileEntity {
}
}
}
- if (mWirelessChargingMap.containsKey(mTemp.getDisplayName())){
- if (mWirelessChargingMap.remove(mTemp.getDisplayName()) != null){
- ChargingHelper.removeValidPlayer(mTemp, this);
- }
- }
}
/*if (this.mMode == 0 || this.mMode == 2){
int tempRange = (int) (this.mMode == 0 ? 4*GT_Values.V[this.mTier] : 2*GT_Values.V[this.mTier]);