diff options
Diffstat (limited to 'src/Java/gtPlusPlus')
33 files changed, 2194 insertions, 165 deletions
diff --git a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java index 249ea78ff3..f57c09b62d 100644 --- a/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java +++ b/src/Java/gtPlusPlus/core/common/compat/COMPAT_Baubles.java @@ -2,6 +2,7 @@ package gtPlusPlus.core.common.compat; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.item.ModItems; +import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; import gtPlusPlus.core.item.general.ItemCloakingDevice; import gtPlusPlus.core.item.general.ItemHealingDevice; import gtPlusPlus.core.item.general.ItemSlowBuildingRing; @@ -23,6 +24,17 @@ public class COMPAT_Baubles { ModItems.itemPersonalCloakingDevice = new ItemCloakingDevice(0); //itemPersonalCloakingDeviceCharged = new ItemCloakingDevice(0).set; ModItems.itemPersonalHealingDevice = new ItemHealingDevice(); + + try { + ModItems.itemChargePack1 = new BatteryPackBaseBauble(6); + ModItems.itemChargePack2 = new BatteryPackBaseBauble(7); + ModItems.itemChargePack3 = new BatteryPackBaseBauble(8); + ModItems.itemChargePack4 = new BatteryPackBaseBauble(9); + } + catch (Throwable t) { + t.printStackTrace(); + } + if (LoadedMods.PlayerAPI){ ModItems.itemSlowBuildingRing = new ItemSlowBuildingRing(); } diff --git a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java index 31819c5030..f6735de8e4 100644 --- a/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java +++ b/src/Java/gtPlusPlus/core/handler/COMPAT_HANDLER.java @@ -143,6 +143,9 @@ public class COMPAT_HANDLER { if (LoadedMods.OpenBlocks){ COMPAT_OpenBlocks.OreDict(); } + if (LoadedMods.Railcraft){ + COMPAT_Railcraft.OreDict(); + } if (LoadedMods.Simply_Jetpacks){ COMPAT_SimplyJetpacks.OreDict(); } diff --git a/src/Java/gtPlusPlus/core/item/ModItems.java b/src/Java/gtPlusPlus/core/item/ModItems.java index b89fd2158f..8d7db4f40a 100644 --- a/src/Java/gtPlusPlus/core/item/ModItems.java +++ b/src/Java/gtPlusPlus/core/item/ModItems.java @@ -29,6 +29,7 @@ import gtPlusPlus.core.item.base.misc.BaseItemMisc; import gtPlusPlus.core.item.base.misc.BaseItemMisc.MiscTypes; import gtPlusPlus.core.item.base.plates.BaseItemPlate; import gtPlusPlus.core.item.base.plates.BaseItemPlateDouble; +import gtPlusPlus.core.item.bauble.BatteryPackBaseBauble; import gtPlusPlus.core.item.bauble.HealthBoostBauble; import gtPlusPlus.core.item.bauble.ModularBauble; import gtPlusPlus.core.item.chemistry.CoalTar; @@ -322,6 +323,11 @@ public final class ModItems { public static IonParticles itemIonParticleBase; public static StandardBaseParticles itemStandarParticleBase; + public static BatteryPackBaseBauble itemChargePack1; + public static BatteryPackBaseBauble itemChargePack2; + public static BatteryPackBaseBauble itemChargePack3; + public static BatteryPackBaseBauble itemChargePack4; + static { Logger.INFO("Items!"); //Default item used when recipes fail, handy for debugging. Let's make sure they exist when this class is called upon. @@ -908,10 +914,23 @@ public final class ModItems { GT_OreDictUnificator.registerOre("platePhasedGold", ItemUtils.getSimpleStack(itemPlateVibrantAlloy)); GT_OreDictUnificator.registerOre("dustPhasedIron", ItemUtils.getSimpleStack(itemDustPulsatingIron)); GT_OreDictUnificator.registerOre("platePhasedIron", ItemUtils.getSimpleStack(itemPlatePulsatingIron)); - GT_OreDictUnificator.registerOre("blockVibrantAlloy", ItemUtils.getItemStackOfAmountFromOreDict("blockPhasedGold", 1)); + GT_OreDictUnificator.registerOre("blockVibrantAlloy", ItemUtils.getItemStackOfAmountFromOreDict("blockPhasedGold", 1)); + + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getPlate(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(144), 10000, 16, 4*9); + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getIngot(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(144), 10000, 16, 4*9); + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getNugget(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(16), 10000, 16, 4); + CORE.RA.addFluidExtractionRecipe(MaterialEIO.REDSTONE_ALLOY.getBlock(1), null, MaterialEIO.REDSTONE_ALLOY.getFluid(1294), 10000, 16, 4*9*9); + } else { - Logger.WARNING("EnderIO not Found - Skipping Resources."); + /*Logger.WARNING("EnderIO not Found - Generating our own Resources."); + MaterialGenerator.generate(MaterialEIO.CONDUCTIVE_IRON); + MaterialGenerator.generate(MaterialEIO.PULSATING_IRON); + MaterialGenerator.generate(MaterialEIO.REDSTONE_ALLOY); + MaterialGenerator.generate(MaterialEIO.SOULARIUM); + MaterialGenerator.generate(MaterialEIO.ELECTRICAL_STEEL); + MaterialGenerator.generate(MaterialEIO.ENERGETIC_ALLOY); + MaterialGenerator.generate(MaterialEIO.VIBRANT_ALLOY); */ } //Big Reactors diff --git a/src/Java/gtPlusPlus/core/item/bauble/BaseBauble.java b/src/Java/gtPlusPlus/core/item/bauble/BaseBauble.java index 2661d3a3b0..fdd148b97b 100644 --- a/src/Java/gtPlusPlus/core/item/bauble/BaseBauble.java +++ b/src/Java/gtPlusPlus/core/item/bauble/BaseBauble.java @@ -51,9 +51,20 @@ public class BaseBauble extends Item implements IBauble { this.setUnlocalizedName(Utils.sanitizeString(displayName.toLowerCase())); GameRegistry.registerItem(this, getUnlocalizedName()); } + + public BaseBauble(BaubleType type, String unlocalName, int register) { + this.mThisBauble = type; + this.mDisplayName = ""; + Utils.registerEvent(this); + this.setMaxStackSize(1); + this.setCreativeTab(AddToCreativeTab.tabMisc); + } @Override - public String getItemStackDisplayName(final ItemStack tItem) { + public String getItemStackDisplayName(final ItemStack tItem) { + if (this.mDisplayName == null || this.mDisplayName.length() < 1) { + return super.getItemStackDisplayName(tItem).replaceAll(".name", ""); + } return this.mDisplayName; } diff --git a/src/Java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java b/src/Java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java new file mode 100644 index 0000000000..cc7979825a --- /dev/null +++ b/src/Java/gtPlusPlus/core/item/bauble/BatteryPackBaseBauble.java @@ -0,0 +1,352 @@ +package gtPlusPlus.core.item.bauble; + +import java.util.List; + +import baubles.api.BaubleType; +import baubles.api.IBauble; +import cpw.mods.fml.common.Optional; +import cpw.mods.fml.common.registry.GameRegistry; +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +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.math.MathUtils; +import gtPlusPlus.xmod.gregtech.common.helpers.ChargingHelper; +import ic2.api.item.ElectricItem; +import ic2.api.item.IElectricItem; +import ic2.api.item.IElectricItemManager; +import net.minecraft.creativetab.CreativeTabs; +import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraft.util.StatCollector; +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 BatteryPackBaseBauble extends BaseBauble implements IElectricItem, IElectricItemManager, IBauble { + + final int mTier; + private final double maxValueEU; + + public BatteryPackBaseBauble(int tier) { + super(BaubleType.BELT, "GTPP.BattPack.0" + tier + ".name", 0); + mTier = tier; + maxValueEU = GT_Values.V[mTier] * 20 * 300; + String aUnlocalName = "GTPP.BattPack.0" + mTier + ".name"; + this.setUnlocalizedName(aUnlocalName); + this.setTextureName(CORE.MODID + ":" + "chargepack/"+tier); + this.setMaxDamage(27); + this.setMaxStackSize(1); + this.setNoRepair(); + this.setCreativeTab(AddToCreativeTab.tabMachines); + if (GameRegistry.findItem(CORE.MODID, aUnlocalName) == null) { + GameRegistry.registerItem(this, aUnlocalName); + } + } + + @SideOnly(Side.CLIENT) + @Override + public void getSubItems(Item item, CreativeTabs par2CreativeTabs, List itemList) { + ItemStack itemStack = new ItemStack(this, 1); + ItemStack charged; + if (this.getEmptyItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, 0.0D, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + if (this.getChargedItem(itemStack) == this) { + charged = new ItemStack(this, 1); + ElectricItem.manager.charge(charged, Double.POSITIVE_INFINITY, Integer.MAX_VALUE, true, false); + itemList.add(charged); + } + + } + + @Override + public void onUpdate(final ItemStack itemStack, final World worldObj, final Entity player, final int p_77663_4_, + final boolean p_77663_5_) { + super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); + } + + @Override + public boolean canProvideEnergy(final ItemStack itemStack) { + double aItemCharge = ElectricItem.manager.getCharge(itemStack); + return aItemCharge > 0; + } + + @Override + public Item getChargedItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(27); + return x.getItem(); + } + + @Override + public Item getEmptyItem(final ItemStack itemStack) { + final ItemStack x = itemStack.copy(); + x.setItemDamage(0); + return x.getItem(); + } + + @Override + public double getMaxCharge(final ItemStack itemStack) { + return maxValueEU; + } + + @Override + public int getTier(final ItemStack itemStack) { + return mTier; + } + + @Override + public double getTransferLimit(final ItemStack itemStack) { + return GT_Values.V[mTier]; + } + + @Override + public String getItemStackDisplayName(final ItemStack p_77653_1_) { + return (EnumChatFormatting.BLUE + super.getItemStackDisplayName(p_77653_1_) + EnumChatFormatting.GRAY); + } + + @Override + 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) { + return true; + } + + public int secondsLeft(final ItemStack stack) { + double r = 0; + r = this.getCharge(stack) / (10000 * 20); + return (int) MathUtils.decimalRounding(r); + } + + @SuppressWarnings("unchecked") + @Override + public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + list.add(""); + String aString1 = StatCollector.translateToLocal("GTPP.battpack.tooltip.1"); + String aString2 = StatCollector.translateToLocal("GTPP.battpack.tooltip.2"); + String aString3 = StatCollector.translateToLocal("GTPP.battpack.tooltip.3"); + String aString4 = StatCollector.translateToLocal("GTPP.battpack.tooltip.4"); + + String aEuInfo = StatCollector.translateToLocal("GTPP.info.euInfo"); + String aTier = StatCollector.translateToLocal("GTPP.machines.tier"); + String aInputLimit = StatCollector.translateToLocal("GTPP.info.inputLimit"); + String aCurrentPower = StatCollector.translateToLocal("GTPP.info.currentPower"); + String aEU = StatCollector.translateToLocal("GTPP.info.eu"); + String aEUT = aEU+"/t"; + + list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString2+" " + (int) getTransferLimit(stack) + aEUT +" "+ aString3 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString4 + EnumChatFormatting.GRAY); + list.add(""); + list.add(EnumChatFormatting.GOLD + aEuInfo + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY + aTier+": [" + EnumChatFormatting.YELLOW + this.getTier(stack) + + EnumChatFormatting.GRAY + "] "+aInputLimit+": [" + EnumChatFormatting.YELLOW + + this.getTransferLimit(stack) + EnumChatFormatting.GRAY + aEUT); + list.add(EnumChatFormatting.GRAY + aCurrentPower +": [" + EnumChatFormatting.YELLOW + (long) this.getCharge(stack) + + EnumChatFormatting.GRAY + aEU +"] [" + EnumChatFormatting.YELLOW + + MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack)) + EnumChatFormatting.GRAY + + "%]"); + super.addInformation(stack, aPlayer, list, bool); + } + + @Override + public double charge(final ItemStack stack, final double amount, final int tier, final boolean ignoreTransferLimit, + final boolean simulate) { + + if (!simulate) { + ElectricItem.manager.charge(stack, amount, tier, true, simulate); + + } + return ElectricItem.manager.charge(stack, amount, tier, true, simulate); + } + + @Override + public double discharge(final ItemStack stack, final double amount, final int tier, + final boolean ignoreTransferLimit, final boolean externally, final boolean simulate) { + if (!simulate) { + ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + return ElectricItem.manager.discharge(stack, amount, tier, ignoreTransferLimit, externally, simulate); + } + + @Override + public double getCharge(final ItemStack stack) { + return ElectricItem.manager.getCharge(stack); + } + + @Override + public boolean canUse(final ItemStack stack, final double amount) { + return ElectricItem.manager.canUse(stack, amount); + } + + @Override + public boolean use(final ItemStack stack, final double amount, final EntityLivingBase entity) { + return ElectricItem.manager.use(stack, amount, entity); + } + + @Override + public void chargeFromArmor(final ItemStack stack, final EntityLivingBase entity) { + ElectricItem.manager.chargeFromArmor(stack, entity); + } + + @Override + public String getToolTip(final ItemStack stack) { + return ElectricItem.manager.getToolTip(stack); + } + + @Override + public boolean canEquip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public boolean canUnequip(final ItemStack arg0, final EntityLivingBase arg1) { + return true; + } + + @Override + public BaubleType getBaubleType(final ItemStack arg0) { + return BaubleType.BELT; + } + + @Override // TODO + public void onEquipped(final ItemStack arg0, final EntityLivingBase arg1) { + + } + + @Override // TODO + public void onUnequipped(final ItemStack arg0, final EntityLivingBase arg1) { + + } + + @Override // TODO + public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase aPlayer) { + if (!aPlayer.worldObj.isRemote) { + if (this.getCharge(aBaubleStack) >= getTransferLimit(aBaubleStack)) { + // Try Iterate Armour Slots of Player + if (aPlayer instanceof EntityPlayer) { + + // amour + for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.armorInventory) { + if (aInvStack != null) { + if (aInvStack == aBaubleStack) { + continue; + } + if (ChargingHelper.isItemValid(aInvStack)) { + double aTransferRate = 0; + final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); + if (electricItem != null) { + aTransferRate = electricItem.getTransferLimit(aInvStack); + double aItemCharge = ElectricItem.manager.getCharge(aInvStack); + if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { + if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { + if (ElectricItem.manager.getCharge(aInvStack) <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + double d = ElectricItem.manager.charge(aInvStack, aTransferRate * 16, mTier, false, true); + if (d > 0) { + d = ElectricItem.manager.charge(aInvStack, aTransferRate * 16, mTier, false, false); + ElectricItem.manager.discharge(aBaubleStack, d, mTier, false, true, false); + //Logger.INFO("Charging " + aInvStack.getDisplayName() + " | " + d + " | "+electricItem.getMaxCharge(aInvStack)); + } + } + else { + //Logger.INFO("5"); + } + } + else { + //Logger.INFO("4"); + } + } + else { + //Logger.INFO("3"); + } + + } + else { + //Logger.INFO("1"); + } + } + + } + } + if (this.getCharge(aBaubleStack) > 0) { + continue; + } else { + break; + } + } + + // Hotbar Slots + int aSlotCounter = 0; + for (final ItemStack aInvStack : ((EntityPlayer) aPlayer).inventory.mainInventory) { + if (aSlotCounter > (InventoryPlayer.getHotbarSize() - 1)) { + break; + } + aSlotCounter++; + if (aInvStack != null) { + if (aInvStack == aBaubleStack) { + continue; + } + if (ChargingHelper.isItemValid(aInvStack)) { + double aTransferRate = 0; + final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); + if (electricItem != null) { + aTransferRate = electricItem.getTransferLimit(aInvStack); + double aItemCharge = ElectricItem.manager.getCharge(aInvStack); + if (aItemCharge >= 0 && aItemCharge != electricItem.getMaxCharge(aInvStack)) { + if (aItemCharge <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + if (ElectricItem.manager.getCharge(aBaubleStack) >= aTransferRate) { + if (ElectricItem.manager.getCharge(aInvStack) <= (electricItem.getMaxCharge(aInvStack) - aTransferRate)) { + double d = ElectricItem.manager.charge(aInvStack, aTransferRate, mTier, false, true); + if (d > 0) { + d = ElectricItem.manager.charge(aInvStack, aTransferRate, mTier, false, false); + ElectricItem.manager.discharge(aBaubleStack, d, mTier, false, true, false); + //Logger.INFO("Charging " + aInvStack.getDisplayName() + " | " + d + " | "+electricItem.getMaxCharge(aInvStack)); + } + } + else { + //Logger.INFO("5"); + } + } + else { + //Logger.INFO("4"); + } + } + else { + //Logger.INFO("3"); + } + + } + else { + //Logger.INFO("1"); + } + } + } + } + if (this.getCharge(aBaubleStack) > 0) { + continue; + } else { + break; + } + } + } + } + } + } + +} diff --git a/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java b/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java index c651fb38d9..4abb84a33c 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemGiantEgg.java @@ -136,7 +136,9 @@ public class ItemGiantEgg extends BaseItemBurnable { if (player && NBTUtils.getTagCompound(aStack, "GT.CraftingComponents") == null) { if (mCorrectStemCells == null) { if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK && Utils.getGregtechSubVersion() > 28) { - ItemList xl = ItemList.valueOf("Circuit_Chip_Stemcell"); + + + ItemList xl = Utils.getValueOfItemList("Circuit_Chip_Stemcell", ItemList.Circuit_Elite); if (xl != null && xl.hasBeenSet()) { mCorrectStemCells = xl.get(1); } diff --git a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java index f458bce139..c8acdc2152 100644 --- a/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java +++ b/src/Java/gtPlusPlus/core/item/general/ItemHealingDevice.java @@ -8,9 +8,13 @@ import cpw.mods.fml.common.registry.GameRegistry; 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.entity.player.InventoryPlayer; 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.world.World; import baubles.api.BaubleType; @@ -18,9 +22,12 @@ import baubles.api.IBauble; 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; @@ -47,29 +54,12 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI if (worldObj.isRemote) { return; } - - if (player instanceof EntityPlayer){ - for (final ItemStack is : ((EntityPlayer) player).inventory.mainInventory) { - if (is == itemStack) { - continue; - } - if (is != null) { - if (is.getItem() instanceof IElectricItem) { - final IElectricItem electricItem = (IElectricItem) is.getItem(); - this.chargeEU = ElectricItem.manager.getCharge(is); - } - - } - } - } - - super.onUpdate(itemStack, worldObj, player, p_77663_4_, p_77663_5_); } @Override public boolean canProvideEnergy(final ItemStack itemStack) { - return true; + return false; } @Override @@ -127,16 +117,43 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI return (int) r; } + @SuppressWarnings({ "rawtypes", "unchecked" }) @Override public void addInformation(final ItemStack stack, final EntityPlayer aPlayer, final List list, final boolean bool) { + + String aString1 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.1"); + String aString2 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.2"); + String aString3 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.3"); + String aString4 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.4"); + String aString5 = StatCollector.translateToLocal("GTPP.nanohealer.tooltip.5"); + String aStringTooltip = StatCollector.translateToLocal("GTPP.nanohealer.hidden"); + String aEuInfo = StatCollector.translateToLocal("GTPP.info.euInfo"); + String aTier = StatCollector.translateToLocal("GTPP.machines.tier"); + String aInputLimit = StatCollector.translateToLocal("GTPP.info.inputLimit"); + String aCurrentPower = StatCollector.translateToLocal("GTPP.info.currentPower"); + String aEU = StatCollector.translateToLocal("GTPP.info.eu"); + String aEUT = aEU+"/t"; + boolean isShowing = getShowMessages(stack); + + list.add(""); + + list.add(EnumChatFormatting.GREEN + aString1 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString2 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GREEN + aString3 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.RED + aString4 + EnumChatFormatting.GRAY); + list.add(""); - list.add(EnumChatFormatting.GREEN+"Worn as a Necklace within Baubles."+EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GREEN+"Drains 1638400eu to restore hunger."+EnumChatFormatting.GRAY); - list.add(""); - list.add(EnumChatFormatting.GOLD+"IC2/EU Information"+EnumChatFormatting.GRAY); - list.add(EnumChatFormatting.GRAY+"Tier: ["+EnumChatFormatting.YELLOW+this.getTier(this.thisStack)+EnumChatFormatting.GRAY+"] Transfer Limit: ["+EnumChatFormatting.YELLOW+this.getTransferLimit(this.thisStack)+EnumChatFormatting.GRAY +"Eu/t]"); - list.add(EnumChatFormatting.GRAY+"Current Power: ["+EnumChatFormatting.YELLOW+(long) this.getCharge(stack)+EnumChatFormatting.GRAY+"Eu] ["+EnumChatFormatting.YELLOW+MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack))+EnumChatFormatting.GRAY +"%]"); - list.add(EnumChatFormatting.GRAY+"Uses Remaining: ["+EnumChatFormatting.YELLOW+this.secondsLeft(stack)+ EnumChatFormatting.GRAY +"]"); + + list.add(EnumChatFormatting.GOLD + aEuInfo + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GRAY + aTier+": [" + EnumChatFormatting.YELLOW + this.getTier(stack) + + EnumChatFormatting.GRAY + "] "+aInputLimit+": [" + EnumChatFormatting.YELLOW + + this.getTransferLimit(stack) + EnumChatFormatting.GRAY + aEUT); + list.add(EnumChatFormatting.GRAY + aCurrentPower +": [" + EnumChatFormatting.YELLOW + (long) this.getCharge(stack) + + EnumChatFormatting.GRAY + aEU +"] [" + EnumChatFormatting.YELLOW + + MathUtils.findPercentage(this.getCharge(stack), this.getMaxCharge(stack)) + EnumChatFormatting.GRAY + + "%]"); + list.add(EnumChatFormatting.GOLD + aString5 + EnumChatFormatting.GRAY); + list.add(EnumChatFormatting.GOLD + aStringTooltip + " " + (!isShowing ? EnumChatFormatting.DARK_GREEN : EnumChatFormatting.DARK_RED) + !isShowing + EnumChatFormatting.GRAY); super.addInformation(stack, aPlayer, list, bool); } @@ -214,19 +231,205 @@ public class ItemHealingDevice extends Item implements IElectricItem, IElectricI } @Override //TODO - public void onWornTick(final ItemStack arg0, final EntityLivingBase arg1) { + public void onWornTick(final ItemStack aBaubleStack, final EntityLivingBase arg1) { if (!arg1.worldObj.isRemote){ - if (this.getCharge(arg0) >= (1638400/4)){ + + //Try Charge First + + //Inv Slots + for (final ItemStack aInvStack : ((EntityPlayer) arg1).inventory.mainInventory) { + if (aInvStack == aBaubleStack) { + continue; + } + + if (this.getCharge(aBaubleStack) == this.getMaxCharge(aBaubleStack)) { + break; + } + + if (aInvStack != null) { + if (ChargingHelper.isItemValid(aInvStack)) { + + + double aTransferRate; + double aCurrentChargeForThisBauble; + int mTier; + final IElectricItem electricItem = (IElectricItem) aInvStack.getItem(); + + if (electricItem != null) { + + aTransferRate = electricItem.getTransferLimit(aInvStack); + mTier = electricItem.getTier(aInvStack); + aCurrentChargeForThisBauble = ElectricItem.manager.getCharge(aBaubleStack); + + if (aCurrentChargeForThisBauble < maxValueEU) { + if ((ElectricItem.manager.getCharge(aInvStack) >= aTransferRate)) { + if (electricItem.canProvideEnergy(aInvStack)) { + double d = ElectricItem.manager.discharge(aInvStack, aTransferRate, mTier, false, true, false); + //Logger.INFO("Charging from "+aInvStack.getDisplayName() +" | "+d); + ElectricItem.manager.charge(aBaubleStack, d, mTier, true, false); + } + } + } + } + } + } + if (this.getCharge(aBaubleStack) <= (this.getMaxCharge(aBaubleStack) - getTransferLimit(aBaubleStack))) { + continue; + } + else { + break; + } + } + + + //Try Heal + if (this.getCharge(aBaubleStack) > 0){ + + //health Check + float hp = 0; if (arg1.getHealth() < arg1.getMaxHealth()){ final float rx = arg1.getMaxHealth()-arg1.getHealth(); Logger.INFO("rx:"+rx); - arg1.heal(rx*2); - this.discharge(arg0, (1638400/4)*rx, 6, true, true, false); - PlayerUtils.messagePlayer((EntityPlayer) arg1, "Your NanoBooster Whirs! Leaving you feeling stronger. It Healed "+rx+" hp."); - PlayerUtils.messagePlayer((EntityPlayer) arg1, "You check it's remaining uses, it has "+this.secondsLeft(arg0)+"."); + arg1.heal(rx*2); + hp = rx; + 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); + } } + + + saturation = (int) saturation; + + //Only show Messages if they're enabled. + if (getShowMessages(aBaubleStack)) { + if (hp > 0 || hunger > 0 || saturation > 0) + PlayerUtils.messagePlayer((EntityPlayer) arg1, + "Your NanoBooster Whirs! Leaving you feeling stronger."); + + if (hp > 0) + PlayerUtils.messagePlayer((EntityPlayer) arg1, "Healed " + hp + " hp."); + + if (hunger > 0) + PlayerUtils.messagePlayer((EntityPlayer) arg1, "Healed " + hunger + " hunger."); + + if (saturation > 0) + PlayerUtils.messagePlayer((EntityPlayer) arg1, "Satured Hunger by " + saturation + "."); + + 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); + rStack.setTagCompound(tagMain); + return true; + } + + public static final boolean getShowMessages(final ItemStack aStack) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT == null) { + if (!createNBT(aStack)) { + return false; + } + else { + aNBT = aStack.getTagCompound(); + } + } + return aNBT.getBoolean("ShowMSG"); + + } + + public static final boolean setShowMessages(final ItemStack aStack, final boolean aShow) { + NBTTagCompound aNBT = aStack.getTagCompound(); + if (aNBT == null) { + if (!createNBT(aStack)) { + return false; + } else { + aNBT = aStack.getTagCompound(); } } + aNBT.setBoolean("ShowMSG", aShow); + return true; + } + + @Override + public boolean onItemUse(ItemStack p_77648_1_, EntityPlayer p_77648_2_, World p_77648_3_, int p_77648_4_, + int p_77648_5_, int p_77648_6_, int p_77648_7_, float p_77648_8_, float p_77648_9_, float p_77648_10_) { + // TODO Auto-generated method stub + return super.onItemUse(p_77648_1_, p_77648_2_, p_77648_3_, p_77648_4_, p_77648_5_, p_77648_6_, p_77648_7_, p_77648_8_, + p_77648_9_, p_77648_10_); + } + + @Override + public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) { + ItemStack superStack = super.onItemRightClick(aStack, aWorld, aPlayer); + boolean isShiftHeld = KeyboardUtils.isShiftKeyDown(); + if (isShiftHeld) { + boolean oldState = getShowMessages(superStack); + boolean newState = Utils.invertBoolean(oldState); + ItemHealingDevice.setShowMessages(superStack, newState); + PlayerUtils.messagePlayer(aPlayer, (!oldState ? "Showing info messages" : "Hiding info messages")); + } + return superStack; + } + + @Override + public boolean doesSneakBypassUse(World world, int x, int y, int z, EntityPlayer player) { + return true; } + + + } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java index eca9e278e2..25103c0f5a 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_GREGTECH.java @@ -61,6 +61,7 @@ public class RECIPES_GREGTECH { if (CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK) { largeChemReactorRecipes(); + fusionRecipes(); } fissionFuelRecipes(); @@ -80,11 +81,48 @@ public class RECIPES_GREGTECH { breweryRecipes(); laserEngraverRecipes(); assemblyLineRecipes(); + addFuels(); } + private static void fusionRecipes() { + + /** + * Adds a Fusion reactor Recipe + * + * @param aInput1 = first Input (not null, and respects StackSize) + * @param aInput2 = second Input (not null, and respects StackSize) + * @param aOutput = Output of the Fusion (can be null, and respects StackSize) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aFusionEnergyPerTick = The EU generated per Tick (can even be negative!) + * @param aEnergyNeededForStartingFusion = EU needed for heating the Reactor up (must be >= 0) + */ + + //Hydrogen Plasma + /*CORE.RA.addFusionReactorRecipe( + Particle.getIon("Hydrogen", 0), + Particle.getIon("Hydrogen", 0), + Materials.Hydrogen.getPlasma(1), + 5000, + 16, + 4096, + 40000000);*/ + + + //Hypogen Creation + GT_Values.RA.addFusionReactorRecipe( + Materials.Neutronium.getMolten(128), + ALLOY.QUANTUM.getFluid(256), + ELEMENT.STANDALONE.HYPOGEN.getFluid(4), + 2048 * 4, + (int) GT_Values.V[9], + 600000000 * 2); + + } + private static void assemblyLineRecipes() { + //Containment Casings CORE.RA.addAssemblylineRecipe( ItemList.Field_Generator_IV.get(1), 20 * 60 * 30, @@ -114,6 +152,59 @@ public class RECIPES_GREGTECH { 20 * 60 * 10 * (GTNH ? 2 : 1), (int) GT_Values.V[6]); + //Slow Fusion Controller + CORE.RA.addAssemblylineRecipe( + GregtechItemList.COMET_Cyclotron.get(1), + 20 * 60 * 30, + new ItemStack[] { + CI.getFieldGenerator(6, GTNH ? 32 : 8), + ItemList.Electric_Motor_EV.get(GTNH ? 32 : 8), + ItemList.Tool_Scanner.get(GTNH ? 4 : 2), + CI.getTieredComponent(OrePrefixes.cableGt12, 6, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.wireGt16, 5, GTNH ? 64 : 32), + CI.getTieredComponent(OrePrefixes.plate, 6, GTNH ? 64 : 32), + ELEMENT.getInstance().GADOLINIUM.getDust(GTNH ? 32 : 8), + ELEMENT.getInstance().SAMARIUM.getDust(GTNH ? 16 : 4), + ALLOY.INCOLOY_MA956.getGear(GTNH ? 8 : 2), + CI.getTieredComponent(OrePrefixes.circuit, 5, GTNH ? 64 : 32), + CI.getTieredComponent(OrePrefixes.circuit, 6, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, 7, GTNH ? 16 : 8) + }, + new FluidStack[] { + CI.getTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), + CI.getTertiaryTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), + CI.getAlternativeTieredFluid(6, 144 * 9 * (GTNH ? 8 : 4)), + CI.getTieredFluid(5, 144 * 9 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(5, 144 * 9 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(5, 144 * 9 * (GTNH ? 16 : 8)), + + }, + GregtechItemList.Miniature_Fusion.get(1), + 20 * 60 * 5 * (GTNH ? 2 : 1), + (int) GT_Values.V[7]); + + + //Plasma Tank + CORE.RA.addAssemblylineRecipe( + ItemUtils.getOrePrefixStack(OrePrefixes.pipeMedium, Materials.Superconductor, 1), + 20 * 60 * 5, + new ItemStack[] { + CI.getTieredComponent(OrePrefixes.plate, 5, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.circuit, 5, GTNH ? 16 : 4), + CI.getTieredComponent(OrePrefixes.pipeHuge, 5, GTNH ? 16 : 4), + CI.getTieredComponent(OrePrefixes.cableGt08, 7, GTNH ? 32 : 16), + CI.getTieredComponent(OrePrefixes.gearGt, 6, GTNH ? 8 : 4), + }, + new FluidStack[] { + CI.getTieredFluid(4, 144 * 9 * (GTNH ? 16 : 8)), + CI.getTertiaryTieredFluid(4, 144 * 9 * (GTNH ? 16 : 8)), + CI.getAlternativeTieredFluid(4, 144 * 9 * (GTNH ? 16 : 8)), + + }, + GregtechItemList.Plasma_Tank.get(1), + 20 * 60 * 1 * (GTNH ? 2 : 1), + (int) GT_Values.V[5]); + } private static void laserEngraverRecipes() { @@ -1347,39 +1438,39 @@ public class RECIPES_GREGTECH { private static void cyclotronRecipes() { - //Polonium + // Polonium CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(0), FluidUtils.getFluidStack("molten.bismuth", 1), - new ItemStack[] { GregtechItemList.Pellet_RTG_PO210.get(1) }, null, new int[] { 100 }, 20 * 300 * 100, 2040, + new ItemStack[] { GregtechItemList.Pellet_RTG_PO210.get(1) }, null, new int[] { 100 }, 20 * 300 * 100, 2040 * 4, 500 * 20); - //Americium + // Americium CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(0), FluidUtils.getFluidStack("molten.americium", 1), - new ItemStack[] { GregtechItemList.Pellet_RTG_AM241.get(4) }, null, new int[] { 2500 }, 20 * 300 * 100, 1020, + new ItemStack[] { GregtechItemList.Pellet_RTG_AM241.get(4) }, null, new int[] { 2500 }, 20 * 300 * 100, 1020 * 4, 500 * 20); //PO Special Value - //Strontium u235 + // Strontium u235 CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(0), FluidUtils.getFluidStack("molten.uranium235", 10), - new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, null, new int[] { 570 }, 20 * 300 * 100, 1020, + new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, null, new int[] { 570 }, 20 * 300 * 100, 1020 * 4, 500 * 20); //PO Special Value - //Strontium u233 + // Strontium u233 CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(0), FluidUtils.getFluidStack("molten.uranium233", 10), - new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, null, new int[] { 660 }, 20 * 300 * 100, 1020, + new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, null, new int[] { 660 }, 20 * 300 * 100, 1020 * 4, 500 * 20); //PO Special Value - //Strontium pu239 + // Strontium pu239 CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(0), FluidUtils.getFluidStack("molten.plutonium239", 10), - new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, null, new int[] { 220 }, 20 * 300 * 100, 1020, + new ItemStack[] { GregtechItemList.Pellet_RTG_SR90.get(1) }, null, new int[] { 220 }, 20 * 300 * 100, 1020 * 4, 500 * 20); //PO Special Value - //Plutonium + // Plutonium CORE.RA.addCyclotronRecipe(CI.getNumberedCircuit(0), FluidUtils.getFluidStack("molten.plutonium238", 1), - new ItemStack[] { GregtechItemList.Pellet_RTG_PU238.get(2) }, null, new int[] { 780 }, 20 * 300 * 100, 1020, + new ItemStack[] { GregtechItemList.Pellet_RTG_PU238.get(2) }, null, new int[] { 780 }, 20 * 300 * 100, 1020 * 4, 500 * 20); //PO Special Value - //Neptunium + // Neptunium CORE.RA.addCyclotronRecipe(new ItemStack[] {ELEMENT.getInstance().URANIUM238.getDust(1) }, FluidUtils.getFluidStack("deuterium", 400), - new ItemStack[] {ItemUtils.getSimpleStack(ModItems.dustNeptunium238)}, null, new int[] { 500 }, 20 * 5, 500, + new ItemStack[] {ItemUtils.getSimpleStack(ModItems.dustNeptunium238)}, null, new int[] { 500 }, 20 * 5, 500 * 4, 500 * 20); //PO Special Value @@ -1424,7 +1515,7 @@ public class RECIPES_GREGTECH { (int) GT_Values.V[7], 750 * 20); - //Boson Smash + // Boson Smash CORE.RA.addCyclotronRecipe( CI.getNumberedCircuit(9), FluidUtils.getFluidStack("plasma.helium", 1500), @@ -1462,7 +1553,7 @@ public class RECIPES_GREGTECH { (int) GT_Values.V[8], 750 * 20); - //Graviton Smash + // Graviton Smash CORE.RA.addCyclotronRecipe( CI.getNumberedCircuit(15), FluidUtils.getFluidStack("plasma.hydrogen", GTNH ? 50 : 10), @@ -1483,7 +1574,7 @@ public class RECIPES_GREGTECH { aPlasma = Materials.Americium.getMolten(GTNH ? 20 : 5); } - //Quantum Anomaly + // Quantum Anomaly CORE.RA.addCyclotronRecipe( new ItemStack[] { CI.getNumberedCircuit(24), @@ -1506,7 +1597,10 @@ public class RECIPES_GREGTECH { int IonCount = 2; int tenCountA = (GTNH ? 2 : 1); int tenCountB = 0; - for (String y : IonParticles.MetaToNameMap.values()) { + for (String y : IonParticles.MetaToNameMap.values()) { + if (y.toLowerCase().contains("hydrogen")) { + continue; + } FluidStack aPlasma2 = FluidUtils.getFluidStack("plasma."+y.toLowerCase(), 2); Materials aTestMat = MaterialUtils.getMaterial(y); FluidStack aPlasma3 = aTestMat != null ? aTestMat.getPlasma(2) : aPlasma2; @@ -1528,7 +1622,7 @@ public class RECIPES_GREGTECH { Particle.getIon(y, -1), }, null, - new int[] { 75, 50, 25, 75, 50, 25, 75, 50, 75}, + new int[] { 275, 250, 225, 275, 250, 225, 275, 250, 275}, 20 * 20 * (IonCount++) * tenCountA, (int) GT_Values.V[7], 1500 * 20 * tenCountA); @@ -1545,6 +1639,101 @@ public class RECIPES_GREGTECH { tenCountB++; } } + + // Generate Hydrogen Ion Recipe + CORE.RA.addCyclotronRecipe( + CI.getNumberedCircuit(24), + FluidUtils.getWildcardFluidStack("hydrogen", 1000), + new ItemStack[] { + Particle.getIon("Hydrogen", 1), + Particle.getIon("Hydrogen", 2), + Particle.getIon("Hydrogen", 3), + Particle.getIon("Hydrogen", 1), + Particle.getIon("Hydrogen", 2), + Particle.getIon("Hydrogen", 3), + Particle.getIon("Hydrogen", -1), + Particle.getIon("Hydrogen", -2), + Particle.getIon("Hydrogen", -3) + }, + null, + new int[] { 125, 125, 125, 125, 125, 125, 125, 125, 125 }, + 20 * 20, + (int) GT_Values.V[6], + 15000); + + // Generate Hydrogen Plasma Recipe + CORE.RA.addCyclotronRecipe( + new ItemStack[] { + Particle.getIon("Hydrogen", 0), + ItemUtils.getItemStackOfAmountFromOreDict("cellHydrogen", 1) + }, + null, + new ItemStack[] { + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.NEUTRON), + Particle.getBaseParticle(Particle.ELECTRON), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + Particle.getBaseParticle(Particle.UNKNOWN), + CI.emptyCells(1) + }, + FluidUtils.getFluidStack("plasma.hydrogen", 1), + new int[] { 250, 250, 250, 500, 500, 500, 10000 }, + 20 * 60 * 2, + (int) GT_Values.V[7], + 750 * 20); + + + // Generate Protons Easily + CORE.RA.addCyclotronRecipe( + new ItemStack[] { + CI.getNumberedCircuit(20), + Particle.getIon("Hydrogen", 0) + }, + FluidUtils.getWildcardFluidStack("hydrogen", 100), + new ItemStack[] { + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + }, + null, + new int[] { 750, 750, 750, 750, 750, 750, 750, 750, 750 }, + 20 * 20, + (int) GT_Values.V[6], + 15000); + + CORE.RA.addCyclotronRecipe( + new ItemStack[] { + CI.getNumberedCircuit(22), + Particle.getBaseParticle(Particle.UNKNOWN), + }, + FluidUtils.getWildcardFluidStack("hydrogen", 100), + new ItemStack[] { + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + Particle.getBaseParticle(Particle.PROTON), + }, + null, + new int[] { 375, 375, 375, 375, 375, 375, 375, 375, 375 }, + 20 * 20, + (int) GT_Values.V[6], + 15000); + + + + } diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java index 5d8c040996..a12e8b28fd 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Machines.java @@ -13,6 +13,7 @@ import gtPlusPlus.core.material.ALLOY; import gtPlusPlus.core.material.ELEMENT; import gtPlusPlus.core.material.Material; import gtPlusPlus.core.recipe.common.CI; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.core.util.minecraft.*; import gtPlusPlus.everglades.dimension.Dimension_Everglades; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; @@ -246,7 +247,7 @@ public class RECIPES_Machines { EV_MACHINE_Wiremill= ItemList.Machine_IV_Wiremill.get(1); HV_MACHINE_Macerator= ItemList.Machine_EV_Macerator.get(1); EV_MACHINE_Macerator= ItemList.Machine_IV_Macerator.get(1); - EV_MACHINE_MassFabricator= CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? ItemList.valueOf("Machine_LuV_Massfab").get(1, ItemList.Machine_IV_Massfab.get(1)) : ItemList.Machine_IV_Massfab.get(1); + EV_MACHINE_MassFabricator= CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? gtPlusPlus.core.util.Utils.getValueOfItemList("Machine_LuV_Massfab", ItemList.Machine_IV_Massfab).get(1) : ItemList.Machine_IV_Massfab.get(1); EV_MACHINE_Centrifuge= ItemList.Machine_IV_Centrifuge.get(1); EV_MACHINE_Cutter = ItemList.Machine_IV_Cutter.get(1); EV_MACHINE_Extruder = ItemList.Machine_IV_Extruder.get(1); @@ -339,6 +340,19 @@ public class RECIPES_Machines { 60 * 20 * 10, 8000); + // Super Jukebox + CORE.RA.addSixSlotAssemblingRecipe( + new ItemStack[] { + CI.machineHull_LV, + ItemUtils.getItemStackOfAmountFromOreDict("circuitBaisc", 8), + ItemUtils.getItemStackOfAmountFromOreDict("plateTumbaga", 8), + ItemUtils.getSimpleStack(Blocks.jukebox) + }, + ELEMENT.getInstance().COPPER.getFluid(144 * 2), + ItemUtils.getSimpleStack(ModBlocks.blockCustomJukebox), + 20 * 30, + 30); + @@ -823,7 +837,10 @@ public class RECIPES_Machines { //Air Intake Hatch - ItemStack aTieredFluidRegulator = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? ItemList.valueOf("FluidRegulator_IV").get(1, ItemList.Pump_IV.get(1)) : ItemList.Pump_IV.get(1); + + + ItemList FluidRegulator_IV = Utils.getValueOfItemList("FluidRegulator_IV", ItemList.Pump_IV); + ItemStack aTieredFluidRegulator = CORE.MAIN_GREGTECH_5U_EXPERIMENTAL_FORK ? FluidRegulator_IV.get(1) : ItemList.Pump_IV.get(1); RecipeUtils.addShapedGregtechRecipe( @@ -1393,19 +1410,7 @@ public class RECIPES_Machines { - ItemStack aDrillController; - if (GTNH) { - aDrillController = ItemList.valueOf("OreDrill4").get(1); - } - else { - ItemList g = ItemList.valueOf("OreDrill4"); - if (g == null) { - aDrillController = CI.machineHull_UV; - } - else { - aDrillController = g.get(1); - } - } + ItemStack aDrillController = Utils.getValueOfItemList("OreDrill4", ItemList.Hull_UV).get(1); //Drilling Platform CORE.RA.addSixSlotAssemblingRecipe( diff --git a/src/Java/gtPlusPlus/core/recipe/RECIPES_Old_Circuits.java b/src/Java/gtPlusPlus/core/recipe/RECIPES_Old_Circuits.java index dbdf6b1437..98ea687747 100644 --- a/src/Java/gtPlusPlus/core/recipe/RECIPES_Old_Circuits.java +++ b/src/Java/gtPlusPlus/core/recipe/RECIPES_Old_Circuits.java @@ -445,7 +445,7 @@ public class RECIPES_Old_Circuits implements IOreRecipeRegistrator { for (String component : CircuitToHide){ try { - API.hideItem(ItemList.valueOf(component).get(1L, new Object[0])); + API.hideItem(Utils.getValueOfItemList(component, null).get(1L, new Object[0])); } catch (IllegalArgumentException I){ Logger.INFO("Could not find "+component+" in the Gregtech item list."); Logger.INFO("This is NOT an error, simply a notification."); diff --git a/src/Java/gtPlusPlus/core/recipe/common/CI.java b/src/Java/gtPlusPlus/core/recipe/common/CI.java index 13a30a510c..b473b30c3c 100644 --- a/src/Java/gtPlusPlus/core/recipe/common/CI.java +++ b/src/Java/gtPlusPlus/core/recipe/common/CI.java @@ -475,9 +475,10 @@ public class CI { public static void init() { //Set Explosives - try { - if (ItemList.valueOf("Block_Powderbarrel") != null){ - explosivePowderKeg = ItemList.valueOf("Block_Powderbarrel").get(1).copy(); + try { + ItemList PowerderBarrel = gtPlusPlus.core.util.Utils.getValueOfItemList("Block_Powderbarrel", null); + if (PowerderBarrel != null){ + explosivePowderKeg = PowerderBarrel.get(1).copy(); } } catch (java.lang.IllegalArgumentException Y) { explosivePowderKeg = ItemUtils.getSimpleStack(Items.gunpowder).copy(); @@ -530,7 +531,6 @@ public class CI { */ private static final Material[] aMaterial_Main = new Material[] { - MaterialEIO.REDSTONE_ALLOY, ALLOY.POTIN, ALLOY.ZIRCONIUM_CARBIDE, ALLOY.EGLIN_STEEL, @@ -541,11 +541,11 @@ public class CI { ALLOY.PIKYONIUM, ELEMENT.STANDALONE.ADVANCED_NITINOL, ALLOY.ABYSSAL, - ALLOY.QUANTUM + ALLOY.QUANTUM, + ELEMENT.STANDALONE.HYPOGEN }; private static final Material[] aMaterial_Secondary = new Material[] { - ELEMENT.getInstance().LEAD, ALLOY.TUMBAGA, ALLOY.SILICON_CARBIDE, ALLOY.TUNGSTEN_CARBIDE, @@ -556,11 +556,11 @@ public class CI { ALLOY.CINOBITE, ALLOY.TITANSTEEL, ALLOY.OCTIRON, - ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN + ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN, + ELEMENT.STANDALONE.HYPOGEN }; private static final Material[] aMaterial_Tertiary = new Material[] { - ELEMENT.getInstance().IRON, ALLOY.STEEL, ELEMENT.getInstance().ALUMINIUM, ALLOY.STAINLESSSTEEL, @@ -571,7 +571,8 @@ public class CI { ALLOY.TRINIUM_REINFORCED_STEEL, //Arceus ALLOY.TITANSTEEL, ELEMENT.STANDALONE.ASTRAL_TITANIUM, - ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN + ELEMENT.STANDALONE.CELESTIAL_TUNGSTEN, + ELEMENT.STANDALONE.HYPOGEN }; private static final Materials[] aMaterial_Cables = new Materials[] { diff --git a/src/Java/gtPlusPlus/core/util/Utils.java b/src/Java/gtPlusPlus/core/util/Utils.java index 968de2f55a..eef768e799 100644 --- a/src/Java/gtPlusPlus/core/util/Utils.java +++ b/src/Java/gtPlusPlus/core/util/Utils.java @@ -31,7 +31,9 @@ import net.minecraft.util.IChatComponent; import net.minecraft.world.World; import gregtech.GT_Mod; +import gregtech.api.enums.ItemList; import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; import gregtech.api.enums.TC_Aspects; import gregtech.api.enums.TC_Aspects.TC_AspectStack; import gregtech.api.util.GT_LanguageManager; @@ -916,4 +918,25 @@ public class Utils { return false; } + public static ItemList getValueOfItemList(String string, ItemList aOther) { + try { + Method method = ItemList.class.getDeclaredMethod("values"); + Object obj = method.invoke(null); + String y = Arrays.toString((Object[]) obj); + String[] aCurrentItemsInList = y.split(","); + boolean found = false; + for (String g : aCurrentItemsInList) { + if (g.equals(string)) { + found = true; + break; + } + } + if (found) { + return ItemList.valueOf(string); + } + } + catch (Throwable t) {} + return aOther; + } + } diff --git a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java index aa1e382278..01efcfb412 100644 --- a/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java +++ b/src/Java/gtPlusPlus/preloader/asm/AsmConfig.java @@ -18,6 +18,7 @@ public class AsmConfig { public static boolean enableChunkDebugging; public static boolean enableCofhPatch; public static boolean enableGcFuelChanges; + public static boolean enableRcFlowFix; public AsmConfig(File file) { if (!loaded) { @@ -75,12 +76,18 @@ public class AsmConfig { prop = config.get("general", "enableGcFuelChanges", true); prop.comment = "Enable/Disable changes to Galacticraft Rocket Fuels."; - prop.setLanguageKey("gtpp.enableGcFuelChanges").setRequiresMcRestart(true); - + prop.setLanguageKey("gtpp.enableGcFuelChanges").setRequiresMcRestart(true); //Disabled because Broken //enableGcFuelChanges = prop.getBoolean(true); - enableGcFuelChanges = false; + enableGcFuelChanges = false; + propOrder.add(prop.getName()); + + //Railcraft Tank fix + prop = config.get("general", "enableRcFlowFix", true); + prop.comment = "Quadruples max RC IO rates on tanks"; + prop.setLanguageKey("gtpp.enableRcFlowFix").setRequiresMcRestart(true); + enableRcFlowFix = prop.getBoolean(true); propOrder.add(prop.getName()); diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidHelper.java b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidHelper.java new file mode 100644 index 0000000000..7359bbeb53 --- /dev/null +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/ClassTransformer_Railcraft_FluidHelper.java @@ -0,0 +1,399 @@ +package gtPlusPlus.preloader.asm.transformers; + +import static org.objectweb.asm.Opcodes.*; + +import org.apache.logging.log4j.Level; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.FieldVisitor; +import org.objectweb.asm.Label; +import org.objectweb.asm.MethodVisitor; + +import cpw.mods.fml.relauncher.FMLRelaunchLog; + +public class ClassTransformer_Railcraft_FluidHelper { + + private final boolean isValid; + private final ClassReader reader; + private final ClassWriter writer; + + public static final int PROCESS_VOLUME = 16000; + + public ClassTransformer_Railcraft_FluidHelper(byte[] basicClass) { + ClassReader aTempReader = null; + ClassWriter aTempWriter = null; + + FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Attempting to patch field PROCESS_VOLUME in mods.railcraft.common.fluids.FluidHelper"); + + aTempReader = new ClassReader(basicClass); + aTempWriter = new ClassWriter(aTempReader, ClassWriter.COMPUTE_FRAMES); + aTempReader.accept(new AddFieldAdapter(aTempWriter), 0); + injectMethod("fillContainers", aTempWriter); + injectMethod("drainContainers", aTempWriter); + + if (aTempReader != null && aTempWriter != null && addField(ACC_PUBLIC + ACC_FINAL + ACC_STATIC, "PROCESS_VOLUME", aTempWriter)) { + isValid = true; + } + else { + isValid = false; + } + + FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Valid? "+isValid+"."); + reader = aTempReader; + writer = aTempWriter; + } + + public boolean isValidTransformer() { + return isValid; + } + + public ClassReader getReader() { + return reader; + } + + public ClassWriter getWriter() { + return writer; + } + + public boolean addField(int access, String fieldName, ClassWriter cv) { + FMLRelaunchLog.log( + "[GT++ ASM] Railcraft PROCESS_VOLUME Patch", + Level.INFO, + "Injecting " + fieldName + " with new value."); + FieldVisitor fv = cv.visitField(access, fieldName, "I", null, 16000); + if (fv != null) { + fv.visitEnd(); + return true; + } + return false; + } + + public boolean injectMethod(String aMethodName, ClassWriter cw) { + MethodVisitor mv; + boolean didInject = false; + FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Injecting " + aMethodName + "."); + + if (aMethodName.equals("fillContainers")) { + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "fillContainers", "(Lnet/minecraftforge/fluids/IFluidHandler;Lnet/minecraft/inventory/IInventory;IILnet/minecraftforge/fluids/Fluid;)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(126, l0); + mv.visitVarInsn(ALOAD, 4); + Label l1 = new Label(); + mv.visitJumpInsn(IFNONNULL, l1); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(127, l2); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + mv.visitLabel(l1); + mv.visitLineNumber(128, l1); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/inventory/IInventory", "getStackInSlot", "(I)Lnet/minecraft/item/ItemStack;", true); + mv.visitVarInsn(ASTORE, 5); + Label l3 = new Label(); + mv.visitLabel(l3); + mv.visitLineNumber(129, l3); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/inventory/IInventory", "getStackInSlot", "(I)Lnet/minecraft/item/ItemStack;", true); + mv.visitVarInsn(ASTORE, 6); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(130, l4); + mv.visitVarInsn(ALOAD, 5); + mv.visitTypeInsn(NEW, "net/minecraftforge/fluids/FluidStack"); + mv.visitInsn(DUP); + mv.visitVarInsn(ALOAD, 4); + mv.visitIntInsn(SIPUSH, PROCESS_VOLUME); + mv.visitMethodInsn(INVOKESPECIAL, "net/minecraftforge/fluids/FluidStack", "<init>", "(Lnet/minecraftforge/fluids/Fluid;I)V", false); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidItemHelper", "fillContainer", "(Lnet/minecraft/item/ItemStack;Lnet/minecraftforge/fluids/FluidStack;)Lmods/railcraft/common/fluids/FluidItemHelper$FillReturn;", false); + mv.visitVarInsn(ASTORE, 7); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(131, l5); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "container", "Lnet/minecraft/item/ItemStack;"); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + mv.visitVarInsn(ALOAD, 6); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "container", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidHelper", "hasPlaceToPutContainer", "(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z", false); + mv.visitJumpInsn(IFEQ, l6); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(132, l7); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraftforge/common/util/ForgeDirection", "UNKNOWN", "Lnet/minecraftforge/common/util/ForgeDirection;"); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "amount", "I"); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraftforge/fluids/IFluidHandler", "drain", "(Lnet/minecraftforge/common/util/ForgeDirection;IZ)Lnet/minecraftforge/fluids/FluidStack;", true); + mv.visitVarInsn(ASTORE, 8); + Label l8 = new Label(); + mv.visitLabel(l8); + mv.visitLineNumber(133, l8); + mv.visitVarInsn(ALOAD, 8); + mv.visitJumpInsn(IFNULL, l6); + mv.visitVarInsn(ALOAD, 8); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/fluids/FluidStack", "amount", "I"); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "amount", "I"); + mv.visitJumpInsn(IF_ICMPNE, l6); + Label l9 = new Label(); + mv.visitLabel(l9); + mv.visitLineNumber(134, l9); + mv.visitVarInsn(ALOAD, 5); + mv.visitVarInsn(ALOAD, 8); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidItemHelper", "fillContainer", "(Lnet/minecraft/item/ItemStack;Lnet/minecraftforge/fluids/FluidStack;)Lmods/railcraft/common/fluids/FluidItemHelper$FillReturn;", false); + mv.visitVarInsn(ASTORE, 7); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(135, l10); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "container", "Lnet/minecraft/item/ItemStack;"); + Label l11 = new Label(); + mv.visitJumpInsn(IFNULL, l11); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "amount", "I"); + mv.visitVarInsn(ALOAD, 8); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/fluids/FluidStack", "amount", "I"); + mv.visitJumpInsn(IF_ICMPNE, l11); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLineNumber(136, l12); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraftforge/common/util/ForgeDirection", "UNKNOWN", "Lnet/minecraftforge/common/util/ForgeDirection;"); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "amount", "I"); + mv.visitInsn(ICONST_1); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraftforge/fluids/IFluidHandler", "drain", "(Lnet/minecraftforge/common/util/ForgeDirection;IZ)Lnet/minecraftforge/fluids/FluidStack;", true); + mv.visitInsn(POP); + Label l13 = new Label(); + mv.visitLabel(l13); + mv.visitLineNumber(137, l13); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 7); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "container", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidHelper", "storeContainer", "(Lnet/minecraft/inventory/IInventory;IILnet/minecraft/item/ItemStack;)V", false); + mv.visitLabel(l11); + mv.visitLineNumber(139, l11); + mv.visitFrame(F_FULL, 9, new Object[] {"net/minecraftforge/fluids/IFluidHandler", "net/minecraft/inventory/IInventory", INTEGER, INTEGER, "net/minecraftforge/fluids/Fluid", "net/minecraft/item/ItemStack", "net/minecraft/item/ItemStack", "mods/railcraft/common/fluids/FluidItemHelper$FillReturn", "net/minecraftforge/fluids/FluidStack"}, 0, new Object[] {}); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + mv.visitLabel(l6); + mv.visitLineNumber(142, l6); + mv.visitFrame(F_CHOP,1, null, 0, null); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + Label l14 = new Label(); + mv.visitLabel(l14); + mv.visitLocalVariable("drain", "Lnet/minecraftforge/fluids/FluidStack;", null, l8, l6, 8); + mv.visitLocalVariable("fluidHandler", "Lnet/minecraftforge/fluids/IFluidHandler;", null, l0, l14, 0); + mv.visitLocalVariable("inv", "Lnet/minecraft/inventory/IInventory;", null, l0, l14, 1); + mv.visitLocalVariable("inputSlot", "I", null, l0, l14, 2); + mv.visitLocalVariable("outputSlot", "I", null, l0, l14, 3); + mv.visitLocalVariable("fluidToFill", "Lnet/minecraftforge/fluids/Fluid;", null, l0, l14, 4); + mv.visitLocalVariable("input", "Lnet/minecraft/item/ItemStack;", null, l3, l14, 5); + mv.visitLocalVariable("output", "Lnet/minecraft/item/ItemStack;", null, l4, l14, 6); + mv.visitLocalVariable("fill", "Lmods/railcraft/common/fluids/FluidItemHelper$FillReturn;", null, l5, l14, 7); + mv.visitMaxs(5, 9); + mv.visitEnd(); + didInject = true; + } + else if (aMethodName.equals("drainContainers")) { + mv = cw.visitMethod(ACC_PUBLIC + ACC_STATIC, "drainContainers", "(Lnet/minecraftforge/fluids/IFluidHandler;Lnet/minecraft/inventory/IInventory;II)Z", null, null); + mv.visitCode(); + Label l0 = new Label(); + mv.visitLabel(l0); + mv.visitLineNumber(146, l0); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/inventory/IInventory", "getStackInSlot", "(I)Lnet/minecraft/item/ItemStack;", true); + mv.visitVarInsn(ASTORE, 4); + Label l1 = new Label(); + mv.visitLabel(l1); + mv.visitLineNumber(147, l1); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 3); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraft/inventory/IInventory", "getStackInSlot", "(I)Lnet/minecraft/item/ItemStack;", true); + mv.visitVarInsn(ASTORE, 5); + Label l2 = new Label(); + mv.visitLabel(l2); + mv.visitLineNumber(148, l2); + mv.visitVarInsn(ALOAD, 4); + Label l3 = new Label(); + mv.visitJumpInsn(IFNULL, l3); + Label l4 = new Label(); + mv.visitLabel(l4); + mv.visitLineNumber(149, l4); + mv.visitVarInsn(ALOAD, 4); + mv.visitIntInsn(SIPUSH, PROCESS_VOLUME); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidItemHelper", "drainContainer", "(Lnet/minecraft/item/ItemStack;I)Lmods/railcraft/common/fluids/FluidItemHelper$DrainReturn;", false); + mv.visitVarInsn(ASTORE, 6); + Label l5 = new Label(); + mv.visitLabel(l5); + mv.visitLineNumber(150, l5); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "fluidDrained", "Lnet/minecraftforge/fluids/FluidStack;"); + mv.visitJumpInsn(IFNULL, l3); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "container", "Lnet/minecraft/item/ItemStack;"); + Label l6 = new Label(); + mv.visitJumpInsn(IFNULL, l6); + mv.visitVarInsn(ALOAD, 5); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "container", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidHelper", "hasPlaceToPutContainer", "(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z", false); + mv.visitJumpInsn(IFEQ, l3); + mv.visitLabel(l6); + mv.visitLineNumber(151, l6); + mv.visitFrame(F_APPEND,3, new Object[] {"net/minecraft/item/ItemStack", "net/minecraft/item/ItemStack", "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn"}, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraftforge/common/util/ForgeDirection", "UNKNOWN", "Lnet/minecraftforge/common/util/ForgeDirection;"); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "fluidDrained", "Lnet/minecraftforge/fluids/FluidStack;"); + mv.visitInsn(ICONST_0); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraftforge/fluids/IFluidHandler", "fill", "(Lnet/minecraftforge/common/util/ForgeDirection;Lnet/minecraftforge/fluids/FluidStack;Z)I", true); + mv.visitVarInsn(ISTORE, 7); + Label l7 = new Label(); + mv.visitLabel(l7); + mv.visitLineNumber(152, l7); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "isAtomic", "Z"); + Label l8 = new Label(); + mv.visitJumpInsn(IFEQ, l8); + mv.visitVarInsn(ILOAD, 7); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "fluidDrained", "Lnet/minecraftforge/fluids/FluidStack;"); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/fluids/FluidStack", "amount", "I"); + Label l9 = new Label(); + mv.visitJumpInsn(IF_ICMPEQ, l9); + mv.visitLabel(l8); + mv.visitFrame(F_APPEND,1, new Object[] {INTEGER}, 0, null); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "isAtomic", "Z"); + mv.visitJumpInsn(IFNE, l3); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "fluidDrained", "Lnet/minecraftforge/fluids/FluidStack;"); + mv.visitFieldInsn(GETFIELD, "net/minecraftforge/fluids/FluidStack", "amount", "I"); + mv.visitJumpInsn(IFLE, l3); + mv.visitLabel(l9); + mv.visitLineNumber(153, l9); + mv.visitFrame(F_SAME, 0, null, 0, null); + mv.visitVarInsn(ALOAD, 0); + mv.visitFieldInsn(GETSTATIC, "net/minecraftforge/common/util/ForgeDirection", "UNKNOWN", "Lnet/minecraftforge/common/util/ForgeDirection;"); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "fluidDrained", "Lnet/minecraftforge/fluids/FluidStack;"); + mv.visitInsn(ICONST_1); + mv.visitMethodInsn(INVOKEINTERFACE, "net/minecraftforge/fluids/IFluidHandler", "fill", "(Lnet/minecraftforge/common/util/ForgeDirection;Lnet/minecraftforge/fluids/FluidStack;Z)I", true); + mv.visitInsn(POP); + Label l10 = new Label(); + mv.visitLabel(l10); + mv.visitLineNumber(154, l10); + mv.visitVarInsn(ALOAD, 1); + mv.visitVarInsn(ILOAD, 2); + mv.visitVarInsn(ILOAD, 3); + mv.visitVarInsn(ALOAD, 6); + mv.visitFieldInsn(GETFIELD, "mods/railcraft/common/fluids/FluidItemHelper$DrainReturn", "container", "Lnet/minecraft/item/ItemStack;"); + mv.visitMethodInsn(INVOKESTATIC, "mods/railcraft/common/fluids/FluidHelper", "storeContainer", "(Lnet/minecraft/inventory/IInventory;IILnet/minecraft/item/ItemStack;)V", false); + Label l11 = new Label(); + mv.visitLabel(l11); + mv.visitLineNumber(155, l11); + mv.visitInsn(ICONST_1); + mv.visitInsn(IRETURN); + mv.visitLabel(l3); + mv.visitLineNumber(159, l3); + mv.visitFrame(F_CHOP,2, null, 0, null); + mv.visitInsn(ICONST_0); + mv.visitInsn(IRETURN); + Label l12 = new Label(); + mv.visitLabel(l12); + mv.visitLocalVariable("used", "I", null, l7, l3, 7); + mv.visitLocalVariable("drain", "Lmods/railcraft/common/fluids/FluidItemHelper$DrainReturn;", null, l5, l3, 6); + mv.visitLocalVariable("fluidHandler", "Lnet/minecraftforge/fluids/IFluidHandler;", null, l0, l12, 0); + mv.visitLocalVariable("inv", "Lnet/minecraft/inventory/IInventory;", null, l0, l12, 1); + mv.visitLocalVariable("inputSlot", "I", null, l0, l12, 2); + mv.visitLocalVariable("outputSlot", "I", null, l0, l12, 3); + mv.visitLocalVariable("input", "Lnet/minecraft/item/ItemStack;", null, l1, l12, 4); + mv.visitLocalVariable("output", "Lnet/minecraft/item/ItemStack;", null, l2, l12, 5); + mv.visitMaxs(4, 8); + mv.visitEnd(); + didInject = true; + + } + FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Method injection complete."); + return didInject; + } + + + + + + + + + + public class AddFieldAdapter extends ClassVisitor { + + public AddFieldAdapter(ClassVisitor cv) { + super(ASM5, cv); + this.cv = cv; + } + + @Override + public FieldVisitor visitField( + int access, String name, String desc, String signature, Object value) { + if (name.equals("PROCESS_VOLUME") && desc.equals("I")) { + FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Removing "+"PROCESS_VOLUME"+"."); + return null; + } + return cv.visitField(access, name, desc, signature, value); + } + + + private final String[] aMethodsToStrip = new String[] {"fillContainers", "drainContainers"}; + + + @Override + public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) { + + MethodVisitor methodVisitor; + boolean found = false; + + for (String s : aMethodsToStrip) { + if (name.equals(s)) { + found = true; + break; + } + } + if (!found) { + methodVisitor = super.visitMethod(access, name, desc, signature, exceptions); + } + else { + methodVisitor = null; + } + + if (found) { + FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, + "Found method " + name + ", removing."); + } + return methodVisitor; + } + + + } + + + + + + +} diff --git a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java index df9cd658be..3886145330 100644 --- a/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java +++ b/src/Java/gtPlusPlus/preloader/asm/transformers/Preloader_Transformer_Handler.java @@ -36,12 +36,13 @@ public class Preloader_Transformer_Handler implements IClassTransformer { System.out.println("[GT++ ASM] Asm Config Location: "+mConfig.config.getConfigFile().getAbsolutePath()); System.out.println("[GT++ ASM] Is DevHelper Valid? "+gtPlusPlus.preloader.DevHelper.mIsValidHelper); } - - @SuppressWarnings("static-access") - public byte[] transform(String name, String transformedName, byte[] basicClass) { - - - // Is this environment obfuscated? (Extra checks just in case some weird shit happens during the check) + + private static Boolean mObf = null; + + public boolean checkObfuscated() { + if (mObf != null) { + return mObf; + } boolean obfuscated = false; try { obfuscated = !(boolean) ReflectionHelper.findField(CoreModManager.class, "deobfuscatedEnvironment").get(null); @@ -59,8 +60,14 @@ public class Preloader_Transformer_Handler implements IClassTransformer { e1.printStackTrace(); obfuscated = false; } - } + } + mObf = obfuscated; + return obfuscated; + } + public byte[] transform(String name, String transformedName, byte[] basicClass) { + // Is this environment obfuscated? (Extra checks just in case some weird shit happens during the check) + boolean obfuscated = checkObfuscated(); boolean probablyShouldBeFalse = false; //Enable mapping of Tickets and loaded chunks. - Forge @@ -87,6 +94,13 @@ public class Preloader_Transformer_Handler implements IClassTransformer { FMLRelaunchLog.log("[GT++ ASM] Bright Fluids", Level.INFO, "Transforming %s", transformedName); return new ClassTransformer_TiConFluids("getLightValue", probablyShouldBeFalse, basicClass).getWriter().toByteArray(); } + + //Fix RC stuff + //Patching PROCESS_VOLUME to allow 4x more transfer limits + if (transformedName.equals("mods.railcraft.common.fluids.FluidHelper") && mConfig.enableRcFlowFix) { + FMLRelaunchLog.log("[GT++ ASM] Railcraft PROCESS_VOLUME Patch", Level.INFO, "Transforming %s", transformedName); + return new ClassTransformer_Railcraft_FluidHelper(basicClass).getWriter().toByteArray(); + } //Fix GC stuff if (mConfig.enableGcFuelChanges) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java index 068f47e0c4..c228364149 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/enums/GregtechItemList.java @@ -544,6 +544,9 @@ public enum GregtechItemList implements GregtechItemContainer { //GT RTG RTG, + //Plasma Tank + Plasma_Tank, + //---------------------------------------------------------------------------- diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java index 621918b370..d5b484e314 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/interfaces/internal/IGregtech_RecipeAdder.java @@ -198,4 +198,42 @@ public interface IGregtech_RecipeAdder { public boolean addBrewingRecipe(int aCircuit, FluidStack aInput, FluidStack aOutput, int aTime, int aEu, boolean aHidden); public boolean addSmeltingAndAlloySmeltingRecipe(ItemStack aDust, ItemStack aOutput); + + public void addFluidExtractionRecipe(ItemStack input, Object input2, FluidStack output, int aTime, int aEu, int aSpecial); + + /** + * Adds a Fusion reactor Recipe + * + * @param aInput1 = first Input (not null, and respects StackSize) + * @param aInput2 = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, int aFusionDurationInTicks, int aEu, int aSpecial); + /** + * Adds a Fusion reactor Recipe + * + * @param aInput1 = first Input (not null, and respects StackSize) + * @param aInput2 = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aOutputChance = chance to output plasma (can be 0) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + public boolean addFusionReactorRecipe(FluidStack aInputStackA, FluidStack aInputStackB, FluidStack plasma, int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial); + /** + * Adds a Fusion reactor Recipe + * + * @param aInput1 = first Input (not null, and respects StackSize) + * @param aInput2 = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aOutputChance = chance to output plasma (can be 0) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java index 939cac2779..47e4a7ae53 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/BaseCustomTileEntity.java @@ -23,7 +23,7 @@ public class BaseCustomTileEntity extends BaseMetaTileEntity { public BaseCustomTileEntity() { super(); - Logger.INFO("Created new BaseCustomTileEntity"); + Logger.MACHINE_INFO("Created new BaseCustomTileEntity"); } public void writeToNBT(NBTTagCompound aNBT) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java index 0b8cb10606..a4440114e8 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/BaseCustomPower_MTE.java @@ -10,7 +10,7 @@ public class BaseCustomPower_MTE extends BaseCustomTileEntity { public BaseCustomPower_MTE() { super(); - Logger.INFO("Created new BaseCustomPower_MTE"); + Logger.MACHINE_INFO("Created new BaseCustomPower_MTE"); } public long injectEnergyUnits(byte aSide, long aVoltage, long aAmperage) { diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java index ba98af25f7..8b7ccc202a 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/custom/power/MetaTileEntityCustomPower.java @@ -29,7 +29,7 @@ public abstract class MetaTileEntityCustomPower extends CustomMetaTileBase { public void doExplosion(long aExplosionPower) { if (MathUtils.randInt(1, 10) > 0) { - Logger.INFO("Machine tried to explode, let's stop that. xo"); + //Logger.INFO("Machine tried to explode, let's stop that. xo"); return; } @@ -70,7 +70,7 @@ public abstract class MetaTileEntityCustomPower extends CustomMetaTileBase { public void onExplosion() { if (MathUtils.randInt(1, 10) > 0) { - Logger.INFO("Machine tried to explode, let's stop that. xo"); + //Logger.INFO("Machine tried to explode, let's stop that. xo"); return; } // TODO Auto-generated method stub diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java new file mode 100644 index 0000000000..d5180ef4e1 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_BasicMachine_GTPP_Recipe.java @@ -0,0 +1,38 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import gregtech.api.interfaces.ITexture; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine_GT_Recipe; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; + +public class GT_MetaTileEntity_BasicMachine_GTPP_Recipe extends GT_MetaTileEntity_BasicMachine_GT_Recipe { + + public GT_MetaTileEntity_BasicMachine_GTPP_Recipe(int aID, String aName, String aNameRegional, int aTier, + String aDescription, GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, + int aGUIParameterA, int aGUIParameterB, String aGUIName, String aSound, boolean aSharedTank, + boolean aRequiresFluidForFiltering, int aSpecialEffect, String aOverlays, Object[] aRecipe) { + super(aID, aName, aNameRegional, aTier, aDescription, aRecipes, aInputSlots, aOutputSlots, aTankCapacity, + aGUIParameterA, aGUIParameterB, aGUIName, aSound, aSharedTank, aRequiresFluidForFiltering, aSpecialEffect, + aOverlays, aRecipe); + } + + public GT_MetaTileEntity_BasicMachine_GTPP_Recipe(String aName, int aTier, String aDescription, + GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, + int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, + String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) { + super(aName, aTier, aDescription, aRecipes, aInputSlots, aOutputSlots, aTankCapacity, aAmperage, aGUIParameterA, + aGUIParameterB, aTextures, aGUIName, aNEIName, aSound, aSharedTank, aRequiresFluidForFiltering, aSpecialEffect); + } + + public GT_MetaTileEntity_BasicMachine_GTPP_Recipe(String aName, int aTier, String[] aDescription, + GT_Recipe_Map aRecipes, int aInputSlots, int aOutputSlots, int aTankCapacity, int aAmperage, + int aGUIParameterA, int aGUIParameterB, ITexture[][][] aTextures, String aGUIName, String aNEIName, + String aSound, boolean aSharedTank, boolean aRequiresFluidForFiltering, int aSpecialEffect) { + super(aName, aTier, aDescription, aRecipes, aInputSlots, aOutputSlots, aTankCapacity, aAmperage, aGUIParameterA, + aGUIParameterB, aTextures, aGUIName, aNEIName, aSound, aSharedTank, aRequiresFluidForFiltering, aSpecialEffect); + } + + + + + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java new file mode 100644 index 0000000000..aeae474fb7 --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GT_MetaTileEntity_Hatch_Plasma.java @@ -0,0 +1,220 @@ +package gtPlusPlus.xmod.gregtech.api.metatileentity.implementations; + +import java.lang.reflect.Field; + +import com.google.common.collect.BiMap; + +import gregtech.api.enums.Textures.BlockIcons; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.core.util.reflect.ReflectionUtils; +import gtPlusPlus.xmod.gregtech.common.StaticFields59; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class GT_MetaTileEntity_Hatch_Plasma extends GT_MetaTileEntity_Hatch_Input { + + public final AutoMap<Fluid> mFluidsToUse = new AutoMap<Fluid>(); + public final int mFluidCapacity; + private int mTotalPlasmaSupported = -1; + + public GT_MetaTileEntity_Hatch_Plasma(final int aID, final String aName, final String aNameRegional) { + super(aID, aName, aNameRegional, 6); + mFluidCapacity = 256000; + initHatch(); + } + + public GT_MetaTileEntity_Hatch_Plasma(final String aName, final String aDescription, + final ITexture[][][] aTextures) { + super(aName, 6, aDescription, aTextures); + mFluidCapacity = 256000; + initHatch(); + } + + public GT_MetaTileEntity_Hatch_Plasma(final String aName, final String[] aDescription, + final ITexture[][][] aTextures) { + super(aName, 6, aDescription[0], aTextures); + mFluidCapacity = 256000; + initHatch(); + } + + private void initHatch() { + + //Get all Plasmas, but the easiest way to do this is to just ask the Fluid Registry what exists and filter through them lazily. + Field fluidNameCache; + try { + fluidNameCache = ReflectionUtils.getField(FluidRegistry.class, "fluidNames"); + } catch (NoSuchFieldException e) { + fluidNameCache = null; + } + AutoMap<String> mValidPlasmaNameCache = new AutoMap<String>(); + if (fluidNameCache != null) { + try { + Object fluidNames = fluidNameCache.get(null); + if (fluidNames != null) { + try { + @SuppressWarnings("unchecked") + BiMap<Integer, String> fluidNamesMap = (BiMap<Integer, String>) fluidNames; + if (fluidNamesMap != null) { + for (String g : fluidNamesMap.values()) { + if (g.toLowerCase().contains("plasma")) { + mValidPlasmaNameCache.put(g); + } + } + } + } catch (ClassCastException e) { + } + } + } catch (IllegalArgumentException | IllegalAccessException e) { + } + } + + AutoMap<Fluid> mPlasmaCache = new AutoMap<Fluid>(); + if (!mValidPlasmaNameCache.isEmpty()) { + for (String y : mValidPlasmaNameCache) { + Fluid t = FluidRegistry.getFluid(y); + if (t != null) { + if (t.getTemperature() > 1000) { + mPlasmaCache.put(t); + } + } + } + } + + if (!mPlasmaCache.isEmpty()) { + for (Fluid w : mPlasmaCache) { + mFluidsToUse.put(w); + } + } + + + + + + } + + public ITexture[] getTexturesActive(final ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture }; + } + + public ITexture[] getTexturesInactive(final ITexture aBaseTexture) { + return new ITexture[] { aBaseTexture }; + } + + public boolean allowPutStack(final IGregTechTileEntity aBaseMetaTileEntity, final int aIndex, final byte aSide, + final ItemStack aStack) { + if (aSide == aBaseMetaTileEntity.getFrontFacing() && aIndex == 0) { + for (Fluid f : mFluidsToUse) { + if (f != null) { + if (GT_Utility.getFluidForFilledItem(aStack, true).getFluid() == f) { + return true; + } + } + } + } + return false; + } + + public boolean isFluidInputAllowed(final FluidStack aFluid) { + for (Fluid f : mFluidsToUse) { + if (f != null) { + if (aFluid.getFluid() == f) { + return true; + } + } + } + return false; + } + + public int getCapacity() { + return this.mFluidCapacity; + } + + public MetaTileEntity newMetaEntity(final IGregTechTileEntity aTileEntity) { + return (MetaTileEntity) new GT_MetaTileEntity_Hatch_Plasma(this.mName, this.mDescription, this.mTextures); + } + + @Override + public String[] getDescription() { + + if (mTotalPlasmaSupported < 0) { + if (mFluidsToUse.isEmpty()) { + mTotalPlasmaSupported = 0; + } + else { + mTotalPlasmaSupported = mFluidsToUse.size(); + } + } + + String aX = EnumChatFormatting.GRAY+""; + String a1 = EnumChatFormatting.GOLD+"Refined containment"+aX; + String a2 = EnumChatFormatting.GOLD+"Capacity: "+EnumChatFormatting.DARK_AQUA+getCapacity()+"L"+aX; + String a3 = EnumChatFormatting.GOLD+"Supports "+EnumChatFormatting.DARK_RED+mTotalPlasmaSupported+EnumChatFormatting.GOLD+" types of plasma"+aX; + + + + String[] s2 = new String[]{ + a1, a2, a3 + }; + return s2; + } + + @Override + public boolean doesFillContainers() { + return true; + } + + @Override + public ITexture[][][] getTextureSet(ITexture[] aTextures) { + // TODO Auto-generated method stub + return super.getTextureSet(aTextures); + } + + private Field F1, F2; + + + @Override + public ITexture[] getTexture(IGregTechTileEntity aBaseMetaTileEntity, byte aSide, byte aFacing, byte aColorIndex, boolean aActive, boolean aRedstone) { + byte a1 = 0, a2 = 0; + try { + if (F1 == null) { + F1 = ReflectionUtils.getField(getClass(), "actualTexture"); + } + if (F2 == null) { + F2 = ReflectionUtils.getField(getClass(), "mTexturePage"); + } + + if (F1 != null) { + a1 = F1.getByte(this); + } + if (F2 != null) { + a2 = F2.getByte(this); + } + } + catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException n) {} + + int textureIndex = a1 | a2 << 7; + byte texturePointer = (byte) (a1 & 127); + + + + if (aSide == 1 || aSide == 0) { + ITexture g = textureIndex > 0 ? StaticFields59.getCasingTexturePages(a2, texturePointer) : BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]; + + return new ITexture[] {g}; + } + + return aSide != aFacing ? + (textureIndex > 0 ? new ITexture[] { StaticFields59.getCasingTexturePages(a2, texturePointer) } : new ITexture[] { BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1] }) + : (textureIndex > 0 ? (aActive ? this.getTexturesActive(StaticFields59.getCasingTexturePages(a2, texturePointer)) : this.getTexturesInactive(StaticFields59.getCasingTexturePages(a2, texturePointer))) + : (aActive ? this.getTexturesActive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]) : this.getTexturesInactive(BlockIcons.MACHINE_CASINGS[this.mTier][aColorIndex + 1]))); + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java index 892f8f332a..04c1cf34cc 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/base/GregtechMeta_MultiBlockBase.java @@ -74,8 +74,8 @@ GT_MetaTileEntity_MultiBlockBase { Method a08 = findRecipe08 = ReflectionUtils.getMethod(GT_Recipe_Map.class, "findRecipe", IHasWorldObjectAndCoords.class, GT_Recipe.class, boolean.class, long.class, FluidStack[].class, ItemStack.class, ItemStack[].class); Method a09 = findRecipe09 = ReflectionUtils.getMethod(GT_Recipe_Map.class, "findRecipe", IHasWorldObjectAndCoords.class, GT_Recipe.class, boolean.class, boolean.class, long.class, FluidStack[].class, ItemStack.class, ItemStack[].class); - Logger.INFO("Found .08 findRecipe method? "+(a08 != null)); - Logger.INFO("Found .09 findRecipe method? "+(a09 != null)); + Logger.MACHINE_INFO("Found .08 findRecipe method? "+(a08 != null)); + Logger.MACHINE_INFO("Found .09 findRecipe method? "+(a09 != null)); //gregtech.api.util.GT_Recipe.GT_Recipe_Map.findRecipe(IHasWorldObjectAndCoords, GT_Recipe, boolean, long, FluidStack[], ItemStack, ItemStack...) @@ -709,7 +709,7 @@ GT_MetaTileEntity_MultiBlockBase { public boolean isMachineRunning() { boolean aRunning = this.getBaseMetaTileEntity().isActive(); - Logger.INFO("Queried Multiblock is currently running: "+aRunning); + log("Queried Multiblock is currently running: "+aRunning); return aRunning; } @@ -1552,7 +1552,7 @@ GT_MetaTileEntity_MultiBlockBase { return true; } else { - Logger.INFO("Found meta Tile: "+aMetaTileID); + log("Found meta Tile: "+aMetaTileID); } } } @@ -1561,17 +1561,17 @@ GT_MetaTileEntity_MultiBlockBase { return true; } else if (aFoundBlock != aExpectedBlock) { - Logger.INFO("A1 - Found: "+aFoundBlock.getLocalizedName()+":"+aFoundMeta+", Expected: "+aExpectedBlock.getLocalizedName()+":"+aExpectedMeta); - Logger.INFO("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); + log("A1 - Found: "+aFoundBlock.getLocalizedName()+":"+aFoundMeta+", Expected: "+aExpectedBlock.getLocalizedName()+":"+aExpectedMeta); + log("Loc: "+(new BlockPos(aBaseMetaTileEntity).getLocationString())); return false; } else if (aFoundMeta != aExpectedMeta) { - Logger.INFO("A2"); + log("A2"); return false; } } - Logger.INFO("A3"); + log("A3"); return false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java index bc067a5e53..0178bac4da 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/helpers/ChargingHelper.java @@ -406,7 +406,7 @@ public class ChargingHelper { return mEntity.getEUVar(); } - public boolean isItemValid(final ItemStack itemstack) { + public static boolean isItemValid(final ItemStack itemstack) { if (itemstack == null){ return false; } @@ -419,7 +419,7 @@ public class ChargingHelper { return false; } - public boolean accepts(final ItemStack stack) { + public static boolean accepts(final ItemStack stack) { if (stack == null) { return false; } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java index c4ef545b09..e721761d82 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/GregtechMetaTileEntity_IndustrialMixer.java @@ -12,6 +12,7 @@ import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input import gregtech.api.objects.GT_RenderedTexture; import gregtech.api.util.GT_Recipe; import gregtech.api.util.GT_Utility; +import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.block.ModBlocks; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; @@ -111,20 +112,7 @@ extends GregtechMeta_MultiBlockBase { @Override public boolean checkRecipe(final ItemStack aStack) { - for (GT_MetaTileEntity_Hatch_InputBus tBus : mInputBusses) { - ArrayList<ItemStack> tBusItems = new ArrayList<ItemStack>(); - tBus.mRecipeMap = getRecipeMap(); - if (isValidMetaTileEntity(tBus)) { - for (int i = tBus.getBaseMetaTileEntity().getSizeInventory() - 1; i >= 0; i--) { - if (tBus.getBaseMetaTileEntity().getStackInSlot(i) != null) - tBusItems.add(tBus.getBaseMetaTileEntity().getStackInSlot(i)); - } - } - - if (checkRecipeGeneric(tBusItems.toArray(new ItemStack[]{}), new FluidStack[]{}, - (8 * GT_Utility.getTier(this.getMaxInputVoltage())), 100, 250, 10000)) return true; - } - return false; + return checkRecipeGeneric(getMaxParallelRecipes(), getEuDiscountForParallelism(), 250); } @Override @@ -152,31 +140,40 @@ extends GregtechMeta_MultiBlockBase { for (int j = -1; j < 2; j++) { for (int h = -1; h < 3; h++) { if ((h != 0) || ((((xDir + i) != 0) || ((zDir + j) != 0)) && ((i != 0) || (j != 0)))) { + final IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, h, zDir + j); - if ((!this.addToMachineList(tTileEntity, CASING_TEXTURE_ID)) && (!this.addMufflerToMachineList(tTileEntity, CASING_TEXTURE_ID)) && (!this.addInputToMachineList(tTileEntity, CASING_TEXTURE_ID)) && (!this.addOutputToMachineList(tTileEntity, CASING_TEXTURE_ID)) && (!this.addEnergyInputToMachineList(tTileEntity, CASING_TEXTURE_ID))) { - final Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); - final byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); - if (h == 0 || h == 1){ - if (i == 0 && j == 0){ - if (((tBlock != GregTech_API.sBlockCasings4) || (tMeta != 11))) { - return false; - } - tAmount++; + final Block tBlock = aBaseMetaTileEntity.getBlockOffset(xDir + i, h, zDir + j); + final byte tMeta = aBaseMetaTileEntity.getMetaIDOffset(xDir + i, h, zDir + j); + + if (h == 0 || h == 1) { + if (i == 0 && j == 0){ + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, false, tBlock, tMeta, GregTech_API.sBlockCasings4, 11)) { + Logger.INFO("Inner casings missing"); + return false; } else { - if (((tBlock != ModBlocks.blockCasings3Misc) || (tMeta != 2))) { - return false; - } tAmount++; } } else { - if (((tBlock != ModBlocks.blockCasings3Misc) || (tMeta != 2))) { + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, true, tBlock, tMeta, ModBlocks.blockCasings3Misc, 2)) { + Logger.INFO("Middle layer casings missing"); return false; } - tAmount++; + else { + tAmount++; + } } } + else { + if (!isValidBlockForStructure(tTileEntity, CASING_TEXTURE_ID, true, tBlock, tMeta, ModBlocks.blockCasings3Misc, 2)) { + Logger.INFO("Top Or Bottom casings missing"); + return false; + } + else { + tAmount++; + } + } } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java index 7fdabceebb..e4f984ee18 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/advanced/GregtechMetaTileEntity_Adv_EBF.java @@ -254,15 +254,14 @@ public class GregtechMetaTileEntity_Adv_EBF extends GregtechMeta_MultiBlockBase if (!isValidBlockForStructure(null, CASING_TEXTURE_ID, false, aBaseMetaTileEntity.getBlockOffset(xDir + i, 2, zDir + j), (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 2, zDir + j), StaticFields59.getBlockCasings5(), tUsedMeta)) { Logger.INFO("Heating Coils missing."); return false; - } - - //Top Layer - final IGregTechTileEntity tTileEntity2 = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j); - if (!isValidBlockForStructure(tTileEntity2, CASING_TEXTURE_ID, true, aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j), (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j), ModBlocks.blockCasings3Misc, 11)) { - Logger.INFO("Top Layer missing."); - return false; - } - + } + } + + //Top Layer + final IGregTechTileEntity tTileEntity2 = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j); + if (!isValidBlockForStructure(tTileEntity2, CASING_TEXTURE_ID, true, aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j), (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j), ModBlocks.blockCasings3Misc, 11)) { + Logger.INFO("Top Layer missing."); + return false; } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java new file mode 100644 index 0000000000..6ec95ff16b --- /dev/null +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMTE_MiniFusionPlant.java @@ -0,0 +1,385 @@ +package gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production; + +import java.util.ArrayList; + +import gregtech.api.enums.GT_Values; +import gregtech.api.enums.TAE; +import gregtech.api.enums.Textures; +import gregtech.api.interfaces.ITexture; +import gregtech.api.interfaces.tileentity.IGregTechTileEntity; +import gregtech.api.metatileentity.MetaTileEntity; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Input; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_InputBus; +import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Output; +import gregtech.api.objects.GT_RenderedTexture; +import gregtech.api.util.GT_Recipe; +import gregtech.api.util.GT_Utility; +import gregtech.api.util.Recipe_GT; +import gregtech.api.util.GT_Recipe.GT_Recipe_Map; +import gtPlusPlus.api.objects.Logger; +import gtPlusPlus.api.objects.data.AutoMap; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_ControlCore; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Plasma; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMeta_MultiBlockBase; +import net.minecraft.item.ItemStack; +import net.minecraft.util.EnumChatFormatting; +import net.minecraftforge.common.util.ForgeDirection; +import net.minecraftforge.fluids.FluidStack; + +public class GregtechMTE_MiniFusionPlant extends GregtechMeta_MultiBlockBase { + + public long currentVoltage = GT_Values.V[7]; + public byte currentTier = 8; + + public void upvolt() { + byte f = currentTier; + if ((f+1) > 10) { + f = 8; + } + else { + f++; + } + this.currentTier = f; + updateVoltage(); + } + + public void downvolt() { + byte f = currentTier; + if ((f-1) < 8) { + f = 10; + } + else { + f--; + } + this.currentTier = f; + updateVoltage(); + } + + private long updateVoltage() { + this.currentVoltage = GT_Values.V[this.currentTier-1]; + return currentVoltage; + } + + public GregtechMTE_MiniFusionPlant(String aName) { + super(aName); + } + + public GregtechMTE_MiniFusionPlant(int aID, String aName, String aNameRegional) { + super(aID, aName, aNameRegional); + } + + @Override + public MetaTileEntity newMetaEntity(IGregTechTileEntity aTileEntity) { + return new GregtechMTE_MiniFusionPlant(this.mName); + } + + @Override + public boolean isCorrectMachinePart(ItemStack aStack) { + return true; + } + + @Override + public int getDamageToComponent(ItemStack aStack) { + return 0; + } + + @Override + public ITexture[] getTexture(final IGregTechTileEntity aBaseMetaTileEntity, final byte aSide, final byte aFacing, + final byte aColorIndex, final boolean aActive, final boolean aRedstone) { + if (aSide == this.getBaseMetaTileEntity().getBackFacing()) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(28)], + Textures.BlockIcons.OVERLAYS_ENERGY_IN_MULTI[(int) this.getInputTier()]}; + } + if (aSide == 1) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(28)], + Textures.BlockIcons.OVERLAYS_ENERGY_OUT_MULTI[(int) this.getOutputTier()]}; + } + if (aSide == aFacing) { + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(28)], + new GT_RenderedTexture(aActive ? Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER_ACTIVE : Textures.BlockIcons.OVERLAY_FRONT_DISASSEMBLER)}; + } + return new ITexture[]{Textures.BlockIcons.CASING_BLOCKS[TAE.GTPP_INDEX(28)]}; + } + + + @Override + public GT_Recipe.GT_Recipe_Map getRecipeMap() { + return Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes; + } + + @Override + public boolean hasSlotInGUI() { + return false; + } + + @Override + public String getCustomGUIResourceName() { + return null; + } + + @Override + public String getMachineType() { + return "Fusion Reactor"; + } + + @Override + public String[] getTooltip() { + return new String[] { + "Small scale fusion", + "16x slower than using Multiblock of the same voltage", + //"Input voltage can be changed within the GUI", + "Place Input/Output Hatches on sides and bottom", + "Power can only be inserted into the back", + "Power can only be extracted from the top", + }; + } + + @Override + public int getMaxParallelRecipes() { + // TODO Auto-generated method stub + return 1; + } + + @Override + public int getEuDiscountForParallelism() { + // TODO Auto-generated method stub + return 0; + } + + @Override + public boolean checkMultiblock(IGregTechTileEntity aBaseMetaTileEntity, ItemStack aStack) { + int xDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetX; + int zDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()).offsetZ; + int xDir2 = ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()).offsetX; + int zDir2 = ForgeDirection.getOrientation(aBaseMetaTileEntity.getFrontFacing()).offsetZ; + int tAmount = 0; + + ForgeDirection aDir = ForgeDirection.getOrientation(aBaseMetaTileEntity.getBackFacing()); + + //Require air in front, I think + if (!aBaseMetaTileEntity.getAirOffset(xDir2, 0, zDir2)) { + Logger.INFO("Did not find air in front"); + return false; + } else { + for (int i = -1; i < 2; ++i) { + for (int j = -1; j < 2; ++j) { + for (int h = -1; h < 2; ++h) { + if (h != 0 || (xDir + i != 0 || zDir + j != 0) && (i != 0 || j != 0)) { + IGregTechTileEntity tTileEntity = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, + h, zDir + j); + if (this.addToMachineList(tTileEntity, TAE.GTPP_INDEX(28))) { + tAmount++; + } + } + } + } + } + } + Logger.INFO("Tanks found: "+tAmount); + return tAmount == 3; + } + + @Override + public boolean checkRecipe(ItemStack arg0) { + + + ArrayList tFluidList = this.getStoredFluids(); + int tFluidList_sS = tFluidList.size(); + + for (int tFluids = 0; tFluids < tFluidList_sS - 1; ++tFluids) { + for (int tRecipe = tFluids + 1; tRecipe < tFluidList_sS; ++tRecipe) { + if (GT_Utility.areFluidsEqual((FluidStack) tFluidList.get(tFluids), + (FluidStack) tFluidList.get(tRecipe))) { + if (((FluidStack) tFluidList.get(tFluids)).amount < ((FluidStack) tFluidList.get(tRecipe)).amount) { + tFluidList.remove(tFluids--); + tFluidList_sS = tFluidList.size(); + break; + } + + tFluidList.remove(tRecipe--); + tFluidList_sS = tFluidList.size(); + } + } + } + int aStep = 0; + //Logger.INFO("Step "+aStep++); + if (tFluidList.size() > 1) { + //Logger.INFO("Step "+aStep++); + FluidStack[] arg5 = (FluidStack[]) tFluidList.toArray(new FluidStack[tFluidList.size()]); + GT_Recipe arg6 = getRecipeMap().findRecipe(this.getBaseMetaTileEntity(), this.mLastRecipe, + false, this.getMaxInputVoltage(), arg5, new ItemStack[0]); + if (arg6 == null && !this.mRunningOnLoad || this.maxEUStore() < (long) arg6.mSpecialValue) { + //Logger.INFO("Bad Step "+aStep++); + //this.turnCasingActive(false); + this.mLastRecipe = null; + return false; + } + //Logger.INFO("Step "+aStep++); + + if (this.mRunningOnLoad || arg6.isRecipeInputEqual(true, arg5, new ItemStack[0])) { + //Logger.INFO("Step "+aStep++); + this.mLastRecipe = arg6; + this.mEUt = this.mLastRecipe.mEUt * 1; + this.mMaxProgresstime = this.mLastRecipe.mDuration / 1; + this.mEfficiencyIncrease = 10000; + this.mOutputFluids = this.mLastRecipe.mFluidOutputs; + //this.turnCasingActive(true); + this.mRunningOnLoad = false; + return true; + } + //Logger.INFO("Step "+aStep++); + } + //Logger.INFO("Step "+aStep++); + + return false; + + + + + //return this.checkRecipeGeneric(this.getMaxParallelRecipes(), getEuDiscountForParallelism(), 0); + } + + @Override + public int getMaxEfficiency(ItemStack arg0) { + return 10000; + } + + @Override + public boolean drainEnergyInput(long aEU) { + // Not applicable to this machine + return true; + } + + @Override + public boolean addEnergyOutput(long aEU) { + // Not applicable to this machine + return true; + } + + @Override + public long maxEUStore() { + return this.getMaxInputVoltage() * 256 * 512; + } + + @Override + public long getMinimumStoredEU() { + return 0; + } + + @Override + public String[] getExtraInfoData() { + String mode = EnumChatFormatting.BLUE + "" + currentVoltage + EnumChatFormatting.RESET; + String aOutput = EnumChatFormatting.BLUE + "" + mEUt + EnumChatFormatting.RESET; + String storedEnergyText; + if (this.getEUVar() > maxEUStore()) { + storedEnergyText = EnumChatFormatting.RED + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; + } else { + storedEnergyText = EnumChatFormatting.GREEN + GT_Utility.formatNumbers(this.getEUVar()) + EnumChatFormatting.RESET; + } + + return new String[]{ + "Stored EU: " + storedEnergyText, + "Capacity: " + EnumChatFormatting.YELLOW + GT_Utility.formatNumbers(this.maxEUStore()) + EnumChatFormatting.RESET, + "Voltage: " + mode, + "Output Voltage: " + aOutput + }; + } + + @Override + public void explodeMultiblock() { + super.explodeMultiblock(); + } + + @Override + public void doExplosion(long aExplosionPower) { + super.doExplosion(aExplosionPower); + } + + @Override + public long getMaxInputVoltage() { + return updateVoltage(); + } + + @Override + public long getInputTier() { + return (long) GT_Utility.getTier(maxEUInput()); + } + + @Override + public boolean isElectric() { + return true; + } + + @Override + public boolean isEnetInput() { + return true; + } + + @Override + public boolean isEnetOutput() { + return true; + } + + @Override + public boolean isInputFacing(byte aSide) { + return (aSide == this.getBaseMetaTileEntity().getBackFacing()); + } + + @Override + public boolean isOutputFacing(byte aSide) { + return aSide == 1; + } + + @Override + public long maxAmperesIn() { + return 32; + } + + @Override + public long maxAmperesOut() { + return 1; + } + + @Override + public long maxEUInput() { + return updateVoltage(); + } + + @Override + public long maxEUOutput() { + return mEUt > 0 ? mEUt : 0; + } + + @Override + public void onPostTick(IGregTechTileEntity aBaseMetaTileEntity, long aTick) { + super.onPostTick(aBaseMetaTileEntity, aTick); + this.mWrench = true; + this.mScrewdriver = true; + this.mSoftHammer = true; + this.mHardHammer = true; + this.mSolderingTool = true; + this.mCrowbar = true; + } + + @Override + public boolean causeMaintenanceIssue() { + return true; + } + + @Override + public int getControlCoreTier() { + return this.currentTier; + } + + @Override + public int getPollutionPerTick(ItemStack arg0) { + return 0; + } + + @Override + public GT_MetaTileEntity_Hatch_ControlCore getControlCoreBus() { + GT_MetaTileEntity_Hatch_ControlCore x = new GT_MetaTileEntity_Hatch_ControlCore("", 0, "", null); + return (GT_MetaTileEntity_Hatch_ControlCore) x; + } + +} diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java index c424172241..4e5c95ad73 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/production/GregtechMetaTileEntity_AlloyBlastSmelter.java @@ -246,13 +246,13 @@ extends GregtechMeta_MultiBlockBase { Logger.INFO("Heating Coils missing."); return false; } - - //Top Layer - final IGregTechTileEntity tTileEntity2 = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j); - if (!isValidBlockForStructure(tTileEntity2, TAE.GTPP_INDEX(15), true, aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j), (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j), ModBlocks.blockCasingsMisc, 15)) { - Logger.INFO("Top Layer missing."); - return false; - } + } + + //Top Layer + final IGregTechTileEntity tTileEntity2 = aBaseMetaTileEntity.getIGregTechTileEntityOffset(xDir + i, 3, zDir + j); + if (!isValidBlockForStructure(tTileEntity2, TAE.GTPP_INDEX(15), true, aBaseMetaTileEntity.getBlockOffset(xDir + i, 3, zDir + j), (int) aBaseMetaTileEntity.getMetaIDOffset(xDir + i, 3, zDir + j), ModBlocks.blockCasingsMisc, 15)) { + Logger.INFO("Top Layer missing."); + return false; } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java index 8294773be3..ad9876bcf0 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/GT_MetaTileEntity_TieredTank.java @@ -146,12 +146,12 @@ public class GT_MetaTileEntity_TieredTank extends GT_MetaTileEntity_BasicTank { @Override public void setItemNBT(NBTTagCompound aNBT) { - if (CORE.NBT_PERSISTENCY_PATCH_APPLIED) { + if (CORE.NBT_PERSISTENCY_PATCH_APPLIED && !CORE.GTNH) { if (mFluid != null){ - Logger.INFO("Setting item fluid nbt"); + Logger.WARNING("Setting item fluid nbt"); aNBT.setTag("mFluid", mFluid.writeToNBT(new NBTTagCompound())); if (aNBT.hasKey("mFluid")) { - Logger.INFO("Set mFluid to NBT."); + Logger.WARNING("Set mFluid to NBT."); } } } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java index 433c07e948..9fe2aeb12e 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/loaders/RecipeGen_Fluids.java @@ -214,11 +214,12 @@ public class RecipeGen_Fluids extends RecipeGen_Base { // Shape_Mold_Screw, // Shape_Mold_Ring, - ItemList mold_Rod = ItemList.valueOf("Shape_Mold_Rod"); - ItemList mold_Rod_Long = ItemList.valueOf("Shape_Mold_Rod_Long"); - ItemList mold_Bolt = ItemList.valueOf("Shape_Mold_Bolt"); - ItemList mold_Screw = ItemList.valueOf("Shape_Mold_Screw"); - ItemList mold_Ring = ItemList.valueOf("Shape_Mold_Ring"); + + ItemList mold_Rod = gtPlusPlus.core.util.Utils.getValueOfItemList("Shape_Mold_Rod", null); + ItemList mold_Rod_Long = gtPlusPlus.core.util.Utils.getValueOfItemList("Shape_Mold_Rod_Long", null); + ItemList mold_Bolt = gtPlusPlus.core.util.Utils.getValueOfItemList("Shape_Mold_Bolt", null); + ItemList mold_Screw = gtPlusPlus.core.util.Utils.getValueOfItemList("Shape_Mold_Screw", null); + ItemList mold_Ring = gtPlusPlus.core.util.Utils.getValueOfItemList("Shape_Mold_Ring", null); // Rod if (ItemUtils.checkForInvalidItems(material.getRod(1))) diff --git a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java index 94486d472b..ace4876639 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/recipes/GregtechRecipeAdder.java @@ -17,8 +17,10 @@ import gregtech.api.util.Recipe_GT; import gtPlusPlus.api.objects.Logger; import gtPlusPlus.core.lib.CORE; import gtPlusPlus.core.lib.LoadedMods; +import gtPlusPlus.core.material.MaterialGenerator; import gtPlusPlus.core.recipe.common.CI; import gtPlusPlus.core.util.data.ArrayUtils; +import gtPlusPlus.core.util.minecraft.FluidUtils; import gtPlusPlus.core.util.minecraft.ItemUtils; import gtPlusPlus.core.util.reflect.ReflectionUtils; import gtPlusPlus.xmod.gregtech.api.interfaces.internal.IGregtech_RecipeAdder; @@ -943,6 +945,103 @@ public class GregtechRecipeAdder implements IGregtech_RecipeAdder { } } + @Override + public void addFluidExtractionRecipe(ItemStack input, Object input2, FluidStack output, int aTime, int aEu, int aSpecial) { + MaterialGenerator.addFluidExtractionRecipe(input, input2, output, aSpecial, aTime, aEu); + + } + + + + + + /** + * Adds a Fusion reactor Recipe + * + * @param aInputStackA = first Input (not null, and respects StackSize) + * @param aInputStackB = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aOutputChance = chance to output plasma (can be 0) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + @Override + public boolean addFusionReactorRecipe(FluidStack aInputStackA, FluidStack aInputStackB, FluidStack plasma, + int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial) { + if (aInputStackA == null || aInputStackB == null || plasma == null || aFusionDurationInTicks < 1 || aEu < 1 || aSpecial < 1) { + return false; + } + Recipe_GT aFusionCustom = new Recipe_GT( + true, + null, + null, + null, + new int[] {aOutputChance}, + new FluidStack[]{aInputStackA, aInputStackB}, + new FluidStack[]{plasma}, + aFusionDurationInTicks, + aEu, + aSpecial); + GT_Recipe.GT_Recipe_Map.sFusionRecipes.addRecipe(aFusionCustom); + return true; + } + + + + + + + /** + * Adds a Fusion reactor Recipe + * + * @param aInputStackA = first Input (not null, and respects StackSize) + * @param aInputStackB = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + @Override + public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, + int aFusionDurationInTicks, int aEu, int aSpecial) { + return addFusionReactorRecipe(aInputStackA, aInputStackB, plasma, 10000, aFusionDurationInTicks, aEu, aSpecial); + } + + + /** + * Adds a Fusion reactor Recipe + * + * @param aInputStackA = first Input (not null, and respects StackSize) + * @param aInputStackB = second Input (not null, and respects StackSize) + * @param plasma = Output of the Fusion (can be null, and respects StackSize) + * @param aOutputChance = chance to output plasma (can be 0) + * @param aFusionDurationInTicks = How many ticks the Fusion lasts (must be > 0) + * @param aEu = The EU generated per Tick (can even be negative!) + * @param aSpecial = EU needed for heating the Reactor up (must be >= 0) + */ + @Override + public boolean addFusionReactorRecipe(ItemStack aInputStackA, ItemStack aInputStackB, FluidStack plasma, + int aOutputChance, int aFusionDurationInTicks, int aEu, int aSpecial) { + if (aInputStackA == null || aInputStackB == null || plasma == null || aFusionDurationInTicks < 1 || aEu < 1 || aSpecial < 1) { + return false; + } + Recipe_GT aFusionCustom = new Recipe_GT( + true, + new ItemStack[]{aInputStackA, aInputStackB}, + null, + null, + new int[] {aOutputChance}, + null, + new FluidStack[]{plasma}, + aFusionDurationInTicks, + aEu, + aSpecial); + GT_Recipe.GT_Recipe_Map.sFusionRecipes.addRecipe(aFusionCustom); + return true; + + } + diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechHiAmpTransformer.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechHiAmpTransformer.java index ee4f32c8ad..d04f71e235 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechHiAmpTransformer.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechHiAmpTransformer.java @@ -9,6 +9,7 @@ import gregtech.api.enums.Materials; import gregtech.api.enums.OrePrefixes; import gregtech.api.util.GT_ModHandler; import gtPlusPlus.core.lib.CORE; +import gtPlusPlus.core.util.Utils; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.base.GregtechMetaTransformerHiAmp; @@ -54,17 +55,17 @@ public class GregtechHiAmpTransformer { ItemStack mItem_2; ItemStack mItem_3; try { - mItem_1 = ItemList.valueOf("Casing_Coil_TungstenSteel").get(1); + mItem_1 = Utils.getValueOfItemList("Casing_Coil_TungstenSteel", ItemList.Circuit_Elite).get(1); } catch (Throwable t){ mItem_1 = ItemList.Circuit_Elite.get(1); } try { - mItem_2 = ItemList.valueOf("Casing_Coil_Naquadah").get(1); + mItem_2 = Utils.getValueOfItemList("Casing_Coil_Naquadah", ItemList.Circuit_Master).get(1); } catch (Throwable t){ mItem_2 = ItemList.Circuit_Master.get(1); } try { - mItem_3 = ItemList.valueOf("Casing_Coil_NaquadahAlloy").get(1); + mItem_3 = Utils.getValueOfItemList("Casing_Coil_NaquadahAlloy", ItemList.Circuit_Ultimate).get(1); } catch (Throwable t){ mItem_3 = ItemList.Circuit_Ultimate.get(1); } diff --git a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java index f624b78ab8..30835b6daa 100644 --- a/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java +++ b/src/Java/gtPlusPlus/xmod/gregtech/registration/gregtech/GregtechMiniRaFusion.java @@ -1,26 +1,34 @@ package gtPlusPlus.xmod.gregtech.registration.gregtech; -import gregtech.api.GregTech_API; -import gregtech.api.metatileentity.implementations.GT_MetaTileEntity_BasicMachine_GT_Recipe; import gregtech.api.util.GT_Recipe; import gregtech.api.util.Recipe_GT; - import gtPlusPlus.api.objects.Logger; import gtPlusPlus.xmod.gregtech.api.enums.GregtechItemList; +import gtPlusPlus.xmod.gregtech.api.metatileentity.implementations.GT_MetaTileEntity_Hatch_Plasma; +import gtPlusPlus.xmod.gregtech.common.tileentities.machines.multi.production.GregtechMTE_MiniFusionPlant; public class GregtechMiniRaFusion { public static void run() { // Register the Simple Fusion Entity. - GregtechItemList.Miniature_Fusion.set(new GT_MetaTileEntity_BasicMachine_GT_Recipe(994, "machine.simplefusion.tier.01", "Mimir", 8, "Universal Machine for Knowledge and Wisdom", Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes, 2, 9, 64000, 0, 1, "Dehydrator.png", (String) GregTech_API.sSoundList.get(Integer.valueOf(208)), false, false, 0, "EXTRUDER", new Object[]{"CCE", "XMP", "CCE", 'M', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.HULL, 'X', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.SENSOR, 'E', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.STICK_ELECTROMAGNETIC, 'P', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.CIRCUIT, 'C', GT_MetaTileEntity_BasicMachine_GT_Recipe.X.FIELD_GENERATOR}).getStackForm(1L)); - + GregtechItemList.Miniature_Fusion.set(new GregtechMTE_MiniFusionPlant(31015, "gtplusplus.fusion.single", "Helium Prime").getStackForm(1L)); + GregtechItemList.Plasma_Tank.set(new GT_MetaTileEntity_Hatch_Plasma(31016, "gtplusplus.tank.plasma", "Plasma Tank").getStackForm(1L)); + } public static boolean generateSlowFusionrecipes() { for (GT_Recipe x : GT_Recipe.GT_Recipe_Map.sFusionRecipes.mRecipeList){ if (x.mEnabled) { - x.mDuration *= 4; - Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes.add(x); + GT_Recipe y = x.copy(); + y.mDuration *= 16; + long z = y.mEUt * 4; + if (z > Integer.MAX_VALUE) { + y.mEnabled = false; + continue; + } + y.mEUt = (int) Math.min(Math.max(0, z), Integer.MAX_VALUE); + y.mCanBeBuffered = true; + Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes.add(y); } } int mRecipeCount = Recipe_GT.Gregtech_Recipe_Map.sSlowFusionRecipes.mRecipeList.size(); |