start work on science book
This commit is contained in:
parent
01273bd63c
commit
d10c570466
24 changed files with 857 additions and 24 deletions
|
@ -140,6 +140,7 @@ gui.pipes.emzuli.title=Extraction Presets
|
|||
gui.pipes.emzuli.paint=Paint Items %s
|
||||
gui.pipes.emzuli.nopaint=Don't Paint Items
|
||||
|
||||
item.scienceBook.name=Engineering Science Book
|
||||
item.bucketFuel.name=Fuel Bucket
|
||||
item.bucketOil.name=Oil Bucket
|
||||
item.woodenGearItem.name=Wood Gear
|
||||
|
|
BIN
buildcraft_resources/assets/buildcraft/textures/gui/science_focus_gui.png
Executable file
BIN
buildcraft_resources/assets/buildcraft/textures/gui/science_focus_gui.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
buildcraft_resources/assets/buildcraft/textures/gui/science_gui.png
Executable file
BIN
buildcraft_resources/assets/buildcraft/textures/gui/science_gui.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
buildcraft_resources/assets/buildcraft/textures/gui/science_icons.png
Executable file
BIN
buildcraft_resources/assets/buildcraft/textures/gui/science_icons.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
BIN
buildcraft_resources/assets/buildcraft/textures/items/science_book.png
Executable file
BIN
buildcraft_resources/assets/buildcraft/textures/items/science_book.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 643 B |
|
@ -75,9 +75,11 @@ import buildcraft.core.BuildCraftConfiguration;
|
|||
import buildcraft.core.CommandBuildCraft;
|
||||
import buildcraft.core.CoreIconProvider;
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.GuiHandler;
|
||||
import buildcraft.core.InterModComms;
|
||||
import buildcraft.core.ItemBuildCraft;
|
||||
import buildcraft.core.ItemMapLocation;
|
||||
import buildcraft.core.ItemScienceBook;
|
||||
import buildcraft.core.ItemSpring;
|
||||
import buildcraft.core.ItemWrench;
|
||||
import buildcraft.core.SpringPopulate;
|
||||
|
@ -94,6 +96,9 @@ import buildcraft.core.recipes.IntegrationRecipeManager;
|
|||
import buildcraft.core.recipes.RefineryRecipeManager;
|
||||
import buildcraft.core.render.BlockHighlightHandler;
|
||||
import buildcraft.core.robots.EntityRobot;
|
||||
import buildcraft.core.science.TechnoTier;
|
||||
import buildcraft.core.science.Technology;
|
||||
import buildcraft.core.science.Tier;
|
||||
import buildcraft.core.triggers.ActionMachineControl;
|
||||
import buildcraft.core.triggers.ActionMachineControl.Mode;
|
||||
import buildcraft.core.triggers.ActionRedstoneOutput;
|
||||
|
@ -139,6 +144,7 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
|
||||
public static final int trackedPassiveEntityId = 156;
|
||||
public static Block springBlock;
|
||||
public static Item scienceBookItem;
|
||||
public static Item woodenGearItem;
|
||||
public static Item stoneGearItem;
|
||||
public static Item ironGearItem;
|
||||
|
@ -183,6 +189,13 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
public static IAction actionOn = new ActionMachineControl(Mode.On);
|
||||
public static IAction actionOff = new ActionMachineControl(Mode.Off);
|
||||
public static IAction actionLoop = new ActionMachineControl(Mode.Loop);
|
||||
|
||||
public static Technology technoWoodenGear;
|
||||
public static Technology technoStoneGear;
|
||||
public static Technology technoIronGear;
|
||||
public static Technology technoGoldenGear;
|
||||
public static Technology technoDiamondGear;
|
||||
|
||||
public static boolean loadDefaultRecipes = true;
|
||||
public static boolean consumeWaterSources = false;
|
||||
//public static BptItem[] itemBptProps = new BptItem[Item.itemsList.length];
|
||||
|
@ -285,6 +298,9 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
consumeWaterSources = consumeWater.getBoolean(consumeWaterSources);
|
||||
consumeWater.comment = "set to true if the Pump should consume water";
|
||||
|
||||
scienceBookItem = (new ItemScienceBook()).setUnlocalizedName("scienceBook");
|
||||
CoreProxy.proxy.registerItem(scienceBookItem);
|
||||
|
||||
woodenGearItem = (new ItemBuildCraft()).setUnlocalizedName("woodenGearItem");
|
||||
CoreProxy.proxy.registerItem(woodenGearItem);
|
||||
OreDictionary.registerOre("gearWood", new ItemStack(woodenGearItem));
|
||||
|
@ -352,6 +368,7 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
CoreProxy.proxy.initializeRendering();
|
||||
CoreProxy.proxy.initializeEntityRendering();
|
||||
|
||||
NetworkRegistry.INSTANCE.registerGuiHandler(instance, new GuiHandler());
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
|
@ -405,13 +422,26 @@ public class BuildCraftCore extends BuildCraftMod {
|
|||
}
|
||||
|
||||
public void loadRecipes() {
|
||||
technoWoodenGear = new TechnoTier(Tier.WoodenGear, null);
|
||||
technoStoneGear = new TechnoTier(Tier.StoneGear, new ItemStack(woodenGearItem, 50), technoWoodenGear);
|
||||
technoIronGear = new TechnoTier(Tier.IronGear, new ItemStack(stoneGearItem, 50), technoStoneGear);
|
||||
technoGoldenGear = new TechnoTier(Tier.GoldenGear, new ItemStack(ironGearItem, 30), technoIronGear);
|
||||
technoDiamondGear = new TechnoTier(Tier.DiamondGear, new ItemStack(goldGearItem, 25), technoGoldenGear);
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(scienceBookItem), "R ", "B ", 'R', Blocks.redstone_torch, 'B',
|
||||
Items.book);
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(wrenchItem), "I I", " G ", " I ", 'I', Items.iron_ingot, 'G', stoneGearItem);
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(woodenGearItem), " S ", "S S", " S ", 'S', "stickWood");
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(stoneGearItem), " I ", "IGI", " I ", 'I', "cobblestone", 'G',
|
||||
CoreProxy.proxy.addCraftingRecipe(technoWoodenGear, new ItemStack(woodenGearItem), " S ", "S S", " S ", 'S',
|
||||
"stickWood");
|
||||
CoreProxy.proxy.addCraftingRecipe(technoStoneGear, new ItemStack(stoneGearItem), " I ", "IGI", " I ", 'I',
|
||||
"cobblestone", 'G',
|
||||
woodenGearItem);
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(ironGearItem), " I ", "IGI", " I ", 'I', Items.iron_ingot, 'G', stoneGearItem);
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(goldGearItem), " I ", "IGI", " I ", 'I', Items.gold_ingot, 'G', ironGearItem);
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(diamondGearItem), " I ", "IGI", " I ", 'I', Items.diamond, 'G', goldGearItem);
|
||||
CoreProxy.proxy.addCraftingRecipe(technoIronGear, new ItemStack(ironGearItem), " I ", "IGI", " I ", 'I',
|
||||
Items.iron_ingot, 'G', stoneGearItem);
|
||||
CoreProxy.proxy.addCraftingRecipe(technoGoldenGear, new ItemStack(goldGearItem), " I ", "IGI", " I ", 'I',
|
||||
Items.gold_ingot, 'G', ironGearItem);
|
||||
CoreProxy.proxy.addCraftingRecipe(technoDiamondGear,
|
||||
new ItemStack(diamondGearItem), " I ", "IGI", " I ", 'I', Items.diamond, 'G', goldGearItem);
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(mapLocationItem), "ppp", "pYp", "ppp", 'p', Items.paper, 'Y', new ItemStack(Items.dye, 1, 11));
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,9 @@ import buildcraft.core.InterModComms;
|
|||
import buildcraft.core.Version;
|
||||
import buildcraft.core.network.BuildCraftChannelHandler;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.science.TechnoSimpleItem;
|
||||
import buildcraft.core.science.Technology;
|
||||
import buildcraft.core.science.Tier;
|
||||
import buildcraft.core.triggers.BCTrigger;
|
||||
import buildcraft.energy.BlockBuildcraftFluid;
|
||||
import buildcraft.energy.BlockEnergyConverter;
|
||||
|
@ -102,6 +105,9 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
public static Item bucketFuel;
|
||||
public static Item bucketRedPlasma;
|
||||
public static Item fuel;
|
||||
public static Technology technoRedstoneEngine;
|
||||
public static Technology technoStoneEngine;
|
||||
public static Technology technoIronEngine;
|
||||
public static boolean canOilBurn;
|
||||
public static double oilWellScalar = 1.0;
|
||||
public static Set<Integer> oilBiomeIDs = new HashSet<Integer>();
|
||||
|
@ -341,6 +347,7 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
if (BuildCraftCore.loadDefaultRecipes) {
|
||||
loadRecipes();
|
||||
}
|
||||
|
||||
EnergyProxy.proxy.registerBlockRenderers();
|
||||
EnergyProxy.proxy.registerTileEntities();
|
||||
}
|
||||
|
@ -364,12 +371,24 @@ public class BuildCraftEnergy extends BuildCraftMod {
|
|||
}
|
||||
|
||||
public static void loadRecipes() {
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 0),
|
||||
technoRedstoneEngine = new TechnoSimpleItem(Tier.WoodenGear, new ItemStack(engineBlock, 1, 0),
|
||||
new ItemStack(BuildCraftCore.woodenGearItem, 5));
|
||||
|
||||
technoStoneEngine = new TechnoSimpleItem(Tier.StoneGear, new ItemStack(engineBlock, 1, 1),
|
||||
new ItemStack(BuildCraftCore.stoneGearItem, 10), technoRedstoneEngine);
|
||||
|
||||
technoIronEngine = new TechnoSimpleItem(Tier.IronGear, new ItemStack(engineBlock, 1, 2),
|
||||
new ItemStack(BuildCraftCore.ironGearItem, 20), technoStoneEngine);
|
||||
|
||||
CoreProxy.proxy.addCraftingRecipe(technoRedstoneEngine,
|
||||
new ItemStack(engineBlock, 1, 0),
|
||||
"www", " g ", "GpG", 'w', "plankWood", 'g', Blocks.glass, 'G',
|
||||
BuildCraftCore.woodenGearItem, 'p', Blocks.piston);
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 1), "www", " g ", "GpG", 'w', "cobblestone",
|
||||
CoreProxy.proxy.addCraftingRecipe(technoStoneEngine,
|
||||
new ItemStack(engineBlock, 1, 1), "www", " g ", "GpG", 'w', "cobblestone",
|
||||
'g', Blocks.glass, 'G', BuildCraftCore.stoneGearItem, 'p', Blocks.piston);
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(engineBlock, 1, 2), "www", " g ", "GpG", 'w', Items.iron_ingot,
|
||||
CoreProxy.proxy.addCraftingRecipe(technoIronEngine,
|
||||
new ItemStack(engineBlock, 1, 2), "www", " g ", "GpG", 'w', Items.iron_ingot,
|
||||
'g', Blocks.glass, 'G', BuildCraftCore.ironGearItem, 'p', Blocks.piston);
|
||||
|
||||
if (blockEnergyConverter != null) {
|
||||
|
|
|
@ -43,6 +43,9 @@ import buildcraft.core.InterModComms;
|
|||
import buildcraft.core.Version;
|
||||
import buildcraft.core.network.BuildCraftChannelHandler;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.science.TechnoSimpleItem;
|
||||
import buildcraft.core.science.Technology;
|
||||
import buildcraft.core.science.Tier;
|
||||
import buildcraft.core.utils.ConfigUtils;
|
||||
import buildcraft.factory.BlockAutoWorkbench;
|
||||
import buildcraft.factory.BlockFloodGate;
|
||||
|
@ -85,6 +88,9 @@ public class BuildCraftFactory extends BuildCraftMod {
|
|||
public static BlockTank tankBlock;
|
||||
public static BlockRefinery refineryBlock;
|
||||
public static BlockHopper hopperBlock;
|
||||
|
||||
public static Technology technoAutoWorkbench;
|
||||
|
||||
public static boolean allowMining = true;
|
||||
public static boolean quarryOneTimeUse = false;
|
||||
public static float miningMultiplier = 1;
|
||||
|
@ -223,6 +229,13 @@ public class BuildCraftFactory extends BuildCraftMod {
|
|||
}
|
||||
|
||||
public static void loadRecipes() {
|
||||
technoAutoWorkbench = new TechnoSimpleItem
|
||||
(Tier.WoodenGear,
|
||||
autoWorkbenchBlock,
|
||||
new ItemStack(BuildCraftCore.woodenGearItem, 10),
|
||||
BuildCraftEnergy.technoRedstoneEngine,
|
||||
BuildCraftTransport.technoWoodenPipe);
|
||||
|
||||
|
||||
if (allowMining) {
|
||||
if (miningWellBlock != null) {
|
||||
|
@ -273,7 +286,7 @@ public class BuildCraftFactory extends BuildCraftMod {
|
|||
}
|
||||
|
||||
if (autoWorkbenchBlock != null) {
|
||||
CoreProxy.proxy.addCraftingRecipe(new ItemStack(autoWorkbenchBlock),
|
||||
CoreProxy.proxy.addCraftingRecipe(technoAutoWorkbench, new ItemStack(autoWorkbenchBlock),
|
||||
" g ",
|
||||
"gwg",
|
||||
" g ",
|
||||
|
|
|
@ -51,6 +51,9 @@ import buildcraft.core.ItemBuildCraft;
|
|||
import buildcraft.core.Version;
|
||||
import buildcraft.core.network.BuildCraftChannelHandler;
|
||||
import buildcraft.core.proxy.CoreProxy;
|
||||
import buildcraft.core.science.TechnoSimpleItem;
|
||||
import buildcraft.core.science.Technology;
|
||||
import buildcraft.core.science.Tier;
|
||||
import buildcraft.core.triggers.ActionPipeClose;
|
||||
import buildcraft.transport.BlockFilteredBuffer;
|
||||
import buildcraft.transport.BlockGenericPipe;
|
||||
|
@ -188,6 +191,8 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
public static IAction actionExtractionPresetGreen = new ActionExtractionPreset(EnumColor.GREEN);
|
||||
public static IAction actionExtractionPresetYellow = new ActionExtractionPreset(EnumColor.YELLOW);
|
||||
|
||||
public static Technology technoWoodenPipe;
|
||||
|
||||
@Mod.Instance("BuildCraft|Transport")
|
||||
public static BuildCraftTransport instance;
|
||||
|
||||
|
@ -461,6 +466,10 @@ public class BuildCraftTransport extends BuildCraftMod {
|
|||
}
|
||||
|
||||
public void loadRecipes() {
|
||||
technoWoodenPipe = new TechnoSimpleItem
|
||||
(Tier.WoodenGear,
|
||||
pipeItemsWood,
|
||||
new ItemStack(BuildCraftCore.woodenGearItem, 5));
|
||||
|
||||
// Add base recipe for pipe waterproof.
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(pipeWaterproof, 1), new ItemStack(Items.dye, 1, 2));
|
||||
|
|
38
common/buildcraft/core/GuiHandler.java
Executable file
38
common/buildcraft/core/GuiHandler.java
Executable file
|
@ -0,0 +1,38 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
|
||||
import buildcraft.core.gui.ContainerScienceBook;
|
||||
import buildcraft.core.gui.GuiScienceBook;
|
||||
|
||||
public class GuiHandler implements IGuiHandler {
|
||||
|
||||
@Override
|
||||
public Object getClientGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (id == GuiIds.SCIENCE_BOOK) {
|
||||
return new GuiScienceBook(player);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int id, EntityPlayer player, World world, int x, int y, int z) {
|
||||
if (id == GuiIds.SCIENCE_BOOK) {
|
||||
return new ContainerScienceBook(player);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -35,6 +35,8 @@ public final class GuiIds {
|
|||
|
||||
public static final int REDSTONE_BOARD = 70;
|
||||
|
||||
public static final int SCIENCE_BOOK = 70;
|
||||
|
||||
/**
|
||||
* Deactivate constructor
|
||||
*/
|
||||
|
|
43
common/buildcraft/core/ItemScienceBook.java
Executable file
43
common/buildcraft/core/ItemScienceBook.java
Executable file
|
@ -0,0 +1,43 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core;
|
||||
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
|
||||
public class ItemScienceBook extends ItemBuildCraft {
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister par1IconRegister) {
|
||||
itemIcon = par1IconRegister.registerIcon("buildcraft:science_book");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemStackLimit(ItemStack stack) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack par1ItemStack, World world, EntityPlayer entityPlayer) {
|
||||
if (!world.isRemote) {
|
||||
entityPlayer.openGui(BuildCraftCore.instance, GuiIds.SCIENCE_BOOK, world, 0, 0, 0);
|
||||
}
|
||||
|
||||
return par1ItemStack;
|
||||
}
|
||||
|
||||
}
|
|
@ -94,17 +94,10 @@ public abstract class AdvancedSlot {
|
|||
}
|
||||
|
||||
public void drawStack(ItemStack item) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
int cornerX = (gui.width - gui.getXSize()) / 2;
|
||||
int cornerY = (gui.height - gui.getYSize()) / 2;
|
||||
|
||||
if (item != null) {
|
||||
int cornerX = (gui.width - gui.getXSize()) / 2;
|
||||
int cornerY = (gui.height - gui.getYSize()) / 2;
|
||||
|
||||
GuiAdvancedInterface.getItemRenderer().zLevel = 200F;
|
||||
GuiAdvancedInterface.getItemRenderer().renderItemAndEffectIntoGUI(gui.getFontRenderer (), mc.renderEngine, item, cornerX + x, cornerY + y);
|
||||
GuiAdvancedInterface.getItemRenderer().renderItemOverlayIntoGUI(gui.getFontRenderer (), mc.renderEngine, item, cornerX + x, cornerY + y);
|
||||
GuiAdvancedInterface.getItemRenderer().zLevel = 0.0F;
|
||||
}
|
||||
gui.drawStack(item, cornerX + x, cornerY + y);
|
||||
}
|
||||
|
||||
public void selected () {
|
||||
|
|
39
common/buildcraft/core/gui/ContainerScienceBook.java
Executable file
39
common/buildcraft/core/gui/ContainerScienceBook.java
Executable file
|
@ -0,0 +1,39 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.gui;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
|
||||
public class ContainerScienceBook extends BuildCraftContainer {
|
||||
|
||||
private EntityPlayer player;
|
||||
|
||||
public ContainerScienceBook(EntityPlayer iPlayer) {
|
||||
super(iPlayer.inventory.getSizeInventory());
|
||||
|
||||
player = iPlayer;
|
||||
|
||||
for (int sy = 0; sy < 3; sy++) {
|
||||
for (int sx = 0; sx < 9; sx++) {
|
||||
addSlotToContainer(new Slot(player.inventory, sx + sy * 9 + 9, 19 + sx * 18, 101 + sy * 18));
|
||||
}
|
||||
}
|
||||
|
||||
for (int sx = 0; sx < 9; sx++) {
|
||||
addSlotToContainer(new Slot(player.inventory, sx, 19 + sx * 18, 159));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInteractWith(EntityPlayer entityplayer) {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ package buildcraft.core.gui;
|
|||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.OpenGlHelper;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
|
@ -28,7 +29,8 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
|||
public int getSlotAtLocation(int i, int j) {
|
||||
for (int position = 0; position < slots.length; ++position) {
|
||||
AdvancedSlot s = slots[position];
|
||||
if (i >= s.x && i <= s.x + 16 && j >= s.y && j <= s.y + 16) {
|
||||
|
||||
if (s != null && i >= s.x && i <= s.x + 16 && j >= s.y && j <= s.y + 16) {
|
||||
return position;
|
||||
}
|
||||
}
|
||||
|
@ -48,9 +50,11 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
|||
OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, i1 / 1.0F, k1 / 1.0F);
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
|
||||
for (AdvancedSlot slot : slots) {
|
||||
if (slot != null) {
|
||||
slot.drawSprite(cornerX, cornerY);
|
||||
if (slots != null) {
|
||||
for (AdvancedSlot slot : slots) {
|
||||
if (slot != null) {
|
||||
slot.drawSprite(cornerX, cornerY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,4 +104,43 @@ public abstract class GuiAdvancedInterface extends GuiBuildCraft {
|
|||
public void renderToolTip(ItemStack stack, int x, int y) {
|
||||
super.renderToolTip(stack, x, y);
|
||||
}
|
||||
|
||||
public void drawStack(ItemStack item, int x, int y) {
|
||||
Minecraft mc = Minecraft.getMinecraft();
|
||||
|
||||
if (item != null) {
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
float prevZ = GuiAdvancedInterface.getItemRenderer().zLevel;
|
||||
GuiAdvancedInterface.getItemRenderer().zLevel = 200F;
|
||||
GuiAdvancedInterface.getItemRenderer().renderItemAndEffectIntoGUI(getFontRenderer(), mc.renderEngine, item, x, y);
|
||||
GuiAdvancedInterface.getItemRenderer().renderItemOverlayIntoGUI(getFontRenderer(), mc.renderEngine, item, x, y);
|
||||
GuiAdvancedInterface.getItemRenderer().zLevel = prevZ;
|
||||
GL11.glDisable(GL11.GL_LIGHTING);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
int position = getSlotAtLocation(mouseX - cornerX, mouseY - cornerY);
|
||||
|
||||
AdvancedSlot slot = null;
|
||||
|
||||
if (position < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (slots[position].isDefined()) {
|
||||
slotClicked(slots[position]);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Use this for all children of this class
|
||||
protected void slotClicked(AdvancedSlot slot) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ public abstract class GuiBuildCraft extends GuiContainer {
|
|||
public static final ResourceLocation LEDGER_TEXTURE = new ResourceLocation("buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/ledger.png");
|
||||
public final LedgerManager ledgerManager = new LedgerManager(this);
|
||||
public final TileEntity tile;
|
||||
public final ResourceLocation texture;
|
||||
public final BuildCraftContainer container;
|
||||
public ResourceLocation texture;
|
||||
|
||||
public GuiBuildCraft(BuildCraftContainer container, IInventory inventory, ResourceLocation texture) {
|
||||
super(container);
|
||||
|
|
239
common/buildcraft/core/gui/GuiScienceBook.java
Executable file
239
common/buildcraft/core/gui/GuiScienceBook.java
Executable file
|
@ -0,0 +1,239 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import buildcraft.core.DefaultProps;
|
||||
import buildcraft.core.science.Technology;
|
||||
import buildcraft.core.science.Tier;
|
||||
|
||||
public class GuiScienceBook extends GuiAdvancedInterface {
|
||||
|
||||
private static final ResourceLocation TEXTURE_BASE = new ResourceLocation(
|
||||
"buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/science_gui.png");
|
||||
private static final ResourceLocation TEXTURE_FOCUS = new ResourceLocation(
|
||||
"buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/science_focus_gui.png");
|
||||
private static final ResourceLocation TEXTURE_ICONS = new ResourceLocation(
|
||||
"buildcraft", DefaultProps.TEXTURE_PATH_GUI + "/science_icons.png");
|
||||
|
||||
private Tier currentTier = null;
|
||||
|
||||
private Technology inFocus = null;
|
||||
|
||||
private List baseInventorySlots;
|
||||
|
||||
static class EmptySlot extends AdvancedSlot {
|
||||
public EmptySlot(GuiAdvancedInterface gui, int x, int y) {
|
||||
super(gui, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
static class TechnologySlot extends AdvancedSlot {
|
||||
private Technology techno;
|
||||
|
||||
public TechnologySlot(GuiAdvancedInterface gui, int x, int y, Technology iTechno) {
|
||||
super(gui, x, y);
|
||||
|
||||
techno = iTechno;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IIcon getIcon() {
|
||||
return techno.getIcon();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return techno.getStackToDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
public GuiScienceBook(EntityPlayer player) {
|
||||
super(new ContainerScienceBook(player), player.inventory, TEXTURE_BASE);
|
||||
|
||||
xSize = 256;
|
||||
ySize = 181;
|
||||
|
||||
slots = new AdvancedSlot[50];
|
||||
|
||||
baseInventorySlots = container.inventorySlots;
|
||||
|
||||
setTier(Tier.WoodenGear);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float f, int mouseX, int mouseY) {
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
bindTexture(TEXTURE_ICONS);
|
||||
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
if (inFocus != null || currentTier.ordinal() != i) {
|
||||
drawTexturedModalRect(cornerX + 28 * i, cornerY - 28, 28 * i, 1, 29, 32);
|
||||
}
|
||||
|
||||
if (inFocus != null || currentTier.ordinal() != i + 7) {
|
||||
drawTexturedModalRect(cornerX + 28 * i, cornerY + ySize - 4, 28 * i, 62, 29, 32);
|
||||
}
|
||||
}
|
||||
|
||||
if (inFocus == null) {
|
||||
texture = TEXTURE_BASE;
|
||||
} else {
|
||||
texture = TEXTURE_FOCUS;
|
||||
}
|
||||
|
||||
super.drawGuiContainerBackgroundLayer(f, mouseX, mouseY);
|
||||
|
||||
bindTexture(TEXTURE_ICONS);
|
||||
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
if (inFocus == null && currentTier.ordinal() == i) {
|
||||
drawTexturedModalRect(cornerX + 28 * i, cornerY - 28, 28 * i, 32, 29, 32);
|
||||
}
|
||||
|
||||
if (inFocus == null && currentTier.ordinal() == i + 7) {
|
||||
drawTexturedModalRect(cornerX + 28 * i, cornerY + ySize - 4, 28 * i, 96, 29, 32);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
drawStack(Tier.values()[i].getStackToDisplay(), cornerX + 28 * i + 6, cornerY - 28 + 9);
|
||||
|
||||
drawStack(Tier.values()[i + 7].getStackToDisplay(), cornerX + 28 * i + 6, cornerY + ySize - 4 + 7);
|
||||
}
|
||||
|
||||
drawBackgroundSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int par1, int par2) {
|
||||
super.drawGuiContainerForegroundLayer(par1, par2);
|
||||
|
||||
drawTooltipForSlotAt(par1, par2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseButton) {
|
||||
super.mouseClicked(mouseX, mouseY, mouseButton);
|
||||
|
||||
int cornerX = (width - xSize) / 2;
|
||||
int cornerY = (height - ySize) / 2;
|
||||
|
||||
for (int i = 0; i < 7; ++i) {
|
||||
int x1 = cornerX + 28 * i;
|
||||
int x2 = x1 + 29;
|
||||
int y1 = cornerY - 30;
|
||||
int y2 = y1 + 32;
|
||||
|
||||
if (mouseX >= x1 && mouseX <= x2 && mouseY >= y1 && mouseY <= y2) {
|
||||
setTier(Tier.values()[i]);
|
||||
return;
|
||||
}
|
||||
|
||||
y1 = cornerY + ySize - 2;
|
||||
y2 = y1 + 32;
|
||||
|
||||
if (mouseX >= x1 && mouseX <= x2 && mouseY >= y1 && mouseY <= y2) {
|
||||
setTier(Tier.values()[i + 7]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void slotClicked(AdvancedSlot slot) {
|
||||
super.slotClicked(slot);
|
||||
|
||||
if (slot instanceof TechnologySlot) {
|
||||
setFocus(((TechnologySlot) slot).techno);
|
||||
}
|
||||
}
|
||||
|
||||
private void setTier(Tier newTier) {
|
||||
if (inFocus != null || newTier != currentTier) {
|
||||
slots = new AdvancedSlot[50];
|
||||
currentTier = newTier;
|
||||
|
||||
int id = 0;
|
||||
|
||||
Collection<Technology> technos = Technology.getTechnologies(currentTier);
|
||||
|
||||
for (Technology t : technos) {
|
||||
int j = id / 10;
|
||||
int i = id - j * 10;
|
||||
|
||||
slots[id] = new TechnologySlot(this, 9 + i * 18, 7 + j * 18, t);
|
||||
id++;
|
||||
}
|
||||
|
||||
while (id < 50) {
|
||||
int j = id / 10;
|
||||
int i = id - j * 10;
|
||||
|
||||
slots[id] = new EmptySlot(this, 9 + i * 18, 7 + j * 18);
|
||||
id++;
|
||||
}
|
||||
}
|
||||
|
||||
inFocus = null;
|
||||
container.inventorySlots = baseInventorySlots;
|
||||
}
|
||||
|
||||
private void setFocus(Technology techno) {
|
||||
inFocus = techno;
|
||||
container.inventorySlots = new ArrayList();
|
||||
slots = new AdvancedSlot[5 + 3 + 1 + 10];
|
||||
|
||||
int id = 0;
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
if (techno.getPrerequisites().size() > i
|
||||
&& techno.getPrerequisites().get(i) != null) {
|
||||
slots[id++] = new TechnologySlot(this, 33, 43 + 18 * i, techno.getPrerequisites().get(i));
|
||||
} else {
|
||||
id++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; ++i) {
|
||||
if (techno.getRequirements() != null) {
|
||||
slots[id++] = new ItemSlot(this, 71, 115 + 18 * i, techno.getRequirements()[i]);
|
||||
} else {
|
||||
id++;
|
||||
}
|
||||
}
|
||||
|
||||
slots[id++] = new TechnologySlot(this, 89, 79, techno);
|
||||
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
for (int j = 0; j < 2; ++j) {
|
||||
int followupId = i * 2 + j;
|
||||
if (techno.getFollowups().size() > followupId
|
||||
&& techno.getFollowups().get(followupId) != null) {
|
||||
slots[id++] = new TechnologySlot(this, 145 + 18 * j, 43 + 18 * i, techno.getFollowups().get(
|
||||
followupId));
|
||||
} else {
|
||||
id++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,6 +18,12 @@ public class ItemSlot extends AdvancedSlot {
|
|||
super(gui, x, y);
|
||||
}
|
||||
|
||||
public ItemSlot(GuiAdvancedInterface gui, int x, int y, ItemStack iStack) {
|
||||
super(gui, x, y);
|
||||
|
||||
stack = iStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack() {
|
||||
return stack;
|
||||
|
|
|
@ -40,6 +40,8 @@ import buildcraft.api.core.ICoreProxy;
|
|||
import buildcraft.core.EntityBlock;
|
||||
import buildcraft.core.ItemBlockBuildCraft;
|
||||
import buildcraft.core.LaserKind;
|
||||
import buildcraft.core.recipes.BuildCraftRecipe;
|
||||
import buildcraft.core.science.Technology;
|
||||
|
||||
public class CoreProxy implements ICoreProxy {
|
||||
|
||||
|
@ -108,6 +110,17 @@ public class CoreProxy implements ICoreProxy {
|
|||
stack.onCrafting(world, player, stack.stackSize);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addCraftingRecipe(Technology techno, ItemStack result, Object... recipe) {
|
||||
String name = Item.itemRegistry.getNameForObject(result.getItem());
|
||||
|
||||
if (BuildCraftCore.recipesBlacklist.contains(name)) {
|
||||
return;
|
||||
}
|
||||
|
||||
CraftingManager.getInstance().getRecipeList().add(new BuildCraftRecipe(techno, result, recipe));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void addCraftingRecipe(ItemStack result, Object... recipe) {
|
||||
String name = Item.itemRegistry.getNameForObject(result.getItem());
|
||||
|
|
64
common/buildcraft/core/recipes/BuildCraftRecipe.java
Executable file
64
common/buildcraft/core/recipes/BuildCraftRecipe.java
Executable file
|
@ -0,0 +1,64 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.recipes;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
import buildcraft.core.science.Technology;
|
||||
|
||||
public class BuildCraftRecipe extends ShapedOreRecipe {
|
||||
|
||||
Technology techno;
|
||||
|
||||
public BuildCraftRecipe(Technology iTechno, ItemStack result, Object[] recipe) {
|
||||
super(result, recipe);
|
||||
|
||||
iTechno = techno;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World world) {
|
||||
try {
|
||||
Field f = InventoryCrafting.class.getDeclaredField("eventHandler");
|
||||
|
||||
if (!f.isAccessible()) {
|
||||
f.setAccessible(true);
|
||||
}
|
||||
|
||||
Container container = (Container) f.get(inv);
|
||||
|
||||
f = Container.class.getDeclaredField("crafters");
|
||||
|
||||
if (!f.isAccessible()) {
|
||||
f.setAccessible(true);
|
||||
}
|
||||
|
||||
List crafters = (List) f.get(container);
|
||||
|
||||
for (Object p : crafters) {
|
||||
EntityPlayer player = (EntityPlayer) p;
|
||||
|
||||
System.out.println(player.getEntityId());
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return super.matches(inv, world);
|
||||
}
|
||||
}
|
67
common/buildcraft/core/science/TechnoSimpleItem.java
Executable file
67
common/buildcraft/core/science/TechnoSimpleItem.java
Executable file
|
@ -0,0 +1,67 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.science;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TechnoSimpleItem extends Technology {
|
||||
|
||||
private ItemStack itemToDisplay;
|
||||
|
||||
public TechnoSimpleItem(Tier iTier,
|
||||
Object iItemToDisplay,
|
||||
ItemStack requirement,
|
||||
Technology... iPrerequisites) {
|
||||
this(iTier, iItemToDisplay, requirement, null, null, iPrerequisites);
|
||||
}
|
||||
|
||||
public TechnoSimpleItem(Tier iTier,
|
||||
Object iItemToDisplay,
|
||||
ItemStack requirement1,
|
||||
ItemStack requirement2,
|
||||
Technology... iPrerequisites) {
|
||||
this(iTier, iItemToDisplay, requirement1, requirement2, null, iPrerequisites);
|
||||
}
|
||||
|
||||
public TechnoSimpleItem(Tier iTier,
|
||||
Object iItemToDisplay,
|
||||
ItemStack requirement1,
|
||||
ItemStack requirement2,
|
||||
ItemStack requirement3,
|
||||
Technology... iPrerequisites) {
|
||||
|
||||
super(iTier, requirement1, requirement2, requirement3, iPrerequisites);
|
||||
|
||||
itemToDisplay = toStack(iItemToDisplay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackToDisplay() {
|
||||
return itemToDisplay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public static ItemStack toStack(Object obj) {
|
||||
if (obj instanceof ItemStack) {
|
||||
return (ItemStack) obj;
|
||||
} else if (obj instanceof Item) {
|
||||
return new ItemStack((Item) obj);
|
||||
} else if (obj instanceof Block) {
|
||||
return new ItemStack((Block) obj);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
57
common/buildcraft/core/science/TechnoTier.java
Executable file
57
common/buildcraft/core/science/TechnoTier.java
Executable file
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.science;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public class TechnoTier extends Technology {
|
||||
|
||||
private ItemStack itemToDisplay;
|
||||
private Technology[] prerequisites;
|
||||
private ItemStack[] requirements;
|
||||
|
||||
public TechnoTier(Tier iTier,
|
||||
Object requirement,
|
||||
Technology... iPrerequisites) {
|
||||
this(iTier, requirement, null, null, iPrerequisites);
|
||||
}
|
||||
|
||||
public TechnoTier(Tier iTier,
|
||||
Object requirement1,
|
||||
Object requirement2,
|
||||
Technology... iPrerequisites) {
|
||||
this(iTier, requirement1, requirement2, null, iPrerequisites);
|
||||
}
|
||||
|
||||
public TechnoTier(Tier iTier,
|
||||
Object requirement1,
|
||||
Object requirement2,
|
||||
Object requirement3,
|
||||
Technology... iPrerequisites) {
|
||||
|
||||
super(Tier.values()[(iTier.ordinal() > 0 ? iTier.ordinal() - 1 : 0)],
|
||||
requirement1,
|
||||
requirement2,
|
||||
requirement3);
|
||||
|
||||
itemToDisplay = toStack(iTier.getStackToDisplay());
|
||||
|
||||
prerequisites = iPrerequisites;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackToDisplay() {
|
||||
return itemToDisplay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalizedName() {
|
||||
return "";
|
||||
}
|
||||
}
|
99
common/buildcraft/core/science/Technology.java
Executable file
99
common/buildcraft/core/science/Technology.java
Executable file
|
@ -0,0 +1,99 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.science;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public abstract class Technology {
|
||||
|
||||
private static final LinkedList[] registry = new LinkedList[Tier.values().length];
|
||||
|
||||
private Tier tier;
|
||||
private ItemStack[] requirements;
|
||||
private ArrayList<Technology> prerequisites = new ArrayList<Technology>();
|
||||
protected ArrayList<Technology> followups = new ArrayList<Technology>();;
|
||||
|
||||
public Technology(Tier iTier,
|
||||
Object requirement1,
|
||||
Object requirement2,
|
||||
Object requirement3,
|
||||
Technology... iPrerequisites) {
|
||||
getTechnologies(iTier).add(this);
|
||||
|
||||
tier = iTier;
|
||||
|
||||
requirements = new ItemStack[]
|
||||
{toStack(requirement1),
|
||||
toStack(requirement2),
|
||||
toStack(requirement3)};
|
||||
|
||||
for (Technology t : iPrerequisites) {
|
||||
prerequisites.add(t);
|
||||
t.followups.add(this);
|
||||
}
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public ItemStack getStackToDisplay() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public abstract String getLocalizedName();
|
||||
|
||||
public final ArrayList<Technology> getPrerequisites() {
|
||||
return prerequisites;
|
||||
}
|
||||
|
||||
public final ArrayList<Technology> getFollowups() {
|
||||
return followups;
|
||||
}
|
||||
|
||||
public final ItemStack[] getRequirements() {
|
||||
return requirements;
|
||||
}
|
||||
|
||||
public final Tier getTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
public static Collection<Technology> getTechnologies(Tier tier) {
|
||||
if (registry[tier.ordinal()] == null) {
|
||||
registry[tier.ordinal()] = new LinkedList();
|
||||
}
|
||||
|
||||
return registry[tier.ordinal()];
|
||||
}
|
||||
|
||||
public static ItemStack toStack(Object obj) {
|
||||
if (obj instanceof ItemStack) {
|
||||
return (ItemStack) obj;
|
||||
} else if (obj instanceof Item) {
|
||||
return new ItemStack((Item) obj);
|
||||
} else if (obj instanceof Block) {
|
||||
return new ItemStack((Block) obj);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
58
common/buildcraft/core/science/Tier.java
Executable file
58
common/buildcraft/core/science/Tier.java
Executable file
|
@ -0,0 +1,58 @@
|
|||
/**
|
||||
* Copyright (c) 2011-2014, SpaceToad and the BuildCraft Team
|
||||
* http://www.mod-buildcraft.com
|
||||
*
|
||||
* BuildCraft is distributed under the terms of the Minecraft Mod Public
|
||||
* License 1.0, or MMPL. Please check the contents of the license located in
|
||||
* http://www.mod-buildcraft.com/MMPL-1.0.txt
|
||||
*/
|
||||
package buildcraft.core.science;
|
||||
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import buildcraft.BuildCraftCore;
|
||||
import buildcraft.silicon.ItemRedstoneChipset;
|
||||
|
||||
public enum Tier {
|
||||
WoodenGear,
|
||||
StoneGear,
|
||||
IronGear,
|
||||
GoldenGear,
|
||||
DiamondGear,
|
||||
EmeraldGear,
|
||||
RedstoneCrystalGear,
|
||||
|
||||
Chipset,
|
||||
IronChipset,
|
||||
GoldenChipset,
|
||||
DiamondChipset,
|
||||
EmeraldChipset,
|
||||
RedstoneCrystalChipset,
|
||||
Unrevealed;
|
||||
|
||||
private static ItemStack[] stacksToDisplay;
|
||||
|
||||
public ItemStack getStackToDisplay () {
|
||||
if (stacksToDisplay == null) {
|
||||
stacksToDisplay = new ItemStack[Tier.values().length];
|
||||
|
||||
stacksToDisplay [WoodenGear.ordinal()] = new ItemStack (BuildCraftCore.woodenGearItem);
|
||||
stacksToDisplay [StoneGear.ordinal()] = new ItemStack (BuildCraftCore.stoneGearItem);
|
||||
stacksToDisplay [IronGear.ordinal()] = new ItemStack (BuildCraftCore.ironGearItem);
|
||||
stacksToDisplay [GoldenGear.ordinal()] = new ItemStack (BuildCraftCore.goldGearItem);
|
||||
stacksToDisplay[DiamondGear.ordinal()] = new ItemStack(BuildCraftCore.diamondGearItem);
|
||||
stacksToDisplay [EmeraldGear.ordinal()] = new ItemStack (Blocks.bedrock);
|
||||
stacksToDisplay [RedstoneCrystalGear.ordinal()] = new ItemStack (Blocks.bedrock);
|
||||
stacksToDisplay[Chipset.ordinal()] = ItemRedstoneChipset.Chipset.RED.getStack();
|
||||
stacksToDisplay[IronChipset.ordinal()] = ItemRedstoneChipset.Chipset.IRON.getStack();
|
||||
stacksToDisplay[GoldenChipset.ordinal()] = ItemRedstoneChipset.Chipset.GOLD.getStack();
|
||||
stacksToDisplay[DiamondChipset.ordinal()] = ItemRedstoneChipset.Chipset.DIAMOND.getStack();
|
||||
stacksToDisplay[EmeraldChipset.ordinal()] = ItemRedstoneChipset.Chipset.EMERALD.getStack();
|
||||
stacksToDisplay[RedstoneCrystalChipset.ordinal()] = new ItemStack(Blocks.bedrock);
|
||||
stacksToDisplay[Unrevealed.ordinal()] = new ItemStack(Blocks.bedrock);
|
||||
}
|
||||
|
||||
return stacksToDisplay[ordinal()];
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue