From 2b28b0849d64b320e42a478f83af6a29c4f28ac1 Mon Sep 17 00:00:00 2001 From: Alkalus Date: Sun, 26 Nov 2017 17:54:25 +1000 Subject: $ Fixed Large Sifter, Tree Farm & Power Sub-Station not forming on SMP. $ Fixed issue where INFO_MACHINE_LOGGING would cause NPE's on SMP. - Removed logging from the Xp Converter. --- .../item/base/itemblock/ItemBlockEntityBase.java | 4 +- .../general/TileEntityXpConverter.java | 38 ++++++------- src/Java/gtPlusPlus/core/util/Utils.java | 65 ++++++++++++++-------- 3 files changed, 64 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java index 0dda165b6b..b13e6b22bc 100644 --- a/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java +++ b/src/Java/gtPlusPlus/core/item/base/itemblock/ItemBlockEntityBase.java @@ -28,8 +28,8 @@ public class ItemBlockEntityBase extends ItemBlock { @Override public final void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){ - list.add(EnumChatFormatting.GRAY+"Liquid Xp can be filled or drained from all four sides."); - list.add(EnumChatFormatting.GRAY+"Mob Essence can be filled or drained from the top and bottom."); + list.add(EnumChatFormatting.GRAY+"Can convert Liquid Xp to Mob Essence and back."); + list.add(EnumChatFormatting.GRAY+"Right click with a Screwdriver to change mode."); } else if (Block.getBlockFromItem(stack.getItem()) instanceof BlockTankXpConverter){ //list.add(EnumChatFormatting.GRAY+"A pile of " + materialName + " dust."); diff --git a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java index 8491cf8f6e..98da5a40fc 100644 --- a/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java +++ b/src/Java/gtPlusPlus/core/tileentities/general/TileEntityXpConverter.java @@ -53,26 +53,26 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { @Override public int fill(final ForgeDirection from, final FluidStack resource, final boolean doFill) { this.needsUpdate = true; - Utils.LOG_INFO("Ticking. | mConvertToEssence: "+this.mConvertToEssence); + Utils.LOG_WARNING("Ticking. | mConvertToEssence: "+this.mConvertToEssence); if (this.mConvertToEssence){ if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ - Utils.LOG_INFO("fill(tankLiquidXp)"); + Utils.LOG_WARNING("fill(tankLiquidXp)"); return this.tankLiquidXp.fill(resource, doFill); } else { - Utils.LOG_INFO("Looking for Liquid Xp, Instead found "+resource.getLocalizedName()+"."); + Utils.LOG_WARNING("Looking for Liquid Xp, Instead found "+resource.getLocalizedName()+"."); } } else { if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ - Utils.LOG_INFO("fill(tankEssence)"); + Utils.LOG_WARNING("fill(tankEssence)"); return this.tankEssence.fill(resource, doFill); } else { - Utils.LOG_INFO("Looking for Essence, Instead found "+resource.getLocalizedName()+"."); + Utils.LOG_WARNING("Looking for Essence, Instead found "+resource.getLocalizedName()+"."); } } - Utils.LOG_INFO("fill(0)"); + Utils.LOG_WARNING("fill(0)"); return 0; } @@ -81,24 +81,24 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { this.needsUpdate = true; if (this.mConvertToEssence){ if (resource.isFluidEqual(EnchantingUtils.getMobEssence(1))){ - Utils.LOG_INFO("drain(mConvertToEssence)"); + Utils.LOG_WARNING("drain(mConvertToEssence)"); return this.tankEssence.drain(resource.amount, doDrain); } } else { if (resource.isFluidEqual(EnchantingUtils.getLiquidXP(1))){ - Utils.LOG_INFO("drain(tankLiquidXp)"); + Utils.LOG_WARNING("drain(tankLiquidXp)"); return this.tankLiquidXp.drain(resource.amount, doDrain); } } - Utils.LOG_INFO("drain(null)"); + Utils.LOG_WARNING("drain(null)"); return null; } @Override public FluidStack drain(final ForgeDirection from, final int maxDrain, final boolean doDrain) { this.needsUpdate = true; - Utils.LOG_INFO("drain(Ex)"); + Utils.LOG_WARNING("drain(Ex)"); final FluidStack fluid_Essence = this.tankEssence.getFluid(); final FluidStack fluid_Xp = this.tankLiquidXp.getFluid(); if ((fluid_Essence == null) && (fluid_Xp == null)) { @@ -143,7 +143,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { this.tankLiquidXp = tank; } - Utils.LOG_INFO("drain(Ex2)"); + Utils.LOG_WARNING("drain(Ex2)"); return stack; } @@ -151,17 +151,17 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { public boolean canFill(final ForgeDirection from, final Fluid fluid) { if (this.mConvertToEssence){ if (this.tankEssence.getFluidAmount() < this.tankEssence.getCapacity()){ - Utils.LOG_INFO("canFill(mConvertToEssence)"); + Utils.LOG_WARNING("canFill(mConvertToEssence)"); return true; } } else { if (this.tankLiquidXp.getFluidAmount() < this.tankLiquidXp.getCapacity()){ - Utils.LOG_INFO("canFill(tankLiquidXp)"); + Utils.LOG_WARNING("canFill(tankLiquidXp)"); return true; } } - Utils.LOG_INFO("canFill(false)"); + Utils.LOG_WARNING("canFill(false)"); return false; } @@ -177,7 +177,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { return true; } } - Utils.LOG_INFO("canDrain(false)"); + Utils.LOG_WARNING("canDrain(false)"); return false; } @@ -192,7 +192,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { } public float getAdjustedVolume() { - Utils.LOG_INFO("AdjustedVolume()"); + Utils.LOG_WARNING("AdjustedVolume()"); this.needsUpdate = true; final float amount = this.tankLiquidXp.getFluidAmount(); final float capacity = this.tankLiquidXp.getCapacity(); @@ -205,7 +205,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { if (this.isServerSide()){ - //Utils.LOG_INFO("Ticking. | mConvertToEssence: "+this.mConvertToEssence); + //Utils.LOG_WARNING("Ticking. | mConvertToEssence: "+this.mConvertToEssence); if (this.needsUpdate) { @@ -227,7 +227,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { this.tankEssence.fill(bigStorage, true); this.tankLiquidXp.drain(100, true); this.needsUpdate = true; - Utils.LOG_INFO("B->A"); + Utils.LOG_WARNING("B->A"); } } else { @@ -237,7 +237,7 @@ public class TileEntityXpConverter extends TileEntity implements IFluidHandler { this.tankLiquidXp.fill(bigStorage, true); this.tankEssence.drain((int) rm, true); this.needsUpdate = true; - Utils.LOG_INFO("A->B"); + Utils.LOG_WARNING("A->B"); } } } diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index f9315a2966..979c1f0287 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -1,12 +1,16 @@ package gtPlusPlus.core.util; -import static gtPlusPlus.core.handler.BookHandler.mBookKeeperCount; - import java.awt.Color; import java.awt.Graphics; import java.io.File; import java.lang.reflect.Method; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Timer; +import java.util.TimerTask; import org.apache.commons.lang3.EnumUtils; import org.apache.logging.log4j.LogManager; @@ -15,7 +19,6 @@ import org.apache.logging.log4j.Logger; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.FMLLog; import cpw.mods.fml.relauncher.FMLRelaunchLog; -import gregtech.api.GregTech_API; import gregtech.api.enums.Materials; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.TC_Aspects.TC_AspectStack; @@ -23,7 +26,6 @@ import gregtech.api.util.GT_LanguageManager; import gregtech.api.util.GT_Log; import gregtech.api.util.GT_Utility; import gtPlusPlus.GTplusplus; -import gtPlusPlus.core.handler.BookHandler; import gtPlusPlus.core.item.ModItems; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.material.Material; @@ -38,7 +40,6 @@ import ic2.core.item.resources.ItemCell; import net.minecraft.block.Block; import net.minecraft.client.Minecraft; import net.minecraft.entity.Entity; -import net.minecraft.init.Items; import net.minecraft.item.Item.ToolMaterial; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; @@ -49,7 +50,9 @@ import net.minecraft.util.ChatComponentText; import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import net.minecraftforge.common.util.EnumHelper; -import net.minecraftforge.fluids.*; +import net.minecraftforge.fluids.FluidContainerRegistry; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.oredict.OreDictionary; public class Utils { @@ -183,8 +186,21 @@ public class Utils { // Non-Dev Comments public static void LOG_MACHINE_INFO(final String s) { - if (CORE.configSwitches.MACHINE_INFO || ClientProxy.playerName.toLowerCase().contains("draknyte1")) { - String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); + + boolean localPlayer = false; + try { + if (ClientProxy.playerName != null){ + if (ClientProxy.playerName.toLowerCase().contains("draknyte1")){ + localPlayer = true; + } + } + } + catch (final Throwable t){ + + } + + if (CORE.configSwitches.MACHINE_INFO || localPlayer) { + final String name1 = gtPlusPlus.core.util.reflect.ReflectionUtils.getMethodName(2); modLogger.info("Machine Info: " + s + " | " + name1); } } @@ -504,7 +520,7 @@ public class Utils { } public static File getMcDir() { - if (MinecraftServer.getServer() != null && MinecraftServer.getServer().isDedicatedServer()) { + if ((MinecraftServer.getServer() != null) && MinecraftServer.getServer().isDedicatedServer()) { return new File("."); } return Minecraft.getMinecraft().mcDataDir; @@ -604,7 +620,7 @@ public class Utils { } - public static int calculateVoltageTier(int Voltage) { + public static int calculateVoltageTier(final int Voltage) { int V; if (Voltage == 8) { V = 0; @@ -732,34 +748,39 @@ public class Utils { return sBookCount; } - public static ItemStack getWrittenBook(ItemStack aBook, int aID, String aMapping, String aTitle, String aAuthor, - String[] aPages) { - if (GT_Utility.isStringInvalid(aMapping)) + public static ItemStack getWrittenBook(final ItemStack aBook, final int aID, final String aMapping, final String aTitle, final String aAuthor, + final String[] aPages) { + if (GT_Utility.isStringInvalid(aMapping)) { return null; - ItemStack rStack = (ItemStack) CORE.sBookList.get(aMapping); - if (rStack != null) + } + ItemStack rStack = CORE.sBookList.get(aMapping); + if (rStack != null) { return GT_Utility.copyAmount(1L, new Object[] { rStack }); - if ((GT_Utility.isStringInvalid(aTitle)) || (GT_Utility.isStringInvalid(aAuthor)) || (aPages.length <= 0)) + } + if ((GT_Utility.isStringInvalid(aTitle)) || (GT_Utility.isStringInvalid(aAuthor)) || (aPages.length <= 0)) { return null; + } sBookCount += 1; - int vMeta = (aID == -1 ? sBookCount : aID); + final int vMeta = (aID == -1 ? sBookCount : aID); rStack = (aBook == null ? new ItemStack(ModItems.itemCustomBook, 1, vMeta) : aBook); - NBTTagCompound tNBT = new NBTTagCompound(); + final NBTTagCompound tNBT = new NBTTagCompound(); tNBT.setString("title", GT_LanguageManager.addStringLocalization( new StringBuilder().append("Book.").append(aTitle).append(".Name").toString(), aTitle)); tNBT.setString("author", aAuthor); - NBTTagList tNBTList = new NBTTagList(); + final NBTTagList tNBTList = new NBTTagList(); for (byte i = 0; i < aPages.length; i = (byte) (i + 1)) { aPages[i] = GT_LanguageManager .addStringLocalization(new StringBuilder().append("Book.").append(aTitle).append(".Page") .append((i < 10) ? new StringBuilder().append("0").append(i).toString() : Byte.valueOf(i)) .toString(), aPages[i]); if (i < 48) { - if (aPages[i].length() < 256) + if (aPages[i].length() < 256) { tNBTList.appendTag(new NBTTagString(aPages[i])); - else + } + else { GT_Log.err.println(new StringBuilder().append("WARNING: String for written Book too long! -> ") .append(aPages[i]).toString()); + } } else { GT_Log.err.println(new StringBuilder().append("WARNING: Too much Pages for written Book! -> ") .append(aTitle).toString()); -- cgit