mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 11:59:17 +00:00
#2203 Clean up baubles code, but I don't think it will affect anything
This commit is contained in:
1 parent
06528517fd
commit
f95895a38d
10 files changed
+62
-74
No files matched your search
@@ -21,7 +21,7 @@ import cpw.mods.fml.common.Optional.Interface;
|
||||
import cpw.mods.fml.common.eventhandler.EventPriority;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.tool.BaublesTool;
|
||||
import crazypants.util.BaublesUtil;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
@Interface(iface = "tterrag.core.api.common.enchant.IAdvancedEnchant", modid = "ttCore")
|
||||
@@ -79,7 +79,7 @@ public class EnchantmentSoulBound extends Enchantment implements IAdvancedEnchan
|
||||
// wait for that because gravestone mods also listen to this event. So we have
|
||||
// to fetch Baubles items ourselves here.
|
||||
// For the same reason we cannot put the items into Baubles slots.
|
||||
IInventory baubles = BaublesTool.getInstance().getBaubles(evt.entityPlayer);
|
||||
IInventory baubles = BaublesUtil.instance().getBaubles(evt.entityPlayer);
|
||||
if (baubles != null) {
|
||||
for (int i = 0; i < baubles.getSizeInventory(); i++) {
|
||||
ItemStack item = baubles.getStackInSlot(i);
|
||||
|
||||
@@ -2,7 +2,6 @@ package crazypants.enderio.item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import baubles.api.BaubleType;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
@@ -12,8 +11,11 @@ import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
import baubles.api.BaubleType;
|
||||
import baubles.api.IBauble;
|
||||
import cofh.api.energy.ItemEnergyContainer;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -24,12 +26,11 @@ import crazypants.enderio.ModObject;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IResourceTooltipProvider;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.tool.BaublesTool;
|
||||
import crazypants.util.BaublesUtil;
|
||||
import crazypants.util.ItemUtil;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
@Optional.Interface(iface="baubles.api.IBauble", modid="Baubles", striprefs=true)
|
||||
public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipProvider, baubles.api.IBauble {
|
||||
@Optional.Interface(iface = "baubles.api.IBauble", modid = "Baubles")
|
||||
public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipProvider, IBauble {
|
||||
|
||||
private static final String ACTIVE_KEY = "magnetActive";
|
||||
|
||||
@@ -71,9 +72,8 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected ItemMagnet() {
|
||||
super(Config.magnetPowerCapacityRF, Config.magnetPowerCapacityRF/100);
|
||||
super(Config.magnetPowerCapacityRF, Config.magnetPowerCapacityRF / 100);
|
||||
setCreativeTab(EnderIOTab.tabEnderIO);
|
||||
setUnlocalizedName(ModObject.itemMagnet.unlocalisedName);
|
||||
setMaxDamage(16);
|
||||
@@ -107,8 +107,8 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer par2EntityPlayer, List list, boolean par4) {
|
||||
super.addInformation(itemStack, par2EntityPlayer, list, par4);
|
||||
String str = PowerDisplayUtil.formatPower(getEnergyStored(itemStack)) + "/"
|
||||
+ PowerDisplayUtil.formatPower(getMaxEnergyStored(itemStack)) + " " + PowerDisplayUtil.abrevation();
|
||||
String str = PowerDisplayUtil.formatPower(getEnergyStored(itemStack)) + "/" + PowerDisplayUtil.formatPower(getMaxEnergyStored(itemStack)) + " "
|
||||
+ PowerDisplayUtil.abrevation();
|
||||
list.add(str);
|
||||
}
|
||||
|
||||
@@ -159,7 +159,6 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
|
||||
stack.setItemDamage(res);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack equipped, World world, EntityPlayer player) {
|
||||
if(player.isSneaking()) {
|
||||
@@ -180,16 +179,15 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "Baubles")
|
||||
public void onWornTick(ItemStack itemstack, EntityLivingBase player) {
|
||||
if (player instanceof EntityPlayer && hasPower(itemstack)) {
|
||||
if(player instanceof EntityPlayer && hasPower(itemstack)) {
|
||||
controller.doHoover((EntityPlayer) player);
|
||||
if(!player.worldObj.isRemote && player.worldObj.getTotalWorldTime() % 20 == 0) {
|
||||
ItemMagnet.drainPerSecondPower(itemstack);
|
||||
IInventory baubles = BaublesTool.getInstance().getBaubles((EntityPlayer)player);
|
||||
if (baubles != null) {
|
||||
IInventory baubles = BaublesUtil.instance().getBaubles((EntityPlayer) player);
|
||||
if(baubles != null) {
|
||||
for (int i = 0; i < baubles.getSizeInventory(); i++) {
|
||||
if (baubles.getStackInSlot(i) == itemstack) {
|
||||
if(baubles.getStackInSlot(i) == itemstack) {
|
||||
baubles.setInventorySlotContents(i, itemstack);
|
||||
}
|
||||
}
|
||||
@@ -199,23 +197,19 @@ public class ItemMagnet extends ItemEnergyContainer implements IResourceTooltipP
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "Baubles")
|
||||
public void onEquipped(ItemStack itemstack, EntityLivingBase player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "Baubles")
|
||||
public void onUnequipped(ItemStack itemstack, EntityLivingBase player) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "Baubles")
|
||||
public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return isActive(itemstack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "Baubles")
|
||||
public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import net.minecraft.util.ChatComponentTranslation;
|
||||
import org.lwjgl.input.Keyboard;
|
||||
|
||||
import static crazypants.enderio.EnderIO.itemMagnet;
|
||||
|
||||
import cpw.mods.fml.client.registry.ClientRegistry;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
@@ -29,7 +28,7 @@ import crazypants.enderio.item.darksteel.SoundDetectorUpgrade;
|
||||
import crazypants.enderio.item.darksteel.SpeedUpgrade;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.thaumcraft.GogglesOfRevealingUpgrade;
|
||||
import crazypants.enderio.tool.BaublesTool;
|
||||
import crazypants.util.BaublesUtil;
|
||||
import crazypants.util.Lang;
|
||||
|
||||
public class KeyTracker {
|
||||
@@ -110,7 +109,7 @@ public class KeyTracker {
|
||||
}
|
||||
}
|
||||
|
||||
IInventory baubles = BaublesTool.getInstance().getBaubles(player);
|
||||
IInventory baubles = BaublesUtil.instance().getBaubles(player);
|
||||
if(baubles != null) {
|
||||
for (int i = 0; i < baubles.getSizeInventory(); i++) {
|
||||
ItemStack stack = baubles.getStackInSlot(i);
|
||||
|
||||
@@ -17,8 +17,7 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.item.PacketMagnetState.SlotType;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.tool.BaublesTool;
|
||||
|
||||
import crazypants.util.BaublesUtil;
|
||||
import static crazypants.enderio.EnderIO.itemMagnet;
|
||||
|
||||
public class MagnetController implements IEntitySelector {
|
||||
@@ -111,7 +110,7 @@ public class MagnetController implements IEntitySelector {
|
||||
case ARMOR:
|
||||
return;
|
||||
case BAUBLES:
|
||||
baubles = BaublesTool.getInstance().getBaubles(player);
|
||||
baubles = BaublesUtil.instance().getBaubles(player);
|
||||
if (baubles != null) {
|
||||
stack = baubles.getStackInSlot(slot);
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import crazypants.enderio.machine.capbank.network.NetworkUtil;
|
||||
import crazypants.enderio.machine.capbank.packet.PacketNetworkIdRequest;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.enderio.power.IInternalPowerHandler;
|
||||
import crazypants.enderio.power.IInternalPowerReceiver;
|
||||
import crazypants.enderio.power.IPowerInterface;
|
||||
import crazypants.enderio.power.IPowerStorage;
|
||||
import crazypants.enderio.power.PowerHandlerUtil;
|
||||
@@ -43,7 +44,7 @@ import crazypants.util.EntityUtil;
|
||||
import crazypants.util.Util;
|
||||
import crazypants.vecmath.Vector3d;
|
||||
|
||||
public class TileCapBank extends TileEntityEio implements IInternalPowerHandler, IInventory, IIoConfigurable, IPowerStorage {
|
||||
public class TileCapBank extends TileEntityEio implements IInternalPowerReceiver, IInventory, IIoConfigurable, IPowerStorage {
|
||||
|
||||
private Map<ForgeDirection, IoMode> faceModes;
|
||||
private Map<ForgeDirection, InfoDisplayType> faceDisplayTypes;
|
||||
@@ -675,10 +676,10 @@ public class TileCapBank extends TileEntityEio implements IInternalPowerHandler,
|
||||
return network.receiveEnergy(maxReceive, simulate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
return 0;
|
||||
}
|
||||
// @Override
|
||||
// public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate) {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored(ForgeDirection from) {
|
||||
|
||||
@@ -14,7 +14,7 @@ import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.gameevent.TickEvent;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.tool.BaublesTool;
|
||||
import crazypants.util.BaublesUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
|
||||
public class WirelessChargerController {
|
||||
@@ -93,7 +93,7 @@ public class WirelessChargerController {
|
||||
private boolean chargeFromCapBank(EntityPlayer player, IWirelessCharger capBank) {
|
||||
boolean res = capBank.chargeItems(player.inventory.armorInventory);
|
||||
res |= capBank.chargeItems(player.inventory.mainInventory);
|
||||
IInventory baubles = BaublesTool.getInstance().getBaubles(player);
|
||||
IInventory baubles = BaublesUtil.instance().getBaubles(player);
|
||||
if (baubles != null) {
|
||||
ItemStack[] item = new ItemStack[1];
|
||||
for (int i = 0; i < baubles.getSizeInventory(); i++) {
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package crazypants.enderio.tool;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
|
||||
public class BaublesTool {
|
||||
|
||||
private static final BaublesTool instance = new BaublesToolwithBaubles();
|
||||
|
||||
public static BaublesTool getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean hasBaubles() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public IInventory getBaubles(EntityPlayer player) {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package crazypants.enderio.tool;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
|
||||
// this cannot be an inner class as fml/Optional does not support them
|
||||
class BaublesToolwithBaubles extends BaublesTool {
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public boolean hasBaubles() {
|
||||
return true;
|
||||
}
|
||||
@Optional.Method(modid = "Baubles")
|
||||
public IInventory getBaubles(EntityPlayer player) {
|
||||
return baubles.api.BaublesApi.getBaubles(player);
|
||||
}
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class WailaCompat implements IWailaDataProvider {
|
||||
registrar.registerBodyProvider(INSTANCE, BlockEio.class);
|
||||
|
||||
registrar.registerNBTProvider(INSTANCE, TileEntityEio.class);
|
||||
|
||||
|
||||
ConfigHandler.instance().addConfig(EnderIO.MOD_NAME, "facades.hidden", Lang.localize("waila.config.hiddenfacades"));
|
||||
IWailaInfoProvider.fmt.setMaximumFractionDigits(1);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package crazypants.util;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import baubles.api.BaublesApi;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
|
||||
public class BaublesUtil {
|
||||
|
||||
private static final BaublesUtil instance = new BaublesUtil();
|
||||
private static final boolean baublesLoaded;
|
||||
static {
|
||||
baublesLoaded = Loader.isModLoaded("Baubles");
|
||||
}
|
||||
|
||||
private BaublesUtil() {
|
||||
}
|
||||
|
||||
public static BaublesUtil instance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
public boolean hasBaubles() {
|
||||
return baublesLoaded;
|
||||
}
|
||||
|
||||
public IInventory getBaubles(EntityPlayer player) {
|
||||
return hasBaubles() ? getBaublesInvUnsafe(player) : null;
|
||||
}
|
||||
|
||||
private IInventory getBaublesInvUnsafe(EntityPlayer player) {
|
||||
return BaublesApi.getBaubles(player);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user