Flattened upgrades

This commit is contained in:
drcrazy 2018-09-04 13:26:09 +03:00
parent a40635e75f
commit a05ba25f31
9 changed files with 80 additions and 139 deletions

View file

@ -39,7 +39,6 @@ import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.init.TRItems; import techreborn.init.TRItems;
import techreborn.init.TRIngredients; import techreborn.init.TRIngredients;
import techreborn.items.*;
import techreborn.lib.ModInfo; import techreborn.lib.ModInfo;
import java.util.Map; import java.util.Map;
@ -51,37 +50,47 @@ public class RegisterItemJsons {
} }
private static void registerItems() { private static void registerItems() {
TRIngredients.registerModel();
// Armor
register(TRItems.CLOAKING_DEVICE, "tool/cloaking_device");
register(TRItems.LAPOTRONIC_ORB_PACK, "tool/lapotronic_orbpack");
register(TRItems.LITHIUM_BATTERY_PACK, "tool/lithium_batpack");
// Battery
register(TRItems.RE_BATTERY, "battery/re_battery"); register(TRItems.RE_BATTERY, "battery/re_battery");
register(TRItems.LITHIUM_BATTERY, "battery/lithium_battery"); register(TRItems.LITHIUM_BATTERY, "battery/lithium_battery");
register(TRItems.ENERGY_CRYSTAL, "battery/energy_crystal"); register(TRItems.ENERGY_CRYSTAL, "battery/energy_crystal");
register(TRItems.LAPOTRONIC_CRYSTAL, "battery/lapotron_crystal"); register(TRItems.LAPOTRONIC_CRYSTAL, "battery/lapotron_crystal");
register(TRItems.LAPOTRONIC_ORB, "battery/lapotronic_orb"); register(TRItems.LAPOTRONIC_ORB, "battery/lapotronic_orb");
// Tools
register(TRItems.ADVANCED_CHAINSAW, "tool/advanced_chainsaw");
register(TRItems.ADVANCED_DRILL, "tool/advanced_drill");
register(TRItems.ADVANCED_JACKHAMMER, "tool/advanced_jackhammer");
register(TRItems.DEBUG, "misc/debug");
register(TRItems.DIAMOND_CHAINSAW, "tool/diamond_chainsaw");
register(TRItems.DIAMOND_DRILL, "tool/diamond_drill");
register(TRItems.DIAMOND_JACKHAMMER, "tool/diamond_jackhammer");
register(TRItems.ELECTRIC_TREE_TAP, "tool/electric_treetap");
register(TRItems.NANOSABER, "tool/nanosaber");
register(TRItems.OMNI_TOOL, "tool/omni_tool");
register(TRItems.ROCK_CUTTER, "tool/rock_cutter");
register(TRItems.STEEL_CHAINSAW, "tool/steel_chainsaw");
register(TRItems.STEEL_DRILL, "tool/steel_drill");
register(TRItems.STEEL_JACKHAMMER, "tool/steel_jackhammer");
register(TRItems.TREE_TAP, "tool/treetap");
register(TRItems.WRENCH, "tool/wrench");
// Other
register(TRItems.FREQUENCY_TRANSMITTER, "misc/frequency_transmitter"); register(TRItems.FREQUENCY_TRANSMITTER, "misc/frequency_transmitter");
register(TRItems.SCRAP_BOX, "misc/scrapbox"); register(TRItems.SCRAP_BOX, "misc/scrapbox");
register(TRItems.MANUAL, "misc/manual"); register(TRItems.MANUAL, "misc/manual");
register(TRItems.DEBUG, "misc/debug"); registerBlockstateMultiItem(TRItems.UPGRADE_OVERCLOCKER, 0, "overclock", "items/misc/upgrades");
register(ModBlocks.RUBBER_SAPLING, "misc/rubber_sapling"); registerBlockstateMultiItem(TRItems.UPGRADE_TRANSFORMER, 0, "transformer", "items/misc/upgrades");
registerBlockstateMultiItem(TRItems.UPGRADE_ENERGY_STORAGE, 0, "energy_storage", "items/misc/upgrades");
register(TRItems.STEEL_DRILL, "tool/steel_drill");
register(TRItems.DIAMOND_DRILL, "tool/diamond_drill");
register(TRItems.ADVANCED_DRILL, "tool/advanced_drill");
register(TRItems.STEEL_CHAINSAW, "tool/steel_chainsaw");
register(TRItems.DIAMOND_CHAINSAW, "tool/diamond_chainsaw");
register(TRItems.ADVANCED_CHAINSAW, "tool/advanced_chainsaw");
register(TRItems.STEEL_JACKHAMMER, "tool/steel_jackhammer");
register(TRItems.DIAMOND_JACKHAMMER, "tool/diamond_jackhammer");
register(TRItems.ADVANCED_JACKHAMMER, "tool/advanced_jackhammer");
register(TRItems.NANOSABER, "tool/nanosaber");
register(TRItems.TREE_TAP, "tool/treetap");
register(TRItems.ELECTRIC_TREE_TAP, "tool/electric_treetap");
register(TRItems.CLOAKING_DEVICE, "tool/cloaking_device");
register(TRItems.OMNI_TOOL, "tool/omni_tool");
register(TRItems.ROCK_CUTTER, "tool/rock_cutter");
register(TRItems.WRENCH, "tool/wrench");
register(TRItems.LAPOTRONIC_ORB_PACK, "tool/lapotronic_orbpack");
register(TRItems.LITHIUM_BATTERY_PACK, "tool/lithium_batpack");
// Gem armor & tools
if (ConfigTechReborn.enableGemArmorAndTools) { if (ConfigTechReborn.enableGemArmorAndTools) {
registerBlockstateMultiItem(TRItems.RUBY_HELMET, "ruby_helmet", "items/tool/armour"); registerBlockstateMultiItem(TRItems.RUBY_HELMET, "ruby_helmet", "items/tool/armour");
registerBlockstateMultiItem(TRItems.RUBY_CHESTPLATE, "ruby_chestplate", "items/tool/armour"); registerBlockstateMultiItem(TRItems.RUBY_CHESTPLATE, "ruby_chestplate", "items/tool/armour");
@ -122,12 +131,8 @@ public class RegisterItemJsons {
registerBlockstateMultiItem(TRItems.BRONZE_HOE, "bronze_hoe", "items/tool/tool"); registerBlockstateMultiItem(TRItems.BRONZE_HOE, "bronze_hoe", "items/tool/tool");
} }
TRIngredients.registerModel();
String[] name = ItemUpgrades.types.clone(); register(ModBlocks.RUBBER_SAPLING, "misc/rubber_sapling");
for (int i = 0; i < ItemUpgrades.types.length; ++i) {
registerBlockstate(TRItems.UPGRADES, i, name[i], "items/misc/");
}
for (EnumCableType cableType : EnumCableType.values()) { for (EnumCableType cableType : EnumCableType.values()) {
registerBlockstateMultiItem(Item.getItemFromBlock(ModBlocks.CABLE), cableType.ordinal(), cableType.getName().toLowerCase(), "cable_inv"); registerBlockstateMultiItem(Item.getItemFromBlock(ModBlocks.CABLE), cableType.ordinal(), cableType.getName().toLowerCase(), "cable_inv");

View file

@ -30,7 +30,7 @@ import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.resources.I18n; import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import techreborn.items.tools.ItemTechManual; import techreborn.items.ItemTechManual;
import java.awt.*; import java.awt.*;

View file

@ -137,12 +137,14 @@ public class SubItemRetriever implements ISubItemRetriever {
@Override @Override
public ItemStack getUpgradeByName(String name) { public ItemStack getUpgradeByName(String name) {
return ItemUpgrades.getUpgradeByName(name); // return ItemUpgrades.getUpgradeByName(name);
return null;
} }
@Override @Override
public ItemStack getUpgradeByName(String name, int count) { public ItemStack getUpgradeByName(String name, int count) {
return ItemUpgrades.getUpgradeByName(name, count); // return ItemUpgrades.getUpgradeByName(name, count);
return null;
} }
@Override @Override

View file

@ -34,10 +34,13 @@ import techreborn.Core;
import techreborn.api.Reference; import techreborn.api.Reference;
import techreborn.blocks.BlockMachineFrames; import techreborn.blocks.BlockMachineFrames;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.events.TRRecipeHandler;
import techreborn.items.*; import techreborn.items.*;
import techreborn.items.armor.*; import techreborn.items.armor.*;
import techreborn.items.battery.*; import techreborn.items.battery.*;
import techreborn.items.tools.*; import techreborn.items.tools.*;
import techreborn.lib.ModInfo;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class TRItems { public class TRItems {
@ -69,7 +72,6 @@ public class TRItems {
public static Item STEEL_CHAINSAW; public static Item STEEL_CHAINSAW;
public static Item STEEL_DRILL; public static Item STEEL_DRILL;
public static Item STEEL_JACKHAMMER; public static Item STEEL_JACKHAMMER;
public static Item MANUAL;
public static Item TREE_TAP; public static Item TREE_TAP;
public static Item WRENCH; public static Item WRENCH;
@ -77,7 +79,10 @@ public class TRItems {
public static DynamicCell CELL; public static DynamicCell CELL;
public static Item FREQUENCY_TRANSMITTER; public static Item FREQUENCY_TRANSMITTER;
public static Item SCRAP_BOX; public static Item SCRAP_BOX;
public static Item UPGRADES; public static Item MANUAL;
public static Item UPGRADE_OVERCLOCKER;
public static Item UPGRADE_TRANSFORMER;
public static Item UPGRADE_ENERGY_STORAGE;
// Gem armor & tools // Gem armor & tools
@Nullable @Nullable
@ -221,8 +226,12 @@ public class TRItems {
registerItem(FREQUENCY_TRANSMITTER, "frequencyTransmitter"); registerItem(FREQUENCY_TRANSMITTER, "frequencyTransmitter");
SCRAP_BOX = new ItemScrapBox(); SCRAP_BOX = new ItemScrapBox();
registerItem(SCRAP_BOX, "scrapbox"); registerItem(SCRAP_BOX, "scrapbox");
UPGRADES = new ItemUpgrades(); UPGRADE_OVERCLOCKER = new ItemUpgrades();
registerItem(UPGRADES, "upgrades"); registerItem(UPGRADE_OVERCLOCKER, "upgrade_overclocker");
UPGRADE_TRANSFORMER = new ItemUpgrades();
registerItem(UPGRADE_TRANSFORMER, "upgrade_transformer");
UPGRADE_ENERGY_STORAGE = new ItemUpgrades();
registerItem(UPGRADE_ENERGY_STORAGE, "upgrade_energystorage");
// Gem armor & tools // Gem armor & tools
if (ConfigTechReborn.enableGemArmorAndTools) { if (ConfigTechReborn.enableGemArmorAndTools) {
@ -314,6 +323,8 @@ public class TRItems {
public static void registerItem(Item item, String name) { public static void registerItem(Item item, String name) {
item.setRegistryName(name); item.setRegistryName(name);
item.setTranslationKey(ModInfo.MOD_ID + "." + name);
TRRecipeHandler.hideEntry(item);
RebornRegistry.registerItem(item); RebornRegistry.registerItem(item);
} }

View file

@ -95,11 +95,11 @@ public class CraftingTableRecipes extends RecipeMethods {
} }
//Upgrades //Upgrades
registerShaped(ItemUpgrades.getUpgradeByName("energy_storage"), "PPP", "WBW", "PCP", 'P', "plankWood", 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic", 'B', "reBattery"); // registerShaped(ItemUpgrades.getUpgradeByName("energy_storage"), "PPP", "WBW", "PCP", 'P', "plankWood", 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic", 'B', "reBattery");
registerShaped(ItemUpgrades.getUpgradeByName("overclock"), "TTT", "WCW", 'T', TRIngredients.Parts.COOLANT_SIMPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic"); // registerShaped(ItemUpgrades.getUpgradeByName("overclock"), "TTT", "WCW", 'T', TRIngredients.Parts.COOLANT_SIMPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic");
registerShaped(ItemUpgrades.getUpgradeByName("overclock", 2), " T ", "WCW", 'T', TRIngredients.Parts.HELIUM_COOLANT_TRIPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic"); // registerShaped(ItemUpgrades.getUpgradeByName("overclock", 2), " T ", "WCW", 'T', TRIngredients.Parts.HELIUM_COOLANT_TRIPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic");
registerShaped(ItemUpgrades.getUpgradeByName("overclock", 2), " T ", "WCW", 'T', TRIngredients.Parts.NAK_COOLANT_SIMPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic"); // registerShaped(ItemUpgrades.getUpgradeByName("overclock", 2), " T ", "WCW", 'T', TRIngredients.Parts.NAK_COOLANT_SIMPLE.getStack(), 'W', EnumCableType.ICOPPER.getStack(), 'C', "circuitBasic");
registerShaped(ItemUpgrades.getUpgradeByName("transformer"), "GGG", "WTW", "GCG", 'G', "blockGlass", 'W', EnumCableType.IGOLD.getStack(), 'C', "circuitBasic", 'T', getStack(ModBlocks.MV_TRANSFORMER)); // registerShaped(ItemUpgrades.getUpgradeByName("transformer"), "GGG", "WTW", "GCG", 'G', "blockGlass", 'W', EnumCableType.IGOLD.getStack(), 'C', "circuitBasic", 'T', getStack(ModBlocks.MV_TRANSFORMER));
//Machines //Machines
registerShapeless(getStack(ModBlocks.SOLID_FUEL_GENEREATOR), "reBattery", "machineBlockBasic", getStack(Blocks.FURNACE)); registerShapeless(getStack(ModBlocks.SOLID_FUEL_GENEREATOR), "reBattery", "machineBlockBasic", getStack(Blocks.FURNACE));

View file

@ -66,8 +66,8 @@ public abstract class RecipeMethods {
return BlockMachineFrames.getFrameByName(name, count); return BlockMachineFrames.getFrameByName(name, count);
} else if (type == Type.MACHINE_CASING) { } else if (type == Type.MACHINE_CASING) {
return BlockMachineCasing.getStackByName(name, count); return BlockMachineCasing.getStackByName(name, count);
} else if (type == Type.UPGRADE) { // } else if (type == Type.UPGRADE) {
return ItemUpgrades.getUpgradeByName(name, count); // return ItemUpgrades.getUpgradeByName(name, count);
} else if (type == Type.ORE) { } else if (type == Type.ORE) {
return BlockOre.getOreByName(name, count); return BlockOre.getOreByName(name, count);
} }

View file

@ -22,7 +22,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
package techreborn.items.tools; package techreborn.items;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
@ -32,7 +32,6 @@ import net.minecraft.util.EnumHand;
import net.minecraft.world.World; import net.minecraft.world.World;
import techreborn.Core; import techreborn.Core;
import techreborn.client.EGui; import techreborn.client.EGui;
import techreborn.items.ItemTR;
import techreborn.utils.TechRebornCreativeTab; import techreborn.utils.TechRebornCreativeTab;
public class ItemTechManual extends ItemTR { public class ItemTechManual extends ItemTR {

View file

@ -24,14 +24,9 @@
package techreborn.items; package techreborn.items;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.inventory.Container; import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly; import net.minecraftforge.fml.relauncher.SideOnly;
import reborncore.api.tile.IUpgrade; import reborncore.api.tile.IUpgrade;
@ -40,16 +35,10 @@ import reborncore.common.recipes.IUpgradeHandler;
import reborncore.common.registration.RebornRegistry; import reborncore.common.registration.RebornRegistry;
import reborncore.common.registration.impl.ConfigRegistry; import reborncore.common.registration.impl.ConfigRegistry;
import reborncore.common.tile.TileLegacyMachineBase; import reborncore.common.tile.TileLegacyMachineBase;
import reborncore.common.util.ItemNBTHelper;
import techreborn.Core;
import techreborn.init.TRItems; import techreborn.init.TRItems;
import techreborn.lib.ModInfo; import techreborn.lib.ModInfo;
import techreborn.utils.TechRebornCreativeTab;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.security.InvalidParameterException;
import java.util.List;
@RebornRegistry(modID = ModInfo.MOD_ID) @RebornRegistry(modID = ModInfo.MOD_ID)
public class ItemUpgrades extends ItemTR implements IUpgrade { public class ItemUpgrades extends ItemTR implements IUpgrade {
@ -61,91 +50,32 @@ public class ItemUpgrades extends ItemTR implements IUpgrade {
public static double overclockerPower = 0.75; public static double overclockerPower = 0.75;
@ConfigRegistry(config = "items", category = "upgrades", key = "energy_storage", comment = "Energy storage upgrade extra power") @ConfigRegistry(config = "items", category = "upgrades", key = "energy_storage", comment = "Energy storage upgrade extra power")
public static double energyStoragePower = 40000; public static double energyStoragePower = 40_000;
public static final String[] types = new String[] { "overclock", "transformer", "energy_storage"};
public ItemUpgrades() { public ItemUpgrades() {
setTranslationKey("techreborn.upgrade");
setHasSubtypes(true);
setCreativeTab(TechRebornCreativeTab.instance);
setMaxStackSize(16); setMaxStackSize(16);
} }
public static ItemStack getUpgradeByName(String name, int count) {
for (int i = 0; i < types.length; i++) {
if (types[i].equalsIgnoreCase(name)) {
return new ItemStack(TRItems.UPGRADES, count, i);
}
}
throw new InvalidParameterException("The upgrade " + name + " could not be found.");
}
public static ItemStack getUpgradeByName(String name) {
return getUpgradeByName(name, 1);
}
@Override @Override
// gets Unlocalized Name depending on meta data public void process(@Nonnull TileLegacyMachineBase tile, @Nullable IUpgradeHandler handler, @Nonnull ItemStack stack) {
public String getTranslationKey(ItemStack itemStack) { TilePowerAcceptor powerAcceptor = null;
int meta = itemStack.getItemDamage(); if (tile instanceof TilePowerAcceptor) {
if (meta < 0 || meta >= types.length) { powerAcceptor = (TilePowerAcceptor) tile;
meta = 0;
} }
if (stack.isItemEqual(new ItemStack(TRItems.UPGRADE_OVERCLOCKER))) {
return super.getTranslationKey() + "." + types[meta];
}
// Adds Dusts SubItems To Creative Tab
@Override
public void getSubItems(CreativeTabs creativeTabs, NonNullList<ItemStack> list) {
if (!isInCreativeTab(creativeTabs)) {
return;
}
for (int meta = 0; meta < types.length; ++meta) {
list.add(new ItemStack(this, 1, meta));
}
}
@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
super.addInformation(stack, world, tooltip, flag);
if (stack.getItemDamage() == 4 || stack.getItemDamage() == 5) {
tooltip.add("Facing: " + getFacing(stack).getName());
String text = Core.proxy.getUpgradeConfigText();
if (!text.isEmpty()) {
tooltip.add(text);
}
}
}
@Override
public void process(
@Nonnull
TileLegacyMachineBase machineBase,
@Nullable
IUpgradeHandler handler,
@Nonnull
ItemStack stack) {
if (stack.getItemDamage() == 0) {
handler.addSpeedMulti(overclockerSpeed); handler.addSpeedMulti(overclockerSpeed);
handler.addPowerMulti(overclockerPower); handler.addPowerMulti(overclockerPower);
if(machineBase instanceof TilePowerAcceptor){ if (powerAcceptor != null) {
TilePowerAcceptor powerAcceptor = (TilePowerAcceptor) machineBase;
powerAcceptor.extraPowerInput += powerAcceptor.getMaxInput(); powerAcceptor.extraPowerInput += powerAcceptor.getMaxInput();
powerAcceptor.extraPowerStoage += powerAcceptor.getBaseMaxPower(); powerAcceptor.extraPowerStoage += powerAcceptor.getBaseMaxPower();
} }
} }
if (machineBase instanceof TilePowerAcceptor) { if (powerAcceptor != null) {
if (stack.getItemDamage() == 2) { if (stack.isItemEqual(new ItemStack(TRItems.UPGRADE_TRANSFORMER))) {
TilePowerAcceptor acceptor = (TilePowerAcceptor) machineBase; powerAcceptor.extraTeir += 1;
acceptor.extraPowerStoage += energyStoragePower;
} }
if (stack.getItemDamage() == 1) { if (stack.isItemEqual(new ItemStack(TRItems.UPGRADE_ENERGY_STORAGE))) {
TilePowerAcceptor acceptor = (TilePowerAcceptor) machineBase; powerAcceptor.extraPowerStoage += energyStoragePower;
acceptor.extraTeir += 1;
} }
} }
} }
@ -155,8 +85,4 @@ public class ItemUpgrades extends ItemTR implements IUpgrade {
public void handleRightClick(TileEntity tile, ItemStack stack, Container container, int slotID) { public void handleRightClick(TileEntity tile, ItemStack stack, Container container, int slotID) {
} }
public EnumFacing getFacing(ItemStack stack) {
return EnumFacing.VALUES[ItemNBTHelper.getInt(stack, "side", 0)];
}
} }

View file

@ -586,11 +586,9 @@ fluid.fluidwolframium=Wolframium
item.techreborn.manual.name=Tech Manual item.techreborn.manual.name=Tech Manual
item.techreborn.debug.name=Debug Tool item.techreborn.debug.name=Debug Tool
item.techreborn.frequencyTransmitter.name=Frequency Transmitter item.techreborn.frequencyTransmitter.name=Frequency Transmitter
item.techreborn.upgrade.overclock.name=Overclocker Upgrade item.techreborn.upgrade_overclocker.name=Overclocker Upgrade
item.techreborn.upgrade.transformer.name=Transformer Upgrade item.techreborn.upgrade_transformer.name=Transformer Upgrade
item.techreborn.upgrade.energy_storage.name=Energy Storage Upgrade item.techreborn.upgrade_energystorage.name=Energy Storage Upgrade
item.techreborn.upgrade.ejection.name=Ejector Upgrade
item.techreborn.upgrade.injection.name=Importer Upgrade
item.techreborn.cell.name=Empty Cell item.techreborn.cell.name=Empty Cell
item.techreborn.cell.fluid.name=$fluid$ Cell item.techreborn.cell.fluid.name=$fluid$ Cell
item.techreborn.rebattery.name=Battery item.techreborn.rebattery.name=Battery