file_name
stringlengths 6
86
| file_path
stringlengths 45
249
| content
stringlengths 47
6.26M
| file_size
int64 47
6.26M
| language
stringclasses 1
value | extension
stringclasses 1
value | repo_name
stringclasses 767
values | repo_stars
int64 8
14.4k
| repo_forks
int64 0
1.17k
| repo_open_issues
int64 0
788
| repo_created_at
stringclasses 767
values | repo_pushed_at
stringclasses 767
values |
---|---|---|---|---|---|---|---|---|---|---|---|
OreDictionarySetup.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/init/OreDictionarySetup.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.init;
import net.minecraftforge.oredict.OreDictionary;
public class OreDictionarySetup {
public static void init() {
OreDictionary.registerOre("oreCopper", BPBlocks.copper_ore);
OreDictionary.registerOre("oreTin", BPBlocks.tin_ore);
OreDictionary.registerOre("oreSilver", BPBlocks.silver_ore);
OreDictionary.registerOre("oreTungsten", BPBlocks.tungsten_ore);
OreDictionary.registerOre("gemRuby", BPItems.ruby);
OreDictionary.registerOre("gemAmethyst", BPItems.amethyst);
OreDictionary.registerOre("gemSapphire", BPItems.sapphire);
OreDictionary.registerOre("dustNikolite", BPItems.nikolite);
OreDictionary.registerOre("ingotCopper", BPItems.copper_ingot);
OreDictionary.registerOre("ingotTin", BPItems.tin_ingot);
OreDictionary.registerOre("ingotSilver", BPItems.silver_ingot);
OreDictionary.registerOre("dyePurple", BPItems.indigo_dye);
}
}
| 1,706 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
Recipes.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/init/Recipes.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.init;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import net.quetzi.bluepower.api.BPRegistry;
import net.quetzi.bluepower.api.part.PartRegistry;
import net.quetzi.bluepower.api.recipe.IAlloyFurnaceRegistry;
import net.quetzi.bluepower.recipe.CanvasBagRecipe;
import net.quetzi.bluepower.references.Refs;
public class Recipes {
public static void init(CraftingManager craftManager) {
GameRegistry.addSmelting(BPBlocks.basalt_cobble, new ItemStack(BPBlocks.basalt), 0);
GameRegistry.addSmelting(BPBlocks.copper_ore, new ItemStack(BPItems.copper_ingot), 0.5F);
GameRegistry.addSmelting(BPBlocks.tin_ore, new ItemStack(BPItems.tin_ingot), 0.5F);
GameRegistry.addSmelting(BPBlocks.silver_ore, new ItemStack(BPItems.silver_ingot), 0.7F);
GameRegistry.addSmelting(BPBlocks.tungsten_block, new ItemStack(BPItems.tungsten_ingot), 0.8F);
GameRegistry.addSmelting(BPBlocks.basalt, new ItemStack(BPBlocks.basalt_tile), 0);
GameRegistry.addSmelting(BPBlocks.marble, new ItemStack(BPBlocks.marble_tile), 0);
GameRegistry.addSmelting(Blocks.stone, new ItemStack(BPItems.stone_wafer, 2), 0);
GameRegistry.addSmelting(BPBlocks.basalt_brick, new ItemStack(BPBlocks.basaltbrick_cracked, 1), 0);
craftManager.addRecipe(new ItemStack(BPBlocks.basalt_brick, 4), new Object[] { "##", "##", '#', BPBlocks.basalt });
craftManager.addRecipe(new ItemStack(BPBlocks.marble_brick, 4), new Object[] { "##", "##", '#', BPBlocks.marble });
craftManager.addRecipe(new ItemStack(BPBlocks.copper_block, 1), new Object[] { "###", "###", "###", '#', BPItems.copper_ingot });
craftManager.addRecipe(new ItemStack(BPBlocks.silver_block, 1), new Object[] { "###", "###", "###", '#', BPItems.silver_ingot });
craftManager.addRecipe(new ItemStack(BPBlocks.tin_block, 1), new Object[] { "###", "###", "###", '#', BPItems.tin_ingot });
craftManager.addRecipe(new ItemStack(BPBlocks.tungsten_block, 1), new Object[] { "###", "###", "###", '#', BPItems.tungsten_ingot });
craftManager.addRecipe(new ItemStack(BPItems.ruby_axe, 1), new Object[] { "GG ", "GS ", " S ", 'G', BPItems.ruby, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.ruby_axe, 1), new Object[] { " GG", " SG", " S ", 'G', BPItems.ruby, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.ruby_pickaxe, 1), new Object[] { "GGG", " S ", " S ", 'G', BPItems.ruby, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.ruby_sword, 1), new Object[] { "G", "G", "S", 'G', BPItems.ruby, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.ruby_spade, 1), new Object[] { "G", "S", "S", 'G', BPItems.ruby, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.ruby_hoe, 1), new Object[] { "GG ", " S ", " S ", 'G', BPItems.ruby, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.ruby_hoe, 1), new Object[] { " GG", " S ", " S ", 'G', BPItems.ruby, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.ruby_sickle, 1), new Object[] { " G ", " G", "SG ", 'G', BPItems.ruby, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.sapphire_axe, 1), new Object[] { "GG ", "GS ", " S ", 'G', BPItems.sapphire, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.sapphire_axe, 1), new Object[] { " GG", " SG", " S ", 'G', BPItems.sapphire, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.sapphire_pickaxe, 1), new Object[] { "GGG", " S ", " S ", 'G', BPItems.sapphire, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.sapphire_sword, 1), new Object[] { "G", "G", "S", 'G', BPItems.sapphire, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.sapphire_spade, 1), new Object[] { "G", "S", "S", 'G', BPItems.sapphire, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.sapphire_hoe, 1), new Object[] { "GG ", " S ", " S ", 'G', BPItems.sapphire, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.sapphire_hoe, 1), new Object[] { " GG", " S ", " S ", 'G', BPItems.sapphire, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.sapphire_sickle, 1), new Object[] { " G ", " G", "SG ", 'G', BPItems.sapphire, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.amethyst_axe, 1), new Object[] { "GG ", "GS ", " S ", 'G', BPItems.amethyst, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.amethyst_axe, 1), new Object[] { " GG", " SG", " S ", 'G', BPItems.amethyst, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.amethyst_pickaxe, 1), new Object[] { "GGG", " S ", " S ", 'G', BPItems.amethyst, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.amethyst_sword, 1), new Object[] { "G", "G", "S", 'G', BPItems.amethyst, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.amethyst_spade, 1), new Object[] { "G", "S", "S", 'G', BPItems.amethyst, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.amethyst_hoe, 1), new Object[] { "GG ", " S ", " S ", 'G', BPItems.amethyst, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.amethyst_hoe, 1), new Object[] { " GG", " S ", " S ", 'G', BPItems.amethyst, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.amethyst_sickle, 1), new Object[] { " G ", " G", "SG ", 'G', BPItems.amethyst, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.wood_sickle, 1), new Object[] { " G ", " G", "SG ", 'G', Blocks.planks, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.stone_sickle, 1), new Object[] { " G ", " G", "SG ", 'G', Blocks.cobblestone, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.iron_sickle, 1), new Object[] { " G ", " G", "SG ", 'G', Items.iron_ingot, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.gold_sickle, 1), new Object[] { " G ", " G", "SG ", 'G', Items.gold_ingot, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.diamond_sickle, 1), new Object[] { " G ", " G", "SG ", 'G', Items.diamond, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.iron_saw, 1), new Object[] { "SSS", " II", " II", 'S', Items.stick, 'I', Items.iron_ingot });
craftManager.addRecipe(new ItemStack(BPItems.ruby_saw, 1), new Object[] { "SSS", " II", " ##", 'S', Items.stick, 'I', Items.iron_ingot, '#', BPItems.ruby });
craftManager.addRecipe(new ItemStack(BPItems.amethyst_saw, 1), new Object[] { "SSS", " II", " ##", 'S', Items.stick, 'I', Items.iron_ingot, '#', BPItems.amethyst });
craftManager.addRecipe(new ItemStack(BPItems.sapphire_saw, 1), new Object[] { "SSS", " II", " ##", 'S', Items.stick, 'I', Items.iron_ingot, '#', BPItems.sapphire });
craftManager.addRecipe(new ItemStack(BPItems.diamond_saw, 1), new Object[] { "SSS", " II", " ##", 'S', Items.stick, 'I', Items.iron_ingot, '#', Items.diamond });
craftManager.addRecipe(new ItemStack(BPItems.indigo_dye, 1), new Object[] { "#", '#', BPBlocks.indigo_flower });
craftManager.addRecipe(new ItemStack(BPBlocks.basalt_brick_small, 4), new Object[] { "##", "##", '#', BPBlocks.basalt_brick });
craftManager.addRecipe(new ItemStack(BPBlocks.marble_brick_small, 4), new Object[] { "##", "##", '#', BPBlocks.marble_brick });
craftManager.addRecipe(new ItemStack(BPBlocks.basalt_brick, 1), new Object[] { "#", '#', BPBlocks.basalt_brick_small });
craftManager.addRecipe(new ItemStack(BPBlocks.marble_brick, 1), new Object[] { "#", '#', BPBlocks.marble_brick_small });
craftManager.addRecipe(new ItemStack(BPBlocks.fancy_basalt, 1), new Object[] { "#", '#', BPBlocks.basalt_brick });
craftManager.addRecipe(new ItemStack(BPBlocks.fancy_marble, 1), new Object[] { "#", '#', BPBlocks.marble_brick });
craftManager.addRecipe(new ItemStack(BPItems.amethyst, 9), new Object[] { "#", '#', BPBlocks.amethyst_block });
craftManager.addRecipe(new ItemStack(BPItems.sapphire, 9), new Object[] { "#", '#', BPBlocks.sapphire_block });
craftManager.addRecipe(new ItemStack(BPItems.ruby, 9), new Object[] { "#", '#', BPBlocks.ruby_block });
craftManager.addRecipe(new ItemStack(BPItems.silver_ingot, 9), new Object[] { "#", '#', BPBlocks.silver_block });
craftManager.addRecipe(new ItemStack(BPItems.copper_ingot, 9), new Object[] { "#", '#', BPBlocks.copper_block });
craftManager.addRecipe(new ItemStack(BPItems.tin_ingot, 9), new Object[] { "#", '#', BPBlocks.tin_block });
craftManager.addRecipe(new ItemStack(BPItems.tungsten_ingot, 9), new Object[] { " # ", '#', BPBlocks.tungsten_block });
if (Config.useAltScrewdriverRecipe) {
craftManager.addRecipe(new ItemStack(BPItems.screwdriver_handle), new Object[] { "#", '#', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.screwdriver, 1), new Object[] { "# ", " S", '#', Items.iron_ingot, 'S', BPItems.screwdriver_handle });
} else {
craftManager.addRecipe(new ItemStack(BPItems.screwdriver, 1), new Object[] { "# ", " S", '#', Items.iron_ingot, 'S', Items.stick });
}
craftManager.addRecipe(new ItemStack(BPItems.athame, 1), new Object[] { "# ", " S", '#', BPItems.silver_ingot, 'S', Items.stick });
craftManager.addRecipe(new ItemStack(BPItems.stone_wire, 1), new Object[] { "#", "W", '#', Items.redstone, 'W', BPItems.stone_wafer });
craftManager.addRecipe(new ItemStack(BPItems.stone_anode, 3), new Object[] { " # ", "###", "WWW", '#', Items.redstone, 'W', BPItems.stone_wafer });
craftManager.addRecipe(new ItemStack(BPItems.stone_cathode, 1), new Object[] { "#", "W", '#', Blocks.redstone_torch, 'W', BPItems.stone_wafer });
craftManager.addRecipe(new ItemStack(BPItems.stone_pointer, 1), new Object[] { "S", "#", "W", 'S', Blocks.stone, '#', Blocks.redstone_torch, 'W', BPItems.stone_wafer });
craftManager.addRecipe(new ItemStack(BPItems.silicon_chip, 1), new Object[] { " # ", "WWW", '#', BPItems.red_doped_wafer, 'W', BPItems.stone_wafer });
craftManager.addRecipe(new ItemStack(BPItems.plate_assembly, 1), new Object[] { " # ", "SRS", "#C#", '#', BPItems.stone_wafer, 'S', Items.stick, 'R', BPItems.red_alloy_ingot, 'C', BPItems.stone_cathode });
craftManager.addShapelessRecipe(new ItemStack(BPItems.taintedsilicon_chip, 1), new Object[] { BPItems.silicon_chip, Items.glowstone_dust });
// TODO: stone_redwire recipe and stone_bundle recipe
craftManager.addRecipe(PartRegistry.getItemForPart("and"), new Object[] { "ACA", "CCC", "#W#", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire });
craftManager.addRecipe(PartRegistry.getItemForPart("buffer"), new Object[] { "ACA", "WCW", "#W#", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire });
// craftManager.addRecipe(PartRegistry.getItemForPart("bustransceiver"), new Object[] {"BBB", "N#N", "BBB", '#', BPItems.stone_wafer, 'B', BPItems.stone_bundle, 'N', BPItems.red_doped_wafer});
craftManager.addRecipe(PartRegistry.getItemForPart("counter"), new Object[] { "#W#", "CPC", "#W#", '#', BPItems.stone_wafer, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire, 'P', BPItems.stone_pointer });
// craftManager.addRecipe(PartRegistry.getItemForPart("invert"), new Object[] {"#R#", "ROR", "#R#", '#', BPItems.stone_wafer, 'O', BPItems.plate_assembly, 'R', BPItems.stone_redwire});
// craftManager.addRecipe(PartRegistry.getItemForPart("light"), new Object[] {"#W#", "#B#", "###", '#', BPItems.stone_wafer, 'B', BPItems.blue_doped_wafer, 'W', BPItems.stone_wire});
craftManager.addRecipe(PartRegistry.getItemForPart("multiplexer"), new Object[] { "ACA", "C#C", "ACW", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire });
// craftManager.addRecipe(PartRegistry.getItemForPart("nand"), new Object[] {"AAA", "CCC", "#W#", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire});
// craftManager.addRecipe(PartRegistry.getItemForPart("noninvert"), new Object[] {"#R#", "ROR", "#RC", '#', BPItems.stone_wafer, 'C', BPItems.stone_cathode, 'O', BPItems.plate_assembly, 'R', BPItems.stone_redwire});
craftManager.addRecipe(PartRegistry.getItemForPart("nor"), new Object[] {"#A#", "WCW", "#W#", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire});
craftManager.addRecipe(PartRegistry.getItemForPart("not"), new Object[] { "#A#", "ACA", "#W#", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire });
// craftManager.addRecipe(PartRegistry.getItemForPart("null"), new Object[] {"#R#", "RRR", "#R#", '#', BPItems.stone_wafer, 'R', BPItems.stone_redwire});
craftManager.addRecipe(PartRegistry.getItemForPart("or"), new Object[] {"#C#", "WCW", "#W#", '#', BPItems.stone_wafer, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire});
craftManager.addRecipe(PartRegistry.getItemForPart("pulseformer"), new Object[] {"ACA", "CAC", "WW#", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire});
craftManager.addRecipe(PartRegistry.getItemForPart("randomizer"), new Object[] {"#T#", "WWW", "TWT", '#', BPItems.stone_wafer, 'T', BPItems.taintedsilicon_chip, 'W', BPItems.stone_wire});
// craftManager.addRecipe(PartRegistry.getItemForPart("repeater"), new Object[] {"#CW", "#AW", "#WC", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire});
// craftManager.addRecipe(PartRegistry.getItemForPart("rs"), new Object[] {"WWA", "C#C", "AWW", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire});
craftManager.addRecipe(PartRegistry.getItemForPart("sequencer"), new Object[] { "#C#", "CPC", "#C#", '#', BPItems.stone_wafer, 'C', BPItems.stone_cathode, 'P', BPItems.stone_pointer });
// craftManager.addRecipe(PartRegistry.getItemForPart("state"), new Object[] {"#AC", "WXP", "#W#", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'P', BPItems.stone_pointer, 'W', BPItems.stone_wire, 'X', BPItems.silicon_chip});
// craftManager.addRecipe(PartRegistry.getItemForPart("synchronizer"), new Object[] {"WCW", "XAX", "WWW", '#', 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire, 'X', BPItems.silicon_chip});
craftManager.addRecipe(PartRegistry.getItemForPart("timer"), new Object[] { "#W#", "WPW", "ACA", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire, 'P', BPItems.stone_pointer });
// craftManager.addRecipe(PartRegistry.getItemForPart("toggle"), new Object[] {"#C#", "WLW", "#C#", '#', BPItems.stone_wafer, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire, 'L', Blocks.lever});
// craftManager.addRecipe(PartRegistry.getItemForPart("transparent"), new Object[] {"ACW", "CCC", "CW#", '#', BPItems.stone_wafer, 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire});
// craftManager.addRecipe(PartRegistry.getItemForPart("xnor"), new Object[] {"ACA", "CAC", "WCW", 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire});
// craftManager.addRecipe(PartRegistry.getItemForPart("xor"), new Object[] {"AWA", "CAC", "WCW", 'A', BPItems.stone_anode, 'C', BPItems.stone_cathode, 'W', BPItems.stone_wire});
craftManager.addRecipe(PartRegistry.getItemForPart("pneumaticTube", 8), new Object[] {"BGB", 'B', BPItems.brass_ingot, 'G', Blocks.glass});
craftManager.addRecipe(new ItemStack(BPBlocks.alloy_furnace, 1), new Object[] { "###", "# #", "###", '#', Blocks.brick_block });
craftManager.addRecipe(new ItemStack(BPBlocks.block_breaker, 1), new Object[] { "#A#", "#P#", "#R#", '#', Blocks.cobblestone, 'A', Items.iron_pickaxe, 'P', Blocks.piston, 'R', Items.redstone });
craftManager.addRecipe(new ItemStack(BPBlocks.buffer, 1), new Object[] { "#P#", "P P", "#P#", '#', Blocks.iron_bars, 'P', Blocks.planks });
craftManager.addRecipe(new ItemStack(BPBlocks.ejector, 1), new Object[] { "PBP", "PTP", "#R#", '#', Blocks.cobblestone, 'P', Blocks.planks, 'B', BPBlocks.buffer, 'T', BPBlocks.transposer, 'R', Items.redstone });
craftManager.addRecipe(new ItemStack(BPBlocks.relay, 1), new Object[] { "PBP", "PTP", "#W#", '#', Blocks.cobblestone, 'P', Blocks.planks, 'B', BPBlocks.buffer, 'T', BPBlocks.transposer, 'W', BPItems.red_doped_wafer });
craftManager.addRecipe(new ItemStack(BPBlocks.transposer, 1), new Object[] { "###", "WPW", "#R#", '#', Blocks.cobblestone, 'P', Blocks.piston, 'R', Items.redstone });
craftManager.addRecipe(new ItemStack(BPItems.canvas, 1), new Object[] { "SSS", "S S", "SSS", 'S', Items.string });
craftManager.addRecipe(new ItemStack(BPItems.seedBag, 1), new Object[] { " S ", "C C", "CCC", 'S', Items.string, 'C', BPItems.canvas });
craftManager.addRecipe(new ItemStack(BPItems.canvas_bag, 1, 0), new Object[] { "SSS", "S S", "SSS", 'S', BPItems.canvas });
registerCanvasBagRecipes(new ItemStack(BPItems.canvas_bag));
craftManager.addShapelessRecipe(new ItemStack(BPItems.copper_wire, 1), new Object[] { BPItems.diamond_drawplate, BPItems.copper_ingot });
craftManager.addShapelessRecipe(new ItemStack(BPItems.iron_wire, 1), new Object[] { BPItems.diamond_drawplate, Items.iron_ingot });
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(Items.string, 4, 0), new ItemStack(BPItems.wool_card, 1, OreDictionary.WILDCARD_VALUE), new ItemStack(Blocks.wool, 1, OreDictionary.WILDCARD_VALUE)));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(BPItems.wool_card, 1, 0), "f", "p", "s", 'f', BPItems.iron_wire, 'p', "plankWood", 's', "stickWood"));
for (int i = 0; i < Refs.oreDictDyes.length; i++) {
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(BPItems.lumar, 2, 15 - i), new ItemStack(Items.redstone, 1), new ItemStack(Items.glowstone_dust, 1), Refs.oreDictDyes[i], Refs.oreDictDyes[i]));
// block lamp recipe (change when made into actual block)
craftManager.addRecipe(PartRegistry.getItemForPart("lamp" + ItemDye.field_150921_b[i].toLowerCase()), new Object[] { "gLg", "gLg", "gRg", 'g', Blocks.glass_pane, 'L', new ItemStack(BPItems.lumar, 1, 15 - i), 'R', Items.redstone });
craftManager.addRecipe(PartRegistry.getItemForPart("invertedlamp" + ItemDye.field_150921_b[i].toLowerCase()), new Object[] { "gLg", "gLg", "gRg", 'g', Blocks.glass_pane, 'L', new ItemStack(BPItems.lumar, 1, 15 - i), 'R', Blocks.redstone_torch });
// other multipart lamps
craftManager.addRecipe(PartRegistry.getItemForPart("fixture" + ItemDye.field_150921_b[i].toLowerCase()), new Object[] { "gLg", "gLg", "sRs", 'g', Blocks.glass_pane, 's', new ItemStack(Blocks.stone_slab, 1, 0), 'L', new ItemStack(BPItems.lumar, 1, 15 - i), 'R', Items.redstone });
craftManager.addRecipe(PartRegistry.getItemForPart("invertedfixture" + ItemDye.field_150921_b[i].toLowerCase()), new Object[] { "gLg", "gLg", "sRs", 'g', Blocks.glass_pane, 's', new ItemStack(Blocks.stone_slab, 1, 0), 'L', new ItemStack(BPItems.lumar, 1, 15 - i), 'R',
Blocks.redstone_torch });
craftManager.addRecipe(PartRegistry.getItemForPart("cagelamp" + ItemDye.field_150921_b[i].toLowerCase()), new Object[] { "cLc", "gLg", "sRs", 'g', Blocks.glass_pane, 'c', Blocks.iron_bars, 's', new ItemStack(Blocks.stone_slab, 1, 0), 'L', new ItemStack(BPItems.lumar, 1, 15 - i), 'R',
Items.redstone });
craftManager.addRecipe(PartRegistry.getItemForPart("invertedcagelamp" + ItemDye.field_150921_b[i].toLowerCase()), new Object[] { "cLc", "gLg", "sRs", 'g', Blocks.glass_pane, 'c', Blocks.iron_bars, 's', new ItemStack(Blocks.stone_slab, 1, 0), 'L', new ItemStack(BPItems.lumar, 1, 15 - i),
'R', Blocks.redstone_torch });
}
// Alloy furnace
IAlloyFurnaceRegistry af = BPRegistry.alloyFurnaceRegistry;
af.addRecipe(new ItemStack(BPItems.red_alloy_ingot, 1), new ItemStack(Items.redstone, 4), Items.iron_ingot);
af.addRecipe(new ItemStack(BPItems.red_alloy_ingot, 1), new ItemStack(Items.redstone, 4), BPItems.copper_ingot);
af.addRecipe(new ItemStack(BPItems.brass_ingot, 4), new ItemStack(BPItems.copper_ingot, 3), BPItems.tin_ingot);
af.addRecipe(new ItemStack(BPItems.blue_alloy_ingot, 1), new ItemStack(BPItems.nikolite, 4), BPItems.silver_ingot);
af.addRecipe(new ItemStack(BPItems.silicon_boule, 1), new ItemStack(Items.coal, 8), new ItemStack(Blocks.sand, 8));
af.addRecipe(new ItemStack(BPItems.red_doped_wafer, 1), new ItemStack(Items.redstone, 4), BPItems.silicon_wafer);
af.addRecipe(new ItemStack(BPItems.blue_doped_wafer, 1), new ItemStack(BPItems.nikolite, 4), BPItems.silicon_wafer);
af.addRecipe(new ItemStack(BPItems.tinplate, 4), new ItemStack(BPItems.tin_ingot, 1), new ItemStack(Items.iron_ingot, 2));
af.addRecyclingRecipe(new ItemStack(Blocks.iron_block));
af.addRecyclingRecipe(new ItemStack(Blocks.gold_block));
af.addRecyclingRecipe(new ItemStack(Items.iron_ingot));
af.addRecyclingRecipe(new ItemStack(Items.gold_ingot));
af.addRecyclingRecipe(new ItemStack(Items.gold_nugget));
}
private static void registerCanvasBagRecipes(ItemStack is) {
for (int damage = Refs.oreDictDyes.length - 1; damage >= 0; damage--) {
ItemStack input = is.copy();
input.setItemDamage(15 - damage);
for (int dye = 0; dye < Refs.oreDictDyes.length; dye++) {
if (15 - dye != input.getItemDamage()) {
ItemStack output = is.copy();
output.setItemDamage(15 - dye);
GameRegistry.addRecipe(new CanvasBagRecipe(output, input, Refs.oreDictDyes[dye]));
}
}
}
}
}
| 24,024 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BPItems.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/init/BPItems.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.init;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.common.registry.GameRegistry;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.Item.ToolMaterial;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.util.EnumHelper;
import net.quetzi.bluepower.compat.fmp.ItemBPMultipart;
import net.quetzi.bluepower.items.*;
import net.quetzi.bluepower.part.ItemBPPart;
import net.quetzi.bluepower.references.Dependencies;
import net.quetzi.bluepower.references.Refs;
public class BPItems {
public static Item amethyst;
public static Item sapphire;
public static Item ruby;
public static Item nikolite;
public static Item copper_ingot;
public static Item silver_ingot;
public static Item tin_ingot;
public static Item brass_ingot;
public static Item blue_alloy_ingot;
public static Item red_alloy_ingot;
public static Item tungsten_ingot;
public static Item ruby_axe;
public static Item ruby_sword;
public static Item ruby_pickaxe;
public static Item ruby_spade;
public static Item ruby_hoe;
public static Item ruby_sickle;
public static Item ruby_saw;
public static Item sapphire_axe;
public static Item sapphire_sword;
public static Item sapphire_pickaxe;
public static Item sapphire_spade;
public static Item sapphire_hoe;
public static Item sapphire_sickle;
public static Item sapphire_saw;
public static Item amethyst_axe;
public static Item amethyst_sword;
public static Item amethyst_pickaxe;
public static Item amethyst_spade;
public static Item amethyst_hoe;
public static Item amethyst_sickle;
public static Item amethyst_saw;
public static Item wood_sickle;
public static Item stone_sickle;
public static Item iron_sickle;
public static Item gold_sickle;
public static Item diamond_sickle;
public static Item iron_saw;
public static Item diamond_saw;
public static Item flax_seed;
public static Item indigo_dye;
public static Item silicon_boule;
public static Item silicon_wafer;
public static Item multipart;
public static Item red_doped_wafer;
public static Item blue_doped_wafer;
public static Item screwdriver;
public static Item athame;
public static Item tinplate;
public static Item stone_wafer;
public static Item stone_wire;
public static Item stone_anode;
public static Item stone_cathode;
public static Item stone_pointer;
public static Item silicon_chip;
public static Item taintedsilicon_chip;
public static Item stone_redwire;
public static Item plate_assembly;
public static Item stone_bundle;
public static Item screwdriver_handle;
public static Item seedBag;
public static Item canvas_bag;
public static Item canvas;
public static Item lumar;
public static Item wool_card;
public static Item diamond_drawplate;
public static Item copper_wire;
public static Item iron_wire;
private static ToolMaterial gemMaterial = EnumHelper.addToolMaterial("GEM", 2, 750, 6.0F, 2.0F, 18);
public static void init() {
amethyst = new ItemGem(Refs.AMETHYST_NAME);
sapphire = new ItemGem(Refs.SAPPHIRE_NAME);
ruby = new ItemGem(Refs.RUBY_NAME);
nikolite = new ItemNikolite();
copper_ingot = new ItemIngot(Refs.COPPERINGOT_NAME);
silver_ingot = new ItemIngot(Refs.SILVERINGOT_NAME);
tin_ingot = new ItemIngot(Refs.TININGOT_NAME);
tungsten_ingot = new ItemIngot(Refs.TUNGSTENINGOT_NAME);
brass_ingot = new ItemIngot(Refs.BRASSINGOT_NAME);
blue_alloy_ingot = new ItemIngot(Refs.BLUEALLOYINGOT_NAME);
red_alloy_ingot = new ItemIngot(Refs.REDALLOYINGOT_NAME);
ruby_axe = new ItemGemAxe(gemMaterial, Refs.RUBYAXE_NAME);
ruby_sword = new ItemGemSword(gemMaterial, Refs.RUBYSWORD_NAME);
ruby_pickaxe = new ItemGemPickaxe(gemMaterial, Refs.RUBYPICKAXE_NAME);
ruby_spade = new ItemGemSpade(gemMaterial, Refs.RUBYSPADE_NAME);
ruby_hoe = new ItemGemHoe(gemMaterial, Refs.RUBYHOE_NAME);
ruby_sickle = new ItemSickle(gemMaterial, Refs.RUBYSICKLE_NAME);
sapphire_axe = new ItemGemAxe(gemMaterial, Refs.SAPPHIREAXE_NAME);
sapphire_sword = new ItemGemSword(gemMaterial, Refs.SAPPHIRESWORD_NAME);
sapphire_pickaxe = new ItemGemPickaxe(gemMaterial, Refs.SAPPHIREPICKAXE_NAME);
sapphire_spade = new ItemGemSpade(gemMaterial, Refs.SAPPHIRESPADE_NAME);
sapphire_hoe = new ItemGemHoe(gemMaterial, Refs.SAPPHIREHOE_NAME);
sapphire_sickle = new ItemSickle(gemMaterial, Refs.SAPPHIRESICKLE_NAME);
amethyst_axe = new ItemGemAxe(gemMaterial, Refs.AMETHYSTAXE_NAME);
amethyst_sword = new ItemGemSword(gemMaterial, Refs.AMETHYSTSWORD_NAME);
amethyst_pickaxe = new ItemGemPickaxe(gemMaterial, Refs.AMETHYSTPICKAXE_NAME);
amethyst_spade = new ItemGemSpade(gemMaterial, Refs.AMETHYSTSPADE_NAME);
amethyst_hoe = new ItemGemHoe(gemMaterial, Refs.AMETHYSTHOE_NAME);
amethyst_sickle = new ItemSickle(gemMaterial, Refs.AMETHYSTSICKLE_NAME);
wood_sickle = new ItemSickle(ToolMaterial.WOOD, Refs.WOODSICKLE_NAME);
stone_sickle = new ItemSickle(ToolMaterial.STONE, Refs.STONESICKLE_NAME);
iron_sickle = new ItemSickle(ToolMaterial.IRON, Refs.IRONSICKLE_NAME);
gold_sickle = new ItemSickle(ToolMaterial.GOLD, Refs.GOLDSICKLE_NAME);
diamond_sickle = new ItemSickle(ToolMaterial.EMERALD, Refs.DIAMONDSICKLE_NAME);
flax_seed = new ItemCropSeed(BPBlocks.flax_crop, Blocks.farmland).setUnlocalizedName(Refs.FLAXSEED_NAME);
indigo_dye = new ItemIndigoDye(Refs.INDIGODYE_NAME);
ruby_saw = new ItemSaw(1, Refs.RUBYSAW_NAME);
amethyst_saw = new ItemSaw(1, Refs.AMETHYSTSAW_NAME);
sapphire_saw = new ItemSaw(1, Refs.SAPPHIRESAW_NAME);
iron_saw = new ItemSaw(1, Refs.IRONSAW_NAME);
diamond_saw = new ItemSaw(2, Refs.DIAMONDSAW_NAME);
silicon_boule = new ItemSiliconBoule(Refs.SILICONBOULE_NAME);
silicon_wafer = new ItemSiliconWafer(Refs.SILICONWAFER_NAME);
blue_doped_wafer = new ItemSiliconWafer(Refs.BLUEDOPEDWAFER_NAME);
red_doped_wafer = new ItemSiliconWafer(Refs.REDDOPEDWAFER_NAME);
screwdriver = new ItemScrewdriver();
athame = new ItemAthame();
tinplate = new ItemTinPlate();
stone_wafer = new ItemCrafting(Refs.STONEWAFER_NAME);
stone_wire = new ItemCrafting(Refs.STONEWIRE_NAME);
stone_anode = new ItemCrafting(Refs.STONEANODE_NAME);
stone_cathode = new ItemCrafting(Refs.STONECATHODE_NAME);
stone_pointer = new ItemCrafting(Refs.STONEPOINTER_NAME);
silicon_chip = new ItemCrafting(Refs.SILICONCHIP_NAME);
taintedsilicon_chip = new ItemCrafting(Refs.TAINTEDSILICONCHIP_NAME);
stone_redwire = new ItemCrafting(Refs.STONEREDWIRE_NAME);
plate_assembly = new ItemCrafting(Refs.PLATEASSEMBLY_NAME);
stone_bundle = new ItemCrafting(Refs.STONEBUNDLE_NAME);
screwdriver_handle = new ItemHandle(Refs.SCREWDRIVERHANDLE_NAME);
seedBag = new ItemSeedBag(Refs.SEEDBAG_NAME);
canvas_bag = new ItemCanvasBag(Refs.CANVASBAG_NAME);
canvas = new ItemCrafting(Refs.CANVAS_NAME);
lumar = new ItemLumar();
copper_wire = new ItemCrafting(Refs.COPPERWIRE_NAME);
iron_wire = new ItemCrafting(Refs.IRONWIRE_NAME);
wool_card = new ItemLimitedCrafting(Refs.WOOLCARD_NAME,64);
diamond_drawplate = new ItemLimitedCrafting(Refs.DIAMONDDRAWPLATE_NAME,256);
if (!Loader.isModLoaded(Dependencies.FMP)) {
multipart = new ItemBPPart();
} else {
initFMP();
}
registerItems();
}
@Optional.Method(modid = Dependencies.FMP)
private static void initFMP() {
multipart = new ItemBPMultipart();
}
public static void registerItems() {
GameRegistry.registerItem(amethyst, Refs.AMETHYST_NAME);
GameRegistry.registerItem(sapphire, Refs.SAPPHIRE_NAME);
GameRegistry.registerItem(ruby, Refs.RUBY_NAME);
GameRegistry.registerItem(nikolite, Refs.NIKOLITE_NAME);
GameRegistry.registerItem(copper_ingot, Refs.COPPERINGOT_NAME);
GameRegistry.registerItem(silver_ingot, Refs.SILVERINGOT_NAME);
GameRegistry.registerItem(tin_ingot, Refs.TININGOT_NAME);
GameRegistry.registerItem(tungsten_ingot, Refs.TUNGSTENINGOT_NAME);
GameRegistry.registerItem(brass_ingot, Refs.BRASSINGOT_NAME);
GameRegistry.registerItem(blue_alloy_ingot, Refs.BLUEALLOYINGOT_NAME);
GameRegistry.registerItem(red_alloy_ingot, Refs.REDALLOYINGOT_NAME);
GameRegistry.registerItem(ruby_axe, Refs.RUBYAXE_NAME);
GameRegistry.registerItem(ruby_sword, Refs.RUBYSWORD_NAME);
GameRegistry.registerItem(ruby_pickaxe, Refs.RUBYPICKAXE_NAME);
GameRegistry.registerItem(ruby_spade, Refs.RUBYSPADE_NAME);
GameRegistry.registerItem(ruby_hoe, Refs.RUBYHOE_NAME);
GameRegistry.registerItem(ruby_sickle, Refs.RUBYSICKLE_NAME);
GameRegistry.registerItem(sapphire_axe, Refs.SAPPHIREAXE_NAME);
GameRegistry.registerItem(sapphire_sword, Refs.SAPPHIRESWORD_NAME);
GameRegistry.registerItem(sapphire_pickaxe, Refs.SAPPHIREPICKAXE_NAME);
GameRegistry.registerItem(sapphire_spade, Refs.SAPPHIRESPADE_NAME);
GameRegistry.registerItem(sapphire_hoe, Refs.SAPPHIREHOE_NAME);
GameRegistry.registerItem(sapphire_sickle, Refs.SAPPHIRESICKLE_NAME);
GameRegistry.registerItem(amethyst_axe, Refs.AMETHYSTAXE_NAME);
GameRegistry.registerItem(amethyst_sword, Refs.AMETHYSTSWORD_NAME);
GameRegistry.registerItem(amethyst_pickaxe, Refs.AMETHYSTPICKAXE_NAME);
GameRegistry.registerItem(amethyst_spade, Refs.AMETHYSTSPADE_NAME);
GameRegistry.registerItem(amethyst_hoe, Refs.AMETHYSTHOE_NAME);
GameRegistry.registerItem(amethyst_sickle, Refs.AMETHYSTSICKLE_NAME);
GameRegistry.registerItem(wood_sickle, Refs.WOODSICKLE_NAME);
GameRegistry.registerItem(stone_sickle, Refs.STONESICKLE_NAME);
GameRegistry.registerItem(iron_sickle, Refs.IRONSICKLE_NAME);
GameRegistry.registerItem(gold_sickle, Refs.GOLDSICKLE_NAME);
GameRegistry.registerItem(diamond_sickle, Refs.DIAMONDSICKLE_NAME);
GameRegistry.registerItem(iron_saw, Refs.IRONSAW_NAME);
GameRegistry.registerItem(diamond_saw, Refs.DIAMONDSAW_NAME);
GameRegistry.registerItem(ruby_saw, Refs.RUBYSAW_NAME);
GameRegistry.registerItem(sapphire_saw, Refs.SAPPHIRESAW_NAME);
GameRegistry.registerItem(amethyst_saw, Refs.AMETHYSTSAW_NAME);
GameRegistry.registerItem(flax_seed, Refs.FLAXSEED_NAME);
GameRegistry.registerItem(indigo_dye, Refs.INDIGODYE_NAME);
GameRegistry.registerItem(silicon_boule, Refs.SILICONBOULE_NAME);
GameRegistry.registerItem(silicon_wafer, Refs.SILICONWAFER_NAME);
GameRegistry.registerItem(blue_doped_wafer, Refs.BLUEDOPEDWAFER_NAME);
GameRegistry.registerItem(red_doped_wafer, Refs.REDDOPEDWAFER_NAME);
GameRegistry.registerItem(screwdriver, Refs.SCREWDRIVER_NAME);
GameRegistry.registerItem(athame, Refs.ATHAME_NAME);
GameRegistry.registerItem(tinplate, Refs.TINPLATE_NAME);
GameRegistry.registerItem(stone_wafer, Refs.STONEWAFER_NAME);
GameRegistry.registerItem(stone_wire, Refs.STONEWIRE_NAME);
GameRegistry.registerItem(stone_anode, Refs.STONEANODE_NAME);
GameRegistry.registerItem(stone_cathode, Refs.STONECATHODE_NAME);
GameRegistry.registerItem(stone_pointer, Refs.STONEPOINTER_NAME);
GameRegistry.registerItem(silicon_chip, Refs.SILICONCHIP_NAME);
GameRegistry.registerItem(taintedsilicon_chip, Refs.TAINTEDSILICONCHIP_NAME);
GameRegistry.registerItem(stone_redwire, Refs.STONEREDWIRE_NAME);
GameRegistry.registerItem(plate_assembly, Refs.PLATEASSEMBLY_NAME);
GameRegistry.registerItem(stone_bundle, Refs.STONEBUNDLE_NAME);
GameRegistry.registerItem(screwdriver_handle, Refs.SCREWDRIVERHANDLE_NAME);
GameRegistry.registerItem(seedBag, Refs.SEEDBAG_NAME);
GameRegistry.registerItem(canvas_bag, Refs.CANVASBAG_NAME);
GameRegistry.registerItem(canvas, Refs.CANVAS_NAME);
GameRegistry.registerItem(lumar, Refs.LUMAR_NAME);
GameRegistry.registerItem(wool_card, Refs.WOOLCARD_NAME);
GameRegistry.registerItem(diamond_drawplate, Refs.DIAMONDDRAWPLATE_NAME);
GameRegistry.registerItem(copper_wire, Refs.COPPERWIRE_NAME);
GameRegistry.registerItem(iron_wire, Refs.IRONWIRE_NAME);
MinecraftForge.addGrassSeed(new ItemStack(flax_seed), 5);
GameRegistry.registerItem(multipart, Refs.MULTIPART_NAME);
}
}
| 14,405 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BPBlocks.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/init/BPBlocks.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.init;
import net.minecraft.block.Block;
import net.minecraft.item.ItemDye;
import net.quetzi.bluepower.blocks.BlockItemOre;
import net.quetzi.bluepower.blocks.computer.BlockCPU;
import net.quetzi.bluepower.blocks.computer.BlockDiskDrive;
import net.quetzi.bluepower.blocks.computer.BlockIOExpander;
import net.quetzi.bluepower.blocks.computer.BlockMonitor;
import net.quetzi.bluepower.blocks.machines.*;
import net.quetzi.bluepower.blocks.machines.BlockKineticGenerator;
import net.quetzi.bluepower.blocks.worldgen.BlockCrackedBasalt;
import net.quetzi.bluepower.blocks.worldgen.BlockCrop;
import net.quetzi.bluepower.blocks.worldgen.BlockCustomFlower;
import net.quetzi.bluepower.blocks.worldgen.BlockStoneOre;
import net.quetzi.bluepower.blocks.worldgen.BlockStoneOreConnected;
import net.quetzi.bluepower.references.Dependencies;
import net.quetzi.bluepower.references.Refs;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.registry.GameRegistry;
public class BPBlocks {
public static Block basalt;
public static Block marble;
public static Block basalt_cobble;
public static Block basalt_brick;
public static Block marble_brick;
public static Block cracked_basalt;
public static Block basaltbrick_cracked;
public static Block basalt_brick_small;
public static Block marble_brick_small;
public static Block fancy_basalt;
public static Block fancy_marble;
public static Block marble_tile;
public static Block basalt_tile;
public static Block marble_paver;
public static Block basalt_paver;
public static Block nikolite_ore;
public static Block ruby_ore;
public static Block sapphire_ore;
public static Block amethyst_ore;
public static Block copper_ore;
public static Block silver_ore;
public static Block tin_ore;
public static Block tungsten_ore;
public static Block ruby_block;
public static Block sapphire_block;
public static Block amethyst_block;
public static Block nikolite_block;
public static Block copper_block;
public static Block silver_block;
public static Block tin_block;
public static Block tungsten_block;
public static Block flax_crop;
public static Block indigo_flower;
public static Block alloy_furnace;
public static Block block_breaker;
public static Block igniter;
public static Block buffer;
public static Block Deployer;
public static Block transposer;
public static Block sorting_machine;
public static Block sortron;
public static Block project_table;
public static Block ejector;
public static Block relay;
public static Block cpu;
public static Block monitor;
public static Block disk_drive;
public static Block io_expander;
public static Block multipart; // DO NOT GENERATE OR REMOVE THIS BLOCK!
public static Block engine;
public static Block kinetic_generator;
public static Block windmill;
public static Block[] blockLamp;
public static Block[] blockLampInverted;
public static void init() {
basalt = new BlockStoneOre(Refs.BASALT_NAME);
marble = new BlockStoneOre(Refs.MARBLE_NAME);
basalt_cobble = new BlockStoneOre(Refs.BASALTCOBBLE_NAME);
basalt_brick = new BlockStoneOre(Refs.BASALTBRICK_NAME);
marble_brick = new BlockStoneOre(Refs.MARBLEBRICK_NAME);
cracked_basalt = new BlockCrackedBasalt(Refs.CRACKED_BASALT);
basaltbrick_cracked = new BlockStoneOre(Refs.CRACKEDBASALTBRICK_NAME);
basalt_brick_small = new BlockStoneOre(Refs.SMALLBASALTBRICK_NAME);
marble_brick_small = new BlockStoneOre(Refs.SMALLMARBLEBRICK_NAME);
fancy_basalt = new BlockStoneOre(Refs.CHISELEDBASALTBRICK_NAME);
fancy_marble = new BlockStoneOre(Refs.CHISELEDMARBLEBRICK_NAME);
marble_tile = new BlockStoneOreConnected(Refs.MARBLETILE_NAME);
basalt_tile = new BlockStoneOreConnected(Refs.BASALTTILE_NAME);
marble_paver = new BlockStoneOre(Refs.MARBLEPAVER_NAME);
basalt_paver = new BlockStoneOre(Refs.BASALTPAVER_NAME);
nikolite_ore = new BlockItemOre(Refs.NIKOLITEORE_NAME);
ruby_ore = new BlockItemOre(Refs.RUBYORE_NAME);
sapphire_ore = new BlockItemOre(Refs.SAPPHIREORE_NAME);
amethyst_ore = new BlockItemOre(Refs.AMETHYSTORE_NAME);
copper_ore = new BlockStoneOre(Refs.COPPERORE_NAME);
silver_ore = new BlockStoneOre(Refs.SILVERORE_NAME);
tin_ore = new BlockStoneOre(Refs.TINORE_NAME);
tungsten_ore = new BlockStoneOre(Refs.TUNGSTENORE_NAME);
ruby_block = new BlockStoneOre(Refs.RUBYBLOCK_NAME);
sapphire_block = new BlockStoneOre(Refs.SAPPHIREBLOCK_NAME);
amethyst_block = new BlockStoneOre(Refs.AMETHYSTBLOCK_NAME);
nikolite_block = new BlockStoneOre(Refs.NIKOLITEBLOCK_NAME);
copper_block = new BlockStoneOre(Refs.COPPERBLOCK_NAME);
silver_block = new BlockStoneOre(Refs.SILVERBLOCK_NAME);
tin_block = new BlockStoneOre(Refs.TINBLOCK_NAME);
tungsten_block = new BlockStoneOre(Refs.TUNGSTENBLOCK_NAME);
flax_crop = new BlockCrop().setBlockName(Refs.FLAXCROP_NAME);
indigo_flower = new BlockCustomFlower(Refs.INDIGOFLOWER_NAME);
alloy_furnace = new BlockAlloyFurnace();
sorting_machine = new BlockSortingMachine();
block_breaker = new BlockBlockBreaker();
igniter = new BlockIgniter();
buffer = new BlockBuffer();
Deployer = new BlockDeployer();
project_table = new BlockProjectTable();
transposer = new BlockTransposer();
ejector = new BlockEjector();
relay = new BlockRelay();
cpu = new BlockCPU();
monitor = new BlockMonitor();
disk_drive = new BlockDiskDrive();
io_expander = new BlockIOExpander();
engine = new BlockEngine();
kinetic_generator = new BlockKineticGenerator();
windmill = new BlockWindmill();
blockLamp = new Block[ItemDye.field_150922_c.length];
blockLampInverted = new Block[ItemDye.field_150922_c.length];
for (int i = 0; i < ItemDye.field_150922_c.length; i++){
blockLamp[i] = new BlockLamp(false, ItemDye.field_150921_b[i].toLowerCase(), ItemDye.field_150922_c[i]);
}
for (int i = 0; i < ItemDye.field_150922_c.length; i++){
blockLampInverted[i] = new BlockLamp(true, ItemDye.field_150921_b[i].toLowerCase(), ItemDye.field_150922_c[i]);
}
registerBlocks();
initModDependantBlocks();
}
private static void registerBlocks() {
GameRegistry.registerBlock(basalt, Refs.BASALT_NAME);
GameRegistry.registerBlock(basalt_cobble, Refs.BASALTCOBBLE_NAME);
GameRegistry.registerBlock(basalt_brick, Refs.BASALTBRICK_NAME);
GameRegistry.registerBlock(basaltbrick_cracked, Refs.CRACKEDBASALTBRICK_NAME);
GameRegistry.registerBlock(fancy_basalt, Refs.CHISELEDBASALTBRICK_NAME);
GameRegistry.registerBlock(basalt_brick_small, Refs.SMALLBASALTBRICK_NAME);
GameRegistry.registerBlock(cracked_basalt, Refs.CRACKED_BASALT);
GameRegistry.registerBlock(basalt_tile, Refs.BASALTTILE_NAME);
GameRegistry.registerBlock(basalt_paver, Refs.BASALTPAVER_NAME);
GameRegistry.registerBlock(marble, Refs.MARBLE_NAME);
GameRegistry.registerBlock(marble_brick, Refs.MARBLEBRICK_NAME);
GameRegistry.registerBlock(fancy_marble, Refs.CHISELEDMARBLEBRICK_NAME);
GameRegistry.registerBlock(marble_brick_small, Refs.SMALLMARBLEBRICK_NAME);
GameRegistry.registerBlock(marble_tile, Refs.MARBLETILE_NAME);
GameRegistry.registerBlock(marble_paver, Refs.MARBLEPAVER_NAME);
GameRegistry.registerBlock(nikolite_ore, Refs.NIKOLITEORE_NAME);
GameRegistry.registerBlock(copper_ore, Refs.COPPERORE_NAME);
GameRegistry.registerBlock(silver_ore, Refs.SILVERORE_NAME);
GameRegistry.registerBlock(tin_ore, Refs.TINORE_NAME);
GameRegistry.registerBlock(tungsten_ore, Refs.TUNGSTENORE_NAME);
GameRegistry.registerBlock(ruby_ore, Refs.RUBYORE_NAME);
GameRegistry.registerBlock(sapphire_ore, Refs.SAPPHIREORE_NAME);
GameRegistry.registerBlock(amethyst_ore, Refs.AMETHYSTORE_NAME);
GameRegistry.registerBlock(ruby_block, Refs.RUBYBLOCK_NAME);
GameRegistry.registerBlock(sapphire_block, Refs.SAPPHIREBLOCK_NAME);
GameRegistry.registerBlock(amethyst_block, Refs.AMETHYSTBLOCK_NAME);
GameRegistry.registerBlock(nikolite_block, Refs.NIKOLITEBLOCK_NAME);
GameRegistry.registerBlock(copper_block, Refs.COPPERBLOCK_NAME);
GameRegistry.registerBlock(silver_block, Refs.SILVERBLOCK_NAME);
GameRegistry.registerBlock(tin_block, Refs.TINBLOCK_NAME);
GameRegistry.registerBlock(tungsten_block, Refs.TUNGSTENBLOCK_NAME);
GameRegistry.registerBlock(flax_crop, Refs.FLAXCROP_NAME);
GameRegistry.registerBlock(indigo_flower, Refs.INDIGOFLOWER_NAME);
GameRegistry.registerBlock(alloy_furnace, Refs.ALLOYFURNACE_NAME);
GameRegistry.registerBlock(sorting_machine, Refs.SORTING_MACHINE_NAME);
GameRegistry.registerBlock(block_breaker, Refs.BLOCKBREAKER_NAME);
GameRegistry.registerBlock(igniter, Refs.BLOCKIGNITER_NAME);
GameRegistry.registerBlock(buffer, Refs.BLOCKBUFFER_NAME);
GameRegistry.registerBlock(Deployer, Refs.BLOCKDEPLOYER_NAME);
GameRegistry.registerBlock(project_table, Refs.PROJECTTABLE_NAME);
GameRegistry.registerBlock(transposer, Refs.TRANSPOSER_NAME);
GameRegistry.registerBlock(ejector, Refs.EJECTOR_NAME);
GameRegistry.registerBlock(relay, Refs.RELAY_NAME);
GameRegistry.registerBlock(cpu, Refs.BLOCKCPU_NAME);
GameRegistry.registerBlock(monitor, Refs.BLOCKMONITOR_NAME);
GameRegistry.registerBlock(disk_drive, Refs.BLOCKDISKDRIVE_NAME);
GameRegistry.registerBlock(io_expander, Refs.BLOCKIOEXPANDER_NAME);
GameRegistry.registerBlock(engine, Refs.ENGINE_NAME);
GameRegistry.registerBlock(kinetic_generator, Refs.KINETICGENERATOR_NAME);
GameRegistry.registerBlock(windmill, Refs.WINDMILL_NAME);
for (int i = 0; i < ItemDye.field_150922_c.length; i++){
GameRegistry.registerBlock(blockLamp[i], blockLamp[i].getUnlocalizedName());
}
for (int i = 0; i < ItemDye.field_150922_c.length; i++){
GameRegistry.registerBlock(blockLampInverted[i], blockLampInverted[i].getUnlocalizedName());
}
}
private static void initModDependantBlocks() {
if (Loader.isModLoaded(Dependencies.COMPUTER_CRAFT) || Loader.isModLoaded(Dependencies.OPEN_COMPUTERS)) {
sortron = new BlockSortron();
GameRegistry.registerBlock(sortron, Refs.BLOCKSORTRON_NAME);
}
}
}
| 11,684 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
WorldGenVolcano.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/world/WorldGenVolcano.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.world;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.init.Config;
/**
*
* @author MineMaarten
*/
public class WorldGenVolcano {
private static final int MAX_VULCANO_RADIUS = 200; // absulute max radius a vulcano can have, this should be a
// magnitude bigger than an average vulcano radius.
private final Map<Pos, Integer> vulcanoMap = new HashMap<Pos, Integer>();
public void generate(World world, Random rand, int middleX, int vulcanoHeight, int middleZ) {
List<Pos>[] distMap = calculateDistMap();
boolean first = true;
for (int dist = 0; dist < distMap.length; dist++) {// Loop through every XZ position of the vulcano, in order of how close the positions are
// from the center. The vulcano will be generated from the center to the edge.
List<Pos> distList = distMap[dist];
boolean isFinished = true;// Will stay true as long as there were still blocks being generated at this distance from the vulcano.
for (Pos p : distList) {
int worldHeight = world.getHeightValue(p.x + middleX, p.z + middleZ) - 1;
int posHeight = first ? vulcanoHeight : getNewVulcanoHeight(worldHeight, p, rand, dist);
if (posHeight >= 0 && (posHeight > worldHeight || canReplace(world, p.x + middleX, posHeight, p.z + middleZ))) {// If the calculated
// desired vulcano
// height is higher
// than the world
// height, generate.
vulcanoMap.put(p, posHeight);
if (!first) {
for (int i = posHeight; i > 0 && (i > worldHeight || canReplace(world, p.x + middleX, i, p.z + middleZ)); i--) {
world.setBlock(p.x + middleX, i, p.z + middleZ, BPBlocks.basalt, 0, 0);
}
for (int i = posHeight + 1; i < vulcanoHeight; i++) {
if (canReplace(world, p.x + middleX, i, p.z + middleZ) && world.getBlock(p.x + middleX, i, p.z + middleZ).getMaterial() != Material.water) world.setBlock(p.x + middleX, i, p.z + middleZ, Blocks.air, 0, 0);
}
}
isFinished = false;
}
first = false;
}
if (isFinished) break;
}
generateLavaColumn(world, middleX, vulcanoHeight, middleZ, rand);
}
private boolean canReplace(World world, int x, int y, int z) {
if (world.isAirBlock(x, y, z)) return true;
Block block = world.getBlock(x, y, z);
Material material = block.getMaterial();
return material == Material.wood || material == Material.cactus || material == Material.leaves || material == Material.plants || material == Material.vine || block == Blocks.water || block == Blocks.flowing_water;
}
private void generateLavaColumn(World world, int x, int topY, int z, Random rand) {
// world.setBlock(x, topY, z, Blocks.lava);
if (rand.nextDouble() < Config.volcanoActiveToInactiveRatio) {
world.setBlock(x, topY, z, BPBlocks.cracked_basalt);
} else {
world.setBlock(x, topY + 1, z, Blocks.lava);
world.setBlock(x, topY, z, Blocks.lava);// This block set, which does update neighbors, will make the lava above update.
}
for (int y = topY - 1; y >= 10; y--) {
world.setBlock(x + 1, y, z, BPBlocks.basalt, 0, 0);
world.setBlock(x - 1, y, z, BPBlocks.basalt, 0, 0);
world.setBlock(x, y, z + 1, BPBlocks.basalt, 0, 0);
world.setBlock(x, y, z - 1, BPBlocks.basalt, 0, 0);
world.setBlock(x, y, z, Blocks.lava, 0, 0);
}
}
/**
* Saves an array of relative Positions with distance to origin. The index is the distance, the element the positions with that distance to the
* origin.
*/
@SuppressWarnings("unchecked")
private List<Pos>[] calculateDistMap() {
List<Pos>[] distMap = new List[MAX_VULCANO_RADIUS];
for (int x = -MAX_VULCANO_RADIUS; x <= MAX_VULCANO_RADIUS; x++) {
for (int z = -MAX_VULCANO_RADIUS; z <= MAX_VULCANO_RADIUS; z++) {
int dist = (int) Math.sqrt(x * x + z * z);
if (dist < MAX_VULCANO_RADIUS) {
List<Pos> distList = distMap[dist];
if (distList == null) {
distList = new ArrayList<Pos>();
distMap[dist] = distList;
}
distList.add(new Pos(x, z));
}
}
}
return distMap;
}
/**
* Calculates a height for the requested position. It looks at the adjacent (already generated) vulcano heights, takes the average, and blends in
* a bit of randomness. If there are no neighbors this is the first vulcano block generated, meaning it's the center, meaning it should get the
* max height.
*
* @param requestedPos
* @param maxHeight
* @return
*/
private int getNewVulcanoHeight(int worldHeight, Pos requestedPos, Random rand, int distFromCenter) {
int neighborCount = 0;
int totalHeight = 0;
for (int x = requestedPos.x - 1; x <= requestedPos.x + 1; x++) {
for (int z = requestedPos.z - 1; z <= requestedPos.z + 1; z++) {
int neighborHeight = getNeighborHeight(x, z);
if (neighborHeight != -1) {
neighborCount++;
totalHeight += neighborHeight;
}
}
}
if (neighborCount != 0) {
double avgHeight = (double) totalHeight / neighborCount;
if ((int) avgHeight < worldHeight + 2 && rand.nextInt(5) != 0) return (int) avgHeight - 2;
// Formula that defines how fast the volcano descends. Using a square function to make it steeper at the top, and added randomness.
int blocksDown;
if (distFromCenter < 2) {
blocksDown = 0;
} else if (distFromCenter == 2) {
blocksDown = rand.nextInt(2);
} else {
blocksDown = (int) (Math.pow(avgHeight - worldHeight + 1, 1.2) * 0.02D + (rand.nextDouble() - 0.5) * 3 + 0.4D);
}
if (blocksDown < 0) blocksDown = 0;
int newHeight = (int) avgHeight - blocksDown;
return newHeight;
} else {
return -1;
}
}
/**
* This helper method is created so we don't have to create an object just to do a vulcanoMap.get(new Pos(x,z)).
*
* @param x
* @param z
* @return
*/
private int getNeighborHeight(int x, int z) {
for (Map.Entry<Pos, Integer> entry : vulcanoMap.entrySet()) {
if (entry.getKey().x == x && entry.getKey().z == z) return entry.getValue();
}
return -1;
}
public class Pos {
public final int x, z;
public Pos(int x, int z) {
this.x = x;
this.z = z;
}
}
}
| 8,332 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
WorldGenMarble.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/world/WorldGenMarble.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.world;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.gen.feature.WorldGenMinable;
import java.util.*;
@SuppressWarnings({ "unchecked", "rawtypes" })
public class WorldGenMarble extends WorldGenMinable {
LinkedList marbleVein = new LinkedList();
HashSet veinsList = new HashSet();
Block block;
int numberOfBlocks;
public WorldGenMarble(Block block, int num) {
super(block, num);
this.block = block;
this.numberOfBlocks = num;
}
private void addBlock(int x, int y, int z, int num) {
List marbleCandidate = Arrays.asList(x, y, z);
if (this.veinsList.contains(marbleCandidate)) return;
this.marbleVein.addLast(Arrays.asList(x, y, z, num));
this.veinsList.add(marbleCandidate);
}
private void searchBlock(World world, int x, int y, int z, int num) {
if (world.isAirBlock(x - 1, y, z) || world.isAirBlock(x + 1, y, z) || world.isAirBlock(x, y - 1, z) || world.isAirBlock(x, y + 1, z)
|| world.isAirBlock(x, y, z - 1) || world.isAirBlock(x, y, z + 1)) {
num = 6;
}
addBlock(x - 1, y, z, num);
addBlock(x + 1, y, z, num);
addBlock(x, y - 1, z, num);
addBlock(x, y + 1, z, num);
addBlock(x, y, z - 1, num);
addBlock(x, y, z + 1, num);
}
public boolean generate(World world, Random random, int x, int y, int z) {
if (!world.blockExists(x, y, z)) {
return false;
}
int i = y;
while (world.getBlock(x, i, z) != Blocks.stone) {
if (i > 96) return false; // Don't generate marble over y96
i++;
addBlock(x, i, z, 6);
}
while ((this.marbleVein.size() > 0) && (this.numberOfBlocks > 0)) {
List blocksToGenerate = (List) this.marbleVein.removeFirst();
Integer[] blockToSet = (Integer[]) blocksToGenerate.toArray();
if (world.getBlock(blockToSet[0], blockToSet[1], blockToSet[2]) == Blocks.stone) {
world.setBlock(blockToSet[0], blockToSet[1], blockToSet[2], this.block);
if (blockToSet[3] > 0) {
searchBlock(world, blockToSet[0], blockToSet[1], blockToSet[2], blockToSet[3] - 1);
}
this.numberOfBlocks -= 1;
}
}
return true;
}
}
| 3,208 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
WorldGenerationHandler.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/world/WorldGenerationHandler.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.world;
import cpw.mods.fml.common.IWorldGenerator;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.IChunkProvider;
import net.minecraft.world.gen.feature.WorldGenFlowers;
import net.minecraft.world.gen.feature.WorldGenMinable;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.init.Config;
import java.util.Random;
public class WorldGenerationHandler implements IWorldGenerator {
@Override
public void generate(Random random, int chunkX, int chunkZ, World world, IChunkProvider chunkGenerator, IChunkProvider chunkProvider) {
if (!world.provider.isSurfaceWorld()) {
return;
}
if (Config.generateAmethyst) {
this.addOreToGenerate(random, Config.veinCountAmethyst, Config.veinSizeAmethyst, Config.minAmethystY, Config.maxAmethystY, BPBlocks.amethyst_ore,
world, chunkX, chunkZ);
}
if (Config.generateRuby) {
this.addOreToGenerate(random, Config.veinCountRuby, Config.veinSizeRuby, Config.minRubyY, Config.maxRubyY, BPBlocks.ruby_ore, world, chunkX,
chunkZ);
}
if (Config.generateSapphire) {
this.addOreToGenerate(random, Config.veinCountSapphire, Config.veinSizeSapphire, Config.minSapphireY, Config.maxSapphireY, BPBlocks.sapphire_ore,
world, chunkX, chunkZ);
}
if (Config.generateSilver) {
this.addOreToGenerate(random, Config.veinCountSilver, Config.veinSizeSilver, Config.minSilverY, Config.maxSilverY, BPBlocks.silver_ore, world,
chunkX, chunkZ);
}
if (Config.generateNikolite) {
this.addOreToGenerate(random, Config.veinCountNikolite, Config.veinSizeNikolite, Config.minNikoliteY, Config.maxNikoliteY, BPBlocks.nikolite_ore,
world, chunkX, chunkZ);
}
if (Config.generateTin) {
this.addOreToGenerate(random, Config.veinCountTin, Config.veinSizeTin, Config.minTinY, Config.maxTinY, BPBlocks.tin_ore, world, chunkX, chunkZ);
}
if (Config.generateCopper) {
this.addOreToGenerate(random, Config.veinCountCopper, Config.veinSizeCopper, Config.minCopperY, Config.maxCopperY, BPBlocks.copper_ore, world,
chunkX, chunkZ);
}
if (Config.generateTungsten) {
this.addOreToGenerate(random, Config.veinCountTungsten, Config.veinSizeTungsten, Config.minTungstenY, Config.maxTungstenY, BPBlocks.tungsten_ore, world, chunkX, chunkZ);
}
BiomeGenBase bgb = world.getWorldChunkManager().getBiomeGenAt(chunkX * 16 + 16, chunkZ * 16 + 16);
int n = 0;
if (bgb == BiomeGenBase.birchForest) n = 1;
else if (bgb == BiomeGenBase.birchForestHills) n = 1;
else if (bgb == BiomeGenBase.plains) n = 1;
else if (bgb == BiomeGenBase.forest) n = 4;
else if (bgb == BiomeGenBase.roofedForest) n = 4;
for (int i = 0; i < n; i++) {
int x = chunkX * 16 + random.nextInt(16) + 8;
int y = random.nextInt(128);
int z = chunkZ * 16 + random.nextInt(16) + 8;
new WorldGenFlowers(BPBlocks.indigo_flower).generate(world, random, x, y, z);
}
for (int i = 0; i < 4; i++) {
int x = chunkX * 16 + random.nextInt(16);
int y = 32 + random.nextInt(32);
int z = chunkZ * 16 + random.nextInt(16);
new WorldGenMarble(BPBlocks.marble, random.nextInt(4096)).generate(world, random, x, y, z);
}
if (random.nextDouble() < Config.volcanoSpawnChance) {
int x = chunkX * 16 + random.nextInt(16);
int z = chunkZ * 16 + random.nextInt(16);
int y = world.getHeightValue(x, z) + 20 + random.nextInt(10);// This number determines the topmost block of the volcano, it increases
// generation time exponentially when increased!
if (world.getBlock(x, 10, z) == Blocks.lava) new WorldGenVolcano().generate(world, random, x, y, z);
}
}
private void addOreToGenerate(Random random, int veinCount, int veinSize, int minY, int maxY, Block block, World world, int chunkX, int chunkZ) {
for (int i = 0; i < veinCount; i++) {
int x = chunkX * 16 + random.nextInt(16);
int y = random.nextInt(maxY - minY) + minY;
int z = chunkZ * 16 + random.nextInt(16);
(new WorldGenMinable(block, veinSize)).generate(world, random, x, y, z);
}
}
}
| 5,392 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BPRegistry.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/BPRegistry.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.api;
import net.quetzi.bluepower.api.recipe.IAlloyFurnaceRegistry;
/**
*
* @author MineMaarten
*/
public class BPRegistry {
public static IAlloyFurnaceRegistry alloyFurnaceRegistry;
}
| 960 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
Vector3Cube.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/vec/Vector3Cube.java | package net.quetzi.bluepower.api.vec;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.util.ForgeDirectionUtils;
public class Vector3Cube {
private Vector3 min, max;
public Vector3Cube(double minX, double minY, double minZ, double maxX, double maxY, double maxZ) {
this(minX, minY, minZ, maxX, maxY, maxZ, null);
}
public Vector3Cube(double minX, double minY, double minZ, double maxX, double maxY, double maxZ, World world) {
this(new Vector3(minX, minY, minZ, world), new Vector3(maxX, maxY, maxZ, world));
}
public Vector3Cube(Vector3 a, Vector3 b) {
World w = a.getWorld();
if (w == null) w = b.getWorld();
double minX = Math.min(a.getX(), b.getX());
double minY = Math.min(a.getY(), b.getY());
double minZ = Math.min(a.getZ(), b.getZ());
double maxX = Math.max(a.getX(), b.getX());
double maxY = Math.max(a.getY(), b.getY());
double maxZ = Math.max(a.getZ(), b.getZ());
min = new Vector3(minX, minY, minZ, w);
max = new Vector3(maxX, maxY, maxZ, w);
}
public Vector3Cube(AxisAlignedBB aabb) {
this(aabb.minX, aabb.minY, aabb.minZ, aabb.maxX, aabb.maxY, aabb.maxZ);
}
public Vector3 getMin() {
return min;
}
public Vector3 getMax() {
return max;
}
public Vector3 getCenter() {
return new Vector3((getMinX() + getMaxX()) / 2D, (getMinY() + getMaxY()) / 2D, (getMinZ() + getMaxZ()) / 2D, getMin().getWorld());
}
public double getMinX() {
return min.getX();
}
public double getMinY() {
return min.getY();
}
public double getMinZ() {
return min.getZ();
}
public double getMaxX() {
return max.getX();
}
public double getMaxY() {
return max.getY();
}
public double getMaxZ() {
return max.getZ();
}
public AxisAlignedBB toAABB() {
return AxisAlignedBB.getBoundingBox(getMinX(), getMinY(), getMinZ(), getMaxX(), getMaxY(), getMaxZ());
}
@Override
public Vector3Cube clone() {
return new Vector3Cube(min.clone(), max.clone());
}
public Vector3Cube expand(double size) {
min.subtract(size, size, size);
max.add(size, size, size);
return this;
}
private ForgeDirection last = ForgeDirection.UNKNOWN;
public Vector3Cube rotate90Degrees(ForgeDirection dir) {
if (last == ForgeDirection.UNKNOWN) {
last = dir;
} else {
dir = ForgeDirection.getOrientation(ForgeDirection.ROTATION_MATRIX[ForgeDirectionUtils.getSide(last)][ForgeDirectionUtils.getSide(dir)]);
}
double mul = 1;
ForgeDirection o = dir;
switch (o) {
case DOWN:
mul = 2;
dir = ForgeDirection.NORTH;
break;
case EAST:
dir = ForgeDirection.SOUTH;
break;
case NORTH:
dir = ForgeDirection.EAST;
break;
case SOUTH:
dir = ForgeDirection.WEST;
break;
case UP:
mul = 0;
break;
case WEST:
dir = ForgeDirection.NORTH;
break;
default:
break;
}
double rx = dir.offsetX * (Math.PI / 2) * mul;
double ry = dir.offsetY * (Math.PI / 2) * mul;
double rz = dir.offsetZ * (Math.PI / 2) * mul;
Vector3 min = this.min.clone().subtract(0.5, 0.5, 0.5);
min.rotate(rx, ry, rz);
min.add(0.5, 0.5, 0.5);
Vector3 max = this.max.clone().subtract(0.5, 0.5, 0.5);
max.rotate(rx, ry, rz);
max.add(0.5, 0.5, 0.5);
Vector3Cube v3c = new Vector3Cube(min, max);
this.min = v3c.min;
this.max = v3c.max;
return this;
}
}
| 4,285 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
Vector3.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/vec/Vector3.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.api.vec;
import java.util.StringTokenizer;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Blocks;
import net.minecraft.server.MinecraftServer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.references.Dependencies;
import codechicken.lib.vec.BlockCoord;
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class Vector3 {
protected double x, y, z;
protected World w = null;
public Vector3(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public Vector3(double x, double y, double z, World w) {
this(x, y, z);
this.w = w;
}
public Vector3(TileEntity te) {
this(te.xCoord, te.yCoord, te.zCoord, te.getWorldObj());
}
public Vector3(Vec3 vec) {
this(vec.xCoord, vec.yCoord, vec.zCoord);
}
public Vector3(Vec3 vec, World w) {
this(vec.xCoord, vec.yCoord, vec.zCoord);
this.w = w;
}
public static Vector3 fromString(String s) {
if (s.startsWith("Vector3{") && s.endsWith("}")) {
World w = null;
double x = 0, y = 0, z = 0;
String s2 = s.substring(s.indexOf("{") + 1, s.lastIndexOf("}"));
StringTokenizer st = new StringTokenizer(s2, ";");
while (st.hasMoreTokens()) {
String t = st.nextToken();
if (t.toLowerCase().startsWith("w")) {
int world = Integer.parseInt(t.split("=")[1]);
if (FMLCommonHandler.instance().getEffectiveSide().isServer()) {
for (World wo : MinecraftServer.getServer().worldServers) {
if (wo.provider.dimensionId == world) {
w = wo;
break;
}
}
} else {
w = getClientWorld(world);
}
}
if (t.toLowerCase().startsWith("x")) x = Double.parseDouble(t.split("=")[1]);
if (t.toLowerCase().startsWith("y")) y = Double.parseDouble(t.split("=")[1]);
if (t.toLowerCase().startsWith("z")) z = Double.parseDouble(t.split("=")[1]);
}
if (w != null) {
return new Vector3(x, y, z, w);
} else {
return new Vector3(x, y, z);
}
}
return null;
}
@SideOnly(Side.CLIENT)
private static World getClientWorld(int world) {
if (Minecraft.getMinecraft().theWorld.provider.dimensionId != world) return null;
return Minecraft.getMinecraft().theWorld;
}
public boolean hasWorld() {
return w != null;
}
public Vector3 add(double x, double y, double z) {
this.x += x;
this.y += y;
this.z += z;
return this;
}
public Vector3 add(ForgeDirection dir) {
return add(dir.offsetX, dir.offsetY, dir.offsetZ);
}
public Vector3 add(Vector3 vec) {
return add(vec.x, vec.y, vec.z);
}
public Vector3 subtract(double x, double y, double z) {
this.x -= x;
this.y -= y;
this.z -= z;
return this;
}
public Vector3 subtract(ForgeDirection dir) {
return subtract(dir.offsetX, dir.offsetY, dir.offsetZ);
}
public Vector3 subtract(Vector3 vec) {
return subtract(vec.x, vec.y, vec.z);
}
public Vector3 multiply(double x, double y, double z) {
this.x *= x;
this.y *= y;
this.z *= z;
return this;
}
public Vector3 multiply(double multiplier) {
return multiply(multiplier, multiplier, multiplier);
}
public Vector3 multiply(ForgeDirection direction) {
return multiply(direction.offsetX, direction.offsetY, direction.offsetZ);
}
public Vector3 divide(double x, double y, double z) {
this.x /= x;
this.y /= y;
this.z /= z;
return this;
}
public Vector3 divide(double multiplier) {
return divide(multiplier, multiplier, multiplier);
}
public Vector3 divide(ForgeDirection direction) {
return divide(direction.offsetX, direction.offsetY, direction.offsetZ);
}
public Vector3 getRelative(double x, double y, double z) {
return clone().add(x, y, z);
}
public Vector3 getRelative(ForgeDirection dir) {
return getRelative(dir.offsetX, dir.offsetY, dir.offsetZ);
}
public ForgeDirection getDirectionTo(Vector3 vec) {
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS)
if (getBlockX() + d.offsetX == vec.getBlockX() && getBlockY() + d.offsetY == vec.getBlockY()
&& getBlockZ() + d.offsetZ == vec.getBlockZ()) return d;
return null;
}
public boolean hasTileEntity() {
if (hasWorld()) { return w.getTileEntity((int) x, (int) y, (int) z) != null; }
return false;
}
public TileEntity getTileEntity() {
if (hasTileEntity()) { return w.getTileEntity((int) x, (int) y, (int) z); }
return null;
}
public boolean isBlock(Block b) {
return isBlock(b, false);
}
public boolean isBlock(Block b, boolean checkAir) {
if (hasWorld()) {
Block bl = w.getBlock((int) x, (int) y, (int) z);
if (b == null && bl == Blocks.air) return true;
if (b == null && checkAir && bl.getMaterial() == Material.air) return true;
if (b == null && checkAir && bl.isAir(w, (int) x, (int) y, (int) z)) return true;
return bl.getClass().isInstance(b);
}
return false;
}
public int getBlockMeta() {
if (hasWorld()) { return w.getBlockMetadata((int) x, (int) y, (int) z); }
return -1;
}
public Block getBlock() {
return getBlock(true);
}
public Block getBlock(boolean airIsNull) {
if (hasWorld()) {
if (airIsNull && isBlock(null, true)) return null;
return w.getBlock((int) x, (int) y, (int) z);
}
return null;
}
public World getWorld() {
return w;
}
public Vector3 setWorld(World world) {
this.w = world;
return this;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getZ() {
return z;
}
public int getBlockX() {
return (int) Math.floor(x);
}
public int getBlockY() {
return (int) Math.floor(y);
}
public int getBlockZ() {
return (int) Math.floor(z);
}
public void rotate(double x, double y, double z){
rotateX(x);
rotateY(y);
rotateZ(z);
}
public void rotateX(double angle) {
double oldY = y;
y = (float) (y * Math.cos(angle) - z * Math.sin(angle));
z = (float) (oldY * Math.sin(angle) + z * Math.cos(angle));
}
public void rotateY(double angle) {
double oldX = x;
x = (float) (x * Math.cos(angle) - z * Math.sin(angle));
z = (float) (oldX * Math.sin(angle) + z * Math.cos(angle));
}
public void rotateZ(double angle) {
double oldX = x;
x = (float) (x * Math.cos(angle) - y * Math.sin(angle));
y = (float) (oldX * Math.sin(angle) + y * Math.cos(angle));
}
public double distanceTo(Vector3 vec) {
return distanceTo(vec.x, vec.y, vec.z);
}
public double distanceTo(double x, double y, double z) {
double dx = x - this.x;
double dy = y - this.y;
double dz = z - this.z;
return dx * dx + dy * dy + dz * dz;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof Vector3) {
Vector3 vec = (Vector3) obj;
return vec.w == w && vec.x == x && vec.y == y && vec.z == z;
}
return false;
}
public Vector3 clone() {
return new Vector3(x, y, z, w);
}
@Override
public String toString() {
String s = "Vector3{";
if (hasWorld()) s += "w=" + w.provider.dimensionId + ";";
s += "x=" + x + ";y=" + y + ";z=" + z + "}";
return s;
}
public Vec3 toVec3() {
return Vec3.createVectorHelper(x, y, z);
}
@Optional.Method(modid = Dependencies.FMP)
public BlockCoord toBlockCoord() {
return new BlockCoord((int) x, (int) y, (int) z);
}
public Vector3 toAbsoulte() {
this.x = Math.abs(this.x);
this.y = Math.abs(this.y);
this.z = Math.abs(this.z);
return this;
}
}
| 10,269 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BPPart.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/part/BPPart.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.api.part;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.client.IItemRenderer.ItemRenderType;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.compat.CompatibilityUtils;
import net.quetzi.bluepower.compat.fmp.IMultipartCompat;
import net.quetzi.bluepower.references.Dependencies;
import net.quetzi.bluepower.util.RayTracer;
import codechicken.multipart.BlockMultipart;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional;
public abstract class BPPart {
public World world = null;
public int x = 0;
public int y = 0;
public int z = 0;
/**
* Holds the exact width of 1 pixel, texturewise
*/
protected static double pixel = 1.0 / 16.0;
/**
* Checks if this tile is part of an FMP block
*
* @return Whether it's part of an FMP block or not
*/
public final boolean isFMPMultipart() {
if (Loader.isModLoaded(Dependencies.FMP)) return isFMPMultipart_();
return false;
}
@Optional.Method(modid = Dependencies.FMP)
private final boolean isFMPMultipart_() {
return world.getBlock(x, y, z) instanceof BlockMultipart;
}
/**
* Gets an unique part type identifier, used to distinguish between this part and others
*
* @return The part type
*/
public abstract String getType();
/**
* Gets the unlocalized name for this part (used for the item name)
*
* @return The unlocalized name of this part
*/
public abstract String getUnlocalizedName();
public boolean canPlacePart(ItemStack is, EntityPlayer player, Vector3 block, MovingObjectPosition mop) {
return true;
}
protected int tick = 0;
/**
* Called every tick to update the part
*/
public void update() {
if (tick == 2) shouldNotifyUpdates = true;
tick++;
}
/**
* Gets all the collision boxes for this block
*
* @return A list with the collision boxes
*/
public List<AxisAlignedBB> getCollisionBoxes() {
List<AxisAlignedBB> aabbs = new ArrayList<AxisAlignedBB>();
aabbs.add(AxisAlignedBB.getBoundingBox(0, 0, 0, 1, 1, 1));
return aabbs;
}
/**
* Gets all the selection boxes for this block
*
* @return A list with the selection boxes
*/
public List<AxisAlignedBB> getSelectionBoxes() {
List<AxisAlignedBB> aabbs = new ArrayList<AxisAlignedBB>();
aabbs.add(AxisAlignedBB.getBoundingBox(0, 0, 0, 1, 1, 1));
return aabbs;
}
/**
* Gets all the occlusion boxes for this block
*
* @return A list with the occlusion boxes
*/
public List<AxisAlignedBB> getOcclusionBoxes() {
return getSelectionBoxes();
}
/**
* Raytraces the block
*
* @param start
* The start of the raytrace
* @param end
* The end of the raytrace
* @return The result of the raytrace
*/
public MovingObjectPosition rayTrace(Vector3 start, Vector3 end) {
return RayTracer.rayTrace(start, end, getSelectionBoxes(), x, y, z);
}
/**
* This render method gets called every tick. You should use this if you're doing animations
*
* @param loc
* Distance from the player's position
* @param pass
* Render pass (0 or 1)
* @param frame
* Partial tick for smoother animations
*/
public void renderDynamic(Vector3 loc, int pass, float frame) {
}
public boolean shouldRenderDynamicOnPass(int pass) {
return pass == 0;
}
/**
* This render method gets called whenever there's a block update in the chunk. You should use this to remove load from the renderer if a part of
* the rendering code doesn't need to get called too often or just doesn't change at all. To call a render update to re-render this just call
* {@link BPPart#markPartForRenderUpdate()}
*
* @param loc
* Distance from the player's position
* @param pass
* Render pass (0 or 1)
* @return Whether or not it rendered something
*/
public boolean renderStatic(Vector3 loc, int pass) {
return false;
}
public boolean shouldRenderStaticOnPass(int pass) {
return pass == 0;
}
/**
* Used to render the item when it's not placed in the world (in the player's hand, as a dropped item, in an inventory...)
*
* @param type
* Render type (Inventory, dropped item, held (first person), held (third person)...)
* @param item
* The item that will be rendered. This can be useful if special data is stored in the item's NBT tag
* @param data
* Extra data provided by the renderer (check {@link ItemRenderType} for javadocs on what data each type will have)
*/
public void renderItem(ItemRenderType type, ItemStack item, Object... data) {
}
private boolean shouldReRender = true;
/**
* Marks the part (and the entire chunk) for a render update on the next render tick
*/
public final void markPartForRenderUpdate() {
shouldReRender = true;
}
/**
* If this part was marked for a render update, unmarks it
*/
public final void resetRenderUpdate() {
shouldReRender = false;
}
public final boolean shouldReRender() {
return shouldReRender;
}
/**
* Gets the amount of light emitted by this block. If you want this to update in real time you'll probably need to call
* {@link BPPart#markPartForRenderUpdate()}
*
* @return The light value (0-15)
*/
public int getLightValue() {
return 0;
}
/**
* Gets the hardness of this part
*
* @return The hardness of the part
*/
public float getHardness() {
return 0;
}
/**
* Gets the hardness of this part based on the player
*
* @param player
* The player that's trying to break the block
* @return The hardness of the part depending on the player
*/
public float getHardness(EntityPlayer player) {
return getHardness();
}
/**
* Gets the hardnes of this part based on the player and the location where it's clicking
*
* @param mop
* Point in the block at which the player is looking when breaking it
* @param player
* The player that's trying to break the block
* @return The hardness of the part depending on the player and where it's looking when breaking it
*/
public float getHardness(MovingObjectPosition mop, EntityPlayer player) {
return getHardness(player);
}
/**
* Gets the explosion resistance of this part
*
* @return The resistance
*/
public float getExplosionResistance() {
return 0;
}
/**
* Gets the picked item when middle-clicked
*
* @return The item that the player will pickup
*/
public ItemStack pickItem() {
return PartRegistry.getItemForPart(getType());
}
/**
* Gets the picked item when middle-clicked
*
* @param hit
* Position at which the player is looking at when middle clicking
* @return The item that the player will pickup
*/
public ItemStack getPickedItem(MovingObjectPosition hit) {
return pickItem();
}
/**
* Gets a list of items that will drop when the part is broken
*
* @return The list of items dropped by this part
*/
public List<ItemStack> getDrops() {
List<ItemStack> items = new ArrayList<ItemStack>();
items.add(PartRegistry.getItemForPart(getType()));
return items;
}
/**
* Event called when the part is placed in the world
*/
public void onAdded() {
}
/**
* Event called when the part is removed from the world
*/
public void onRemoved() {
}
/**
* Event called when another part in the same block is changed
*/
public void onPartChanged() {
}
/**
* Event called when an entity collides with the part
*
* @param entity
* The entity that collided with the part
*/
public void onEntityCollision(Entity entity) {
}
/**
* Event called whenever a nearby block updates
*/
public void onNeighborUpdate() {
}
/**
* Event called when the part is activated (right clicked)
*
* @param item
* Item that was used to click it
* @return Whether or not an action occurred
*/
public boolean onActivated(ItemStack item) {
return false;
}
/**
* Event called when the part is activated (right clicked)
*
* @param player
* Player that right clicked the part
* @param item
* Item that was used to click it
* @return Whether or not an action occurred
*/
public boolean onActivated(EntityPlayer player, ItemStack item) {
return onActivated(item);
}
/**
* Event called when the part is activated (right clicked)
*
* @param player
* Player that right clicked the part
* @param mop
* Location in the part that was clicked by the player
* @param item
* Item that was used to click it
* @return Whether or not an action occurred
*/
public boolean onActivated(EntityPlayer player, MovingObjectPosition mop, ItemStack item) {
return onActivated(player, item);
}
/**
* Notifies surrounding blocks of a part update in this block
*/
private boolean shouldNotifyUpdates = false;
public void notifyUpdate() {
if (!shouldNotifyUpdates) return;
if (world == null) return;
world.notifyBlockChange(x, y, z, world.getBlock(x, y, z));
markPartForRenderUpdate();
world.notifyBlockOfNeighborChange(x, y, z, world.getBlock(x, y + 1, z));
}
/**
* Sends this part's data to the client
*/
public void sendUpdatePacket() {
if (world == null) return;
((IMultipartCompat) CompatibilityUtils.getModule(Dependencies.FMP)).sendUpdatePacket(this);
}
/**
* Saves the data either to the save file or to an update packet
* @param tag
* NBT tag the data will be written to
*/
public void save(NBTTagCompound tag) {
}
/**
* Loads the data either from the save file or from an update packet
* @param tag
* NBT tag with the data
*/
public void load(NBTTagCompound tag) {
}
/**
* Gets the creative tab to display on
* @return The creative tab instance
*/
public CreativeTabs getCreativeTab() {
return null;
}
/**
* Gets the creative tab index to display on
* @return The index in the creative tab to display on
*/
public int getCreativeTabIndex() {
return 0;
}
/**
* Gets the creative tabs to display on
* @return The creative tab instances
*/
public CreativeTabs[] getCreativeTabs() {
return new CreativeTabs[] { getCreativeTab() };
}
/**
* Gets the creative tab indexes to display on
* @return The indexes in the creative tabs to display on
*/
public int[] getCreativeTabIndexes() {
int[] indexes = new int[getCreativeTabs().length];
Arrays.fill(indexes, getCreativeTabIndex());
return indexes;
}
/**
* Renders the highlight for the selected cube
* @param cube
* Cube that's highlighted
* @return False if it wasn't rendered, true if it was
*/
public boolean drawHighlight(AxisAlignedBB cube, MovingObjectPosition mop) {
return false;
}
/**
* Checks if there's another part colliding with the cube passed as an argument
* @param cube
* Cube that will be checked for collision
* @return True if there's another part in that position, false if there's not
*/
public boolean checkOcclusion(AxisAlignedBB cube) {
return ((IMultipartCompat) CompatibilityUtils.getModule(Dependencies.FMP)).checkOcclusion(world.getTileEntity(x, y, z), cube);
}
/**
* Adds information to the waila tooltip
* @author amadornes
*
* @param info
*/
public void addWailaInfo(List<String> info) {
}
public boolean hasCustomItemEntity() {
return false;
}
public EntityItem createItemEntity(World w, double x, double y, double z, ItemStack item) {
return null;
}
}
| 14,430 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
FaceDirection.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/part/FaceDirection.java | package net.quetzi.bluepower.api.part;
import net.minecraft.client.resources.I18n;
import net.minecraftforge.common.util.ForgeDirection;
public enum FaceDirection {
FRONT("front"), BACK("back"), LEFT("left"), RIGHT("right");
private FaceDirection(String name) {
this.name = name;
}
private String name; // used in texture paths
public FaceDirection getOpposite() {
return FaceDirection.getDirection((getDirection() + 2) % 4);
}
public int getDirection() {
switch (this) {
case FRONT:
return 0;
case LEFT:
return 1;
case BACK:
return 2;
case RIGHT:
return 3;
}
return -1;
}
public String getName() {
return name;
}
public String getLocalizedName() {
return I18n.format("direction." + getName());
}
public static FaceDirection getDirection(int id) {
for (FaceDirection d : values())
if (d.getDirection() == id) return d;
return null;
}
public static FaceDirection getDirection(ForgeDirection face, ForgeDirection direction, int rotation) {
FaceDirection dir = null;
int rot = rotation;
switch (face) {
case UP:
case DOWN:
switch (direction) {
case NORTH:
dir = FRONT;
break;
case EAST:
dir = RIGHT;
break;
case SOUTH:
dir = BACK;
break;
case WEST:
dir = LEFT;
break;
default:
break;
}
if (face == ForgeDirection.UP && dir != null) dir = dir.getOpposite();
break;
case WEST:
case EAST:
rot++;
switch (direction) {
case UP:
dir = FRONT;
break;
case NORTH:
dir = RIGHT;
break;
case DOWN:
dir = BACK;
break;
case SOUTH:
dir = LEFT;
break;
default:
break;
}
if (face == ForgeDirection.WEST && dir != null) dir = dir.getOpposite();
break;
case NORTH:
case SOUTH:
switch (direction) {
case UP:
dir = FRONT;
break;
case EAST:
dir = RIGHT;
break;
case DOWN:
dir = BACK;
break;
case WEST:
dir = LEFT;
break;
default:
break;
}
if (face == ForgeDirection.NORTH && dir != null) dir = dir.getOpposite();
break;
default:
break;
}
if (dir != null) dir = getDirection((dir.getDirection() + rot) % 4);
return dir;
}
}
| 3,666 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RedstoneConnection.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/part/RedstoneConnection.java | package net.quetzi.bluepower.api.part;
import net.minecraft.nbt.NBTTagCompound;
public class RedstoneConnection {
private BPPartFace part;
private boolean isInput = true;
private int power = 0;
private boolean isEnabled = false;
private String id = "";
public RedstoneConnection(BPPartFace part, String id) {
this.part = part;
this.id = id;
}
public RedstoneConnection(BPPartFace part, String id, boolean isInput) {
this(part, id);
this.isInput = isInput;
}
public RedstoneConnection(BPPartFace part, String id, boolean isInput, boolean isEnabled) {
this(part, id, isInput);
this.isEnabled = isEnabled;
}
public void setInput() {
this.isInput = true;
part.notifyUpdate();
}
public void setOutput() {
this.isInput = false;
part.notifyUpdate();
}
public boolean isInput() {
return isInput;
}
public boolean isOutput() {
return !isInput;
}
public void enable() {
boolean was = this.isEnabled;
this.isEnabled = true;
part.notifyUpdate();
if(!was)
part.notifyUpdate();
}
public void disable() {
boolean was = this.isEnabled;
this.isEnabled = false;
if(was)
part.notifyUpdate();
}
public boolean isEnabled() {
return isEnabled;
}
public void setPower(int power) {
int last = this.power;
this.power = power;
if(last != power)
part.notifyUpdate();
}
public int getPower() {
return power;
}
public void setID(String id) {
this.id = id;
}
public String getID() {
return id;
}
public NBTTagCompound getNBTTag() {
NBTTagCompound tag = new NBTTagCompound();
tag.setBoolean("isInput", isInput);
tag.setBoolean("isEnabled", isEnabled);
tag.setInteger("power", power);
tag.setString("id", id);
return tag;
}
public void load(NBTTagCompound tag) {
isInput = tag.getBoolean("isInput");
isEnabled = tag.getBoolean("isEnabled");
power = tag.getInteger("power");
id = tag.getString("id");
}
}
| 2,498 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ComparatorCreativeTabIndex.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/part/ComparatorCreativeTabIndex.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.api.part;
import java.util.Comparator;
import net.minecraft.creativetab.CreativeTabs;
/**
* @author amadornes
*
*/
public class ComparatorCreativeTabIndex implements Comparator<BPPart> {
private CreativeTabs tab;
/**
* @author amadornes
*
*/
public ComparatorCreativeTabIndex(CreativeTabs tab) {
this.tab = tab;
}
@Override
public int compare(BPPart o1, BPPart o2) {
int i1 = 0;
CreativeTabs[] t1 = o1.getCreativeTabs();
for (int i = 0; i < t1.length; i++) {
if (t1[i] == tab) {
i1 = o1.getCreativeTabIndexes()[i];
break;
}
}
int i2 = 0;
CreativeTabs[] t2 = o2.getCreativeTabs();
for (int i = 0; i < t2.length; i++) {
if (t2[i] == tab) {
i2 = o1.getCreativeTabIndexes()[i];
break;
}
}
return i1 - i2;
}
}
| 1,681 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IBPFacePart.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/part/IBPFacePart.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.api.part;
public interface IBPFacePart {
public int getFace();
public void setFace(int face);
public int getRotation();
public void setRotation(int rotation);
public boolean canStay();
}
| 977 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BPPartFace.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/part/BPPartFace.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.api.part;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.part.redstone.IBPRedstonePart;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.api.vec.Vector3Cube;
import net.quetzi.bluepower.helper.RedstoneHelper;
import net.quetzi.bluepower.util.ForgeDirectionUtils;
import org.lwjgl.opengl.GL11;
public abstract class BPPartFace extends BPPart implements IBPFacePart, IBPRedstonePart {
private int face = 0;
private int rotation = 0;
protected RedstoneConnection[] connections = new RedstoneConnection[4];
private final List<Vector3Cube> selectionBoxes = new ArrayList<Vector3Cube>();
private final List<Vector3Cube> collisionBoxes = new ArrayList<Vector3Cube>();
private final List<Vector3Cube> occlusionBoxes = new ArrayList<Vector3Cube>();
@Override
public int getFace() {
return face;
}
@Override
public void setFace(int face) {
this.face = face;
notifyUpdate();
}
@Override
public int getRotation() {
return rotation;
}
@Override
public void setRotation(int rotation) {
this.rotation = rotation % 4;
notifyUpdate();
}
@Override
public boolean canPlacePart(ItemStack is, EntityPlayer player, Vector3 block, MovingObjectPosition mop) {
world = block.getWorld();
x = block.getBlockX();
y = block.getBlockY();
z = block.getBlockZ();
ForgeDirection dir = ForgeDirection.getOrientation(mop.sideHit).getOpposite();
if (dir == ForgeDirection.DOWN) {
dir = ForgeDirection.UP;
} else {
if (dir == ForgeDirection.UP) dir = ForgeDirection.DOWN;
}
setFace(ForgeDirectionUtils.getSide(dir));
int rotation = 0;
{
double s1 = 0;
double s2 = 0;
switch (dir) {
case WEST:
case EAST:
s1 = -(mop.hitVec.yCoord - player.posY - player.height);
s2 = mop.hitVec.zCoord - player.posZ;
break;
case DOWN:
case UP:
s1 = mop.hitVec.xCoord - player.posX;
s2 = mop.hitVec.zCoord - player.posZ;
break;
case NORTH:
case SOUTH:
s1 = mop.hitVec.xCoord - player.posX;
s2 = -(mop.hitVec.yCoord - player.posY - player.height);
break;
default:
break;
}
if (Math.abs(s1) >= Math.abs(s2)) {
if (s1 >= 0) {
rotation = 3;
} else {
rotation = 1;
}
} else {
if (s2 >= 0) {
rotation = 0;
} else {
rotation = 2;
}
}
}
setRotation(rotation);
return world.isSideSolid(x, y, z, dir);
}
@Override
public boolean canStay() {
ForgeDirection d = ForgeDirection.getOrientation(getFace());
if (d == ForgeDirection.UP || d == ForgeDirection.DOWN) d = d.getOpposite();
return world.isSideSolid(x + d.offsetX, y + d.offsetY, z + d.offsetZ, d.getOpposite());
}
@Override
public final boolean canConnect(ForgeDirection side) {
RedstoneConnection con = getConnection(FaceDirection.getDirection(ForgeDirection.getOrientation(getFace()), side, rotation));
if (con == null) return false;
return con.isEnabled();
}
@Override
public final int getStrongOutput(ForgeDirection side) {
return getWeakOutput(side);
}
@Override
public final int getWeakOutput(ForgeDirection side) {
RedstoneConnection con = getConnection(side);
if (con == null) return 0;
ForgeDirection face = ForgeDirection.getOrientation(getFace()).getOpposite();
int p = RedstoneHelper.setOutput(world, x, y, z, side, face, con.getPower());
return con.isOutput() ? p : 0;
}
@Override
public void renderDynamic(Vector3 loc, int pass, float frame) {
}
public void rotateAndTranslateDynamic(Vector3 loc, int pass, float frame) {
GL11.glTranslated(loc.getX(), loc.getY(), loc.getZ());
GL11.glTranslated(0.5, 0.5, 0.5);
{
switch (getFace()) {
case 0:
GL11.glRotated(180, 1, 0, 0);
break;
case 1:
break;
case 2:
GL11.glRotated(90, 1, 0, 0);
break;
case 3:
GL11.glRotated(90, -1, 0, 0);
break;
case 4:
GL11.glRotated(90, 0, 0, -1);
break;
case 5:
GL11.glRotated(90, 0, 0, 1);
break;
}
GL11.glRotated(90 * (rotation == 0 || rotation == 2 ? (rotation + 2) % 4 : rotation), 0, 1, 0);
}
GL11.glTranslated(-0.5, -0.5, -0.5);
}
public void translateStatic(Vector3 loc, int pass) {
Tessellator tess = Tessellator.instance;
tess.addTranslation((float) loc.getX(), (float) loc.getY(), (float) loc.getZ());
}
public void undoTranslateStatic(Vector3 loc, int pass) {
Tessellator tess = Tessellator.instance;
tess.addTranslation((float) -loc.getX(), (float) -loc.getY(), (float) -loc.getZ());
}
public RedstoneConnection getConnection(FaceDirection dir) {
if (dir == null) return null;
try {
return connections[dir.getDirection()];
} catch (Exception ex) {
}
return null;
}
public RedstoneConnection getConnectionOrCreate(FaceDirection dir) {
if (dir == null) return null;
RedstoneConnection c = getConnection(dir);
if (c == null) c = connections[dir.getDirection()] = new RedstoneConnection(this, dir.getDirection() + "");
return c;
}
public RedstoneConnection getConnection(ForgeDirection dir) {
return getConnection(FaceDirection.getDirection(ForgeDirection.getOrientation(getFace()), dir, rotation));
}
@Override
public void update() {
super.update();
ForgeDirection face = ForgeDirection.getOrientation(getFace()).getOpposite();
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
RedstoneConnection rc = getConnection(d);
if (rc != null && rc.isInput()) {
rc.setPower(RedstoneHelper.getInput(world, x, y, z, d, face));
}
}
}
@Override
public final List<AxisAlignedBB> getCollisionBoxes() {
List<AxisAlignedBB> aabbs = new ArrayList<AxisAlignedBB>();
ForgeDirection d = ForgeDirection.getOrientation(getFace());
collisionBoxes.clear();
List<AxisAlignedBB> boxes = new ArrayList<AxisAlignedBB>();
addCollisionBoxes(boxes);
for (AxisAlignedBB b : boxes) {
Vector3Cube c = new Vector3Cube(b);
c.getMin().subtract(0.5, 0.5, 0.5);
c.getMax().subtract(0.5, 0.5, 0.5);
c.getMin().rotate(0, Math.PI / 2 * getRotation(), 0);
c.getMax().rotate(0, Math.PI / 2 * getRotation(), 0);
c.getMin().add(0.5, 0.5, 0.5);
c.getMax().add(0.5, 0.5, 0.5);
c = c.rotate90Degrees(d);
collisionBoxes.add(new Vector3Cube(c.getMin(), c.getMax()));
}
for (Vector3Cube c : collisionBoxes)
aabbs.add(c.toAABB());
return aabbs;
}
public void addCollisionBoxes(List<AxisAlignedBB> boxes) {
}
@Override
public final List<AxisAlignedBB> getSelectionBoxes() {
List<AxisAlignedBB> aabbs = new ArrayList<AxisAlignedBB>();
ForgeDirection d = ForgeDirection.getOrientation(getFace());
selectionBoxes.clear();
List<AxisAlignedBB> boxes = new ArrayList<AxisAlignedBB>();
addSelectionBoxes(boxes);
for (AxisAlignedBB b : boxes) {
Vector3Cube c = new Vector3Cube(b);
c.getMin().subtract(0.5, 0.5, 0.5);
c.getMax().subtract(0.5, 0.5, 0.5);
c.getMin().rotate(0, Math.PI / 2 * getRotation(), 0);
c.getMax().rotate(0, Math.PI / 2 * getRotation(), 0);
c.getMin().add(0.5, 0.5, 0.5);
c.getMax().add(0.5, 0.5, 0.5);
c = c.rotate90Degrees(d);
selectionBoxes.add(new Vector3Cube(c.getMin(), c.getMax()));
}
for (Vector3Cube c : selectionBoxes)
aabbs.add(c.toAABB());
return aabbs;
}
public void addSelectionBoxes(List<AxisAlignedBB> boxes) {
}
@Override
public final List<AxisAlignedBB> getOcclusionBoxes() {
List<AxisAlignedBB> aabbs = new ArrayList<AxisAlignedBB>();
ForgeDirection d = ForgeDirection.getOrientation(getFace());
occlusionBoxes.clear();
List<AxisAlignedBB> boxes = new ArrayList<AxisAlignedBB>();
addOcclusionBoxes(boxes);
for (AxisAlignedBB b : boxes) {
Vector3Cube c = new Vector3Cube(b);
c.getMin().subtract(0.5, 0.5, 0.5);
c.getMax().subtract(0.5, 0.5, 0.5);
c.getMin().rotate(0, Math.PI / 2 * getRotation(), 0);
c.getMax().rotate(0, Math.PI / 2 * getRotation(), 0);
c.getMin().add(0.5, 0.5, 0.5);
c.getMax().add(0.5, 0.5, 0.5);
c = c.rotate90Degrees(d);
occlusionBoxes.add(new Vector3Cube(c.getMin(), c.getMax()));
}
for (Vector3Cube c : occlusionBoxes)
aabbs.add(c.toAABB());
return aabbs;
}
public void addOcclusionBoxes(List<AxisAlignedBB> boxes) {
}
}
| 11,618 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
PartRegistry.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/part/PartRegistry.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.api.part;
import java.lang.reflect.Constructor;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
import net.quetzi.bluepower.init.BPItems;
import net.quetzi.bluepower.part.cable.RedAlloyWire;
import net.quetzi.bluepower.part.gate.GateAnd;
import net.quetzi.bluepower.part.gate.GateBuffer;
import net.quetzi.bluepower.part.gate.GateCounter;
import net.quetzi.bluepower.part.gate.GateMux;
import net.quetzi.bluepower.part.gate.GateNand;
import net.quetzi.bluepower.part.gate.GateNor;
import net.quetzi.bluepower.part.gate.GateNot;
import net.quetzi.bluepower.part.gate.GateOr;
import net.quetzi.bluepower.part.gate.GatePulseFormer;
import net.quetzi.bluepower.part.gate.GateRandomizer;
import net.quetzi.bluepower.part.gate.GateSequencer;
import net.quetzi.bluepower.part.gate.GateTimer;
import net.quetzi.bluepower.part.lamp.PartCageLamp;
import net.quetzi.bluepower.part.lamp.PartFixture;
import net.quetzi.bluepower.part.tube.PneumaticTube;
import net.quetzi.bluepower.references.Refs;
public class PartRegistry {
private static Map<String, Entry<Class<? extends BPPart>, Object[]>> parts = new LinkedHashMap<String, Entry<Class<? extends BPPart>, Object[]>>();
private static Map<String, BPPart> samples = new LinkedHashMap<String, BPPart>();
public static String ICON_PART;
private PartRegistry() {
}
/**
* Register a part
*
* @param part
* Part class
*/
public static void registerPart(Class<? extends BPPart> part, Object... constructorArgs) {
if (part == null) return;
Entry<Class<? extends BPPart>, Object[]> e = new AbstractMap.SimpleEntry<Class<? extends BPPart>, Object[]>(part, constructorArgs);
if (parts.containsKey(e)) return;
parts.put("tmp", e);
BPPart p = createPart("tmp");
samples.put(p.getType(), p);
parts.remove("tmp");
parts.put(p.getType(), e);
}
/**
* Creates a part from its ID
*
* @param id
* The part ID
* @param isMultipart
* Whether it's using a multipart id or not (this is usually false)
* @return A new instance of the part or null if it couldn't be found
*/
public static BPPart createPart(String id, boolean isMultipart) {
try {
Entry<Class<? extends BPPart>, Object[]> e = getPartData(id, isMultipart);
if (e == null) return null;
Class<? extends BPPart> c = e.getKey();
Object[] args = e.getValue();
Class<?>[] argsClasses = new Class<?>[args.length];
for (int i = 0; i < args.length; i++)
argsClasses[i] = args[i].getClass();
Constructor<? extends BPPart> cons = c.getConstructor(argsClasses);
boolean wasAccessible = cons.isAccessible();
cons.setAccessible(true);
BPPart inst = cons.newInstance(args);
cons.setAccessible(wasAccessible);
return inst;
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
/**
* Creates a part from its ID
*
* @param id
* The part ID
* @return A new instance of the part or null if it couldn't be found
*/
public static BPPart createPart(String id) {
return createPart(id, false);
}
public static Map<String, Entry<Class<? extends BPPart>, Object[]>> getMappings() {
return Collections.unmodifiableMap(parts);
}
public static List<String> getRegisteredParts() {
return Collections.unmodifiableList(new ArrayList<String>(parts.keySet()));
}
public static List<String> getRegisteredPartsForTab(CreativeTabs tab) {
List<String> partIds = new ArrayList<String>();
List<BPPart> parts = new ArrayList<BPPart>();
if (tab != null) {
for (BPPart p : PartRegistry.samples.values())
if (Arrays.asList(p.getCreativeTabs()).contains(tab)) parts.add(p);
Collections.sort(parts, new ComparatorCreativeTabIndex(tab));
for (BPPart p : parts)
partIds.add(p.getType());
}
return Collections.unmodifiableList(new ArrayList<String>(partIds));
}
/**
* Gets the part's item from an ID
*
* @param id
* The part's ID
* @return An item with the part ID
*/
public static ItemStack getItemForPart(String id) {
if (parts.containsKey(id)) {
ItemStack is = new ItemStack(BPItems.multipart);
NBTTagCompound tag = new NBTTagCompound();
tag.setString("id", id);
is.setTagCompound(tag);
return is;
}
return null;
}
public static ItemStack getItemForPart(String id, int stacksize) {
if (parts.containsKey(id)) {
ItemStack is = new ItemStack(BPItems.multipart);
NBTTagCompound tag = new NBTTagCompound();
tag.setString("id", id);
is.setTagCompound(tag);
is.stackSize = stacksize;
return is;
}
return null;
}
/**
* Gets the part id stored in the item and creates a new part with that id
*
* @param is
* The item to get the part id from
* @return A new instance of the part or null if it couldn't be found
*/
public static BPPart createPartFromItem(ItemStack is) {
String id = getPartIdFromItem(is);
return createPart(id);
}
public static Entry<Class<? extends BPPart>, Object[]> getPartData(String id) {
return getPartData(id, false);
}
public static Entry<Class<? extends BPPart>, Object[]> getPartData(String id, boolean isMultipart) {
try {
for (String s : parts.keySet()) {
if ((isMultipart ? Refs.MODID + "_" + s : s).equals(id)) {
try {
return parts.get(s);
} catch (Exception e) {
e.printStackTrace();
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static Entry<Class<? extends BPPart>, Object[]> getPartDataFromItem(ItemStack is) {
String id = getPartIdFromItem(is);
return getPartData(id);
}
/**
* Gets the part ID stored in the item
*
* @param is
* Item to get the part ID from
* @return The part ID
*/
public static String getPartIdFromItem(ItemStack is) {
try {
NBTTagCompound tag = is.getTagCompound();
return tag.getString("id");
} catch (Exception ex) {
}
return null;
}
/**
* Gets the metadata for the multipart itemstack passed as an argument
* @param is
* ItemsStack to get the metadata from
* @return The metadata that stack should have
*/
public static int getStackMetadata(ItemStack is) {
String id = getPartIdFromItem(is);
if (id == null) return 0;
int i = 0;
for (String s : parts.keySet()) {
if (s.equals(id)) break;
i++;
}
return i;
}
public static boolean hasCustomItemEntity(ItemStack is) {
String id = getPartIdFromItem(is);
BPPart part = samples.get(id);
return part != null && part.hasCustomItemEntity();
}
public static EntityItem createItemEntityForPart(String id, World w, double x, double y, double z, ItemStack item) {
BPPart part = samples.get(id);
if (part == null) return null;
return part.createItemEntity(w, x, y, z, item);
}
public static EntityItem createItemEntityForStack(World w, double x, double y, double z, ItemStack item) {
String id = getPartIdFromItem(item);
BPPart part = samples.get(id);
if (part == null) return null;
return part.createItemEntity(w, x, y, z, item);
}
public static void init() {
ICON_PART = "timer";
// Gates
registerPart(GateNot.class);
registerPart(GateAnd.class);
registerPart(GateTimer.class);
registerPart(GateSequencer.class);
registerPart(GateBuffer.class);
registerPart(GateCounter.class);
registerPart(GateMux.class);
registerPart(GateNand.class);
registerPart(GateOr.class);
registerPart(GateNor.class);
registerPart(GatePulseFormer.class);
registerPart(GateRandomizer.class);
// Lamps
for (int i = 0; i < ItemDye.field_150922_c.length; i++)
registerPart(PartCageLamp.class, ItemDye.field_150921_b[i].toLowerCase(), ItemDye.field_150922_c[i], false);
for (int i = 0; i < ItemDye.field_150922_c.length; i++)
registerPart(PartFixture.class, ItemDye.field_150921_b[i].toLowerCase(), ItemDye.field_150922_c[i], false);
for (int i = 0; i < ItemDye.field_150922_c.length; i++)
registerPart(PartCageLamp.class, ItemDye.field_150921_b[i].toLowerCase(), ItemDye.field_150922_c[i], true);
/*
* for (int i = 0; i < ItemDye.field_150922_c.length; i++)
* registerPart(PartLamp.class, ItemDye.field_150921_b[i].toLowerCase(), ItemDye.field_150922_c[i], true);
*/
for (int i = 0; i < ItemDye.field_150922_c.length; i++)
registerPart(PartFixture.class, ItemDye.field_150921_b[i].toLowerCase(), ItemDye.field_150922_c[i], true);
// Pneumatic Tubes
registerPart(PneumaticTube.class);
// Red alloy
registerPart(RedAlloyWire.class); // Uncovered
for (int i = 0; i < ItemDye.field_150922_c.length; i++)
registerPart(RedAlloyWire.class, ItemDye.field_150921_b[i].toLowerCase(), ItemDye.field_150922_c[i]); // Covered
}
}
| 11,424 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IBPRedstoneConductor.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/part/redstone/IBPRedstoneConductor.java | package net.quetzi.bluepower.api.part.redstone;
import java.util.List;
import net.minecraftforge.common.util.ForgeDirection;
public interface IBPRedstoneConductor {
public List<IBPRedstonePart> getConnections(ForgeDirection side);
public RedstoneNetwork getNetwork();
public void setNetwork(RedstoneNetwork network);
public void onUpdateConnection();
public void onRedstoneUpdate();
}
| 438 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IBPRedstonePart.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/part/redstone/IBPRedstonePart.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.api.part.redstone;
import net.minecraftforge.common.util.ForgeDirection;
public interface IBPRedstonePart {
public boolean canConnect(ForgeDirection side);
public int getStrongOutput(ForgeDirection side);
public int getWeakOutput(ForgeDirection side);
}
| 974 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RedstoneNetworkTickHandler.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/part/redstone/RedstoneNetworkTickHandler.java | package net.quetzi.bluepower.api.part.redstone;
import java.util.ArrayList;
import java.util.List;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.TickEvent;
import cpw.mods.fml.common.gameevent.TickEvent.Phase;
import cpw.mods.fml.common.gameevent.TickEvent.Type;
public class RedstoneNetworkTickHandler {
private List<RedstoneNetwork> despawn = new ArrayList<RedstoneNetwork>();
@SubscribeEvent
public void onTick(TickEvent event) {
if (event.phase == Phase.START && event.type == Type.WORLD) {
for (RedstoneNetwork net : RedstoneNetwork.networks) {
if (net.shouldDespawn) {
despawn.add(net);
continue;
}
net.tick();
}
for (RedstoneNetwork net : despawn) {
net.despawn();
}
despawn.clear();
}
}
}
| 963 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RedstoneNetwork.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/part/redstone/RedstoneNetwork.java | package net.quetzi.bluepower.api.part.redstone;
import java.util.ArrayList;
import java.util.List;
public final class RedstoneNetwork {
public static final List<RedstoneNetwork> networks = new ArrayList<RedstoneNetwork>();
public static RedstoneNetwork getNetworkForPart(IBPRedstoneConductor c) {
if (c == null) return null;
return null;
}
private List<IBPRedstoneConductor> parts = new ArrayList<IBPRedstoneConductor>();
protected boolean shouldDespawn = false;
private RedstoneNetwork(IBPRedstoneConductor c) {
parts.add(c);
}
public void tick() {
}
public void markForDespawn() {
shouldDespawn = true;
}
public void despawn() {
RedstoneNetwork.networks.remove(this);
for (IBPRedstoneConductor c : parts)
if (c.getNetwork() == this) c = null;
for (IBPRedstoneConductor c : parts)
if (c.getNetwork() == null) c.setNetwork(getNetworkForPart(c));
}
public void merge(RedstoneNetwork net) {
for (IBPRedstoneConductor p : net.parts)
parts.add(p);
net.markForDespawn();
}
public void split(IBPRedstonePart part) {
}
}
| 1,343 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IPneumaticTube.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/tube/IPneumaticTube.java | package net.quetzi.bluepower.api.tube;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
/**
* later there will be a way for API implementers to get an IPneumaticTube for a given TileEntity.
*/
public interface IPneumaticTube {
/**
* The colors that a tube can have. These are in the same order as dye. Also note the 'NONE' as last entry.
*/
public static enum TubeColor {
BLACK, RED, GREEN, BROWN, BLUE, PURPLE, CYAN, SILVER, GRAY, PINK, LIME, YELLOW, LIGHT_BLUE, MAGENTA, ORANGE, WHITE, NONE
}
/**
* Returns true if the network accepted the stack.
* @param stack
* @param from
* @param itemColor
* @param simulate
* @return
*/
public boolean injectStack(ItemStack stack, ForgeDirection from, TubeColor itemColor, boolean simulate);
}
| 864 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IAlloyFurnaceRegistry.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/recipe/IAlloyFurnaceRegistry.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.api.recipe;
import net.minecraft.item.ItemStack;
/**
*
* @author MineMaarten
*/
public interface IAlloyFurnaceRegistry {
/**
* With this you can add recipes that require special handling (like NBT dependent recipes). It's similar to Vanilla's IRecipe
* For the normal recipes, use addRecipe(ItemStack output, Object... input).
*
* @param recipe
*/
void addRecipe(IAlloyFurnaceRecipe recipe);
/**
* Adds a recipe to the Alloy Furnace.
*
* @param output the crafting result
* @param input input items. These can be ItemStack, Item or Block objects. You can specify up to 9 input objects.
* You can only specify
*/
void addRecipe(ItemStack output, Object... input);
/**
* Any item added here will cause dynamically generated recipes that allows items to be broken down to this item.
* In BluePower, this is called with an iron ingot.
* It doesn't matter when you call this, as the recipes will be generated in the postInit.
*
* @param recycledItem
* @param blacklist list of item registry names ("minecraft:bucket") that shouldn't be added by the generator.
* As modder you could pass a config entry to this.
*/
void addRecyclingRecipe(ItemStack recycledItem, String... blacklist);
}
| 2,092 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IAlloyFurnaceRecipe.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/api/recipe/IAlloyFurnaceRecipe.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.api.recipe;
import net.minecraft.item.ItemStack;
/**
* This class only should be used for special recipes, like recipes taht depend on NBT. For normal recipes use
* {@link net.quetzi.bluepower.recipe.AlloyFurnaceRegistry#addRecipe(ItemStack, ItemStack...)}.
* @author MineMaarten
*/
public interface IAlloyFurnaceRecipe {
/**
* Return true if this recipe can be smelted using the input stacks. The input stacks are the 9 inventory slots, so an element can be null.
*
* @param input
* @return
*/
boolean matches(ItemStack[] input);
/**
* The items that are needed in this recipe need to be removed from the input inventory.
*/
void useItems(ItemStack[] input);
ItemStack getCraftingResult(ItemStack[] input);
}
| 1,541 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
CanvasBagRecipe.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/recipe/CanvasBagRecipe.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Lumien
*/
package net.quetzi.bluepower.recipe;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import net.quetzi.bluepower.items.ItemCanvasBag;
public class CanvasBagRecipe extends ShapelessOreRecipe {
public CanvasBagRecipe(ItemStack result, Object... recipe) {
super(result, recipe);
}
@Override
public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) {
ItemStack bag=null;
for (int slot=0;slot<inventoryCrafting.getSizeInventory();slot++)
{
if (inventoryCrafting.getStackInSlot(slot)!=null && inventoryCrafting.getStackInSlot(slot).getItem() instanceof ItemCanvasBag)
{
bag = inventoryCrafting.getStackInSlot(slot);
}
}
if (bag!=null)
{
bag=bag.copy();
bag.setItemDamage(this.getRecipeOutput().getItemDamage());
return bag;
}
return this.getRecipeOutput();
}
}
| 1,830 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
AlloyFurnaceRegistry.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/recipe/AlloyFurnaceRegistry.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.recipe;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import net.quetzi.bluepower.BluePower;
import net.quetzi.bluepower.api.recipe.IAlloyFurnaceRecipe;
import net.quetzi.bluepower.api.recipe.IAlloyFurnaceRegistry;
import net.quetzi.bluepower.init.Config;
import net.quetzi.bluepower.util.ItemStackUtils;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.ModContainer;
import cpw.mods.fml.common.registry.GameData;
/**
*
* @author MineMaarten
*/
public class AlloyFurnaceRegistry implements IAlloyFurnaceRegistry {
private static AlloyFurnaceRegistry INSTANCE = new AlloyFurnaceRegistry();
private final List<IAlloyFurnaceRecipe> alloyFurnaceRecipes = new ArrayList<IAlloyFurnaceRecipe>();
private final List<ItemStack> bufferedRecyclingItems = new ArrayList<ItemStack>();
private final List<String> blacklist = new ArrayList<String>();
private AlloyFurnaceRegistry() {
}
public static AlloyFurnaceRegistry getInstance() {
return INSTANCE;
}
@Override
public void addRecipe(IAlloyFurnaceRecipe recipe) {
alloyFurnaceRecipes.add(recipe);
}
/**
* getter for NEI plugin
*
* @return
*/
public List<IAlloyFurnaceRecipe> getAllRecipes() {
return alloyFurnaceRecipes;
}
@Override
public void addRecipe(ItemStack craftingResult, Object... requiredItems) {
ItemStack[] requiredStacks = new ItemStack[requiredItems.length];
for (int i = 0; i < requiredStacks.length; i++) {
if (requiredItems[i] instanceof ItemStack) {
requiredStacks[i] = (ItemStack) requiredItems[i];
} else if (requiredItems[i] instanceof Item) {
requiredStacks[i] = new ItemStack((Item) requiredItems[i], 1, OreDictionary.WILDCARD_VALUE);
} else if (requiredItems[i] instanceof Block) {
requiredStacks[i] = new ItemStack((Item) requiredItems[i], 1, OreDictionary.WILDCARD_VALUE);
} else {
throw new IllegalArgumentException("Alloy Furnace crafting ingredients can only be ItemStack, Item or Block!");
}
}
addRecipe(new StandardAlloyFurnaceRecipe(craftingResult, requiredStacks));
}
@Override
public void addRecyclingRecipe(ItemStack recycledItem, String... blacklist) {
bufferedRecyclingItems.add(recycledItem);
if (blacklist.length > 0) {
ModContainer mc = Loader.instance().activeModContainer();
BluePower.log.info((mc != null ? mc.getName() : "Unknown mod") + " added to the Alloy Furnace recycling blacklist: " + Arrays.toString(blacklist));
Collections.addAll(this.blacklist, blacklist);
}
}
@SuppressWarnings("unchecked")
public void generateRecyclingRecipes() {
Collections.addAll(blacklist, Config.alloyFurnaceBlacklist);
List<Item> blacklist = new ArrayList<Item>();
for (String configString : this.blacklist) {
Item item = GameData.getItemRegistry().getObject(configString);
if (item != null) {
blacklist.add(item);
} else {
BluePower.log.info("Config entry \"" + configString + "\" not an existing item/block name! Will not be added to the blacklist");
}
}
List<IRecipe> registeredRecipes = new ArrayList<IRecipe>();
for (ItemStack recyclingItem : bufferedRecyclingItems) {
List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
for (IRecipe recipe : recipes) {
try {
int recyclingAmount = 0;
if (recipe instanceof ShapedRecipes) {
ShapedRecipes shaped = (ShapedRecipes) recipe;
if (shaped.recipeItems != null) {
for (ItemStack input : shaped.recipeItems) {
if (input != null && ItemStackUtils.isItemFuzzyEqual(input, recyclingItem)) {
recyclingAmount++;
}
}
}
} else if (recipe instanceof ShapelessRecipes) {
ShapelessRecipes shapeless = (ShapelessRecipes) recipe;
if (shapeless.recipeItems != null) {
for (ItemStack input : (List<ItemStack>) shapeless.recipeItems) {
if (input != null && ItemStackUtils.isItemFuzzyEqual(input, recyclingItem)) {
recyclingAmount++;
}
}
}
} else if (recipe instanceof ShapedOreRecipe) {
ShapedOreRecipe shapedOreRecipe = (ShapedOreRecipe) recipe;
if (shapedOreRecipe.getInput() != null) {
for (Object input : shapedOreRecipe.getInput()) {
if (input != null) {
List<ItemStack> itemList;
if (input instanceof ItemStack) {
itemList = new ArrayList<ItemStack>();
itemList.add((ItemStack) input);
} else {
itemList = (List<ItemStack>) input;
}
for (ItemStack item : itemList) {
if (item != null && ItemStackUtils.isItemFuzzyEqual(item, recyclingItem)) {
recyclingAmount++;
break;
}
}
}
}
}
} else if (recipe instanceof ShapelessOreRecipe) {
ShapelessOreRecipe shapeless = (ShapelessOreRecipe) recipe;
for (Object input : shapeless.getInput()) {
if (input != null) {
List<ItemStack> itemList;
if (input instanceof ItemStack) {
itemList = new ArrayList<ItemStack>();
itemList.add((ItemStack) input);
} else {
itemList = (List<ItemStack>) input;
}
for (ItemStack item : itemList) {
if (item != null && ItemStackUtils.isItemFuzzyEqual(item, recyclingItem)) {
recyclingAmount++;
break;
}
}
}
}
}
if (recyclingAmount > 0 && !registeredRecipes.contains(recipe)) {
if (blacklist.contains(recipe.getRecipeOutput().getItem())) {
BluePower.log.info("Skipped adding item/block " + recipe.getRecipeOutput().getDisplayName() + " to the Alloy Furnace recipes.");
continue;
}
registeredRecipes.add(recipe);
addRecipe(new ItemStack(recyclingItem.getItem(), recyclingAmount, recyclingItem.getItemDamage()), recipe.getRecipeOutput());
}
} catch (Throwable e) {
BluePower.log.error("Error when generating an Alloy Furnace recipe for item " + recyclingItem.getDisplayName() + ", recipe output: " + recipe.getRecipeOutput().getDisplayName());
e.printStackTrace();
}
}
}
}
public IAlloyFurnaceRecipe getMatchingRecipe(ItemStack[] input, ItemStack outputSlot) {
for (IAlloyFurnaceRecipe recipe : alloyFurnaceRecipes) {
if (recipe.matches(input)) {
if (outputSlot != null) {
if (outputSlot != null) {// check if we can add the crafting result to the output slot
ItemStack craftingResult = recipe.getCraftingResult(input);
if (!ItemStack.areItemStackTagsEqual(outputSlot, craftingResult) || !outputSlot.isItemEqual(craftingResult)) {
continue;
} else if (craftingResult.stackSize + outputSlot.stackSize > outputSlot.getMaxStackSize()) {
continue;
}
}
}
return recipe;
}
}
return null;
}
public class StandardAlloyFurnaceRecipe implements IAlloyFurnaceRecipe {
private final ItemStack craftingResult;
private final ItemStack[] requiredItems;
private StandardAlloyFurnaceRecipe(ItemStack craftingResult, ItemStack... requiredItems) {
if (craftingResult == null) throw new IllegalArgumentException("Alloy Furnace crafting result can't be null!");
if (requiredItems.length > 9) throw new IllegalArgumentException("There can't be more than 9 crafting ingredients for the Alloy Furnace!");
for (ItemStack requiredItem : requiredItems) {
if (requiredItem == null) throw new NullPointerException("An Alloy Furnace crafting ingredient can't be null!");
}
for (ItemStack stack : requiredItems) {
for (ItemStack stack2 : requiredItems) {
if (stack != stack2 && ItemStackUtils.isItemFuzzyEqual(stack, stack2)) throw new IllegalArgumentException("No equivalent Alloy Furnace crafting ingredient can be given twice! This does take OreDict + wildcard values in account.");
}
}
this.craftingResult = craftingResult;
this.requiredItems = requiredItems;
}
@Override
public boolean matches(ItemStack[] input) {
for (ItemStack requiredItem : requiredItems) {
int itemsNeeded = requiredItem.stackSize;
for (ItemStack inputStack : input) {
if (inputStack != null && ItemStackUtils.isItemFuzzyEqual(inputStack, requiredItem)) {
itemsNeeded -= inputStack.stackSize;
if (itemsNeeded <= 0) break;
}
}
if (itemsNeeded > 0) return false;
}
return true;
}
@Override
public void useItems(ItemStack[] input) {
for (ItemStack requiredItem : requiredItems) {
int itemsNeeded = requiredItem.stackSize;
for (int i = 0; i < input.length; i++) {
ItemStack inputStack = input[i];
if (inputStack != null && ItemStackUtils.isItemFuzzyEqual(inputStack, requiredItem)) {
int itemsSubstracted = Math.min(inputStack.stackSize, itemsNeeded);
inputStack.stackSize -= itemsSubstracted;
if (inputStack.stackSize <= 0) input[i] = null;
itemsNeeded -= itemsSubstracted;
if (itemsNeeded <= 0) break;
}
}
if (itemsNeeded > 0) throw new IllegalArgumentException("Alloy Furnace recipe using items, after using still items required?? This is a bug!");
}
}
@Override
public ItemStack getCraftingResult(ItemStack[] input) {
return craftingResult;
}
/**
* getter for NEI plugin
*
* @return
*/
public ItemStack[] getRequiredItems() {
return requiredItems;
}
}
}
| 13,640 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BPTileMultipart.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/BPTileMultipart.java | package net.quetzi.bluepower.tileentities;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.util.ComparatorMOP;
import org.lwjgl.opengl.GL11;
public class BPTileMultipart extends TileEntity {
private List<BPPart> parts = new ArrayList<BPPart>();
public List<AxisAlignedBB> getCollisionBoxes() {
List<AxisAlignedBB> aabbs = new ArrayList<AxisAlignedBB>();
for (BPPart p : parts)
aabbs.addAll(p.getCollisionBoxes());
return aabbs;
}
public List<AxisAlignedBB> getSelectionBoxes() {
List<AxisAlignedBB> aabbs = new ArrayList<AxisAlignedBB>();
for (BPPart p : parts)
aabbs.addAll(p.getSelectionBoxes());
return aabbs;
}
public List<AxisAlignedBB> getOcclusionBoxes() {
List<AxisAlignedBB> aabbs = new ArrayList<AxisAlignedBB>();
for (BPPart p : parts)
aabbs.addAll(p.getOcclusionBoxes());
return aabbs;
}
public MovingObjectPosition rayTrace(Vector3 start, Vector3 end) {
List<MovingObjectPosition> mops = new ArrayList<MovingObjectPosition>();
for (BPPart p : parts) {
MovingObjectPosition mop = p.rayTrace(start, end);
if (mop != null) mops.add(mop);
}
Collections.sort(mops, new ComparatorMOP(start));
if (mops.isEmpty()) return null;
return mops.get(0);
}
public void renderDynamic(Vector3 loc, int pass, float frame) {
for (BPPart p : parts) {
GL11.glPushMatrix();
p.renderDynamic(loc, pass, frame);
GL11.glPopMatrix();
}
}
public void renderStatic(Vector3 loc, int pass) {
for (BPPart p : parts) {
GL11.glPushMatrix();
p.renderStatic(loc, pass);
GL11.glPopMatrix();
}
}
public int getLightValue() {
int val = 0;
for (BPPart p : parts)
val = Math.max(val, p.getLightValue());
return Math.max(0, Math.min(val, 15));
}
public float getHardness(MovingObjectPosition mop, EntityPlayer player) {
return -1;// FIXME BLUEPOWER Get clicked part
}
public float getExplosionResistance() {
float res = 0;
for (BPPart p : parts)
res = Math.max(res, p.getExplosionResistance());
return res;
}
public ItemStack getPickedItem(MovingObjectPosition hit) {
return null;// FIXME BLUEPOWER Get clicked part
}
public List<ItemStack> getDrops() {
List<ItemStack> items = new ArrayList<ItemStack>();
// FIXME BLUEPOWER Get clicked part
return items;
}
public void notifyPartChange(BPPart part) {
for (BPPart p : parts) {
if (p == part) continue;
p.onPartChanged();
}
}
public void onEntityCollision(Entity entity) {
for (BPPart p : parts) {
p.onEntityCollision(entity);// FIXME BLUEPOWER Check if entity is actually colliding
}
}
public void onNeighborUpdate() {
for (BPPart p : parts)
p.onNeighborUpdate();
}
public boolean onActivated(EntityPlayer player, MovingObjectPosition mop, ItemStack item) {
return false;// FIXME BLUEPOWER Get clicked part
}
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
}
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
}
public boolean drawHighlight(AxisAlignedBB cube, MovingObjectPosition mop) {
return false;// FIXME BLUEPOWER Get clicked part
}
public List<BPPart> getParts() {
return parts;
}
}
| 4,400 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileMachineBase.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/TileMachineBase.java | package net.quetzi.bluepower.tileentities;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.tube.IPneumaticTube.TubeColor;
import net.quetzi.bluepower.helper.IOHelper;
import net.quetzi.bluepower.helper.TileEntityCache;
import net.quetzi.bluepower.part.tube.ITubeConnection;
import net.quetzi.bluepower.part.tube.IWeightedTubeInventory;
import net.quetzi.bluepower.part.tube.TubeStack;
public class TileMachineBase extends TileBase implements ITubeConnection, IWeightedTubeInventory {
protected boolean spawnItemsInWorld = true;
protected boolean acceptsTubeItems = true;
private final List<TubeStack> internalItemStackBuffer = new ArrayList<TubeStack>();
private TileEntityCache[] tileCache;
public static final int BUFFER_EMPTY_INTERVAL = 10;
@Override
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote) {
if (getTicker() % BUFFER_EMPTY_INTERVAL == 0 && !internalItemStackBuffer.isEmpty()) {
if (IOHelper.canInterfaceWith(getTileCache()[getOutputDirection().ordinal()].getTileEntity(), getFacingDirection())) {
TubeStack tubeStack = internalItemStackBuffer.get(0);
ItemStack returnedStack = IOHelper.insert(getTileCache()[getOutputDirection().ordinal()].getTileEntity(), tubeStack.stack, getFacingDirection(), tubeStack.color, false);
if (returnedStack == null) {
internalItemStackBuffer.remove(0);
onItemOutputted();
markDirty();
} else if (returnedStack.stackSize != tubeStack.stack.stackSize) {
onItemOutputted();
markDirty();
}
}
} else if (spawnItemsInWorld) {
ForgeDirection direction = getFacingDirection().getOpposite();
if (worldObj.isAirBlock(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ)) {
for (Iterator<TubeStack> iterator = internalItemStackBuffer.iterator(); iterator.hasNext();) {
ItemStack itemStack = iterator.next().stack;
ejectItemInWorld(itemStack, direction);
onItemOutputted();
iterator.remove();
}
}
}
}
}
@Override
public void onBlockNeighbourChanged() {
super.onBlockNeighbourChanged();
for (TileEntityCache cache : getTileCache()) {
cache.update();
}
}
protected void addItemToOutputBuffer(ItemStack stack, TubeColor color) {
if (!worldObj.isRemote) internalItemStackBuffer.add(new TubeStack(stack, getOutputDirection().getOpposite(), color));
}
protected void addItemToOutputBuffer(ItemStack stack) {
addItemToOutputBuffer(stack, TubeColor.NONE);
}
protected void addItemsToOutputBuffer(Iterable<ItemStack> stacks) {
addItemsToOutputBuffer(stacks, TubeColor.NONE);
}
protected void addItemsToOutputBuffer(Iterable<ItemStack> stacks, TubeColor color) {
for (ItemStack stack : stacks) {
addItemToOutputBuffer(stack, color);
}
}
protected boolean isBufferEmpty() {
return internalItemStackBuffer.isEmpty();
}
/**
* Called when an item is outputted from this block, can be used for animation (See Sortron)
*/
protected void onItemOutputted() {
}
public TileEntityCache[] getTileCache() {
if (tileCache == null) {
tileCache = TileEntityCache.getDefaultCache(worldObj, xCoord, yCoord, zCoord);
}
return tileCache;
}
public ForgeDirection getOutputDirection() {
return ForgeDirection.getOrientation(getBlockMetadata()).getOpposite();
}
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
NBTTagList nbttaglist = compound.getTagList("ItemBuffer", 10);
for (int i = 0; i < nbttaglist.tagCount(); ++i) {
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
internalItemStackBuffer.add(TubeStack.loadFromNBT(nbttagcompound1));
}
}
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
NBTTagList nbttaglist = new NBTTagList();
for (TubeStack tubeStack : internalItemStackBuffer) {
if (tubeStack != null) {
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
tubeStack.writeToNBT(nbttagcompound1);
nbttaglist.appendTag(nbttagcompound1);
}
}
compound.setTag("ItemBuffer", nbttaglist);
}
public void ejectItemInWorld(ItemStack stack, ForgeDirection oppDirection) {
float spawnX = xCoord + 0.5F + oppDirection.offsetX * 0.8F;
float spawnY = yCoord + 0.5F + oppDirection.offsetY * 0.8F;
float spawnZ = zCoord + 0.5F + oppDirection.offsetZ * 0.8F;
EntityItem droppedItem = new EntityItem(worldObj, spawnX, spawnY, spawnZ, stack);
droppedItem.motionX = oppDirection.offsetX * 0.20F;
droppedItem.motionY = oppDirection.offsetY * 0.20F;
droppedItem.motionZ = oppDirection.offsetZ * 0.20F;
worldObj.spawnEntityInWorld(droppedItem);
}
@Override
public List<ItemStack> getDrops() {
List<ItemStack> drops = super.getDrops();
for (TubeStack stack : internalItemStackBuffer)
drops.add(stack.stack);
return drops;
}
@Override
public boolean isConnectedTo(ForgeDirection from) {
ForgeDirection dir = getOutputDirection();
return from == dir.getOpposite() || acceptsTubeItems && from == dir;
}
@Override
public TubeStack acceptItemFromTube(TubeStack stack, ForgeDirection from, boolean simulate) {
if (!simulate) internalItemStackBuffer.add(stack);
return null;
}
@Override
public int getWeight(ForgeDirection from) {
return from == getOutputDirection().getOpposite() ? 1000000 : 0;//make the buffer side the last place to go
}
}
| 6,813 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileEntities.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/TileEntities.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.tileentities;
import net.quetzi.bluepower.tileentities.tier1.*;
import net.quetzi.bluepower.tileentities.tier2.TileSortingMachine;
import net.quetzi.bluepower.tileentities.tier3.TileCPU;
import net.quetzi.bluepower.tileentities.tier3.TileDiskDrive;
import net.quetzi.bluepower.tileentities.tier3.TileIOExpander;
import net.quetzi.bluepower.tileentities.tier3.TileMonitor;
import net.quetzi.bluepower.tileentities.tier3.TileSortron;
import cpw.mods.fml.common.registry.GameRegistry;
public class TileEntities {
/**
* Method to register the TE's to the game. If a TE is not registered, it _will_ cause issues!
*/
public static void init() {
GameRegistry.registerTileEntity(TileAlloyFurnace.class, "tileAlloyFurnace");
GameRegistry.registerTileEntity(TileBlockBreaker.class, "tileBlockBreaker");
GameRegistry.registerTileEntity(TileIgniter.class, "tileIgniter");
GameRegistry.registerTileEntity(TileBuffer.class, "tileBuffer");
GameRegistry.registerTileEntity(TileTransposer.class, "tileTransposer");
GameRegistry.registerTileEntity(TileSortingMachine.class, "tileSortingMachine");
GameRegistry.registerTileEntity(TileSortron.class, "tileSortron");
GameRegistry.registerTileEntity(TileCPU.class, "tileCPU");
GameRegistry.registerTileEntity(TileMonitor.class, "tileMonitor");
GameRegistry.registerTileEntity(TileDiskDrive.class, "tileDiskDrive");
GameRegistry.registerTileEntity(TileIOExpander.class, "tileIOExpander");
GameRegistry.registerTileEntity(TileEngine.class, "tileEngine");
GameRegistry.registerTileEntity(TileWindmill.class, "windmill");
GameRegistry.registerTileEntity(TileKinectGenerator.class, "kinectgenerator");
GameRegistry.registerTileEntity(TileDeployer.class, "deployer");
GameRegistry.registerTileEntity(TileEjector.class, "ejector");
GameRegistry.registerTileEntity(TileRelay.class, "relay");
GameRegistry.registerTileEntity(TileLamp.class, "tileLamp");
}
}
| 2,810 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileBase.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/TileBase.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.tileentities;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
public class TileBase extends TileEntity {
private boolean isRedstonePowered;
private int ticker = 0;
/*************** BASIC TE FUNCTIONS **************/
/**
* This function gets called whenever the world/chunk loads
*/
@Override
public void readFromNBT(NBTTagCompound tCompound) {
super.readFromNBT(tCompound);
isRedstonePowered = tCompound.getBoolean("isRedstonePowered");
}
/**
* This function gets called whenever the world/chunk is saved
*/
@Override
public void writeToNBT(NBTTagCompound tCompound) {
super.writeToNBT(tCompound);
tCompound.setBoolean("isRedstonePowered", isRedstonePowered);
}
/**
* Function gets called every tick. Do not forget to call the super method!
*/
@Override
public void updateEntity() {
if (ticker == 0) {
onTileLoaded();
}
super.updateEntity();
ticker++;
}
/**
* ************** ADDED FUNCTIONS ****************
*/
public void onBlockNeighbourChanged() {
checkRedstonePower();
}
/**
* Checks if redstone has changed.
*/
public void checkRedstonePower() {
boolean isIndirectlyPowered = getWorldObj().isBlockIndirectlyGettingPowered(xCoord, yCoord, zCoord);
if (isIndirectlyPowered && !getIsRedstonePowered()) {
redstoneChanged(true);
} else if (getIsRedstonePowered() && !isIndirectlyPowered) {
redstoneChanged(false);
}
}
/**
* This method can be overwritten to get alerted when the redstone level has
* changed.
*
* @param newValue
* The redstone level it is at now
*/
protected void redstoneChanged(boolean newValue) {
isRedstonePowered = newValue;
}
/**
* Check whether or not redstone level is high
*/
public boolean getIsRedstonePowered() {
return isRedstonePowered;
}
/**
* Returns the ticker of the Tile, this number wll increase every tick
*
* @return the ticker
*/
public int getTicker() {
return ticker;
}
/**
* Gets called when the TileEntity ticks for the first time, the world is
* accessible and updateEntity() has not been ran yet
*/
protected void onTileLoaded() {
onBlockNeighbourChanged();
}
public List<ItemStack> getDrops() {
return new ArrayList<ItemStack>();
}
public ForgeDirection getFacingDirection() {
return ForgeDirection.getOrientation(getBlockMetadata());
}
}
| 3,726 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileBlockBreaker.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileBlockBreaker.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.tileentities.tier1;
import java.util.ArrayList;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.helper.IOHelper;
import net.quetzi.bluepower.tileentities.TileMachineBase;
public class TileBlockBreaker extends TileMachineBase {
@Override
protected void redstoneChanged(boolean newValue) {
super.redstoneChanged(newValue);
if (!worldObj.isRemote && newValue && isBufferEmpty()) {
ForgeDirection direction = getFacingDirection();
ForgeDirection oppDirection = direction.getOpposite();
Block breakBlock = worldObj.getBlock(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
int breakMeta = worldObj.getBlockMetadata(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
float breakHardness = breakBlock.getBlockHardness(worldObj, xCoord, yCoord, zCoord);
ArrayList<ItemStack> breakStacks = breakBlock.getDrops(worldObj, xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ, breakMeta, 0);
TileEntity tileEntity = worldObj.getTileEntity(xCoord + oppDirection.offsetX, yCoord + oppDirection.offsetY, zCoord + oppDirection.offsetZ);
if(breakHardness == -1.0F) {
return;
}
worldObj.func_147480_a(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ, false); //destroyBlock
if (IOHelper.canInterfaceWith(tileEntity, direction)) {
for (ItemStack breakStack : breakStacks) {
ItemStack returnedStack = IOHelper.insert(tileEntity, breakStack, direction, false);
if (returnedStack != null) {
this.addItemToOutputBuffer(returnedStack);
}
}
} else if (worldObj.isAirBlock(xCoord + oppDirection.offsetX, yCoord + oppDirection.offsetY, zCoord + oppDirection.offsetZ)) {
for (ItemStack breakStack : breakStacks) {
ejectItemInWorld(breakStack, oppDirection);
}
} else {
addItemsToOutputBuffer(breakStacks);
}
}
}
}
| 3,215 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileRelay.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileRelay.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.tileentities.tier1;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.quetzi.bluepower.tileentities.TileMachineBase;
import java.util.List;
public class TileRelay extends TileMachineBase implements IInventory {
private final ItemStack[] inventory = new ItemStack[9];
@Override
public void updateEntity() {
super.updateEntity();
for (int i=0; i < inventory.length; i++) {
if (inventory[i] != null && inventory[i].stackSize > 0) {
addItemToOutputBuffer(inventory[i]);
inventory[i] = null;
break;
}
}
}
/**
* This function gets called whenever the world/chunk loads
*/
@Override
public void readFromNBT(NBTTagCompound tCompound) {
super.readFromNBT(tCompound);
for (int i = 0; i < 9; i++) {
NBTTagCompound tc = tCompound.getCompoundTag("inventory" + i);
inventory[i] = ItemStack.loadItemStackFromNBT(tc);
}
}
/**
* This function gets called whenever the world/chunk is saved
*/
@Override
public void writeToNBT(NBTTagCompound tCompound) {
super.writeToNBT(tCompound);
for (int i = 0; i < 9; i++) {
if (inventory[i] != null) {
NBTTagCompound tc = new NBTTagCompound();
inventory[i].writeToNBT(tc);
tCompound.setTag("inventory" + i, tc);
}
}
}
/**
* Returns the number of slots in the inventory.
*/
@Override public int getSizeInventory() {
return inventory.length;
}
/**
* Returns the stack in slot i
*
* @param slot
*/
@Override public ItemStack getStackInSlot(int slot) {
return inventory[slot];
}
/**
* Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
* new stack.
*
* @param slot
* @param amount
*/
@Override public ItemStack decrStackSize(int slot, int amount) {
ItemStack itemStack = getStackInSlot(slot);
if (itemStack != null) {
if (itemStack.stackSize <= amount) {
setInventorySlotContents(slot, null);
} else {
itemStack = itemStack.splitStack(amount);
if (itemStack.stackSize == 0) {
setInventorySlotContents(slot, null);
}
}
}
return itemStack;
}
/**
* When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
* like when you close a workbench GUI.
*
* @param slot
*/
@Override public ItemStack getStackInSlotOnClosing(int slot) {
return getStackInSlot(slot);
}
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
*
* @param slot
* @param itemStack
*/
@Override public void setInventorySlotContents(int slot, ItemStack itemStack) {
inventory[slot] = itemStack;
}
/**
* Returns the name of the inventory
*/
@Override public String getInventoryName() {
return "tile.relay.name";
}
/**
* Returns if the inventory is named
*/
@Override public boolean hasCustomInventoryName() {
return true;
}
/**
* Returns the maximum stack size for a inventory slot.
*/
@Override public int getInventoryStackLimit() {
return 64;
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*
* @param var1
*/
@Override public boolean isUseableByPlayer(EntityPlayer var1) {
return true;
}
@Override public void openInventory() {
}
@Override public void closeInventory() {
}
/**
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
*
* @param var1
* @param var2
*/
@Override public boolean isItemValidForSlot(int var1, ItemStack var2) {
return true;
}
@Override
public List<ItemStack> getDrops() {
List<ItemStack> drops = super.getDrops();
for (ItemStack stack : inventory)
if (stack != null) drops.add(stack);
return drops;
}
}
| 5,332 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileEngine.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileEngine.java | package net.quetzi.bluepower.tileentities.tier1;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.tileentities.TileMachineBase;
/**
*
* @author TheFjong
*
*/
public class TileEngine extends TileMachineBase{
private ForgeDirection orientation;
public boolean isActive = false;
public byte pumpTick;
public byte pumpSpeed;
public byte gearSpeed;
public byte gearTick;
public TileEngine(){
pumpTick = 0;
pumpSpeed = 16;
gearSpeed = 16;
}
@Override
public void updateEntity() {
super.updateEntity();
if(worldObj.isRemote){
if(isActive){
gearTick++;
pumpTick++;
if(pumpTick >= pumpSpeed *2){
pumpTick = 0;
if(pumpSpeed > 4){
pumpSpeed--;
}
}
}else{
pumpTick = 0;
}
}
isActive = true;
}
public Packet getDescriptionPacket() {
NBTTagCompound nbtTag = new NBTTagCompound();
this.writeToNBT(nbtTag);
return new S35PacketUpdateTileEntity(this.xCoord, this.yCoord, this.zCoord, 1, nbtTag);
}
public void onDataPacket(NetworkManager net, S35PacketUpdateTileEntity packet) {
readFromNBT(packet.func_148857_g());
}
public void setOrientation(ForgeDirection orientation)
{
this.orientation = orientation;
}
public void setOrientation(int orientation)
{
this.orientation = ForgeDirection.getOrientation(orientation);
}
public ForgeDirection getOrientation()
{
return orientation;
}
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
int rotation = orientation.ordinal();
compound.setInteger("rotation", rotation);
// compound.setByte("pumpTick", pumpTick);
// compound.setByte("pumpSpeed", pumpSpeed);
// compound.setByte("gearTick", gearTick);
}
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
setOrientation(compound.getInteger("rotation"));
// pumpTick = compound.getByte("pumpTick");
// pumpSpeed =compound.getByte("pumpSpeed");
// gearTick =compound.getByte("gearTick");
}
}
| 2,404 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileWindmill.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileWindmill.java | package net.quetzi.bluepower.tileentities.tier1;
import net.minecraft.tileentity.TileEntity;
public class TileWindmill extends TileEntity {
public int turbineTick;
public TileWindmill(){
turbineTick = 0;
}
@Override
public void updateEntity() {
if(worldObj.isRemote){
turbineTick++;
}
}
}
| 318 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileBuffer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileBuffer.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.tileentities.tier1;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.tileentities.TileBase;
public class TileBuffer extends TileBase implements ISidedInventory {
private final ItemStack[] allInventories = new ItemStack[20];
/**
* This function gets called whenever the world/chunk loads
*/
@Override
public void readFromNBT(NBTTagCompound tCompound) {
super.readFromNBT(tCompound);
for (int i = 0; i < 20; i++) {
NBTTagCompound tc = tCompound.getCompoundTag("inventory" + i);
allInventories[i] = ItemStack.loadItemStackFromNBT(tc);
}
}
/**
* This function gets called whenever the world/chunk is saved
*/
@Override
public void writeToNBT(NBTTagCompound tCompound) {
super.writeToNBT(tCompound);
for (int i = 0; i < 20; i++) {
if (allInventories[i] != null) {
NBTTagCompound tc = new NBTTagCompound();
allInventories[i].writeToNBT(tc);
tCompound.setTag("inventory" + i, tc);
}
}
}
@Override
public int getSizeInventory() {
return allInventories.length;
}
@Override
public ItemStack getStackInSlot(int i) {
return allInventories[i];
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
ItemStack itemStack = getStackInSlot(slot);
if (itemStack != null) {
if (itemStack.stackSize <= amount) {
setInventorySlotContents(slot, null);
} else {
itemStack = itemStack.splitStack(amount);
if (itemStack.stackSize == 0) {
setInventorySlotContents(slot, null);
}
}
}
return itemStack;
}
@Override
public ItemStack getStackInSlotOnClosing(int i) {
return getStackInSlot(i);
}
@Override
public void setInventorySlotContents(int i, ItemStack itemStack) {
allInventories[i] = itemStack;
}
@Override
public String getInventoryName() {
return "tile.buffer.name";
}
@Override
public boolean hasCustomInventoryName() {
return true;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return true;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
return true;
}
@Override
public List<ItemStack> getDrops() {
List<ItemStack> drops = super.getDrops();
for (ItemStack stack : allInventories)
if (stack != null) drops.add(stack);
return drops;
}
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
ForgeDirection access = ForgeDirection.getOrientation(var1);
ForgeDirection dir = ForgeDirection.getOrientation(getBlockMetadata());
if (access == dir) {
int[] allSlots = new int[allInventories.length];
for (int i = 0; i < allSlots.length; i++)
allSlots[i] = i;
return allSlots;
}
if (var1 > dir.getOpposite().ordinal()) var1--;
int[] slots = new int[4];
for (int i = 0; i < 4; i++) {
slots[i] = var1 + i * 5;
}
return slots;
}
@Override
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
return true;
}
@Override
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
return true;
}
}
| 4,916 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileProjectTable.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileProjectTable.java | package net.quetzi.bluepower.tileentities.tier1;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.quetzi.bluepower.tileentities.TileBase;
public class TileProjectTable extends TileBase implements IInventory {
//So, we need 3x3 inventories for crafting.
//and 2x9 for the other inventory.
//0-8 = crafting
//9 = output
//10 - 28 = other inventory
private ItemStack[] inventories;
class LocalInventoryCrafting extends InventoryCrafting {
public LocalInventoryCrafting() {
super(new Container() {
@Override
public boolean canInteractWith(EntityPlayer var1) {
return false;
}
}, 3, 3);
}
public Container eventHandler;
}
public TileProjectTable(){
inventories = new ItemStack[28];
}
@Override
public int getSizeInventory() {
return 0;
}
@Override
public ItemStack getStackInSlot(int var1) {
// TODO Auto-generated method stub
return null;
}
@Override
public ItemStack decrStackSize(int var1, int var2) {
// TODO Auto-generated method stub
return null;
}
@Override
public ItemStack getStackInSlotOnClosing(int var1) {
// TODO Auto-generated method stub
return null;
}
@Override
public void setInventorySlotContents(int var1, ItemStack var2) {
// TODO Auto-generated method stub
}
@Override
public String getInventoryName() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean hasCustomInventoryName() {
// TODO Auto-generated method stub
return false;
}
@Override
public int getInventoryStackLimit() {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
// TODO Auto-generated method stub
return false;
}
@Override
public void openInventory() {
// TODO Auto-generated method stub
}
@Override
public void closeInventory() {
// TODO Auto-generated method stub
}
@Override
public boolean isItemValidForSlot(int var1, ItemStack var2) {
// TODO Auto-generated method stub
return false;
};
}
| 2,202 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileKinectGenerator.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileKinectGenerator.java | package net.quetzi.bluepower.tileentities.tier1;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.quetzi.bluepower.tileentities.TileBase;
public class TileKinectGenerator extends TileBase implements ISidedInventory{
public int windspeed = 10;
public int windtick = 0;
public TileKinectGenerator(){
}
@Override
public void updateEntity() {
if (windspeed < 0){
windtick +=windspeed;
}
}
private final ItemStack[] allInventories = new ItemStack[1];
/**
* This function gets called whenever the world/chunk loads
*/
@Override
public void readFromNBT(NBTTagCompound tCompound) {
super.readFromNBT(tCompound);
for (int i = 0; i < 1; i++) {
NBTTagCompound tc = tCompound.getCompoundTag("inventory" + i);
allInventories[i] = ItemStack.loadItemStackFromNBT(tc);
}
}
/**
* This function gets called whenever the world/chunk is saved
*/
@Override
public void writeToNBT(NBTTagCompound tCompound) {
super.writeToNBT(tCompound);
for (int i = 0; i < 1; i++) {
if (allInventories[i] != null) {
NBTTagCompound tc = new NBTTagCompound();
allInventories[i].writeToNBT(tc);
tCompound.setTag("inventory" + i, tc);
}
}
}
@Override
public int getSizeInventory() {
return allInventories.length;
}
@Override
public ItemStack getStackInSlot(int i) {
return this.allInventories[i];
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
// this needs to be side aware as well
ItemStack itemStack = getStackInSlot(slot);
if (itemStack != null) {
if (itemStack.stackSize <= amount) {
setInventorySlotContents(slot, null);
} else {
itemStack = itemStack.splitStack(amount);
if (itemStack.stackSize == 0) {
setInventorySlotContents(slot, null);
}
}
}
return itemStack;
}
@Override
public ItemStack getStackInSlotOnClosing(int i) {
return getStackInSlot(i);
}
@Override
public void setInventorySlotContents(int i, ItemStack itemStack) {
this.allInventories[i] = itemStack;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public String getInventoryName() {
return "tile.kinect.name";
}
@Override
public boolean hasCustomInventoryName() {
return true;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return true;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
return true;
}
@Override
public List<ItemStack> getDrops() {
List<ItemStack> drops = super.getDrops();
for (ItemStack stack : allInventories)
if (stack != null) drops.add(stack);
return drops;
}
@Override
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
return false;
}
@Override
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
return false;
}
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
return null;
}
}
| 3,747 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileTransposer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileTransposer.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.tileentities.tier1;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.helper.IOHelper;
import net.quetzi.bluepower.tileentities.TileMachineBase;
import java.util.List;
public class TileTransposer extends TileMachineBase {
@Override
public void updateEntity() {
super.updateEntity();
if (isBufferEmpty() && !worldObj.isRemote) {
suckEntity();
}
}
@Override
protected void redstoneChanged(boolean newValue) {
super.redstoneChanged(newValue);
if (newValue) {
suckItems();
pullItem();
}
}
private void pullItem() {
if (isBufferEmpty()) {
ForgeDirection dir = getOutputDirection().getOpposite();
TileEntity inputTE = getTileCache()[dir.ordinal()].getTileEntity();
ItemStack extractedStack = IOHelper.extractOneItem(inputTE, dir);
if (extractedStack != null) addItemToOutputBuffer(extractedStack);
}
}
private boolean suckItems() {
// TODO: Set bounding box correctly to do a 3x3x1 area.
ForgeDirection direction = getFacingDirection();
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ, xCoord + direction.offsetX + 1, yCoord + direction.offsetY + 1, zCoord + direction.offsetZ + 1);
if (!worldObj.getEntitiesWithinAABB(EntityItem.class, box).isEmpty()) {
for (Entity entity : (List<Entity>)worldObj.getEntitiesWithinAABB(EntityItem.class, box)) {
ItemStack stack = ((EntityItem)entity).getEntityItem();
addItemToOutputBuffer(stack);
entity.setDead();
worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.click", 0.3F, 0.4F);
return true;
}
}
return false;
}
private boolean suckEntity() {
ForgeDirection direction = getFacingDirection();
AxisAlignedBB box = AxisAlignedBB.getBoundingBox(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ, xCoord + direction.offsetX + 1, yCoord + direction.offsetY + 1, zCoord + direction.offsetZ + 1);
if (!worldObj.getEntitiesWithinAABB(EntityItem.class, box).isEmpty()) {
for (Entity entity : (List<Entity>)worldObj.getEntitiesWithinAABB(EntityItem.class, box)) {
ItemStack stack = ((EntityItem)entity).getEntityItem();
addItemToOutputBuffer(stack);
entity.setDead();
worldObj.playSoundEffect(xCoord + 0.5D, yCoord + 0.5D, zCoord + 0.5D, "random.click", 0.3F, 0.6F);
return true;
}
}
return false;
}
}
| 3,844 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileAlloyFurnace.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileAlloyFurnace.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.tileentities.tier1;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityFurnace;
import net.quetzi.bluepower.api.recipe.IAlloyFurnaceRecipe;
import net.quetzi.bluepower.recipe.AlloyFurnaceRegistry;
import net.quetzi.bluepower.tileentities.TileBase;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* @author MineMaarten, Koen Beckers (K4Unl)
*/
public class TileAlloyFurnace extends TileBase implements IInventory {
private boolean isActive;
public int currentBurnTime;
public int currentProcessTime;
public int maxBurnTime;
private boolean metaSet = false;
private ItemStack[] inventory;
private ItemStack fuelInventory;
private ItemStack outputInventory;
public TileAlloyFurnace() {
inventory = new ItemStack[9];
}
/*************** BASIC TE FUNCTIONS **************/
/**
* This function gets called whenever the world/chunk loads
*/
@Override
public void readFromNBT(NBTTagCompound tCompound) {
super.readFromNBT(tCompound);
isActive = tCompound.getBoolean("isActive");
metaSet = false;
for (int i = 0; i < 9; i++) {
NBTTagCompound tc = tCompound.getCompoundTag("inventory" + i);
inventory[i] = ItemStack.loadItemStackFromNBT(tc);
}
fuelInventory = ItemStack.loadItemStackFromNBT(tCompound.getCompoundTag("fuelInventory"));
outputInventory = ItemStack.loadItemStackFromNBT(tCompound.getCompoundTag("outputInventory"));
}
/**
* This function gets called whenever the world/chunk is saved
*/
@Override
public void writeToNBT(NBTTagCompound tCompound) {
super.writeToNBT(tCompound);
tCompound.setBoolean("isActive", isActive);
for (int i = 0; i < 9; i++) {
if (inventory[i] != null) {
NBTTagCompound tc = new NBTTagCompound();
inventory[i].writeToNBT(tc);
tCompound.setTag("inventory" + i, tc);
}
}
if (fuelInventory != null) {
NBTTagCompound fuelCompound = new NBTTagCompound();
fuelInventory.writeToNBT(fuelCompound);
tCompound.setTag("fuelInventory", fuelCompound);
}
if (outputInventory != null) {
NBTTagCompound outputCompound = new NBTTagCompound();
outputInventory.writeToNBT(outputCompound);
tCompound.setTag("outputInventory", outputCompound);
}
}
/**
* Function gets called every tick. Do not forget to call the super method!
*/
@Override
public void updateEntity() {
super.updateEntity();
// Check if the meta is already set after loading the NBT.
if (!metaSet) {
metaSet = true;
if (isActive) {
int newMeta = getBlockMetadata();
newMeta = newMeta & 7;
newMeta |= isActive == true ? 8 : 0;
getWorldObj().setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 2);
}
}
if (!worldObj.isRemote) {
setIsActive(currentBurnTime > 0);
if (isActive) {
currentBurnTime--;
}
IAlloyFurnaceRecipe recipe = AlloyFurnaceRegistry.getInstance().getMatchingRecipe(inventory, outputInventory);
if (recipe != null) {
if (currentBurnTime <= 0) {
if (TileEntityFurnace.isItemFuel(fuelInventory)) {
// Put new item in
currentBurnTime = maxBurnTime = TileEntityFurnace.getItemBurnTime(fuelInventory) + 1;
if (fuelInventory != null) {
fuelInventory.stackSize--;
if (fuelInventory.stackSize <= 0) {
fuelInventory = fuelInventory.getItem().getContainerItem(fuelInventory);
}
}
} else {
currentProcessTime = 0;
}
}
if (++currentProcessTime >= 200) {
currentProcessTime = 0;
if (outputInventory != null) {
outputInventory.stackSize += recipe.getCraftingResult(inventory).stackSize;
} else {
outputInventory = recipe.getCraftingResult(inventory).copy();
}
recipe.useItems(inventory);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
} else {
currentProcessTime = 0;
}
}
}
@Override
protected void redstoneChanged(boolean newValue) {
// setIsActive(newValue);
}
@SideOnly(Side.CLIENT)
public void setBurnTicks(int _maxBurnTime, int _currentBurnTime) {
maxBurnTime = _maxBurnTime;
currentBurnTime = _currentBurnTime;
}
public float getBurningPercentage() {
if (maxBurnTime > 0) {
return (float) currentBurnTime / (float) maxBurnTime;
} else {
return 0;
}
}
public float getProcessPercentage() {
return (float) currentProcessTime / 200;
}
/**
* ************* ADDED FUNCTIONS *************
*/
public boolean getIsActive() {
return isActive;
}
public void setIsActive(boolean _isActive) {
isActive = _isActive;
int newMeta = getBlockMetadata();
newMeta = newMeta & 7;
newMeta |= _isActive == true ? 8 : 0;
getWorldObj().setBlockMetadataWithNotify(xCoord, yCoord, zCoord, newMeta, 2);
}
/**
* ************ IINVENTORY ****************
*/
@Override
public int getSizeInventory() {
return 9 + 1 + 1; // 9 inventory, 1 fuel, 1 output
}
@Override
public ItemStack getStackInSlot(int var1) {
if (var1 == 0) {
return fuelInventory;
} else if (var1 == 1) {
return outputInventory;
} else if (var1 < 11) { return inventory[var1 - 2]; }
return null;
}
@Override
public ItemStack decrStackSize(int var1, int var2) {
ItemStack tInventory = getStackInSlot(var1);
if (tInventory == null) { return null; }
ItemStack ret = null;
if (tInventory.stackSize < var2) {
ret = tInventory;
inventory = null;
} else {
ret = tInventory.splitStack(var2);
if (tInventory.stackSize <= 0) {
if (var1 == 0) {
fuelInventory = null;
} else if (var1 == 1) {
outputInventory = null;
} else {
inventory[var1 - 2] = null;
}
}
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
return ret;
}
@Override
public ItemStack getStackInSlotOnClosing(int var1) {
return getStackInSlot(var1);
}
@Override
public void setInventorySlotContents(int var1, ItemStack itemStack) {
if (var1 == 0) {
fuelInventory = itemStack;
} else if (var1 == 1) {
outputInventory = itemStack;
} else {
inventory[var1 - 2] = itemStack;
}
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public String getInventoryName() {
return null;
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
// Todo: Some fancy code here that detects whether the player is far
// away
return true;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
@Override
public boolean isItemValidForSlot(int var1, ItemStack itemStack) {
if (var1 == 0) {
return TileEntityFurnace.isItemFuel(itemStack);
} else if (var1 == 1) { // Output slot
return false;
} else {
return true;
}
}
@Override
public List<ItemStack> getDrops() {
List<ItemStack> drops = super.getDrops();
if (fuelInventory != null) drops.add(fuelInventory);
if (outputInventory != null) drops.add(outputInventory);
for (ItemStack stack : inventory)
if (stack != null) drops.add(stack);
return drops;
}
}
| 9,952 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileIgniter.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileIgniter.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.tileentities.tier1;
import net.minecraft.block.Block;
import net.minecraft.init.Blocks;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.tileentities.TileBase;
public class TileIgniter extends TileBase {
@Override
protected void redstoneChanged(boolean newValue) {
super.redstoneChanged(newValue);
ForgeDirection direction = this.getFacingDirection();
if (this.getIsRedstonePowered()) {
ignite(direction);
} else {
extinguish(direction);
}
}
private void ignite(ForgeDirection direction) {
if (this.getIsRedstonePowered() && worldObj.isAirBlock(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ)) {
worldObj.setBlock(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ, Blocks.fire);
}
}
private void extinguish(ForgeDirection direction) {
Block target = worldObj.getBlock(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
if (!this.getIsRedstonePowered() && (target == Blocks.fire || target == Blocks.portal)) {
worldObj.setBlock(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ, Blocks.air);
}
}
@Override
public void updateEntity() {
if (this.getTicker() % 5 == 0) {
this.ignite(this.getFacingDirection());
}
super.updateEntity();
}
}
| 2,273 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileDeployer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileDeployer.java | package net.quetzi.bluepower.tileentities.tier1;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.FakePlayer;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.tileentities.TileBase;
public class TileDeployer extends TileBase implements ISidedInventory{
public boolean isActive = false;
private ForgeDirection orientation;
private boolean redstoneSignal;
protected static FakePlayer fakeplayer = null;
@Override
public void updateEntity() {
isActive = worldObj.isDaytime();
}
private final ItemStack[] allInventories = new ItemStack[9];
/**
* This function gets called whenever the world/chunk loads
*/
@Override
public void readFromNBT(NBTTagCompound tCompound) {
super.readFromNBT(tCompound);
for (int i = 0; i < 9; i++) {
NBTTagCompound tc = tCompound.getCompoundTag("inventory" + i);
allInventories[i] = ItemStack.loadItemStackFromNBT(tc);
}
}
/**
* This function gets called whenever the world/chunk is saved
*/
@Override
public void writeToNBT(NBTTagCompound tCompound) {
super.writeToNBT(tCompound);
for (int i = 0; i < 9; i++) {
if (allInventories[i] != null) {
NBTTagCompound tc = new NBTTagCompound();
allInventories[i].writeToNBT(tc);
tCompound.setTag("inventory" + i, tc);
}
}
}
@Override
public int getSizeInventory() {
return allInventories.length;
}
@Override
public ItemStack getStackInSlot(int i) {
return this.allInventories[i];
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
// this needs to be side aware as well
ItemStack itemStack = getStackInSlot(slot);
if (itemStack != null) {
if (itemStack.stackSize <= amount) {
setInventorySlotContents(slot, null);
} else {
itemStack = itemStack.splitStack(amount);
if (itemStack.stackSize == 0) {
setInventorySlotContents(slot, null);
}
}
}
return itemStack;
}
@Override
public ItemStack getStackInSlotOnClosing(int i) {
return getStackInSlot(i);
}
@Override
public void setInventorySlotContents(int i, ItemStack itemStack) {
this.allInventories[i] = itemStack;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
@Override
public String getInventoryName() {
return "tile.buffer.name";
}
@Override
public boolean hasCustomInventoryName() {
return true;
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer player) {
return true;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemStack) {
return true;
}
@Override
public List<ItemStack> getDrops() {
List<ItemStack> drops = super.getDrops();
for (ItemStack stack : allInventories)
if (stack != null) drops.add(stack);
return drops;
}
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
ForgeDirection direction = ForgeDirection.getOrientation(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
if (var1 == direction.ordinal()){
return new int[]{};
}
return new int[] { 0, 1, 2, 3, 4, 5, 6, 7, 8};
}
@Override
public boolean canInsertItem(int slot, ItemStack itemStack, int side) {
for (int i : this.getAccessibleSlotsFromSide(side)) {
if (slot == i) { return true; }
}
return false;
}
@Override
public boolean canExtractItem(int slot, ItemStack itemStack, int side) {
for (int i : this.getAccessibleSlotsFromSide(side)) {
if (slot == i) { return true; }
}
return false;
}
public void setOrientation(ForgeDirection orientation)
{
this.orientation = orientation;
}
public void setOrientation(int orientation)
{
this.orientation = ForgeDirection.getOrientation(orientation);
}
public ForgeDirection getOrientation()
{
return orientation;
}
}
| 4,824 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileLamp.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileLamp.java | package net.quetzi.bluepower.tileentities.tier1;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.helper.RedstoneHelper;
import net.quetzi.bluepower.tileentities.TileBase;
/**
* @author Koen Beckers (K4Unl)
* Yes. I only need this class to do the getPower() function.. damn :(
*/
public class TileLamp extends TileBase {
public int getPower() {
int power = 0;
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
power = Math.max(power, RedstoneHelper.getInput(getWorldObj(), xCoord, yCoord, zCoord, d));
}
return power;
}
}
| 631 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileEjector.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier1/TileEjector.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.tileentities.tier1;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.quetzi.bluepower.tileentities.TileMachineBase;
import java.util.List;
public class TileEjector extends TileMachineBase implements IInventory {
private final ItemStack[] inventory = new ItemStack[9];
@Override
protected void redstoneChanged(boolean newValue) {
super.redstoneChanged(newValue);
if (newValue) {
for (int i=0; i < inventory.length; i++) {
if (inventory[i] != null && inventory[i].stackSize > 0) {
ItemStack output = inventory[i].copy();
output.stackSize = 1;
addItemToOutputBuffer(output);
inventory[i].stackSize--;
break;
}
}
}
}
/**
* This function gets called whenever the world/chunk loads
*/
@Override
public void readFromNBT(NBTTagCompound tCompound) {
super.readFromNBT(tCompound);
for (int i = 0; i < 9; i++) {
NBTTagCompound tc = tCompound.getCompoundTag("inventory" + i);
inventory[i] = ItemStack.loadItemStackFromNBT(tc);
}
}
/**
* This function gets called whenever the world/chunk is saved
*/
@Override
public void writeToNBT(NBTTagCompound tCompound) {
super.writeToNBT(tCompound);
for (int i = 0; i < 9; i++) {
if (inventory[i] != null) {
NBTTagCompound tc = new NBTTagCompound();
inventory[i].writeToNBT(tc);
tCompound.setTag("inventory" + i, tc);
}
}
}
/**
* Returns the number of slots in the inventory.
*/
@Override public int getSizeInventory() {
return inventory.length;
}
/**
* Returns the stack in slot i
*
* @param slot
*/
@Override public ItemStack getStackInSlot(int slot) {
return inventory[slot];
}
/**
* Removes from an inventory slot (first arg) up to a specified number (second arg) of items and returns them in a
* new stack.
*
* @param slot
* @param amount
*/
@Override public ItemStack decrStackSize(int slot, int amount) {
ItemStack itemStack = getStackInSlot(slot);
if (itemStack != null) {
if (itemStack.stackSize <= amount) {
setInventorySlotContents(slot, null);
} else {
itemStack = itemStack.splitStack(amount);
if (itemStack.stackSize == 0) {
setInventorySlotContents(slot, null);
}
}
}
return itemStack;
}
/**
* When some containers are closed they call this on each slot, then drop whatever it returns as an EntityItem -
* like when you close a workbench GUI.
*
* @param slot
*/
@Override public ItemStack getStackInSlotOnClosing(int slot) {
return getStackInSlot(slot);
}
/**
* Sets the given item stack to the specified slot in the inventory (can be crafting or armor sections).
*
* @param slot
* @param itemStack
*/
@Override public void setInventorySlotContents(int slot, ItemStack itemStack) {
inventory[slot] = itemStack;
}
/**
* Returns the name of the inventory
*/
@Override public String getInventoryName() {
return "tile.relay.name";
}
/**
* Returns if the inventory is named
*/
@Override public boolean hasCustomInventoryName() {
return true;
}
/**
* Returns the maximum stack size for a inventory slot.
*/
@Override public int getInventoryStackLimit() {
return 64;
}
/**
* Do not make give this method the name canInteractWith because it clashes with Container
*
* @param var1
*/
@Override public boolean isUseableByPlayer(EntityPlayer var1) {
return true;
}
@Override public void openInventory() {
}
@Override public void closeInventory() {
}
/**
* Returns true if automation is allowed to insert the given stack (ignoring stack size) into the given slot.
*
* @param var1
* @param var2
*/
@Override public boolean isItemValidForSlot(int var1, ItemStack var2) {
return true;
}
@Override
public List<ItemStack> getDrops() {
List<ItemStack> drops = super.getDrops();
for (ItemStack stack : inventory)
if (stack != null) drops.add(stack);
return drops;
}
}
| 5,504 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileSortingMachine.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier2/TileSortingMachine.java | package net.quetzi.bluepower.tileentities.tier2;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.tube.IPneumaticTube.TubeColor;
import net.quetzi.bluepower.helper.IOHelper;
import net.quetzi.bluepower.part.IGuiButtonSensitive;
import net.quetzi.bluepower.part.tube.TubeStack;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.TileMachineBase;
/**
*
* @author MineMaarten
*/
public class TileSortingMachine extends TileMachineBase implements ISidedInventory, IGuiButtonSensitive {
private ItemStack[] inventory = new ItemStack[40];
public int curColumn = 0;
public PullMode pullMode = PullMode.SINGLE_STEP;
public SortMode sortMode = SortMode.ANYSTACK_SEQUENTIAL;
private boolean sweepTriggered;
public final TubeColor[] colors = new TubeColor[9];
public TileSortingMachine() {
for (int i = 0; i < colors.length; i++)
colors[i] = TubeColor.NONE;
}
public enum PullMode {
SINGLE_STEP("single_step"), AUTOMATIC("automatic"), SINGLE_SWEEP("single_sweep");
private final String name;
private PullMode(String name) {
this.name = name;
}
@Override
public String toString() {
return "gui.pullMode." + name;
}
}
public enum SortMode {
ANYSTACK_SEQUENTIAL("any_stack_sequential"), ALLSTACK_SEQUENTIAL("all_stacks_sequential"), RANDOM_ALLSTACKS("all_stacks_random"), ANY_ITEM("any_item"), ANY_ITEM_DEFAULT("any_item_default"), ANY_STACK("any_stack"), ANY_STACK_DEFAULT("any_stack_default");
private final String name;
private SortMode(String name) {
this.name = name;
}
@Override
public String toString() {
return "gui.sortMode." + name;
}
}
@Override
public void updateEntity() {
super.updateEntity();
if (!worldObj.isRemote && worldObj.getWorldTime() % TileMachineBase.BUFFER_EMPTY_INTERVAL == 0 && (pullMode == PullMode.SINGLE_SWEEP && sweepTriggered || pullMode == PullMode.AUTOMATIC)) {
triggerSorting();
}
}
@Override
protected void redstoneChanged(boolean newValue) {
super.redstoneChanged(newValue);
if (newValue) {
if (pullMode == PullMode.SINGLE_STEP) triggerSorting();
if (pullMode == PullMode.SINGLE_SWEEP) sweepTriggered = true;
}
}
private void triggerSorting() {
if (isBufferEmpty()) {
ForgeDirection dir = getOutputDirection().getOpposite();
TileEntity inputTE = getTileCache()[dir.ordinal()].getTileEntity();//might need opposite
if (inputTE instanceof IInventory) {
IInventory inputInv = (IInventory) inputTE;
int[] accessibleSlots;
if (inputInv instanceof ISidedInventory) {
accessibleSlots = ((ISidedInventory) inputInv).getAccessibleSlotsFromSide(dir.getOpposite().ordinal());
} else {
accessibleSlots = new int[inputInv.getSizeInventory()];
for (int i = 0; i < accessibleSlots.length; i++)
accessibleSlots[i] = i;
}
for (int slot : accessibleSlots) {
ItemStack stack = inputInv.getStackInSlot(slot);
if (stack != null && IOHelper.canExtractItemFromInventory(inputInv, stack, slot, dir.getOpposite().ordinal())) {
if (tryProcessItem(stack, false)) {
if (stack.stackSize == 0) inputInv.setInventorySlotContents(slot, null);
return;
}
}
}
if (sortMode == SortMode.ANYSTACK_SEQUENTIAL) {
for (int i = curColumn; i < inventory.length; i += 8) {
ItemStack filterStack = inventory[curColumn];
if (filterStack != null) {
ItemStack extractedStack = IOHelper.extract(inputTE, dir.getOpposite(), filterStack, false);
if (extractedStack != null) {
addItemToOutputBuffer(extractedStack.copy(), colors[i % 8]);
gotoNextNonEmptyColumn();
}
}
}
} else if (sortMode == SortMode.ALLSTACK_SEQUENTIAL) {
if (matchAndProcessColumn(inputInv, accessibleSlots, curColumn)) {
gotoNextNonEmptyColumn();
}
} else if (sortMode == SortMode.RANDOM_ALLSTACKS) {
for (int i = 0; i < 8; i++) {
if (matchAndProcessColumn(inputInv, accessibleSlots, i)) {
break;
}
}
}
}
}
}
private boolean matchAndProcessColumn(IInventory inputInventory, int[] accessibleSlots, int column) {
List<ItemStack> requirements = new ArrayList<ItemStack>();
for (int i = 0; i < 5; i++) {
ItemStack filterStack = inventory[column + 8 * i];
if (filterStack != null) {
boolean duplicate = false;
for (ItemStack requirement : requirements) {
if (requirement.isItemEqual(filterStack)) {
requirement.stackSize += filterStack.stackSize;
duplicate = true;
break;
}
}
if (!duplicate) requirements.add(filterStack.copy());
}
}
if (requirements.size() == 0) return false;
ItemStack[] copy = new ItemStack[requirements.size()];
for (int i = 0; i < copy.length; i++)
copy[i] = requirements.get(i).copy();
Iterator<ItemStack> iterator = requirements.iterator();
while (iterator.hasNext()) {
ItemStack stack = iterator.next();
for (int slot : accessibleSlots) {
ItemStack invStack = inputInventory.getStackInSlot(slot);
if (invStack != null && invStack.isItemEqual(stack)) {
stack.stackSize -= invStack.stackSize;
if (stack.stackSize <= 0) {
iterator.remove();
break;
}
}
}
}
if (requirements.isEmpty()) {
for (ItemStack stack : copy) {
for (int slot : accessibleSlots) {
ItemStack invStack = inputInventory.getStackInSlot(slot);
if (invStack != null && invStack.isItemEqual(stack)) {
int substracted = Math.min(stack.stackSize, invStack.stackSize);
stack.stackSize -= substracted;
invStack.stackSize -= substracted;
if (invStack.stackSize <= 0) {
inputInventory.setInventorySlotContents(slot, null);
}
ItemStack bufferStack = invStack.copy();
bufferStack.stackSize = substracted;
addItemToOutputBuffer(bufferStack, TubeColor.values()[column]);
}
}
}
inputInventory.markDirty();
return true;
} else {
return false;
}
}
private boolean tryProcessItem(ItemStack stack, boolean simulate) {
switch (sortMode) {
case ANYSTACK_SEQUENTIAL:
break;
case ALLSTACK_SEQUENTIAL:
break;
case RANDOM_ALLSTACKS:
break;
case ANY_ITEM:
case ANY_ITEM_DEFAULT:
for (int i = 0; i < inventory.length; i++) {
ItemStack filter = inventory[i];
if (filter != null && stack.isItemEqual(filter) && stack.stackSize >= filter.stackSize) {
if (!simulate) {
addItemToOutputBuffer(filter.copy(), colors[i % 8]);
stack.stackSize -= filter.stackSize;
}
return true;
}
}
if (sortMode == SortMode.ANY_ITEM_DEFAULT) {
if (!simulate) {
addItemToOutputBuffer(stack.copy(), colors[8]);
stack.stackSize = 0;
}
return true;
}
break;
case ANY_STACK:
case ANY_STACK_DEFAULT:
for (int i = 0; i < inventory.length; i++) {
ItemStack filter = inventory[i];
if (filter != null && stack.isItemEqual(filter)) {
if (!simulate) {
addItemToOutputBuffer(stack.copy(), colors[i % 8]);
stack.stackSize = 0;
}
return true;
}
}
if (sortMode == SortMode.ANY_STACK_DEFAULT) {
if (!simulate) {
addItemToOutputBuffer(stack.copy(), colors[8]);
stack.stackSize = 0;
}
return true;
}
break;
}
return false;
}
private void gotoNextNonEmptyColumn() {
int oldColumn = curColumn++;
if (curColumn > 7) {
curColumn = 0;
sweepTriggered = false;
}
while (oldColumn != curColumn) {
for (int i = curColumn; i < inventory.length; i += 8) {
if (inventory[i] != null) return;
}
if (++curColumn > 7) {
curColumn = 0;
sweepTriggered = false;
}
}
curColumn = 0;
}
@Override
public void onButtonPress(int messageId, int value) {
if (messageId < 9) {
colors[messageId] = TubeColor.values()[value];
} else if (messageId == 9) {
pullMode = PullMode.values()[value];
} else {
sortMode = SortMode.values()[value];
}
}
@Override
public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag);
tag.setByte("pullMode", (byte) pullMode.ordinal());
tag.setByte("sortMode", (byte) sortMode.ordinal());
int[] colorArray = new int[colors.length];
for (int i = 0; i < colorArray.length; i++) {
colorArray[i] = colors[i].ordinal();
}
tag.setIntArray("colors", colorArray);
NBTTagList tagList = new NBTTagList();
for (int currentIndex = 0; currentIndex < inventory.length; ++currentIndex) {
if (inventory[currentIndex] != null) {
NBTTagCompound tagCompound = new NBTTagCompound();
tagCompound.setByte("Slot", (byte) currentIndex);
inventory[currentIndex].writeToNBT(tagCompound);
tagList.appendTag(tagCompound);
}
}
tag.setTag("Items", tagList);
}
@Override
public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag);
pullMode = PullMode.values()[tag.getByte("pullMode")];
sortMode = SortMode.values()[tag.getByte("sortMode")];
int[] colorArray = tag.getIntArray("colors");
for (int i = 0; i < colorArray.length; i++) {
colors[i] = TubeColor.values()[colorArray[i]];
}
NBTTagList tagList = tag.getTagList("Items", 10);
inventory = new ItemStack[40];
for (int i = 0; i < tagList.tagCount(); ++i) {
NBTTagCompound tagCompound = tagList.getCompoundTagAt(i);
byte slot = tagCompound.getByte("Slot");
if (slot >= 0 && slot < inventory.length) {
inventory[slot] = ItemStack.loadItemStackFromNBT(tagCompound);
}
}
}
@Override
public int getSizeInventory() {
return inventory.length + 1;
}
/**
* Returns the stack in slot i
*/
@Override
public ItemStack getStackInSlot(int slot) {
return slot < inventory.length ? inventory[slot] : null;
}
@Override
public ItemStack decrStackSize(int slot, int amount) {
ItemStack itemStack = getStackInSlot(slot);
if (itemStack != null) {
if (itemStack.stackSize <= amount) {
setInventorySlotContents(slot, null);
} else {
itemStack = itemStack.splitStack(amount);
if (itemStack.stackSize == 0) {
setInventorySlotContents(slot, null);
}
}
}
return itemStack;
}
@Override
public ItemStack getStackInSlotOnClosing(int slot) {
ItemStack itemStack = getStackInSlot(slot);
if (itemStack != null) {
setInventorySlotContents(slot, null);
}
return itemStack;
}
@Override
public void setInventorySlotContents(int slot, ItemStack itemStack) {
if (slot < inventory.length) {
inventory[slot] = itemStack;
if (itemStack != null && itemStack.stackSize > getInventoryStackLimit()) {
itemStack.stackSize = getInventoryStackLimit();
}
} else {
if (itemStack != null) tryProcessItem(itemStack, false);
}
}
@Override
public TubeStack acceptItemFromTube(TubeStack stack, ForgeDirection from, boolean simulate) {
boolean success = tryProcessItem(stack.stack, simulate);
if (success) {
if (stack.stack.stackSize <= 0) {
return null;
} else {
return stack;
}
} else {
return stack;
}
}
@Override
public int getInventoryStackLimit() {
return 64;
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1) {
return true;
}
@Override
public void openInventory() {
}
@Override
public void closeInventory() {
}
@Override
public boolean isItemValidForSlot(int var1, ItemStack var2) {
return var1 < inventory.length ? true : isBufferEmpty() && var2 != null && tryProcessItem(var2, true);
}
@Override
public int[] getAccessibleSlotsFromSide(int var1) {
return new int[] { inventory.length };
}
@Override
public boolean canInsertItem(int var1, ItemStack var2, int var3) {
return getOutputDirection().getOpposite().ordinal() == var3 && isItemValidForSlot(var1, var2);
}
@Override
public boolean canExtractItem(int var1, ItemStack var2, int var3) {
return false;
}
@Override
public String getInventoryName() {
return Refs.SORTING_MACHINE_NAME;
}
@Override
public boolean hasCustomInventoryName() {
return false;
}
}
| 16,188 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileMonitor.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier3/TileMonitor.java | package net.quetzi.bluepower.tileentities.tier3;
import net.quetzi.bluepower.tileentities.TileBase;
/**
* @author fabricator77
*/
public class TileMonitor extends TileBase implements IRedBusWindow {
public byte framebufferRow = 0;
public byte cursorX = 0;
public byte cursorY = 0;
public byte blit_command = 0;
public byte blit_sourceX = 0;
public byte blit_sourceY = 0;
public byte blit_destX = 0;
public byte blit_destY = 0;
public byte blit_rectWidth = 0;
public byte blit_rectHeight = 0;
public byte[] framebuffer = new byte[80];
public byte[] keybuffer = new byte[16];
//Also used by GUI
public byte[] screenMemory = new byte[4000];
public static boolean mode80x40 = false;
public static float[] screenColor = new float[]{1.0F, 0.8F, 0.0F};
public TileMonitor() {
blankMemory();
testMemory();
}
private void blankMemory ()
{
for (int i=0; i<4000; i++) {
screenMemory[i] = (byte)32;
}
}
private void testMemory ()
{
if (mode80x40) {
for (int i=0; i<256; i++) {
screenMemory[i] = (byte)i;
}
}
else {
for (int i=0; i<40; i++) {
screenMemory[i*2] = (byte)i;
screenMemory[(i+80)*2] = (byte)(i+40);
//screenMemory[(i+160)*2] = (byte)(i+80);
//screenMemory[(i+240)*2] = (byte)(i+120);
//screenMemory[(i+320)*2] = (byte)(i+160);
}
}
}
public byte[] getRedbusMemory () {
//return new byte[95];
return redBus_memory;
// first 16 addresses for control
// remaining 80 char FrameBuffer data window
}
/** redbus memory block
* addr size function
* 0x00 1 Framebuffer access row
* 0x01 1 Cursor X position
* 0x02 1 Cursor Y position
* 0x03 1 Cursor style
* 0x04 1 Keyboard buffer tail pointer
* 0x05 1 Keyboard buffer head pointer
* 0x06 1 Keyboard buffer data window
* 0x07 1 Blitter command
* 0x08 1 Blitter source rectangle X or fill character
* 0x09 1 Blitter source rectangle Y
* 0x0A 1 Blitter destination rectangle X
* 0x0B 1 Blitter destination rectangle Y
* 0x0C 1 Blitter rectangle width
* 0x0D 1 Blitter rectangle height
* 0x10 80 Framebuffer data window
*/
}
| 2,165 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileSortron.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier3/TileSortron.java | package net.quetzi.bluepower.tileentities.tier3;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.Optional;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import dan200.computercraft.api.lua.ILuaContext;
import dan200.computercraft.api.peripheral.IComputerAccess;
import dan200.computercraft.api.peripheral.IPeripheral;
import li.cil.oc.api.network.Arguments;
import li.cil.oc.api.network.Callback;
import li.cil.oc.api.network.Context;
import li.cil.oc.api.network.SimpleComponent;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import net.quetzi.bluepower.api.tube.IPneumaticTube;
import net.quetzi.bluepower.part.tube.TubeStack;
import net.quetzi.bluepower.references.Dependencies;
import net.quetzi.bluepower.tileentities.TileMachineBase;
import java.util.HashSet;
import java.util.Set;
/**
* @author Dynious
*/
@Optional.InterfaceList(value = {@Optional.Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = Dependencies.COMPUTER_CRAFT),
@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = Dependencies.OPEN_COMPUTERS)})
public class TileSortron extends TileMachineBase implements IPeripheral, SimpleComponent {
private static final String NAME = "BluePower.Sortron";
private static final int ANIMATION_TIME = 10;
private Set<IComputerAccess> connectedComputers = new HashSet<IComputerAccess>();
private Set<Context> contexts = new HashSet<Context>();
private IInventory connectedInventory;
private byte acceptedColor = -1;
private ItemStack acceptedStack = null;
private int acceptedStackSize = 0;
private byte ticksLeftToShowItemTransport = 0;
@Override
public void onBlockNeighbourChanged() {
super.onBlockNeighbourChanged();
ForgeDirection direction = ForgeDirection.getOrientation(getBlockMetadata());
TileEntity tile = worldObj.getTileEntity(xCoord + direction.offsetX, yCoord + direction.offsetY, zCoord + direction.offsetZ);
if (tile instanceof IInventory) {
connectedInventory = (IInventory) tile;
}
else
{
connectedInventory = null;
}
}
@Override
protected void onItemOutputted() {
super.onItemOutputted();
worldObj.addBlockEvent(xCoord, yCoord, zCoord, getBlockType(), 1, 0);
}
@Override
@SideOnly(Side.CLIENT)
public boolean receiveClientEvent(int id, int data) {
switch (id) {
case 1:
ticksLeftToShowItemTransport = ANIMATION_TIME;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
return true;
}
return super.receiveClientEvent(id, data);
}
@Override
public void updateEntity() {
super.updateEntity();
if (worldObj.isRemote && ticksLeftToShowItemTransport > 0) {
ticksLeftToShowItemTransport--;
if (ticksLeftToShowItemTransport == 0) {
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
}
}
}
public boolean showOutPutAnimation() {
return ticksLeftToShowItemTransport > 0;
}
/*
Sortron functions
*/
public Object[] setAcceptedCol(Object[] arguments) throws Exception {
if (arguments.length > 0) {
acceptedColor = parseColorFromObject(arguments[0]);
return new Boolean[] { true };
}
throw new IllegalArgumentException("No expected argument was given");
}
public Object[] getAcceptedCol(Object[] arguments) throws Exception {
return new Integer[] { (int) acceptedColor };
}
public Object[] setAcceptedItem(Object[] arguments) throws Exception {
if (arguments.length > 0 && arguments[0] instanceof String) {
String unlocalizedName = ((String) arguments[0]);
if (unlocalizedName.isEmpty()) {
acceptedStack = null;
return new Boolean[] { true };
}
Item item = (Item) Item.itemRegistry.getObject(unlocalizedName);
if (item != null) {
ItemStack stack;
if (arguments.length > 1 && arguments[1] instanceof Double) {
int meta = ((Double)arguments[1]).intValue();
if (meta >= 0) {
stack = new ItemStack(item, 0, meta);
} else {
throw new IllegalArgumentException("Metadata must be greater than or equal to 0");
}
} else {
stack = new ItemStack(item, 0, OreDictionary.WILDCARD_VALUE);
}
acceptedStack = stack;
return new Boolean[] { true };
}
throw new IllegalArgumentException("Item not found");
}
throw new IllegalArgumentException("No expected argument was given");
}
public Object[] getAcceptedItem(Object[] arguments) throws Exception {
return new String[]{ getStringFromStack(acceptedStack) };
}
public Object[] getNumSlots(Object[] arguments) throws Exception {
if (connectedInventory != null) {
return new Integer[] { connectedInventory.getSizeInventory() };
}
throw new Exception("Sortron has no connected Inventory");
}
public Object[] getSlotContents(Object[] arguments) throws Exception {
if (connectedInventory != null) {
if (arguments.length > 0 && arguments[0] instanceof Double) {
int slot = ((Double)arguments[0]).intValue();
if (slot >= 0 && slot < connectedInventory.getSizeInventory()) {
return new String[] { getStringFromStack(connectedInventory.getStackInSlot(slot))};
}
throw new IllegalArgumentException("Slot value should be greater than or equal to 0 and smaller than the number of slots");
}
throw new IllegalArgumentException("No expected argument was given");
}
throw new Exception("Sortron has no connected Inventory");
}
public Object[] pullFromSlot(Object[] arguments) throws Exception {
if (connectedInventory != null) {
if (arguments.length > 0 && arguments[0] instanceof Double) {
int slot = ((Double)arguments[0]).intValue();
if (slot >= 0 && slot < connectedInventory.getSizeInventory()) {
ItemStack stack = connectedInventory.getStackInSlot(slot);
if (stack != null) {
if (arguments.length > 1) {
byte color = parseColorFromObject(arguments[1]);
addItemToOutputBuffer(stack, IPneumaticTube.TubeColor.values()[color]);
} else {
addItemToOutputBuffer(stack);
}
connectedInventory.setInventorySlotContents(slot, null);
return new String[] { getStringFromStack(stack) };
}
return new Boolean[] { false };
}
throw new IllegalArgumentException("Slot value should be greater than or equal to 0 and smaller than the number of slots");
}
throw new IllegalArgumentException("No expected argument was given");
}
throw new Exception("Sortron has no connected Inventory");
}
public Object[] sort(Object[] arguments) throws Exception {
if (arguments.length > 0 && arguments[0] instanceof Double) {
int stackSize = ((Double)arguments[0]).intValue();
if (stackSize >= 0) {
acceptedStackSize = stackSize;
return new Boolean[] { true };
}
throw new IllegalArgumentException("StackSize value must be greater than or equal to 0");
}
throw new IllegalArgumentException("No expected argument was given");
}
public Object[] getStackSizeLeft(Object[] arguments) throws Exception {
return new Integer[] { acceptedStackSize };
}
/*
Sortron helper functions
*/
public static String getStringFromStack(ItemStack stack) {
if (stack != null) {
String string = Item.itemRegistry.getNameForObject(stack.getItem());
if (stack.getItemDamage() != OreDictionary.WILDCARD_VALUE) {
string += " " + stack.getItemDamage();
}
if (stack.stackSize != 0) {
string += " " + stack.stackSize;
}
return string;
}
return null;
}
public static byte parseColorFromObject(Object argument) throws Exception {
if (argument instanceof Double) {
byte color = ((Double) argument).byteValue();
if (color >= -1 && color < 16) {
return color;
}
throw new IllegalArgumentException("Color values should be greater than or equal to -1 and smaller than 16");
} else if (argument instanceof String) {
String input = (String) argument;
if (input.isEmpty()) {
return -1;
}
for (byte color = 0; color < ItemDye.field_150923_a.length; color++) {
String colorName = ItemDye.field_150923_a[color];
if (colorName.equals(input)) {
return color;
}
}
throw new IllegalArgumentException("Given String is not a color");
}
throw new IllegalArgumentException("No expected argument was given");
}
public static boolean doItemStacksMatch(ItemStack itemStack1, ItemStack itemStack2) {
return (itemStack1 == null && itemStack2 == null) || ( !(itemStack1 == null || itemStack2 == null) && itemStack1.getItem().equals(itemStack2.getItem())
&& (itemStack1.getItemDamage() == OreDictionary.WILDCARD_VALUE || itemStack2.getItemDamage() == OreDictionary.WILDCARD_VALUE
|| itemStack1.getItemDamage() == itemStack2.getItemDamage()));
}
private void removeFromAcceptedStack(int amount) {
acceptedStackSize -= amount;
if (Loader.isModLoaded(Dependencies.COMPUTER_CRAFT)) {
for (IComputerAccess computer : connectedComputers) {
computer.queueEvent("sortChange", new Integer[] { acceptedStackSize });
}
}
}
/*
ITubeConnection implementation
*/
@Override
public TubeStack acceptItemFromTube(TubeStack stack, ForgeDirection from, boolean simulate) {
if (acceptedStackSize <= 0) return stack;
if ((acceptedStack == null || doItemStacksMatch(stack.stack, acceptedStack)) && (acceptedColor == -1 || acceptedColor == stack.color.ordinal())) {
int acceptedSize = Math.min(stack.stack.stackSize, acceptedStackSize);
removeFromAcceptedStack(acceptedSize);
ItemStack stack1 = stack.stack.splitStack(acceptedSize);
TubeStack tubeStack = super.acceptItemFromTube(new TubeStack(stack1, from, stack.color), from, simulate);
if (tubeStack != null)
stack.stack.stackSize += tubeStack.stack.stackSize;
if (stack.stack.stackSize == 0) return null;
return stack;
}
return stack;
}
/*
NBT saving
*/
@Override
public void readFromNBT(NBTTagCompound compound) {
super.readFromNBT(compound);
acceptedColor = compound.getByte("acceptedCol");
if (compound.hasKey("ItemStack")) {
NBTTagList list = compound.getTagList("ItemStack", 10);
acceptedStack = ItemStack.loadItemStackFromNBT(list.getCompoundTagAt(0));
}
acceptedStackSize = compound.getInteger("stackSize");
}
@Override
public void writeToNBT(NBTTagCompound compound) {
super.writeToNBT(compound);
compound.setByte("acceptedCol", acceptedColor);
if (acceptedStack != null) {
NBTTagList list = new NBTTagList();
NBTTagCompound compound1 = new NBTTagCompound();
acceptedStack.writeToNBT(compound1);
list.appendTag(compound1);
compound.setTag("ItemStack", list);
}
compound.setInteger("stackSize", acceptedStackSize);
}
/*
ComputerCraft implementation
*/
@Override
@Optional.Method(modid = Dependencies.COMPUTER_CRAFT)
public String getType() {
return NAME;
}
@Override
@Optional.Method(modid = Dependencies.COMPUTER_CRAFT)
public String[] getMethodNames() {
return new String[] { "setAcceptedCol", "getAcceptedCol", "setAcceptedItem", "getAcceptedItem",
"getNumSlots", "getSlotContents", "pullFromSlot", "sort", "getStackSizeLeft" };
}
@Override
@Optional.Method(modid = Dependencies.COMPUTER_CRAFT)
public Object[] callMethod(IComputerAccess computer, ILuaContext context, int method, Object[] arguments) throws Exception {
switch (method) {
case 0:
return setAcceptedCol(arguments);
case 1:
return getAcceptedCol(arguments);
case 2:
return setAcceptedItem(arguments);
case 3:
return getAcceptedItem(arguments);
case 4:
return getNumSlots(arguments);
case 5:
return getSlotContents(arguments);
case 6:
return pullFromSlot(arguments);
case 7:
return sort(arguments);
case 8:
return getStackSizeLeft(arguments);
}
return new Object[0];
}
@Override
@Optional.Method(modid = Dependencies.COMPUTER_CRAFT)
public void attach(IComputerAccess computer) {
connectedComputers.add(computer);
}
@Override
@Optional.Method(modid = Dependencies.COMPUTER_CRAFT)
public void detach(IComputerAccess computer) {
connectedComputers.remove(computer);
}
@Override
@Optional.Method(modid = Dependencies.COMPUTER_CRAFT)
public boolean equals(IPeripheral other) {
return other.getType().equals(this.getType());
}
/*
OpenComputers implementation
*/
@Override
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public String getComponentName() {
return NAME;
}
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] setAcceptedCol(Context context, Arguments arguments) throws Exception {
Object[] args = new Object[arguments.count()];
for (int i = 0; i < args.length; i++) {
args[i] = arguments.checkAny(i);
}
return setAcceptedCol(args);
}
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] getAcceptedCol(Context context, Arguments arguments) throws Exception {
Object[] args = new Object[arguments.count()];
for (int i = 0; i < args.length; i++) {
args[i] = arguments.checkAny(i);
}
return getAcceptedCol(args);
}
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] setAcceptedItem(Context context, Arguments arguments) throws Exception {
Object[] args = new Object[arguments.count()];
for (int i = 0; i < args.length; i++) {
args[i] = arguments.checkAny(i);
}
return setAcceptedItem(args);
}
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] getAcceptedItem(Context context, Arguments arguments) throws Exception {
Object[] args = new Object[arguments.count()];
for (int i = 0; i < args.length; i++) {
args[i] = arguments.checkAny(i);
}
return getAcceptedItem(args);
}
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] getNumSlots(Context context, Arguments arguments) throws Exception {
Object[] args = new Object[arguments.count()];
for (int i = 0; i < args.length; i++) {
args[i] = arguments.checkAny(i);
}
return getNumSlots(args);
}
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] getSlotContents(Context context, Arguments arguments) throws Exception {
Object[] args = new Object[arguments.count()];
for (int i = 0; i < args.length; i++) {
args[i] = arguments.checkAny(i);
}
return getSlotContents(args);
}
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] pullFromSlot(Context context, Arguments arguments) throws Exception {
Object[] args = new Object[arguments.count()];
for (int i = 0; i < args.length; i++) {
args[i] = arguments.checkAny(i);
}
return pullFromSlot(args);
}
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] sort(Context context, Arguments arguments) throws Exception {
Object[] args = new Object[arguments.count()];
for (int i = 0; i < args.length; i++) {
args[i] = arguments.checkAny(i);
}
return sort(args);
}
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] getStackSizeLeft(Context context, Arguments arguments) throws Exception {
Object[] args = new Object[arguments.count()];
for (int i = 0; i < args.length; i++) {
args[i] = arguments.checkAny(i);
}
return getStackSizeLeft(args);
}
@Callback
@Optional.Method(modid = Dependencies.OPEN_COMPUTERS)
public Object[] greet(Context context, Arguments arguments) {
contexts.add(context);
return null;
}
}
| 18,378 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileDiskDrive.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier3/TileDiskDrive.java | package net.quetzi.bluepower.tileentities.tier3;
import net.quetzi.bluepower.tileentities.TileBase;
/**
* @author fabricator77
*/
public class TileDiskDrive extends TileBase implements IRedBusWindow {
/** redbus memory block
* addr size function
* 0x00 128 Data buffer
* 0x80 2 Sector number
* 0x82 1 Command
*
* command modes
* command function
* 0x01 Read name
* 0x02 Write name
* 0x03 Read serial
* 0x04 Read sector
* 0x05 Write sector
*/
}
| 492 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileCPU.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier3/TileCPU.java | package net.quetzi.bluepower.tileentities.tier3;
import java.io.IOException;
import java.io.InputStream;
import net.minecraft.init.Blocks;
import net.quetzi.bluepower.BluePower;
import net.quetzi.bluepower.tileentities.TileBase;
/**
* @author fabricator77
*/
public class TileCPU extends TileBase implements IRedBusWindow {
//config option
public int cpuStoredCycles = 100000;
public int cpuForTickCycles = 1; // default is 1000 for 20khz
//front panel switches
public byte deviceID = 0;
public byte screenID = 1;
public byte discDriveID = 2;
public boolean halt = false;;
private byte[] memory;
// registers
private int programCounter;
private int stackPointer;
private int reg_X;
private int reg_Y;
private int reg_A; // accumulator
private int reg_B; // 65EL02 ?
private int reg_D; // ???
private int reg_I; // 65EL02
private int reg_R; // 65EL02 ?
// flags
private boolean flag_C; // carry
private boolean flag_D; // ?
private boolean flag_E; // E flag 65C816
private boolean flag_M; // M flag 65C816 (true 8 bit mode, false = 16bit)
private boolean flag_N; // negative
private boolean flag_O; // overflow
private boolean flag_X; // ?
private boolean flag_Z; // zero
private boolean flag_BRK; // break flag
private boolean flag_WAI; // wait flag (for virtual IRQ)
// redbus
private int redbus_remote_address; // current remote redbus device
private boolean redbus_timeout;
private boolean redbus_window_enabled = true;
private Object redbus_cache;
private int availableCycles;
public int rtc = 0;
// used in decoding opcodes
private int effectiveAddress;
private int BRKaddress;
public TileCPU() {
//TODO: make memory a config option
this.memory = new byte[8192];
powerOnReset();
}
public void powerOnReset () {
//TODO: set start addresses
this.programCounter = 1024;
BRKaddress = 1024; //8192;
stackPointer = 512;
reg_R = 768;
//front panel switches
//TODO: read frontpanel from NBT data
this.memory[0] = this.discDriveID;
this.memory[1] = this.screenID;
this.memory[2] = this.redbus_id; // own redbus address
// clear registers
reg_A = reg_Y = reg_A = 0;
//TODO: reset internal CPU flags
flag_BRK = false;
boolean preloadRam = true;
if (preloadRam) {
preLoadRAM();
return;
}
//load program/OS into memory
String bootLoader = "/assets/bluepower/software/rpcboot.bin";
InputStream disc = BluePower.class.getResourceAsStream(bootLoader);
if (disc == null) {
BluePower.log.info("[BluePowerControl] CPU failed to load bootloader "+bootLoader);
return;
}
try {
BluePower.log.info("[BluePowerControl] CPU loaded bootloader "+bootLoader);
//loads 256byte boot loader into memory
disc.read(this.memory, 1024, 256);
disc.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
// temp to load data into memory for testing
private void preLoadRAM () {
this.memory[1024] = (byte)0xDB; // STP
}
//TODO: NBT read/write
public void updateEntity() {
// 20 ticks per second = 20khz
if (halt) return;
this.rtc += 1;
this.flag_WAI = false;
this.redbus_timeout = false;
availableCycles += cpuForTickCycles;
if (availableCycles > cpuStoredCycles) {
availableCycles = cpuStoredCycles;
}
while (availableCycles > 0 && !this.flag_WAI && !this.redbus_timeout) {
executeInstruction();
// dumpMemory();
}
}
private void dumpMemory () {
if (this.programCounter > this.memory.length) {
availableCycles = -1;
halt = true;
return;
}
availableCycles -= 1;
String message = "[BluePowerControl] "+this.programCounter+": ";
for (int i=0; i<16; i++) {
message += Integer.toHexString(readMemory(this.programCounter) & 0xFF) + " ";
this.programCounter++;
}
BluePower.log.info(message);
this.availableCycles -= 1;
}
private void executeInstruction() {
availableCycles -= 1;
// TODO: read block of memory etc
int opcode = readMemory(this.programCounter);
BluePower.log.info("[BluePowerControl] CPU " + Integer.toHexString(this.programCounter) + ":"+Integer.toHexString(opcode));
this.programCounter++;
//TODO: sort instruction according to frequency of usage
// for speed reasons
// Octal numbers for ease of lookup in documentation.
// Reference http://www.eloraam.com/nonwp/redcpu.php
switch (opcode) {
// row 0
case 0:// 6502 BRK (calls 65EL02 MMU #0)
opBRK();
break;
case 0x01:// 6502 ORA (indirect,X)
invalid(opcode);
break;
case 0x02:// 65E02 NXT
invalid(opcode);
break;
case 0x03:// 65C816 ORA r,S
invalid(opcode);
break;
case 0x04:// 65C02 TSB zeropage
invalid(opcode);
break;
case 0x05:// 6502 ORA zeropage
invalid(opcode);
break;
case 0x06:// 6502 ASL zeropage
invalid(opcode);
break;
case 0x07:// 65EL02 ORA r,R
invalid(opcode);
break;
case 0x08:// 6502 PHP
invalid(opcode);
break;
case 0x09:// 6502 ORA #
invalid(opcode);
break;
case 0x0A:// 6502 ASL A
invalid(opcode);
break;
case 0x0B:// 65EL02 RHI
invalid(opcode);
break;
case 0x0C:// 65C02 STB absolute
invalid(opcode);
break;
case 0x0D:// 6502 ORA absolute
invalid(opcode);
break;
case 0x0E:// 6502 ASL absolute
invalid(opcode);
break;
case 0x0F:// 6502 MUL zeropage
invalid(opcode);
break;
// row 1
case 0x10:// 6502 BPL relative
invalid(opcode);
break;
case 0x11:// 6502 ORA indirect, Y
invalid(opcode);
break;
case 0x12:// 65C02 ORA indirect
invalid(opcode);
break;
case 0x13:// 65C816 ORA (r,S),Y
invalid(opcode);
break;
case 0x14:// 65C02 TRB zeropage
invalid(opcode);
break;
case 0x15:// 6502 ORA zeropage,X
invalid(opcode);
break;
case 0x16:// 6502 ASL zeropage,X
invalid(opcode);
break;
case 0x17:// 65EL02 ORA (r,R),Y
invalid(opcode);
break;
case 0x18:// 6502 CLC
opCLC();
break;
case 0x19:// 6502 ORA absolute,Y
invalid(opcode);
break;
case 0x1A:// 65C02 INC A
opINC(this.reg_A);
break;
case 0x1B:// 65EL02 RHX
invalid(opcode);
break;
case 0x1C:// 65C02 TRB absolute
invalid(opcode);
break;
case 0x1D:// 6502 ORA absolute,X
invalid(opcode);
break;
case 0x1E:// 6502 ASL absolute,X
invalid(opcode);
break;
case 0x1F:// 65EL02 MUL zeropage,X
invalid(opcode);
break;
// row 2
case 0x20:// 6502 JSR absolute
invalid(opcode);
break;
case 0x21:// 6502 AND (indirect,X)
invalid(opcode);
break;
case 0x22:// 65EL02 ENT
invalid(opcode);
break;
case 0x23:// 65C816 AND r,S
invalid(opcode);
break;
case 0x24:// 6502 BIT zeropage
opBIT();
break;
case 0x25:// 6502 AND zeropage
invalid(opcode);
break;
case 0x26:// 6502 ROL zeropage
invalid(opcode);
break;
case 0x27:// 65EL02 AND r,R
invalid(opcode);
break;
case 0x28:// 6502 PLP
invalid(opcode);
break;
case 0x29:// 6502 AND #
invalid(opcode);
break;
case 0x2A:// 6502 ROL A
invalid(opcode);
break;
case 0x2B:// 65EL02 RLI
invalid(opcode);
break;
case 0x2C:// 6502 BIT absolute
opBIT();
break;
case 0x2D:// 6502 AND absolute
invalid(opcode);
break;
case 0x2E:// 6502 ROL absolute
invalid(opcode);
break;
case 0x2F:// 65EL02 MUL absolute
invalid(opcode);
break;
// row 3
case 0x30:// 6502 BMI relative
invalid(opcode);
break;
case 0x31:// 6502 AND (indirect), Y
invalid(opcode);
break;
case 0x32:// 65C02 AND indirect
invalid(opcode);
break;
case 0x33:// 65C816 AND (r,S),Y
invalid(opcode);
break;
case 0x34:// 65C02 BIT zeropage, X
invalid(opcode);
break;
case 0x35:// 6502 AND zeropage, X
invalid(opcode);
break;
case 0x36:// 6502 ROL zeropage, X
invalid(opcode);
break;
case 0x37:// 65EL02 AND (r,R),Y
invalid(opcode);
break;
case 0x38:// 6502 SEC
//set carry flag
this.flag_C = true;
break;
case 0x39:// 6502 AND absolute, Y
invalid(opcode);
break;
case 0x3A:// 65C02 DEC A
opDEC(this.reg_A);
break;
case 0x3B:// 65EL02 RLX
invalid(opcode);
break;
case 0x3C:// 65C02 BIT absolute, X
invalid(opcode);
break;
case 0x3D:// 6502 AND absolute, X
invalid(opcode);
break;
case 0x3E:// 6502 ROL absolute, X
invalid(opcode);
break;
case 0x3F:// 65EL02 MUL absolute, X
invalid(opcode);
break;
// row 4
case 0x40:// 6502 RTI
invalid(opcode);
break;
case 0x41:// 6502 EOR (indirect,X)
invalid(opcode);
break;
case 0x42:// 65EL02 NXA
invalid(opcode);
break;
case 0x43:// 65C816 EOR r,S
invalid(opcode);
break;
case 0x44:// 65EL02 REA absolute
invalid(opcode);
break;
case 0x45:// 6502 EOR zeropage
invalid(opcode);
break;
case 0x46:// 6502 LSR zeropage
invalid(opcode);
break;
case 0x47:// 65EL02 EOR r,R
invalid(opcode);
break;
case 0x48:// 6502 PHA
invalid(opcode);
break;
case 0x49:// 6502 EOR #
invalid(opcode);
break;
case 0x4A:// 6502 LSR A
invalid(opcode);
break;
case 0x4B:// 65EL02 RHA
invalid(opcode);
break;
case 0x4C:// 6502 JMP absolute
invalid(opcode);
break;
case 0x4D:// 6502 EOR absolute
invalid(opcode);
break;
case 0x4E:// 6502 LSR absolute
invalid(opcode);
break;
case 0x4F:// 65EL02 DIV zeropage
invalid(opcode);
break;
// row 5
case 0x50:// 6502 BVC relative
invalid(opcode);
break;
case 0x51:// 6502 EOR (indirect),Y
invalid(opcode);
break;
case 0x52:// 65C02 EOR indirect
invalid(opcode);
break;
case 0x53:// 65C816 EOR (r,S),Y
invalid(opcode);
break;
case 0x54:// 65EL02 REI (zeropage)
invalid(opcode);
break;
case 0x55:// 6502 EOR zeropage,X
invalid(opcode);
break;
case 0x56:// 6502 LSR zeropage,X
invalid(opcode);
break;
case 0x57:// 65EL02 EOR (r,R),Y
invalid(opcode);
break;
case 0x58:// 6502 CLI
invalid(opcode);
break;
case 0x59:// 6502 EOR absolute,Y
invalid(opcode);
break;
case 0x5A:// 65C02 PHY
invalid(opcode);
break;
case 0x5B:// 65EL02 RHY
invalid(opcode);
break;
case 0x5C:// 65EL02 TXI
opTXI();
break;
case 0x5D:// 6502 EOR absolute,X
invalid(opcode);
break;
case 0x5E:// 6502 LSR absolute,X
invalid(opcode);
break;
case 0x5F:// 65EL02 DIV zeropage,X
invalid(opcode);
break;
// row 6
case 0x60:// 6502 RTS
invalid(opcode);
break;
case 0x61:// 6502 ADC (indirect,X)
invalid(opcode);
break;
case 0x62:// 65C816 PER relative
invalid(opcode);
break;
case 0x63:// 65C816 ADC r,S
invalid(opcode);
break;
case 0x64:// 65C02 STZ zeropage
invalid(opcode);
break;
case 0x65:// 6502 ADC zeropage
invalid(opcode);
break;
case 0x66:// 6502 ROR zeropage
invalid(opcode);
break;
case 0x67:// 65EL02 ADC r,R
invalid(opcode);
break;
case 0x68:// 6502 PLA
invalid(opcode);
break;
case 0x69:// 6502 ADC #
invalid(opcode);
break;
case 0x6A:// 6502 ROR A
invalid(opcode);
break;
case 0x6B:// 65EL02 RLA
invalid(opcode);
break;
case 0x6C:// 6502 JMP (indirect)
invalid(opcode);
break;
case 0x6D:// 6502 ADC absolute
invalid(opcode);
break;
case 0x6E:// 6502 ROR absolute
invalid(opcode);
break;
case 0x6F:// 6502 DIV absolute
invalid(opcode);
break;
// row 7
case 0x70:// 6502 BVS relative
invalid(opcode);
break;
case 0x71:// 6502 ADC (indirect),Y
invalid(opcode);
break;
case 0x72:// 65C02 ADC (indirect)
invalid(opcode);
break;
case 0x73:// 65C816 ADC (r,S),Y
invalid(opcode);
break;
case 0x74:// 65C02 STZ zeropage,X
invalid(opcode);
break;
case 0x75:// 6502 ADC zeropage,X
invalid(opcode);
break;
case 0x76:// 6502 ROR zeropage,X
invalid(opcode);
break;
case 0x77:// 65EL02 ADC (r,R),Y
invalid(opcode);
break;
case 0x78:// 6502 SEI
invalid(opcode);
break;
case 0x79:// 6502 ADC absolute,Y
invalid(opcode);
break;
case 0x7A:// 65C02 PLY
invalid(opcode);
break;
case 0x7B:// 65EL02 RLY
invalid(opcode);
break;
case 0x7C:// 65C02 JMP (absolute,X)
invalid(opcode);
break;
case 0x7D:// 6502 ADC absolute,X
invalid(opcode);
break;
case 0x7E:// 6502 ROR absolute,X
invalid(opcode);
break;
case 0x7F:// 6502 DIV absolute,X
invalid(opcode);
break;
// row 8
case 0x80:// 65C02 BRA relative
invalid(opcode);
break;
case 0x81:// 6502 STA (indirect,X)
invalid(opcode);
break;
case 0x82:// 65EL02 RER relative
invalid(opcode);
break;
case 0x83:// 65C816 STA (r,S)
invalid(opcode);
break;
case 0x84:// 6502 STY zeropage
invalid(opcode);
break;
case 0x85:// 6502 STA zeropage
invalid(opcode);
break;
case 0x86:// 6502 STX zeropage
invalid(opcode);
break;
case 0x87:// 65EL02 STA r,R
invalid(opcode);
break;
case 0x88:// 6502 DEY
invalid(opcode);
break;
case 0x89:// 65C02 BIT #
invalid(opcode);
break;
case 0x8A:// 6502 TXA
opTXA();
break;
case 0x8B:// 65EL02 TXR
opTXR();
break;
case 0x8C:// 6502 STY absolute
invalid(opcode);
break;
case 0x8D:// 6502 STA absolute
invalid(opcode);
break;
case 0x8E:// 6502 STX absolute
invalid(opcode);
break;
case 0x8F:// 65EL02 SEA
opTXR();
break;
// row 9
case 0x90:// 6502 BCC relative
invalid(opcode);
break;
case 0x91:// 6502 STA (indirect),Y
invalid(opcode);
break;
case 0x92:// 65C02 STA (indirect)
invalid(opcode);
break;
case 0x93:// 65C816 STA (r, S),Y
invalid(opcode);
break;
case 0x94:// 6502 STY zeropage,X
invalid(opcode);
break;
case 0x95:// 6502 STA zeropage,X
invalid(opcode);
break;
case 0x96:// 6502 STX zeropage,Y
invalid(opcode);
break;
case 0x97:// 65EL02 STA (r,R),X
invalid(opcode);
break;
case 0x98:// 6502 TYA
opTYA();
break;
case 0x99:// 6502 STA absolute,Y
invalid(opcode);
break;
case 0x9A:// 6502 TXS
opTXS();
break;
case 0x9B:// 65C816 TXY
opTXY();
break;
case 0x9C:// 65C02 STZ absolute
invalid(opcode);
break;
case 0x9D:// 6502 STA absolute,X
invalid(opcode);
break;
case 0x9E:// 65C02 STZ absolute,X
invalid(opcode);
break;
case 0x9F:// 65EL02 SEA
invalid(opcode);
break;
// row A
case 0xA0:// 6502 LDY #
invalid(opcode);
break;
case 0xA1:// 6502 LDA (indirect),X
invalid(opcode);
break;
case 0xA2:// 6502 LDA #
invalid(opcode);
break;
case 0xA3:// 65C816 LDA r,S
invalid(opcode);
break;
case 0xA4:// 6502 LDY zeropage
invalid(opcode);
break;
case 0xA5:// 6502 LDA zeropage
opLDA();
break;
case 0xA6:// 6502 LDY zeropage
invalid(opcode);
break;
case 0xA7:// 65EL02 LDA r,R
invalid(opcode);
break;
case 0xA8:// 6502 TAY
opTAY();
break;
case 0xA9:// 6502 LDA #
invalid(opcode);
break;
case 0xAA:// 6502 TAX
opTAY();
break;
case 0xAB:// 65EL02 TRX
opTRX();
break;
case 0xAC:// 6502 LDY absolute
invalid(opcode);
break;
case 0xAD:// 6502 LDA absolute
invalid(opcode);
break;
case 0xAE:// 6502 LDX absolute
invalid(opcode);
break;
case 0xAF:// 65EL02 TDA
opTDA();
break;
// row B
case 0xB0:// 6502 BCS relative
invalid(opcode);
break;
case 0xB1:// 6502 LDA (indirect), Y
invalid(opcode);
break;
case 0xB2:// 65C02 LDA (indirect)
invalid(opcode);
break;
case 0xB3:// 65C816 LDA (r, S), Y
invalid(opcode);
break;
case 0xB4:// 6502 LDY zeropage, X
invalid(opcode);
break;
case 0xB5:// 6502 LDA zeropage, X
invalid(opcode);
break;
case 0xB6:// 6502 LDX zeropage, Y
invalid(opcode);
break;
case 0xB7:// 65EL02 LDA (r, R), Y
invalid(opcode);
break;
case 0xB8:// 6502 CLV
invalid(opcode);
break;
case 0xB9:// 6502 LDA absolute, Y
invalid(opcode);
break;
case 0xBA:// 6502 TSX
opTSX();
break;
case 0xBB:// 65C816 TYX
opTYX();
break;
case 0xBC:// 6502 LDY absolute, X
invalid(opcode);
break;
case 0xBD:// 6502 LDA absolute, X
invalid(opcode);
break;
case 0xBE:// 6502 LDX absolute, Y
invalid(opcode);
break;
case 0xBF:// 65EL02 TAD
opTAD();
break;
// row C
case 0xC0:// 6502 CDY #
invalid(opcode);
break;
case 0xC1:// 6502 CMP (indirect, X)
invalid(opcode);
break;
case 0xC2:// 65C816 REP #
opREP();
break;
case 0xC3:// 65C816 CMP r, S
invalid(opcode);
break;
case 0xC4:// 6502 CPY zeropage
invalid(opcode);
break;
case 0xC5:// 6502 CMP zeropage
invalid(opcode);
break;
case 0xC6:// 6502 DEC zeropage
opDEC(decodeMemoryMode(AddressMode.ZEROPAGE));
break;
case 0xC7:// 65EL02 CMP r,R
invalid(opcode);
break;
case 0xC8:// 6502 INY
invalid(opcode);
break;
case 0xC9:// 6502 CMP #
invalid(opcode);
break;
case 0xCA:// 6502 DEX
invalid(opcode);
break;
case 0xCB:// 65C02 WAI
opWAI();
break;
case 0xCC:// 6502 CPY absolute
invalid(opcode);
break;
case 0xCD:// 6502 CMP absolute
invalid(opcode);
break;
case 0xCE:// 6502 DEC absolute
opDEC(decodeMemoryMode(AddressMode.ABSOLUTE));
break;
case 0xCF:// 65EL02 PLD
invalid(opcode);
break;
// row D
case 0xD0:// 6502 BNE relative
invalid(opcode);
break;
case 0xD1:// 6502 CMP (indirect), Y
invalid(opcode);
break;
case 0xD2:// 65C02 CMP (indirect)
invalid(opcode);
break;
case 0xD3:// 65C816 CMP (r, S), Y
invalid(opcode);
break;
case 0xD4:// 65C816 PEI (zeropage)
invalid(opcode);
break;
case 0xD5:// 6502 CMP zeropage, X
invalid(opcode);
break;
case 0xD6:// 6502 DEC zeropage, X
opDEC(decodeMemoryMode(AddressMode.ZEROPAGE,this.reg_X));
break;
case 0xD7:// 65EL02 CMP (r, R), Y
invalid(opcode);
break;
case 0xD8:// 6502 CLD
invalid(opcode);
break;
case 0xD9:// 6502 CMP absolute, Y
invalid(opcode);
break;
case 0xDA:// 65C02 PHX
invalid(opcode);
break;
case 0xDB:// 65C02 STP
opSTP();
break;
case 0xDC:// 65EL02 TIX
opTIX();
break;
case 0xDD:// 6502 CMP absolute, X
invalid(opcode);
break;
case 0xDE:// 6502 DEC absolute, X
opDEC(decodeMemoryMode(AddressMode.ABSOLUTE,this.reg_X));
break;
case 0xDF:// 65EL02 PHD
invalid(opcode);
break;
// row E
case 0xE0:// 6502 CPX #
invalid(opcode);
break;
case 0xE1:// 6502 SBC (indirect, X)
invalid(opcode);
break;
case 0xE2:// 65C816 SEP #
invalid(opcode);
break;
case 0xE3:// 65C816 SBC r, S
invalid(opcode);
break;
case 0xE4:// 6502 CPX zeropage
invalid(opcode);
break;
case 0xE5:// 6502 SBC zeropage
invalid(opcode);
break;
case 0xE6:// 6502 INC zeropage
opINC(decodeMemoryMode(AddressMode.ZEROPAGE));
break;
case 0xE7:// 65EL02 SBC r, R
invalid(opcode);
break;
case 0xE8:// 6502 INX
invalid(opcode);
break;
case 0xE9:// 6502 SBC #
invalid(opcode);
break;
case 0xEA:// 6502 NOP
// No OPerand
// do nothing this cycle
break;
case 0xEB:// 65C816 XBA
invalid(opcode);
break;
case 0xEC:// 6502 CPX absolute
invalid(opcode);
break;
case 0xED:// 6502 SBC absolute
invalid(opcode);
break;
case 0xEE:// 6502 INC absolute
opINC(decodeMemoryMode(AddressMode.ABSOLUTE));
break;
case 0xEF:// 65EL02 MMU
opMMU(readMemory(this.programCounter));
break;
// row F
case 0xF0:// 6502 BEQ relative
invalid(opcode);
break;
case 0xF1:// 6502 SBC (indirect),Y
invalid(opcode);
break;
case 0xF2:// 65C02 SBC (indirect)
invalid(opcode);
break;
case 0xF3:// 65C816 SBC (r,S),Y
invalid(opcode);
break;
case 0xF4:// 65C816 PEA absolute
invalid(opcode);
break;
case 0xF5:// 6502 SBC zeropage,X
invalid(opcode);
break;
case 0xF6:// 6502 INC zeropage,X
opINC(decodeMemoryMode(AddressMode.ZEROPAGE,this.reg_X));
break;
case 0xF7:// 65EL02 SBC (r,R),Y
invalid(opcode);
break;
case 0xF8:// 6502 SED
invalid(opcode);
break;
case 0xF9:// 6502 SBC absolute,Y
invalid(opcode);
break;
case 0xFA:// 65C02 PLX
invalid(opcode);
break;
case 0xFB:// 65C816 XCE relative
opXCE();
break;
case 0xFC:// 65C816 JSR (absolute,X)
invalid(opcode);
break;
case 0xFD:// 6502 SBC absolute,X
invalid(opcode);
break;
case 0xFE:// 6502 INC absolute,X
opINC(decodeMemoryMode(AddressMode.ABSOLUTE,this.reg_X));
break;
case 0xFF:// invalid
invalid(opcode);
break;
}
}
// 65C816
private void opREP() {
// 65C816 Reset Processor Status Flag
setFlags(getFlags() & (readMemory(this.programCounter) ^ 0xFFFFFFFF));
}
private void opTYX() {
// 65C816 TYX
this.reg_X = this.reg_Y;
}
private void opTXY() {
// 65C816 TXY
this.reg_Y = this.reg_X;
}
public void opSTP() {// 65EL02 modified
availableCycles = -1;
halt = true;
BluePower.log.info("self block=" + this.blockType);
if ( this.worldObj.isAirBlock(this.xCoord, this.yCoord+1, this.zCoord)) {
//set CPU on fire for the lolz
this.worldObj.playSoundEffect((double)this.xCoord + 0.5D, (double)this.yCoord + 0.5D, (double)this.zCoord + 0.5D, "fire.ignite", 1.0F, this.worldObj.rand.nextFloat() * 0.4F + 0.8F);
this.worldObj.setBlock(this.xCoord, this.yCoord+1, this.zCoord, Blocks.fire);
}
}
public void opTRX() {// 65EL02
// TRX opcode
// tranfer R to X
this.reg_X = this.reg_R;
}
public void opTXR() {// 65EL02
// TXR opcode
// transfer X to R
this.reg_R = this.reg_X;
}
public void opTAD() {// 65EL02
// 65LE02 TAD
// transfer A to D
this.reg_D = this.reg_A;
}
public void opTDA() {
// 65EL02 TDA
this.reg_A = this.reg_D;
}
public void opTIX() {
// 65EL02 TIX
this.reg_X = this.reg_I;
}
public void opTXI() {
// 65EL02 TXI
this.reg_I = this.reg_X;
}
public void opMMU(int mode) {
this.programCounter++;
switch (mode) {
case 0:
// set remote redbus address
int t = this.reg_A & 0xFF;
if (t != this.redbus_remote_address) {
// if output buffer full
if (this.redbus_cache != null) {
this.redbus_timeout = true;
}
this.redbus_remote_address = t;
}
break;
case 1:
// set redbus window to memory address in A
break;
case 2:
// enable redbus window
redbus_window_enabled = true;
break;
case 3:
// set external memory mapped window to A.
break;
case 4:
// enable external memory mapped window
break;
case 5:
// set BRK address to A
break;
case 6:
// set POR address to A
break;
case 0x80:
// get remote redbus address
this.reg_A = this.redbus_remote_address;
break;
case 0x81:
// get redbus window to memory address in A
break;
case 0x82:
// disable redbus window
redbus_window_enabled = false;
break;
case 0x83:
// get external memory mapped window to A.
break;
case 0x84:
// disable external memory mapped window
break;
case 0x85:
// get BRK address to A
break;
case 0x86:
// get POR address to A
break;
case 0x87:
// get RTC to A and D
this.reg_A = (this.rtc & 0xFFFF);
this.reg_D = (this.rtc >> 16 & 0xFFFF);
break;
case 0xFF:
// Output A register to MC logfile.
break;
}
}
private void opBRK() {
// push program counter
// push flags
flag_BRK = true;
programCounter = BRKaddress;
}
private void opXCE() {//65C816
// exchange C and E flags
boolean temp = flag_C;
flag_E = flag_C;
flag_C = temp;
}
private void opLDA() {
this.reg_A = readMemory(effectiveAddress);
this.programCounter++;
}
private void opWAI() {//65C02
// wait for interrupt (actually waits for next world tick)
this.flag_WAI = true;
}
// Modfied from sysmon
private void opBIT() {
// BIT opcode
int tmp = readMemory(programCounter + effectiveAddress);
flag_Z = ((reg_A & tmp) == 0);
flag_N = ((tmp & 0x80) != 0);
flag_O = ((tmp & 0x40) != 0);
}
private void opCLC() {//6502
// CLC opcode
flag_C = false;
}
private void opTAX(){// 6502
// TAX opcode
// transfer A to X
this.reg_X = this.reg_A;
}
private void opTXA(){// 6502
// TXA opcode
// transfer X to A
this.reg_A = this.reg_X;
}
private void opTAY(){// 6502
// TAY opcode
// transfer A to Y
this.reg_Y = this.reg_A;
}
private void opTYA() {//6502
// TYA opcode
// transfer Y to A
this.reg_A = this.reg_Y;
}
private void opTSX() {// 6502
// TSX opcode
// transfer stack pointer to X
this.reg_X = this.stackPointer;
}
private void opTXS() {// 6502
// TXS opcode
// transfer X to stack pointer
this.stackPointer = this.reg_X;
}
private void opINC(int pc){
int i = readMemory(pc);
i = i + 1 & maskMemory();
writeMemory(pc, i);
setArithmeticFlags(i);
}
private void opDEC(int pc){
int i = readMemory(pc);
i = i - 1 & maskMemory();
writeMemory(pc, i);
setArithmeticFlags(i);
}
private void setArithmeticFlags(int reg) {
this.flag_Z = (reg == 0);
this.flag_N = (reg & 0x80) != 0;
}
private int readMemory(int pc) {
//TODO: redbus memory
if (pc < memory.length) {//do not try to access more memory than we have.
return (int)this.memory[pc] & 0xFF;//TODO: likely issues with forcing 8bit mod here
}
//TODO: throw error here
return 0;
}
private void writeMemory(int pc, int data) {
//TODO: redbus memory
if (pc < memory.length) {//do not try to access more memory than we have.
this.memory[pc] = (byte)(data & 0xFF);//TODO: likely issues with forcing 8bit mod here
return;
}
//TODO: throw error here
return;
}
private int maskMemory() {//TODO: maybe faster to simply change a stored int whenever 8/16it mode is toggled.
if (this.flag_M) return 255;// 8 bit
else return 65535;// 16 bit
}
private int decodeMemoryMode(AddressMode mode) {
int baseAddress = 0;
int localAddress = readMemory(programCounter);
// non-Indexed memory modes
switch (mode) {
case ABSOLUTE:
baseAddress = sixteenBitAddress(localAddress, readMemory(programCounter++));
break;
case INDIRECT:
baseAddress = readMemory(sixteenBitAddress(localAddress, readMemory(programCounter++)));
break;
case RELATIVE:
// +127 to -128
baseAddress = programCounter - 129;
break;
case ZEROPAGE:
baseAddress = 0 + (localAddress & 0xFF);
programCounter++;
break;
default:
break;
}
return baseAddress;
}
private int decodeMemoryMode(AddressMode mode, int offset) {
int baseAddress = 0;
int localAddress = readMemory(programCounter);
// Indexed memory modes
switch (mode) {
case ABSOLUTE:
baseAddress = sixteenBitAddress(localAddress, readMemory(programCounter++)) + offset;
break;
case INDIRECT:
//TODO: multiple version of this exist
break;
case ZEROPAGE:
baseAddress = 0 + (localAddress + offset) & 0xFF;
programCounter++;
break;
default:
break;
}
return baseAddress;
}
/**
* Given two bytes, return a 16 bit address.
*/
int sixteenBitAddress(int lowByte, int hiByte) {
return ((hiByte << 8) | lowByte) & 0xffff;
}
private void setFlags(int flag) {
}
private int getFlags() {
return 0;
}
// Opcode functions
private void invalid(int op) {
this.halt = true;
BluePower.log.error("BluePower CPU, Invalid OP code:"+Integer.toHexString(op));
}
public static enum AddressMode{
ABSOLUTE, INDIRECT, RELATIVE, ZEROPAGE
}
}
| 36,684 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileIOExpander.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier3/TileIOExpander.java | package net.quetzi.bluepower.tileentities.tier3;
import net.quetzi.bluepower.tileentities.TileBase;
/**
* @author fabricator77
*/
public class TileIOExpander extends TileBase implements IRedBusWindow {
//TODO: half height block
}
| 235 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IRedBusWindow.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/tileentities/tier3/IRedBusWindow.java | package net.quetzi.bluepower.tileentities.tier3;
public interface IRedBusWindow {
public byte redbus_id = 0;
public byte[] redBus_memory = new byte[256];
//TODO: read/write update status flags/events
}
| 206 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BPEventHandler.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/events/BPEventHandler.java | package net.quetzi.bluepower.events;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntityHopper;
import net.minecraft.util.EntityDamageSource;
import net.minecraftforge.event.entity.living.LivingDeathEvent;
import net.minecraftforge.event.entity.player.EntityItemPickupEvent;
import net.quetzi.bluepower.containers.ContainerSeedBag;
import net.quetzi.bluepower.containers.inventorys.InventoryItem;
import net.quetzi.bluepower.init.BPEnchantments;
import net.quetzi.bluepower.items.ItemSeedBag;
import cpw.mods.fml.common.eventhandler.Event.Result;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
public class BPEventHandler {
@SubscribeEvent
public void itemPickUp(EntityItemPickupEvent event) {
EntityPlayer player = event.entityPlayer;
ItemStack pickUp = event.item.getEntityItem();
if (!(player.openContainer instanceof ContainerSeedBag)) {
for (ItemStack is : player.inventory.mainInventory) {
if (is != null && is.getItem() instanceof ItemSeedBag) {
ItemStack seedType = ItemSeedBag.getSeedType(is);
if (seedType != null && seedType.isItemEqual(pickUp)) {
InventoryItem inventory = InventoryItem.getItemInventory(is, "Seed Bag", 9);
inventory.openInventory();
ItemStack pickedUp = TileEntityHopper.func_145889_a(inventory, pickUp, -1);
inventory.closeInventory(is);
if (pickedUp == null) {
event.setResult(Result.ALLOW);
event.item.setDead();
return;
} else {
event.item.setEntityItemStack(pickedUp);
}
}
}
}
}
}
@SubscribeEvent
public void onEntityDeath(LivingDeathEvent event) {
if(event.source instanceof EntityDamageSource) {
EntityDamageSource entitySource = (EntityDamageSource) event.source;
if(entitySource.getEntity() instanceof EntityPlayer) {
EntityPlayer killer = (EntityPlayer) entitySource.getEntity();
if(killer.inventory.getCurrentItem() != null) {
if(EnchantmentHelper.getEnchantments(killer.inventory.getCurrentItem()).containsKey(BPEnchantments.vorpal.effectId)) {
int level = EnchantmentHelper.getEnchantmentLevel(BPEnchantments.vorpal.effectId, killer.inventory.getCurrentItem());
if(level == 1) {
if(killer.worldObj.rand.nextInt(6) == 1) {
this.dropHeads(event);
}
} else if(level == 2) {
if(killer.worldObj.rand.nextInt(3) == 1) {
this.dropHeads(event);
}
}
}
}
}
}
}
private void dropHeads(LivingDeathEvent event) {
if(event.entityLiving instanceof EntityCreeper) {
event.entityLiving.entityDropItem(new ItemStack(Items.skull, 1, 4), 0.0F);
return;
}
if(event.entityLiving instanceof EntityPlayer) {
ItemStack drop = new ItemStack(Items.skull, 1, 3);
drop.stackTagCompound = new NBTTagCompound();
drop.stackTagCompound.setString("SkullOwner", ((EntityPlayer) event.entityLiving).getDisplayName());
event.entityLiving.entityDropItem(drop, 0.0F);
return;
}
if(event.entityLiving instanceof EntitySkeleton) {
EntitySkeleton sk = (EntitySkeleton) event.entityLiving;
if(sk.getSkeletonType() == 0) {
event.entityLiving.entityDropItem(new ItemStack(Items.skull, 1, 0), 0.0F);
return;
} else {
event.entityLiving.entityDropItem(new ItemStack(Items.skull, 1, 1), 0.0F);
return;
}
}
if(event.entityLiving instanceof EntityZombie) {
event.entityLiving.entityDropItem(new ItemStack(Items.skull, 1, 2), 0.0F);
return;
}
}
}
| 4,285 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockBase.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/BlockBase.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.quetzi.bluepower.client.renderers.RendererBlockBase;
import net.quetzi.bluepower.init.CustomTabs;
public abstract class BlockBase extends Block {
public BlockBase(Material material) {
super(material);
setStepSound(soundTypeStone);
setCreativeTab(CustomTabs.tabBluePowerMachines);
blockHardness = 3.0F;
}
/**
* Method to detect how the block was placed, and what way it's facing.
*/
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack iStack) {
int sideToPlace;
if (canRotateVertical() && player.rotationPitch > 45) {
sideToPlace = 4;
} else if (canRotateVertical() && player.rotationPitch < -45) {
sideToPlace = 5;
} else {
sideToPlace = MathHelper.floor_double(player.rotationYaw / 90F + 0.5D) & 3;
}
int metaDataToSet = 0;
switch (sideToPlace) {
case 0:
metaDataToSet = 2;
break;
case 1:
metaDataToSet = 5;
break;
case 2:
metaDataToSet = 3;
break;
case 3:
metaDataToSet = 4;
break;
case 4:
metaDataToSet = 1;
break;
case 5:
metaDataToSet = 0;
break;
}
world.setBlockMetadataWithNotify(x, y, z, metaDataToSet, 2);
}
protected boolean canRotateVertical() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderType() {
return RendererBlockBase.RENDER_ID;
}
}
| 2,846 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockItemOre.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/BlockItemOre.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.item.Item;
import net.minecraft.util.MathHelper;
import net.minecraft.world.IBlockAccess;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.init.BPItems;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
import java.util.Random;
public class BlockItemOre extends Block {
private Random rand = new Random();
public BlockItemOre(String type) {
super(Material.iron);
this.setCreativeTab(CustomTabs.tabBluePowerBlocks);
this.setStepSound(soundTypeStone);
this.setHardness(2.5F);
this.setResistance(10.0F);
this.textureName = Refs.MODID + ":" + type;
this.setBlockName(type);
}
@Override
public int quantityDropped(Random rand) {
return this == BPBlocks.nikolite_ore ? 4 + rand.nextInt(2) : 1;
}
@Override
public Item getItemDropped(int par1, Random par2, int par3) {
return getDropFromBlockName(this.getUnlocalizedName().substring(5));
}
@Override
protected boolean canSilkHarvest() {
return true;
}
@Override
public int quantityDroppedWithBonus(int quantity, Random rand) {
if (quantity > 0 && Item.getItemFromBlock(this) != this.getItemDropped(0, rand, quantity)) {
int j = rand.nextInt(quantity + 2) - 1;
if (j < 0) {
j = 0;
}
return this.quantityDropped(rand) * (j + 1);
} else {
return this.quantityDropped(rand);
}
}
@Override
public int getExpDrop(IBlockAccess par1, int par2, int par3) {
if (this.getItemDropped(par2, rand, par3) != Item.getItemFromBlock(this)) {
int j1 = 0;
if (this == BPBlocks.amethyst_ore) {
j1 = MathHelper.getRandomIntegerInRange(rand, 3, 7);
} else if (this == BPBlocks.ruby_ore) {
j1 = MathHelper.getRandomIntegerInRange(rand, 3, 7);
} else if (this == BPBlocks.sapphire_ore) {
j1 = MathHelper.getRandomIntegerInRange(rand, 3, 7);
} else if (this == BPBlocks.nikolite_ore) {
j1 = MathHelper.getRandomIntegerInRange(rand, 2, 5);
}
return j1;
}
return 0;
}
public static Item getDropFromBlockName(String blockName) {
if (blockName.equalsIgnoreCase(Refs.NIKOLITEORE_NAME)) {
return BPItems.nikolite;
} else if (blockName.equalsIgnoreCase(Refs.RUBYORE_NAME)) {
return BPItems.ruby;
} else if (blockName.equalsIgnoreCase(Refs.SAPPHIREORE_NAME)) {
return BPItems.sapphire;
} else if (blockName.equalsIgnoreCase(Refs.AMETHYSTORE_NAME)) {
return BPItems.amethyst;
} else {
return null;
}
}
}
| 3,696 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockContainer6Sided.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/BlockContainer6Sided.java | package net.quetzi.bluepower.blocks;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.references.Refs;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public abstract class BlockContainer6Sided extends BlockContainerBase {
private IIcon textureFront;
private IIcon textureBack;
public BlockContainer6Sided(Material material) {
super(material);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
String unlocName = getUnlocalizedName().substring(5);
textureFront = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + unlocName + "_front");
textureBack = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + unlocName + "_back");
blockIcon = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + unlocName + "_side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection direction = ForgeDirection.getOrientation(meta);
if (side == direction.ordinal()) {
return textureFront;
} else if (side == direction.getOpposite().ordinal()) { return textureBack; }
return blockIcon;
}
}
| 1,502 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockContainerBase.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/BlockContainerBase.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.quetzi.bluepower.BluePower;
import net.quetzi.bluepower.helper.IOHelper;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.tileentities.TileBase;
public abstract class BlockContainerBase extends BlockBase implements ITileEntityProvider {
public BlockContainerBase(Material material) {
super(material);
this.isBlockContainer = true;
}
@Override
public TileEntity createNewTileEntity(World world, int metadata) {
try {
return getTileEntity().newInstance();
} catch (Exception e) {
return null;
}
}
/**
* Method to be overwritten to fetch the TileEntity Class that goes with the block
*
* @return a .class
*/
protected abstract Class<? extends TileEntity> getTileEntity();
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block);
// Only do this on the server side.
if (!world.isRemote) {
TileBase tileEntity = (TileBase) world.getTileEntity(x, y, z);
if (tileEntity != null) {
tileEntity.onBlockNeighbourChanged();
}
}
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) {
if (player.isSneaking()) {
return false;
}
TileEntity entity = world.getTileEntity(x, y, z);
if (entity == null || !(entity instanceof TileBase)) {
return false;
}
if (getGuiID() != GuiIDs.INVALID) {
player.openGui(BluePower.instance, getGuiID().ordinal(), world, x, y, z);
return true;
}
return false;
}
@Override
public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
TileBase tile = (TileBase) world.getTileEntity(x, y, z);
for (ItemStack stack : tile.getDrops()) {
IOHelper.spawnItemInWorld(world, stack, x + 0.5F, y + 0.5F, z + 0.5F);
}
super.breakBlock(world, x, y, z, block, meta);
world.removeTileEntity(x, y, z);
}
@Override
public boolean onBlockEventReceived(World world, int x, int y, int z, int id, int data)
{
super.onBlockEventReceived(world, x, y, z, id, data);
TileEntity tileentity = world.getTileEntity(x, y, z);
return tileentity != null && tileentity.receiveClientEvent(id, data);
}
/**
* Method to be overwritten that returns a GUI ID
*
* @return
*/
public abstract GuiIDs getGuiID();
}
| 3,760 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BPBlockMultipart.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/BPBlockMultipart.java | package net.quetzi.bluepower.blocks;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EnumCreatureType;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.tileentities.BPTileMultipart;
import net.quetzi.bluepower.util.RayTracer;
public class BPBlockMultipart extends BlockContainer {
protected BPBlockMultipart() {
super(Material.rock);
}
private BPPart hovered = null;
@Override
public TileEntity createNewTileEntity(World world, int meta) {
return new BPTileMultipart();
}
private BPTileMultipart getTile(IBlockAccess w, int x, int y, int z) {
TileEntity tile = w.getTileEntity(x, y, z);
if (tile == null) return null;
if (tile instanceof BPTileMultipart) return ((BPTileMultipart) tile);
return null;
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void addCollisionBoxesToList(World w, int x, int y, int z, AxisAlignedBB unused, List l, Entity entity) {
BPTileMultipart t = getTile(w, x, y, z);
if (t == null) return;
l.addAll(t.getCollisionBoxes());
}
@Override
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_) {
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
}
@Override
public boolean canConnectRedstone(IBlockAccess w, int x, int y, int z, int side) {
BPTileMultipart t = getTile(w, x, y, z);
if (t == null) return false;
return super.canConnectRedstone(w, x, y, z, side);
}
@Override
public boolean canCreatureSpawn(EnumCreatureType type, IBlockAccess world, int x, int y, int z) {
return false;
}
@Override
public MovingObjectPosition collisionRayTrace(World w, int x, int y, int z, Vec3 start, Vec3 end) {
BPTileMultipart t = getTile(w, x, y, z);
if (t == null) return null;
MovingObjectPosition mop = t.rayTrace(new Vector3(start), new Vector3(end));
if (mop == null) return null;
@SuppressWarnings("unused")
EntityPlayer p = null;// FIXME BLUEPOWER Return the player that's raytracing
hovered = null;// FIXME BLUEPOWER Get selected part
return mop;
}
@Override
public float getBlockHardness(World w, int x, int y, int z) {
BPTileMultipart t = getTile(w, x, y, z);
if (t == null) return 0;
if (hovered != null && hovered.world == w && hovered.x == x && hovered.y == y && hovered.z == z) {
EntityPlayer player = null;// FIXME BLUEPOWER Get player that's breaking it
return hovered.getHardness(t.rayTrace(new Vector3(RayTracer.getCorrectedHeadVec(player)), new Vector3(RayTracer.getEndVec(player))),
player);
}
hovered = null;
return 0;
}
@Override
public ArrayList<ItemStack> getDrops(World w, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> items = new ArrayList<ItemStack>();
BPTileMultipart t = getTile(w, x, y, z);
if (t == null) return items;
for (BPPart p : t.getParts()) {
List<ItemStack> i = p.getDrops();
if (i != null) items.addAll(i);
}
return items;
}
@Override
public float getExplosionResistance(Entity par1Entity, World w, int x, int y, int z, double explosionX, double explosionY, double explosionZ) {
BPTileMultipart t = getTile(w, x, y, z);
if (t == null) return -1;
return t.getExplosionResistance();
}
@Override
public int getLightOpacity(IBlockAccess world, int x, int y, int z) {
return 0;
}
@Override
public int getLightValue(IBlockAccess w, int x, int y, int z) {
BPTileMultipart t = getTile(w, x, y, z);
if (t == null) return -1;
return t.getLightValue();
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World w, int x, int y, int z) {
BPTileMultipart t = getTile(w, x, y, z);
if (t == null) return null;
return t.getPickedItem(target);
}
@Override
public AxisAlignedBB getSelectedBoundingBoxFromPool(World w, int x, int y, int z) {
// BPTileMultipart t = getTile(w, x, y, z);
// if (t == null) return null;
//
// if (hovered != null && hovered.world == w && hovered.x == x && hovered.y == y && hovered.z == z) {
// EntityPlayer player = null;// FIXME BLUEPOWER Get player that's breaking it
//
// return hovered.getSelectionBoxes();
// }
//
// hovered = null;
return null;
}
@Override
public boolean isNormalCube() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int isProvidingWeakPower(IBlockAccess p_149709_1_, int p_149709_2_, int p_149709_3_, int p_149709_4_, int p_149709_5_) {
return super.isProvidingWeakPower(p_149709_1_, p_149709_2_, p_149709_3_, p_149709_4_, p_149709_5_);
}
@Override
public int isProvidingStrongPower(IBlockAccess p_149748_1_, int p_149748_2_, int p_149748_3_, int p_149748_4_, int p_149748_5_) {
return super.isProvidingStrongPower(p_149748_1_, p_149748_2_, p_149748_3_, p_149748_4_, p_149748_5_);
}
@Override
public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_,
float p_149727_7_, float p_149727_8_, float p_149727_9_) {
return super.onBlockActivated(p_149727_1_, p_149727_2_, p_149727_3_, p_149727_4_, p_149727_5_, p_149727_6_, p_149727_7_, p_149727_8_,
p_149727_9_);
}
@Override
public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_) {
super.onEntityCollidedWithBlock(p_149670_1_, p_149670_2_, p_149670_3_, p_149670_4_, p_149670_5_);
}
@Override
public int quantityDropped(int meta, int fortune, Random random) {
return 0;
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess p_149719_1_, int p_149719_2_, int p_149719_3_, int p_149719_4_) {
super.setBlockBoundsBasedOnState(p_149719_1_, p_149719_2_, p_149719_3_, p_149719_4_);
}
}
| 7,490 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockRelay.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockRelay.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks.machines;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileRelay;
public class BlockRelay extends BlockContainerBase {
private IIcon textureFront;
private IIcon textureBack;
private IIcon textureSide1;
private IIcon textureSide2;
private IIcon textureSide2Active;
public boolean isActive = false;
public BlockRelay() {
super(Material.rock);
this.setBlockName(Refs.RELAY_NAME);
this.setCreativeTab(CustomTabs.tabBluePowerMachines);
}
/**
* Method to be overwritten to fetch the TileEntity Class that goes with the block
*
* @return a .class
*/
@Override protected Class<? extends TileEntity> getTileEntity() {
return TileRelay.class;
}
/**
* Method to be overwritten that returns a GUI ID
*
* @return
*/
@Override public GuiIDs getGuiID() {
return GuiIDs.RELAY_ID;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.textureFront = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.RELAY_NAME + "_front");
this.textureBack = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.RELAY_NAME + "_back");
this.textureSide1 = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.RELAY_NAME + "_side_0");
this.textureSide2 = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.RELAY_NAME + "_side_1");
this.textureSide2Active = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.RELAY_NAME + "_side_1_active");
this.blockIcon = this.textureSide1;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection direction = ForgeDirection.getOrientation(meta);
if (side == direction.ordinal()) {
return textureFront;
} else if (side == direction.getOpposite().ordinal()) {
return textureBack;
} if ((side == 3) || (side == 2)) {
return isActive ? textureSide2Active : textureSide2;
}
return blockIcon;
}
}
| 3,511 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockEngine.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockEngine.java | package net.quetzi.bluepower.blocks.machines;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.init.BPItems;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileEngine;
/**
*
* @author TheFjong
*
*/
public class BlockEngine extends BlockContainer {
public BlockEngine() {
super(Material.iron);
setCreativeTab(CustomTabs.tabBluePowerMachines);
setBlockName(Refs.ENGINE_NAME);
setBlockTextureName("models/engineoff");
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderType() {
return -1;
}
@SuppressWarnings("cast")
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack) {
if (world.getTileEntity(x, y, z) instanceof TileEngine) {
int direction = 0;
int facing;
if (player.rotationPitch > 45) {
facing = 5;
} else if (player.rotationPitch < -45) {
facing = 4;
} else {
facing = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
}
if (facing == 0) {
direction = ForgeDirection.SOUTH.ordinal();
} else if (facing == 1) {
direction = ForgeDirection.WEST.ordinal();
} else if (facing == 2) {
direction = ForgeDirection.NORTH.ordinal();
} else if (facing == 3) {
direction = ForgeDirection.EAST.ordinal();
} else if (facing == 4) {
direction = ForgeDirection.UP.ordinal();
} else if (facing == 5) {
direction = ForgeDirection.DOWN.ordinal();
}
TileEngine tile = (TileEngine) world.getTileEntity(x, y, z);
tile.setOrientation(direction);
}
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileEngine();
}
@Override
public IIcon getIcon(int p_149691_1_, int p_149691_2_) {
return this.blockIcon;
}
@Override
public void registerBlockIcons(IIconRegister p_149651_1_) {
this.blockIcon = p_149651_1_.registerIcon(Refs.MODID + ":" + "models/engineoff");
}
@SuppressWarnings("cast")
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int p_149727_6_, float p_149727_7_, float p_149727_8_,
float p_149727_9_) {
Item item = player.inventory.getCurrentItem().getItem();
if (item != null) {
if (item == BPItems.screwdriver) {
if (!world.isRemote) {
int direction = 0;
int facing = 0;
if (player.rotationPitch > 45) {
facing = 5;
} else if (player.rotationPitch < -45) {
facing = 4;
} else {
facing = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
}
TileEngine engine = (TileEngine) world.getTileEntity(x, y, z);
if (facing == 0) {
if (player.isSneaking())
direction = ForgeDirection.NORTH.ordinal();
direction = ForgeDirection.SOUTH.ordinal();
} else if (facing == 1) {
if (player.isSneaking())
direction = ForgeDirection.EAST.ordinal();
direction = ForgeDirection.WEST.ordinal();
} else if (facing == 2) {
if (player.isSneaking())
direction = ForgeDirection.SOUTH.ordinal();
direction = ForgeDirection.NORTH.ordinal();
} else if (facing == 3) {
if (player.isSneaking())
direction = ForgeDirection.WEST.ordinal();
direction = ForgeDirection.EAST.ordinal();
} else if (facing == 4) {
if (player.isSneaking())
direction = ForgeDirection.DOWN.ordinal();
direction = ForgeDirection.UP.ordinal();
} else if (facing == 5) {
if (player.isSneaking())
direction = ForgeDirection.UP.ordinal();
direction = ForgeDirection.DOWN.ordinal();
}
engine.setOrientation(direction);
world.markBlockForUpdate(x, y, z);
System.out.println(direction + " Direction:Facing " + facing);
}
}
}
return false;
}
}
| 5,613 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockBlockBreaker.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockBlockBreaker.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks.machines;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.quetzi.bluepower.blocks.BlockContainer6Sided;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileBlockBreaker;
public class BlockBlockBreaker extends BlockContainer6Sided {
public BlockBlockBreaker() {
super(Material.rock);
setBlockName(Refs.BLOCKBREAKER_NAME);
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileBlockBreaker.class;
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.INVALID; // TODO: Not sure what to return if it has no gui
}
}
| 1,543 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockKineticGenerator.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockKineticGenerator.java | package net.quetzi.bluepower.blocks.machines;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileKinectGenerator;
/**
*
* @author TheFjong
*
*/
public class BlockKineticGenerator extends BlockContainerBase {
public BlockKineticGenerator() {
super(Material.iron);
setCreativeTab(CustomTabs.tabBluePowerMachines);
setBlockName(Refs.KINETICGENERATOR_NAME);
this.setBlockTextureName(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.KINETICGENERATOR_NAME + "_front");
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileKinectGenerator.class;
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.KINETICGENERATOR_ID;
}
}
| 1,035 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockAlloyFurnace.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockAlloyFurnace.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks.machines;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileAlloyFurnace;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockAlloyFurnace extends BlockContainerBase {
public static IIcon textureTop;
private IIcon textureBottom;
private IIcon textureSide;
private IIcon textureFrontOn;
private IIcon textureFrontOff;
public BlockAlloyFurnace() {
super(Material.rock);
setBlockName(Refs.ALLOYFURNACE_NAME);
// This might not be needed actually.
setBlockTextureName(Refs.ALLOYFURNACE_NAME + "_front");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection s = ForgeDirection.getOrientation(side);
// If is facing
if ((meta & 7) == side) {
// Do some bitmasking
if ((meta & 8) != 0) {
return textureFrontOn;
} else {
return textureFrontOff;
}
}
switch (s) {
case UP:
return textureTop;
case DOWN:
return textureBottom;
case EAST:
case NORTH:
case SOUTH:
case WEST:
case UNKNOWN:
return textureSide;
default:
break;
}
return null;
}
@Override
public boolean isOpaqueCube() {
return true;
}
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rnd) {
int metadata = world.getBlockMetadata(x, y, z);
if ((metadata & 8) != 0) {
int l = world.getBlockMetadata(x, y, z) & 7;
float f = x + 0.5F;
float f1 = y + 0.0F + rnd.nextFloat() * 6.0F / 16.0F;
float f2 = z + 0.5F;
float f3 = 0.52F;
float f4 = rnd.nextFloat() * 0.6F - 0.3F;
if (l == 4) {
world.spawnParticle("smoke", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f - f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
} else if (l == 5) {
world.spawnParticle("smoke", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f3, f1, f2 + f4, 0.0D, 0.0D, 0.0D);
} else if (l == 2) {
world.spawnParticle("smoke", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 - f3, 0.0D, 0.0D, 0.0D);
} else if (l == 3) {
world.spawnParticle("smoke", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
world.spawnParticle("flame", f + f4, f1, f2 + f3, 0.0D, 0.0D, 0.0D);
}
}
}
// Not sure if you need this function.
@Override
public Item getItemDropped(int p_149650_1_, Random random, int p_149650_3_) {
return Item.getItemFromBlock(BPBlocks.alloy_furnace);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
textureTop = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + getUnlocalizedName().substring(5) + "_top");
textureBottom = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + getUnlocalizedName().substring(5) + "_bottom");
textureSide = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + getUnlocalizedName().substring(5) + "_side");
textureFrontOn = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + getUnlocalizedName().substring(5) + "_front_on");
textureFrontOff = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + getUnlocalizedName().substring(5) + "_front_off");
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
int metadata = world.getBlockMetadata(x, y, z);
if ((metadata & 8) != 0) { return 13; }
return 0;
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileAlloyFurnace.class;
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.ALLOY_FURNACE;
}
@Override
protected boolean canRotateVertical() {
return false;
}
@Override
public int getRenderType() {
return 0;
}
}
| 5,920 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockIgniter.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockIgniter.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks.machines;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileIgniter;
public class BlockIgniter extends BlockContainerBase {
private IIcon textureFrontOn;
private IIcon textureFrontOff;
private IIcon textureSide1;
private IIcon textureSide2;
private IIcon textureBack;
public BlockIgniter() {
super(Material.rock);
this.setBlockName(Refs.BLOCKIGNITER_NAME);
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileIgniter.class;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
// TODO: Set textures correctly
ForgeDirection direction = ForgeDirection.getOrientation(meta);
if (side == direction.ordinal()) {
return textureFrontOff;
} else if (side == direction.getOpposite().ordinal()) {
return textureBack;
} if ((side == 3) || (side == 2)) {
return textureSide2;
}
return blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.textureFrontOn = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKIGNITER_NAME + "_front_on");
this.textureFrontOff = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKIGNITER_NAME + "_front_off");
this.textureBack = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKIGNITER_NAME + "_back");
this.textureSide1 = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKIGNITER_NAME + "_side_0");
this.textureSide2 = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKIGNITER_NAME + "_side_1");
this.blockIcon = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKIGNITER_NAME + "_side_0");
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.INVALID;
}
@Override
public boolean isFireSource(World world, int x, int y, int z, ForgeDirection side) {
boolean orientation = ForgeDirection.getOrientation(world.getBlockMetadata(x, y, z)) == ForgeDirection.UP;
TileIgniter tile = (TileIgniter) world.getTileEntity(x, y, z);
return orientation && tile.getIsRedstonePowered();
}
}
| 3,691 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockBuffer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockBuffer.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.blocks.machines;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileBuffer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockBuffer extends BlockContainerBase {
private IIcon textureFront;
private IIcon textureBack;
public BlockBuffer() {
super(Material.rock);
this.setBlockName(Refs.BLOCKBUFFER_NAME);
this.setCreativeTab(CustomTabs.tabBluePowerMachines);
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileBuffer.class;
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.BUFFER;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.textureFront = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKBUFFER_NAME + "_front");
this.textureBack = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKBUFFER_NAME + "_back");
this.blockIcon = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKBUFFER_NAME + "_side");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection direction = ForgeDirection.getOrientation(meta);
if (side == direction.ordinal()) {
return textureFront;
} else if (side == direction.getOpposite().ordinal()) { return textureBack; }
return blockIcon;
}
}
| 2,749 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockTransposer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockTransposer.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.blocks.machines;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileTransposer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockTransposer extends BlockContainerBase {
private IIcon textureFront;
private IIcon textureSide;
private IIcon textureSideActive;
private IIcon textureBack;
public BlockTransposer() {
super(Material.rock);
this.setBlockName(Refs.TRANSPOSER_NAME);
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileTransposer.class;
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.INVALID;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection direction = ForgeDirection.getOrientation(meta);
if (side == direction.ordinal()) {
return textureFront;
} else if (side == direction.getOpposite().ordinal()) { return textureBack; }
// if () { return textureSideActive; } TODO: Check if block is powered
return blockIcon;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.textureFront = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.TRANSPOSER_NAME + "_front");
this.textureBack = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.TRANSPOSER_NAME + "_back");
this.textureSide = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.TRANSPOSER_NAME + "_side_0");
this.textureSideActive = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.TRANSPOSER_NAME + "_side_0_active");
this.blockIcon = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.TRANSPOSER_NAME + "_side_0");
}
}
| 3,095 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockSortingMachine.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockSortingMachine.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks.machines;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier2.TileSortingMachine;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* @author MineMaarten
*/
public class BlockSortingMachine extends BlockContainerBase {
private IIcon textureFront;
private IIcon textureBack;
public BlockSortingMachine() {
super(Material.rock);
setBlockName(Refs.SORTING_MACHINE_NAME);
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileSortingMachine.class;
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.SORTING_MACHINE;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
String unlocName = getUnlocalizedName().substring(5);
textureFront = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + unlocName + "_front");
textureBack = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + unlocName + "_back_1");
blockIcon = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + unlocName + "_side_1");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection direction = ForgeDirection.getOrientation(meta);
if (side == direction.ordinal()) {
return textureFront;
} else if (side == direction.getOpposite().ordinal()) { return textureBack; }
return blockIcon;
}
}
| 2,747 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockLamp.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockLamp.java | package net.quetzi.bluepower.blocks.machines;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.client.renderers.RenderLamp;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileLamp;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
* @author Koen Beckers (K4Unl)
*
*/
public class BlockLamp extends BlockContainerBase {
private boolean isInverted;
private String colorName;
private int color;
public BlockLamp(boolean _isInverted, String _colorName, int _color) {
super(Material.iron);
setInverted(_isInverted);
colorName = _colorName;
setColor(_color);
setBlockName(Refs.LAMP_NAME + (isInverted ? "inverted" : "") + colorName);
setCreativeTab(CustomTabs.tabBluePowerLighting);
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileLamp.class;
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.INVALID;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
blockIcon = iconRegister.registerIcon(Refs.MODID + ":lamps/lamp_on");
blockIcon = iconRegister.registerIcon(Refs.MODID + ":lamps/lamp_off");
}
@Override
public int getLightValue(IBlockAccess w, int x, int y, int z) {
TileLamp tileEntity = (TileLamp) w.getTileEntity(x, y, z);
if (tileEntity != null) {
int power = tileEntity.getPower();
if (isInverted()) {
power = 15 - power;
}
return power;
} else {
return 0;
}
}
@Override
@SideOnly(Side.CLIENT)
public int getRenderType() {
return RenderLamp.RENDER_ID;
}
public int getColor() {
return color;
}
public void setColor(int color) {
this.color = color;
}
public boolean isInverted() {
return isInverted;
}
public void setInverted(boolean isInverted) {
this.isInverted = isInverted;
}
}
| 2,542 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockProjectTable.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockProjectTable.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks.machines;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileAlloyFurnace;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockProjectTable extends BlockContainerBase {
public static IIcon textureTop;
private IIcon textureBottom;
private IIcon textureSide;
private IIcon textureFront;
public BlockProjectTable() {
super(Material.rock);
setBlockName(Refs.PROJECTTABLE_NAME);
// This might not be needed actually.
setBlockTextureName(Refs.PROJECTTABLE_NAME + "_front");
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection s = ForgeDirection.getOrientation(side);
// If is facing
if (meta == side) {
return textureFront;
}
switch (s) {
case UP:
return textureTop;
case DOWN:
return textureBottom;
case EAST:
case NORTH:
case SOUTH:
case WEST:
case UNKNOWN:
return textureSide;
default:
break;
}
return null;
}
@Override
public boolean isOpaqueCube() {
return true;
}
// Not sure if you need this function.
@Override
public Item getItemDropped(int p_149650_1_, Random random, int p_149650_3_) {
return Item.getItemFromBlock(BPBlocks.project_table);
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
textureTop = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.PROJECTTABLE_NAME + "_top");
textureBottom = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.PROJECTTABLE_NAME + "_bottom");
textureSide = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.PROJECTTABLE_NAME + "_side");
textureFront = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.PROJECTTABLE_NAME + "_front");
}
@Override
public int getLightValue(IBlockAccess world, int x, int y, int z) {
int metadata = world.getBlockMetadata(x, y, z);
if ((metadata & 8) != 0) {
return 13;
}
return 0;
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileAlloyFurnace.class;
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.INVALID;
}
@Override
protected boolean canRotateVertical() {
return false;
}
@Override
public int getRenderType() {
return 0;
}
}
| 3,988 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockWindmill.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockWindmill.java | package net.quetzi.bluepower.blocks.machines;
import net.minecraft.block.Block;
import net.minecraft.block.ITileEntityProvider;
import net.minecraft.block.material.Material;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileWindmill;
/**
*
* @author TheFjong
*
*/
public class BlockWindmill extends Block implements ITileEntityProvider {
public BlockWindmill() {
super(Material.iron);
setCreativeTab(CustomTabs.tabBluePowerItems);
setBlockName(Refs.WINDMILL_NAME);
setBlockBounds(0, 0, 0, 1, 1, 1);
}
@Override
public TileEntity createNewTileEntity(World var1, int var2) {
return new TileWindmill();
}
@Override
public boolean renderAsNormalBlock() {
return false;
}
@Override
public boolean isOpaqueCube() {
return false;
}
@Override
public int getRenderType() {
return -1;
}
}
| 1,131 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockEjector.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockEjector.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.blocks.machines;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileEjector;
public class BlockEjector extends BlockContainerBase {
private IIcon textureFront;
private IIcon textureBack;
private IIcon textureSide1;
private IIcon textureSide2;
private IIcon textureSide2Active;
public boolean isActive = false;
public BlockEjector() {
super(Material.rock);
this.setBlockName(Refs.EJECTOR_NAME);
this.setCreativeTab(CustomTabs.tabBluePowerMachines);
}
/**
* Method to be overwritten to fetch the TileEntity Class that goes with the block
*
* @return a .class
*/
@Override protected Class<? extends TileEntity> getTileEntity() {
return TileEjector.class;
}
/**
* Method to be overwritten that returns a GUI ID
*
* @return
*/
@Override public GuiIDs getGuiID() {
return GuiIDs.EJECTOR_ID;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
this.textureFront = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.EJECTOR_NAME + "_front");
this.textureBack = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.EJECTOR_NAME + "_back");
this.textureSide1 = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.EJECTOR_NAME + "_side_0");
this.textureSide2 = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.EJECTOR_NAME + "_side_1");
this.textureSide2Active = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.EJECTOR_NAME + "_side_1_active");
this.blockIcon = this.textureSide1;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection direction = ForgeDirection.getOrientation(meta);
if (side == direction.ordinal()) {
return textureFront;
} else if (side == direction.getOpposite().ordinal()) {
return textureBack;
} if ((side == 3) || (side == 2)) {
return isActive ? textureSide2Active : textureSide2;
}
return blockIcon;
}
}
| 3,558 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockDeployer.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockDeployer.java | package net.quetzi.bluepower.blocks.machines;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier1.TileDeployer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* @author TheFjong
*
*/
public class BlockDeployer extends BlockContainerBase{
private IIcon textureFront;
private IIcon textureFront_active;
private IIcon textureBack;
public BlockDeployer() {
super(Material.rock);
setCreativeTab(CustomTabs.tabBluePowerMachines);
setBlockName(Refs.BLOCKDEPLOYER_NAME);
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileDeployer.class;
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.DEPLOYER_ID;
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
String unlocName = getUnlocalizedName().substring(5);
textureFront_active = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + unlocName + "_front_active");
textureFront = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + unlocName + "_front");
textureBack = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + unlocName + "_back");
blockIcon = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + unlocName + "_side");
}
@Override
public IIcon getIcon(int side, int meta) {
ForgeDirection direction = ForgeDirection.getOrientation(meta);
if (side == direction.ordinal()) {
return textureFront;
} else if (side == direction.getOpposite().ordinal()) { return textureBack; }
return blockIcon;
}
@SuppressWarnings("cast")
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLivingBase player, ItemStack stack)
{
super.onBlockPlacedBy(world, x, y, z, player, stack);
if (world.getTileEntity(x, y, z) instanceof TileDeployer)
{
int direction = 0;
int facing;
if (player.rotationPitch > 45) {
facing = 5;
} else if (player.rotationPitch < -45) {
facing = 4;
} else {
facing = MathHelper.floor_double((double)(player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
}
if (facing == 0){
direction = ForgeDirection.SOUTH.ordinal();
}else
if(facing == 1){
direction = ForgeDirection.WEST.ordinal();
}else
if(facing == 2){
direction = ForgeDirection.NORTH.ordinal();
}else
if(facing == 3){
direction = ForgeDirection.EAST.ordinal();
}else
if(facing == 4){
direction = ForgeDirection.UP.ordinal();
}else
if(facing == 5){
direction = ForgeDirection.DOWN.ordinal();
}
TileDeployer tile = (TileDeployer) world.getTileEntity(x, y, z);
tile.setOrientation(direction);
}
}
}
| 4,264 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockSortron.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/machines/BlockSortron.java | package net.quetzi.bluepower.blocks.machines;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier3.TileSortron;
/**
* @author Dynious
*/
public class BlockSortron extends BlockContainerBase {
private IIcon[] icons = new IIcon[8];
public BlockSortron() {
super(Material.rock);
setBlockName(Refs.BLOCKSORTRON_NAME);
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileSortron.class;
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.INVALID;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection direction = ForgeDirection.getOrientation(meta);
if (side == direction.ordinal()) {
return icons[0];
} else if (side == direction.getOpposite().ordinal()) { return icons[1]; }
return icons[2];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileSortron tile = (TileSortron) world.getTileEntity(x, y, z);
ForgeDirection dir = tile.getFacingDirection();
if (dir.ordinal() == side) {
return icons[0];
} else if (dir.getOpposite().ordinal() == side) {
return icons[1];
} else if ((side == 1 && dir.ordinal() != 1 && dir.getOpposite().ordinal() != 1) || (side == 3 && (dir.ordinal() == 1 || dir.getOpposite().ordinal() == 1))) { // && isPowered
return icons[6];
} else if (tile.showOutPutAnimation()) { // && isPowered
return icons[4];
} else { // && isPowered
return icons[3];
}
//TODO: different icons when powered
}
@Override
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister) {
icons[0] = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKSORTRON_NAME + "_front");
icons[1] = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKSORTRON_NAME + "_back");
icons[2] = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKSORTRON_NAME + "_side_off");
icons[3] = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKSORTRON_NAME + "_side_on");
icons[4] = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKSORTRON_NAME + "_side_on_1");
icons[5] = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKSORTRON_NAME + "_side");
icons[6] = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + Refs.BLOCKSORTRON_NAME + "_side_active");
}
}
| 3,279 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockMonitor.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/computer/BlockMonitor.java | package net.quetzi.bluepower.blocks.computer;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier3.TileMonitor;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockMonitor extends BlockContainerBase {
@SideOnly(Side.CLIENT)
protected IIcon topTexture;
@SideOnly(Side.CLIENT)
protected IIcon frontTexture;
@SideOnly(Side.CLIENT)
protected IIcon sideTexture;
@SideOnly(Side.CLIENT)
protected IIcon backTexture;
@SideOnly(Side.CLIENT)
protected IIcon bottomTexture;
public BlockMonitor() {
super(Material.iron);
setBlockName(Refs.BLOCKMONITOR_NAME);
}
public void updateTick(World world, int x, int y, int z, Random random){
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileMonitor) {
//((TileCPU)tileEntity).updateEntity();
//Logs.log(Level.INFO, "[BluePowerControl] CPU TE ticked");
}
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.MONITOR;
}
@Override
public int tickRate(World world)
{
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection dir = ForgeDirection.getOrientation(meta);
if (side == dir.ordinal()) {
return this.topTexture;
}
else if (side == dir.getOpposite().ordinal()) {
return this.bottomTexture;
}
else if (side == dir.WEST.ordinal()) {
return this.frontTexture;
}
else if (side == dir.EAST.ordinal()) {
return this.backTexture;
}
return this.sideTexture;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileMonitor tile = (TileMonitor) world.getTileEntity(x, y, z);
ForgeDirection dir = tile.getFacingDirection();
if (dir.ordinal() == side) {
return this.frontTexture;
}
else if (dir.getOpposite().ordinal() == side) {
return this.backTexture;
}
else if (dir.UP.ordinal() == side) {
return this.topTexture;
}
else if (dir.DOWN.ordinal() == side) {
return this.bottomTexture;
}
else {
return this.sideTexture;
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister){
this.frontTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "monitor_front");
this.sideTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_side");
this.topTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_top");
this.backTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_back");
this.bottomTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_bottom");
//this.frontTexture = this.blockIcon;
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileMonitor.class;
}
}
| 3,656 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockDiskDrive.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/computer/BlockDiskDrive.java | package net.quetzi.bluepower.blocks.computer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier3.TileDiskDrive;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockDiskDrive extends BlockContainerBase {
@SideOnly(Side.CLIENT)
protected IIcon topTexture;
@SideOnly(Side.CLIENT)
protected IIcon frontTexture;
@SideOnly(Side.CLIENT)
protected IIcon sideTexture;
@SideOnly(Side.CLIENT)
protected IIcon backTexture;
@SideOnly(Side.CLIENT)
protected IIcon bottomTexture;
public BlockDiskDrive() {
super(Material.iron);
setBlockName(Refs.BLOCKDISKDRIVE_NAME);
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.DISK_DRIVE;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection dir = ForgeDirection.getOrientation(meta);
if (side == dir.ordinal()) {
return this.topTexture;
}
else if (side == dir.getOpposite().ordinal()) {
return this.bottomTexture;
}
else if (side == dir.WEST.ordinal()) {
return this.frontTexture;
}
else if (side == dir.EAST.ordinal()) {
return this.backTexture;
}
return this.sideTexture;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileDiskDrive tile = (TileDiskDrive) world.getTileEntity(x, y, z);
ForgeDirection dir = tile.getFacingDirection();
if (dir.ordinal() == side) {
return this.frontTexture;
}
else if (dir.getOpposite().ordinal() == side) {
return this.backTexture;
}
else if (dir.UP.ordinal() == side) {
return this.topTexture;
}
else if (dir.DOWN.ordinal() == side) {
return this.bottomTexture;
}
else {
return this.sideTexture;
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister){
this.frontTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "disk_drive_front");
this.sideTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_side");
this.topTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_top");
this.backTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_back");
this.bottomTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_bottom");
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileDiskDrive.class;
}
}
| 3,207 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockIOExpander.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/computer/BlockIOExpander.java | package net.quetzi.bluepower.blocks.computer;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier3.TileIOExpander;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockIOExpander extends BlockContainerBase {
@SideOnly(Side.CLIENT)
protected IIcon topTexture;
@SideOnly(Side.CLIENT)
protected IIcon frontTexture;
@SideOnly(Side.CLIENT)
protected IIcon sideTexture;
@SideOnly(Side.CLIENT)
protected IIcon backTexture;
@SideOnly(Side.CLIENT)
protected IIcon bottomTexture;
public BlockIOExpander() {
super(Material.iron);
setBlockName(Refs.BLOCKIOEXPANDER_NAME);
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.IO_EXPANDER;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection dir = ForgeDirection.getOrientation(meta);
if (side == dir.ordinal()) {
return this.topTexture;
}
else if (side == dir.getOpposite().ordinal()) {
return this.bottomTexture;
}
else if (side == dir.WEST.ordinal()) {
return this.frontTexture;
}
else if (side == dir.EAST.ordinal()) {
return this.backTexture;
}
return this.sideTexture;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileIOExpander tile = (TileIOExpander) world.getTileEntity(x, y, z);
ForgeDirection dir = tile.getFacingDirection();
if (dir.ordinal() == side) {
return this.frontTexture;
}
else if (dir.getOpposite().ordinal() == side) {
return this.backTexture;
}
else if (dir.UP.ordinal() == side) {
return this.topTexture;
}
else if (dir.DOWN.ordinal() == side) {
return this.bottomTexture;
}
else {
return this.sideTexture;
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister){
this.frontTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "io_expander_front");
this.sideTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_side");
this.topTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_top");
this.backTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "io_expander_back");
this.bottomTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_bottom");
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileIOExpander.class;
}
}
| 3,222 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockCPU.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/computer/BlockCPU.java | package net.quetzi.bluepower.blocks.computer;
import java.util.Random;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.blocks.BlockContainerBase;
import net.quetzi.bluepower.references.GuiIDs;
import net.quetzi.bluepower.references.Refs;
import net.quetzi.bluepower.tileentities.tier3.TileCPU;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class BlockCPU extends BlockContainerBase {
@SideOnly(Side.CLIENT)
protected IIcon topTexture;
@SideOnly(Side.CLIENT)
protected IIcon frontTexture;
@SideOnly(Side.CLIENT)
protected IIcon sideTexture;
@SideOnly(Side.CLIENT)
protected IIcon backTexture;
@SideOnly(Side.CLIENT)
protected IIcon bottomTexture;
public BlockCPU() {
super(Material.iron);
setBlockName(Refs.BLOCKCPU_NAME);
}
public void updateTick(World world, int x, int y, int z, Random random)
{
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (tileEntity instanceof TileCPU) {
}
}
@Override
public GuiIDs getGuiID() {
return GuiIDs.CPU;
}
@Override
public int tickRate(World world)
{
return 1;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(int side, int meta) {
ForgeDirection dir = ForgeDirection.getOrientation(meta);
if (side == dir.ordinal()) {
return this.topTexture;
}
else if (side == dir.getOpposite().ordinal()) {
return this.bottomTexture;
}
else if (side == dir.WEST.ordinal()) {
return this.frontTexture;
}
else if (side == dir.EAST.ordinal()) {
return this.backTexture;
}
return this.sideTexture;
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
TileCPU tile = (TileCPU) world.getTileEntity(x, y, z);
ForgeDirection dir = tile.getFacingDirection();
if (dir.ordinal() == side) {
return this.frontTexture;
}
else if (dir.getOpposite().ordinal() == side) {
return this.backTexture;
}
else if (dir.UP.ordinal() == side) {
return this.topTexture;
}
else if (dir.DOWN.ordinal() == side) {
return this.bottomTexture;
}
else {
return this.sideTexture;
}
}
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister iconRegister){
this.frontTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_front");
this.sideTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_side");
this.topTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_top");
this.backTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_back");
this.bottomTexture = iconRegister.registerIcon(Refs.MODID + ":" + Refs.MACHINE_TEXTURE_LOCATION + "cpu_bottom");
}
@Override
protected Class<? extends TileEntity> getTileEntity() {
return TileCPU.class;
}
}
| 3,471 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockCustomFlower.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/worldgen/BlockCustomFlower.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks.worldgen;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockBush;
import net.minecraft.block.BlockFlower;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraftforge.common.EnumPlantType;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
public class BlockCustomFlower extends BlockBush {
public static final String[] field_149858_b = new String[] { "indigo_flower" };
@SideOnly(Side.CLIENT)
private IIcon icon;
// private int meta;
public BlockCustomFlower(String name) {
super();
this.setCreativeTab(CustomTabs.tabBluePowerBlocks);
this.setHardness(0.0F);
this.setStepSound(soundTypeGrass);
this.setBlockName(name);
}
public static BlockFlower func_149857_e(String name) {
String[] astring = field_149858_b;
int i = astring.length;
int j;
String s1;
for (j = 0; j < i; ++j) {
s1 = astring[j];
if (s1.equals(name)) {
return (BlockFlower) BPBlocks.indigo_flower;
}
}
return null;
}
public static int func_149856_f(String name) {
int i;
for (i = 0; i < field_149858_b.length; ++i) {
if (field_149858_b[i].equals(name)) {
return i;
}
}
return 0;
}
@Override
public EnumPlantType getPlantType(IBlockAccess world, int x, int y, int z) {
return EnumPlantType.Plains;
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta) {
return this.icon;
}
@Override
public int damageDropped(int damage) {
return damage;
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister iconRegister) {
this.icon = iconRegister.registerIcon(Refs.MODID + ":" + this.getUnlocalizedName().substring(5));
}
}
| 2,896 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockStoneOreConnected.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/worldgen/BlockStoneOreConnected.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks.worldgen;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.quetzi.bluepower.references.Refs;
import java.util.Arrays;
public class BlockStoneOreConnected extends BlockStoneOre {
public IIcon[] icons = new IIcon[iconRefByID.length];
public static int[] iconRefByID = { 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31, 2, 2, 27, 14,
0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31, 2, 2, 27, 14, 4, 4, 5, 5, 4, 4, 5, 5, 17,
17, 22, 26, 17, 17, 22, 26, 16, 16, 20, 20, 16, 16, 28, 28, 21, 21, 46, 42, 21, 21, 43, 38, 4, 4, 5, 5, 4, 4, 5, 5, 9, 9, 30, 12, 9, 9,
30, 12, 16, 16, 20, 20, 16, 16, 28, 28, 25, 25, 45, 37, 25, 25, 40, 32, 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18,
1, 1, 13, 13, 2, 2, 23, 31, 2, 2, 27, 14, 0, 0, 6, 6, 0, 0, 6, 6, 3, 3, 19, 15, 3, 3, 19, 15, 1, 1, 18, 18, 1, 1, 13, 13, 2, 2, 23, 31,
2, 2, 27, 14, 4, 4, 5, 5, 4, 4, 5, 5, 17, 17, 22, 26, 17, 17, 22, 26, 7, 7, 24, 24, 7, 7, 10, 10, 29, 29, 44, 41, 29, 29, 39, 33, 4, 4,
5, 5, 4, 4, 5, 5, 9, 9, 30, 12, 9, 9, 30, 12, 7, 7, 24, 24, 7, 7, 10, 10, 8, 8, 36, 35, 8, 8, 34, 11 };
private String name;
public BlockStoneOreConnected(String name) {
super(name);
this.name = name;
}
@Override
public IIcon getIcon(int side, int meta) {
return icons[0];
}
@Override
public IIcon getIcon(IBlockAccess world, int x, int y, int z, int side) {
boolean[] bitMatrix = new boolean[8];
int a = -1;
int b = 1;
if (side == 0 || side == 1) {
Arrays.fill(bitMatrix, true);
bitMatrix[0] = world.getBlock(x - 1, y, z - 1) == this;
bitMatrix[1] = world.getBlock(x, y, z - 1) == this;
bitMatrix[2] = world.getBlock(x + 1, y, z - 1) == this;
bitMatrix[3] = world.getBlock(x - 1, y, z) == this;
bitMatrix[4] = world.getBlock(x + 1, y, z) == this;
bitMatrix[5] = world.getBlock(x - 1, y, z + 1) == this;
bitMatrix[6] = world.getBlock(x, y, z + 1) == this;
bitMatrix[7] = world.getBlock(x + 1, y, z + 1) == this;
}
if (side == 2 || side == 3) {
bitMatrix[0] = world.getBlock(x + a, y + 1, z) == this;
bitMatrix[1] = world.getBlock(x, y + 1, z) == this;
bitMatrix[2] = world.getBlock(x + b, y + 1, z) == this;
bitMatrix[3] = world.getBlock(x + a, y, z) == this;
bitMatrix[4] = world.getBlock(x + b, y, z) == this;
bitMatrix[5] = world.getBlock(x + a, y - 1, z) == this;
bitMatrix[6] = world.getBlock(x, y - 1, z) == this;
bitMatrix[7] = world.getBlock(x + b, y - 1, z) == this;
}
if (side == 4 || side == 5) {
bitMatrix[0] = world.getBlock(x, y + 1, z + a) == this;
bitMatrix[1] = world.getBlock(x, y + 1, z) == this;
bitMatrix[2] = world.getBlock(x, y + 1, z + b) == this;
bitMatrix[3] = world.getBlock(x, y, z + a) == this;
bitMatrix[4] = world.getBlock(x, y, z + b) == this;
bitMatrix[5] = world.getBlock(x, y - 1, z + a) == this;
bitMatrix[6] = world.getBlock(x, y - 1, z) == this;
bitMatrix[7] = world.getBlock(x, y - 1, z + b) == this;
}
int idBuilder = 0;
for (int i = 0; i <= 7; i++)
idBuilder = idBuilder
+ (bitMatrix[i] ? (i == 0 ? 1 : (i == 1 ? 2 : (i == 2 ? 4 : (i == 3 ? 8 : (i == 4 ? 16 : (i == 5 ? 32 : (i == 6 ? 64 : 128)))))))
: 0);
return idBuilder > 255 || idBuilder < 0 ? icons[0] : icons[iconRefByID[idBuilder]];
}
@Override
public void registerBlockIcons(IIconRegister iconRegister) {
for (int i = 0; i < 47; i++)
icons[i] = iconRegister.registerIcon(Refs.MODID + ":" + this.name + "/" + this.name + "_" + (i + 1));
}
}
| 4,910 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockCrop.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/worldgen/BlockCrop.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks.worldgen;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.*;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.init.BPItems;
import net.quetzi.bluepower.references.Refs;
import java.util.ArrayList;
import java.util.Random;
public class BlockCrop extends BlockCrops implements IGrowable {
@SideOnly(Side.CLIENT)
private IIcon[] iconArray;
public BlockCrop() {
this.setTickRandomly(true);
this.setCreativeTab((CreativeTabs) null);
this.setHardness(0.0F);
this.setStepSound(soundTypeGrass);
this.disableStats();
this.setBlockName(Refs.FLAXCROP_NAME);
this.setBlockTextureName(Refs.MODID + ":" + Refs.FLAXCROP_NAME);
}
public static boolean func_149887_c(int meta) {
return (meta & 8) != 0;
}
@Override
public void setBlockBoundsBasedOnState(IBlockAccess world, int x, int y, int z) {
int l = world.getBlockMetadata(x, y, z);
if (l <= 2) {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.25F, 1.0F);
} else if (l <= 4) {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.5F, 1.0F);
} else if (l <= 6) {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 0.75F, 1.0F);
} else {
this.setBlockBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
}
}
@Override
public void onBlockHarvested(World world, int x, int y, int z, int meta, EntityPlayer player) {
if (world.getBlock(x, y, z) instanceof BlockCrop) {
if (world.getBlockMetadata(x, y, z) == 8) {
world.setBlockMetadataWithNotify(x, y - 1, z, 5, 2);
}
}
}
public void fertilize(World world, int x, int y, int z) {
int meta = world.getBlockMetadata(x, y, z);
if (world.getBlock(x, y + 1, z) instanceof BlockAir) {
if (meta < 5) {
world.setBlockMetadataWithNotify(x, y, z, 7, 2);
world.setBlock(x, y + 1, z, BPBlocks.flax_crop, 8, 2);
return;
}
return;
} else {
if (meta < 5) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
}
}
/**
* is the block grass, dirt or farmland
*/
@Override
protected boolean canPlaceBlockOn(Block block) {
return block == Blocks.farmland;
}
/**
* Ticks the block if it's been scheduled
*/
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
super.updateTick(world, x, y, z, random);
if (world.getBlockLightValue(x, y + 1, z) >= 9) {
int meta = world.getBlockMetadata(x, y, z);
if ((meta == 4) || (meta == 5)) {
return;
}
if ((world.getBlock(x, y - 1, z) != Blocks.farmland) || (world.getBlock(x, y - 1, z) == BPBlocks.flax_crop)
|| (!world.isAirBlock(x, y + 1, z))) {
return;
}
if (random.nextInt(30) == 0) {
world.setBlockMetadataWithNotify(x, y, z, meta + 1, 2);
}
if ((meta > 6) && (world.getBlock(x, y - 1, z) == Blocks.farmland) && (world.getBlock(x, y + 1, z) == Blocks.air)) {
if (meta == 7) {
world.setBlock(x, y + 1, z, BPBlocks.flax_crop, 8, 2);
}
world.setBlockMetadataWithNotify(x, y, z, 7, 2);
}
}
}
/**
* Gets the block's texture. Args: side, meta
*/
@SideOnly(Side.CLIENT)
@Override
public IIcon getIcon(int side, int meta) {
if (meta < 0 || meta > 8) {
meta = 8;
}
return this.iconArray[meta];
}
/**
* The type of render function that is called for this block
*/
@Override
public int getRenderType() {
return 6;
}
@Override
protected Item func_149866_i() {
return BPItems.flax_seed;
}
@Override
protected Item func_149865_P() {
return Items.string;
}
/**
* Drops the block items with a specified chance of dropping the specified items
*/
@Override
public void dropBlockAsItemWithChance(World world, int x, int y, int z, int p_149690_5_, float p_149690_6_, int p_149690_7_) {
super.dropBlockAsItemWithChance(world, x, y, z, p_149690_5_, p_149690_6_, 0);
}
@Override
public Item getItemDropped(int meta, Random random, int p_149650_3_) {
return meta == 8 ? this.func_149865_P() : this.func_149866_i();
}
/**
* Returns the quantity of items to drop on block destruction.
*/
@Override
public int quantityDropped(Random random) {
return random.nextInt(2);
}
@Override
public boolean func_149851_a(World world, int x, int y, int z, boolean p_149851_5_) {
return world.getBlockMetadata(x, y, z) != 7;
}
@Override
public boolean func_149852_a(World world, Random random, int x, int y, int z) {
return true;
}
/**
* Gets an item for the block being called on. Args: world, x, y, z
*/
@SideOnly(Side.CLIENT)
@Override
public Item getItem(World world, int x, int y, int z) {
return this.func_149866_i();
}
@SideOnly(Side.CLIENT)
@Override
public void registerBlockIcons(IIconRegister iconRegister) {
this.iconArray = new IIcon[9];
for (int i = 0; i < this.iconArray.length; ++i) {
int tex = 0;
if (i == 0 || i == 1) {
tex = 0;
} else if (i == 2) {
tex = 1;
} else if (i == 3 || i == 4) {
tex = 2;
} else if ((i == 5) || (i == 6)) {
tex = 3;
} else if (i == 7) {
tex = 4;
} else if (i == 8) {
tex = 5;
}
this.iconArray[i] = iconRegister.registerIcon(this.getTextureName() + "_stage_" + tex);
}
}
@Override
public void func_149853_b(World world, Random random, int x, int y, int z) {
this.fertilize(world, x, y, z);
}
@Override
public ArrayList<ItemStack> getDrops(World world, int x, int y, int z, int metadata, int fortune) {
ArrayList<ItemStack> ret = super.getDrops(world, x, y, z, metadata, fortune);
if (metadata >= 8) {
for (int i = 0; i < 3 + fortune; ++i) {
if (world.rand.nextInt(15) <= metadata) {
ret.add(new ItemStack(this.func_149865_P(), 1, 0));
}
}
}
return ret;
}
/**
* Checks to see if its valid to put this block at the specified coordinates. Args: world, x, y, z
*/
@Override
public boolean canPlaceBlockAt(World world, int x, int y, int z) {
return super.canPlaceBlockAt(world, x, y, z) && world.isAirBlock(x, y + 1, z);
}
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, Block block) {
super.onNeighborBlockChange(world, x, y, z, block);
if ((world.getBlockMetadata(x, y, z) == 7) && (world.getBlock(x, y + 1, z) == Blocks.air)) {
world.setBlockMetadataWithNotify(x, y, z, 5, 2);
}
this.checkAndDropBlock(world, x, y, z);
}
/**
* checks if the block can stay, if not drop as item
*/
@Override
protected void checkAndDropBlock(World world, int x, int y, int z) {
if (!this.canBlockStay(world, x, y, z)) {
int l = world.getBlockMetadata(x, y, z);
this.dropBlockAsItem(world, x, y, z, l, 0);
world.setBlock(x, y, z, Blocks.air, 0, 2);
}
}
/**
* Can this block stay at this position. Similar to canPlaceBlockAt except gets checked often with plants.
*/
@Override
public boolean canBlockStay(World world, int x, int y, int z) {
if (world.getBlock(x, y, z) != this) return super.canBlockStay(world, x, y, z);
return (world.getBlock(x, y - 1, z) instanceof BlockFarmland) || (world.getBlock(x, y - 1, z) instanceof BlockCrop);
}
}
| 9,419 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockStoneOre.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/worldgen/BlockStoneOre.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks.worldgen;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.item.Item;
import net.minecraft.world.IBlockAccess;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.references.Refs;
import java.util.Random;
public class BlockStoneOre extends Block {
private String name;
public BlockStoneOre(String name) {
super(Material.rock);
this.name = name;
this.setBlockName(name);
this.setHardness(3.0F);
if (name == Refs.BASALT_NAME) {
this.setResistance(25.0F);
this.setHarvestLevel("pickaxe", 1);
} else if (name == Refs.MARBLE_NAME) {
this.setResistance(1.0F);
this.setHarvestLevel("pickaxe", 1);
this.setHardness(1.5F);
} else if (name == Refs.TUNGSTENORE_NAME) {
this.setResistance(6.0F);
this.setHarvestLevel("pickaxe", 3);
}else if (name == Refs.TUNGSTENBLOCK_NAME) {
this.setResistance(25.0F);
this.setHarvestLevel("pickaxe", 3);
}else {
this.setResistance(5.0F);
this.setHarvestLevel("pickaxe", 2);
}
// this.textureName = Refs.MODID + ":" + name;
this.setCreativeTab(CustomTabs.tabBluePowerBlocks);
this.setStepSound(soundTypeStone);
}
@Override
public Item getItemDropped(int par1, Random par2, int par3) {
if (this.name.matches(Refs.BASALT_NAME)) {
return Item.getItemFromBlock(Block.getBlockFromName(Refs.MODID + ":" + Refs.BASALTCOBBLE_NAME));
}
return Item.getItemFromBlock(Block.getBlockFromName(Refs.MODID + ":" + this.name));
}
@Override
public void registerBlockIcons(IIconRegister iconRegister) {
blockIcon = iconRegister.registerIcon(Refs.MODID + ":" + this.name);
}
// Allow storage blocks to be used as a beacon base
@Override
public boolean isBeaconBase(IBlockAccess worldObj, int x, int y, int z, int beaconX, int beaconY, int beaconZ) {
return this == BPBlocks.amethyst_block || this == BPBlocks.ruby_block || this == BPBlocks.sapphire_block || this == BPBlocks.copper_block
|| this == BPBlocks.tin_block || this == BPBlocks.silver_block || this == BPBlocks.tungsten_block;
}
}
| 3,190 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
BlockCrackedBasalt.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/blocks/worldgen/BlockCrackedBasalt.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.blocks.worldgen;
import java.util.Random;
import net.minecraft.entity.item.EntityFallingBlock;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.world.World;
import net.quetzi.bluepower.init.BPBlocks;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
/**
*
* @author MineMaarten
*/
public class BlockCrackedBasalt extends BlockStoneOre {
public BlockCrackedBasalt(String name) {
super(name);
setTickRandomly(true);
setResistance(25.0F);
setHarvestLevel("pickaxe", 1);
}
@Override
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
if (world.getBlockMetadata(x, y, z) == 0) {
world.setBlockMetadataWithNotify(x, y, z, 1, 2);
world.scheduleBlockUpdate(x, y, z, this, 1);
}
}
@Override
public void updateTick(World world, int x, int y, int z, Random random) {
int meta = world.getBlockMetadata(x, y, z);
// When this block was active already (meta > 0) or when the random chance hit, spew lava.
if (!world.isRemote && (meta > 0 || random.nextInt(100) == 0)) {
if (meta > 4) {
spawnLava(world, x, y, z, random);
}
if (meta < 15) {
if (random.nextInt(40) == 0 || meta == 0) world.setBlockMetadataWithNotify(x, y, z, meta + 1, 2);
world.scheduleBlockUpdate(x, y, z, this, 1);
} else {
world.setBlock(x, y, z, Blocks.flowing_lava);
}
}
}
@Override
protected boolean canSilkHarvest() {
return false;
}
private void spawnLava(World world, int x, int y, int z, Random random) {
EntityFallingBlock entity = new EntityFallingBlock(world, x + 0.5, y + 0.5, z + 0.5, Blocks.flowing_lava);
entity.motionY = 1 + random.nextDouble();
entity.motionX = (random.nextDouble() - 0.5) * 0.8D;
entity.motionZ = (random.nextDouble() - 0.5) * 0.8D;
entity.field_145812_b = 1;// make this field that keeps track of the ticks set to 1, so it doesn't kill itself when it searches for a lava
// block.
entity.field_145813_c = false; // disable item drops when the falling block fails to place.
world.spawnEntityInWorld(entity);
}
@Override
public Item getItemDropped(int par1, Random par2, int par3) {
return Item.getItemFromBlock(BPBlocks.basalt_cobble);
}
/**
* A randomly called display update to be able to add particles or other items for display
*/
@Override
@SideOnly(Side.CLIENT)
public void randomDisplayTick(World world, int x, int y, int z, Random rand) {
if (world.getBlockMetadata(x, y, z) > 0) {
for (int i = 0; i < 10; i++)
world.spawnParticle("largesmoke", x + rand.nextDouble(), y + 1, z + rand.nextDouble(), (rand.nextDouble() - 0.5) * 0.2, rand.nextDouble() * 0.1, (rand.nextDouble() - 0.5) * 0.2);
}
}
}
| 3,938 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemStackHelper.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/helper/ItemStackHelper.java | package net.quetzi.bluepower.helper;
import net.minecraft.item.ItemStack;
public class ItemStackHelper {
/**
* compares ItemStack argument to the instance ItemStack; returns true if both ItemStacks are equal
*/
public static boolean areItemStacksEqual(ItemStack itemStack1, ItemStack itemStack2) {
return itemStack1 == null && itemStack2 == null || (!(itemStack1 == null || itemStack2 == null) && (itemStack1.getItem() == itemStack2.getItem() && (
itemStack1.getItemDamage() == itemStack2.getItemDamage() && (!(itemStack1.stackTagCompound == null && itemStack2.stackTagCompound != null) && (
itemStack1.stackTagCompound == null || itemStack1.stackTagCompound.equals(itemStack2.stackTagCompound))))));
}
}
| 779 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
TileEntityCache.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/helper/TileEntityCache.java | package net.quetzi.bluepower.helper;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
/**
*
* @author MineMaarten
*/
public class TileEntityCache {
private TileEntity te;
private final World world;
private final int x, y, z;
public TileEntityCache(World world, int x, int y, int z) {
if (world == null) throw new NullPointerException("World can't be null!");
this.world = world;
this.x = x;
this.y = y;
this.z = z;
update();
}
public void update() {
te = world.getTileEntity(x, y, z);
}
public TileEntity getTileEntity() {
return te;
}
public static TileEntityCache[] getDefaultCache(World world, int x, int y, int z) {
TileEntityCache[] cache = new TileEntityCache[6];
for (int i = 0; i < 6; i++) {
ForgeDirection d = ForgeDirection.getOrientation(i);
cache[i] = new TileEntityCache(world, x + d.offsetX, y + d.offsetY, z + d.offsetZ);
}
return cache;
}
}
| 1,164 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IOHelper.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/helper/IOHelper.java | package net.quetzi.bluepower.helper;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.tube.IPneumaticTube.TubeColor;
import net.quetzi.bluepower.compat.CompatibilityUtils;
import net.quetzi.bluepower.compat.fmp.IMultipartCompat;
import net.quetzi.bluepower.part.tube.ITubeConnection;
import net.quetzi.bluepower.part.tube.PneumaticTube;
import net.quetzi.bluepower.part.tube.TubeLogic;
import net.quetzi.bluepower.part.tube.TubeStack;
import net.quetzi.bluepower.references.Dependencies;
public class IOHelper {
public static ItemStack extract(IInventory inventory, ForgeDirection direction) {
if (inventory instanceof ISidedInventory) {
ISidedInventory isidedinventory = (ISidedInventory) inventory;
int[] accessibleSlotsFromSide = isidedinventory.getAccessibleSlotsFromSide(direction.ordinal());
for (int anAccessibleSlotsFromSide : accessibleSlotsFromSide) {
ItemStack stack = extract(inventory, direction, anAccessibleSlotsFromSide);
if (stack != null) return stack;
}
} else {
int j = inventory.getSizeInventory();
for (int k = 0; k < j; ++k) {
ItemStack stack = extract(inventory, direction, k);
if (stack != null) return stack;
}
}
return null;
}
public static ItemStack extract(IInventory inventory, ForgeDirection direction, int slot) {
ItemStack itemstack = inventory.getStackInSlot(slot);
if (itemstack != null && canExtractItemFromInventory(inventory, itemstack, slot, direction.ordinal())) {
inventory.setInventorySlotContents(slot, null);
return itemstack;
}
return null;
}
public static ItemStack extract(TileEntity tile, ForgeDirection direction, ItemStack requestedStack, boolean simulate) {
if (requestedStack == null) return requestedStack;
if (tile instanceof IInventory) {
IInventory inv = (IInventory) tile;
int[] accessibleSlots;
if (inv instanceof ISidedInventory) {
accessibleSlots = ((ISidedInventory) inv).getAccessibleSlotsFromSide(direction.ordinal());
} else {
accessibleSlots = new int[inv.getSizeInventory()];
for (int i = 0; i < accessibleSlots.length; i++)
accessibleSlots[i] = i;
}
int itemsFound = 0;
for (int slot : accessibleSlots) {
ItemStack stack = inv.getStackInSlot(slot);
if (stack != null && stack.isItemEqual(requestedStack) && IOHelper.canExtractItemFromInventory(inv, stack, slot, direction.ordinal())) {
itemsFound += stack.stackSize;
}
}
if (itemsFound >= requestedStack.stackSize) {
int itemsNeeded = requestedStack.stackSize;
for (int slot : accessibleSlots) {
ItemStack stack = inv.getStackInSlot(slot);
if (stack != null && stack.isItemEqual(requestedStack) && IOHelper.canExtractItemFromInventory(inv, stack, slot, direction.ordinal())) {
int itemsSubstracted = Math.min(itemsNeeded, stack.stackSize);
itemsNeeded -= itemsSubstracted;
if (!simulate) {
stack.stackSize -= itemsSubstracted;
if (stack.stackSize == 0) inv.setInventorySlotContents(slot, null);
tile.markDirty();
}
}
}
return requestedStack.copy();
}
}
return null;
}
public static ItemStack extractOneItem(TileEntity tile, ForgeDirection dir) {
if (tile instanceof IInventory) {
IInventory inv = (IInventory) tile;
int[] accessibleSlots;
if (inv instanceof ISidedInventory) {
accessibleSlots = ((ISidedInventory) inv).getAccessibleSlotsFromSide(dir.ordinal());
} else {
accessibleSlots = new int[inv.getSizeInventory()];
for (int i = 0; i < accessibleSlots.length; i++)
accessibleSlots[i] = i;
}
for (int slot : accessibleSlots) {
ItemStack stack = inv.getStackInSlot(slot);
if (stack != null && IOHelper.canExtractItemFromInventory(inv, stack, slot, dir.ordinal())) {
ItemStack ret = stack.splitStack(1);
if (stack.stackSize == 0) inv.setInventorySlotContents(slot, null);
tile.markDirty();
return ret;
}
}
}
return null;
}
public static ItemStack insert(TileEntity tile, ItemStack itemStack, ForgeDirection direction, boolean simulate) {
return insert(tile, itemStack, direction, TubeColor.NONE, simulate);
}
public static ItemStack insert(TileEntity tile, ItemStack itemStack, ForgeDirection direction, TubeColor color, boolean simulate) {
if (tile instanceof IInventory) {
return insert((IInventory) tile, itemStack, direction.ordinal(), simulate);
} else if (tile instanceof ITubeConnection) {
TubeStack tubeStack = ((ITubeConnection) tile).acceptItemFromTube(new TubeStack(itemStack, direction.getOpposite(), color), direction, simulate);
if (tubeStack == null) return null;
return tubeStack.stack;
}
IMultipartCompat compat = (IMultipartCompat) CompatibilityUtils.getModule(Dependencies.FMP);
PneumaticTube tube = compat.getBPPart(tile, PneumaticTube.class);
if (tube != null) {//we don't need to check connections, that's catched earlier.
TubeLogic logic = tube.getLogic();
return logic.injectStack(itemStack, direction.getOpposite(), color, simulate) ? null : itemStack;
}
return itemStack;
}
public static ItemStack insert(IInventory inventory, ItemStack itemStack, int side, boolean simulate) {
if (inventory instanceof ISidedInventory && side > -1) {
ISidedInventory isidedinventory = (ISidedInventory) inventory;
int[] aint = isidedinventory.getAccessibleSlotsFromSide(side);
for (int j = 0; j < aint.length && itemStack != null && itemStack.stackSize > 0; ++j) {
itemStack = insert(inventory, itemStack, aint[j], side, simulate);
}
} else {
int k = inventory.getSizeInventory();
for (int l = 0; l < k && itemStack != null && itemStack.stackSize > 0; ++l) {
itemStack = insert(inventory, itemStack, l, side, simulate);
}
}
if (itemStack != null && itemStack.stackSize == 0) {
itemStack = null;
}
return itemStack;
}
public static ItemStack insert(IInventory inventory, ItemStack itemStack, int slot, int side, boolean simulate) {
ItemStack itemstack1 = inventory.getStackInSlot(slot);
if (canInsertItemToInventory(inventory, itemStack, slot, side)) {
boolean flag = false;
if (itemstack1 == null) {
int max = Math.min(itemStack.getMaxStackSize(), inventory.getInventoryStackLimit());
if (max >= itemStack.stackSize) {
if (!simulate) {
inventory.setInventorySlotContents(slot, itemStack);
flag = true;
}
itemStack = null;
} else {
if (!simulate) {
inventory.setInventorySlotContents(slot, itemStack.splitStack(max));
flag = true;
} else {
itemStack.splitStack(max);
}
}
} else if (ItemStackHelper.areItemStacksEqual(itemstack1, itemStack)) {
int max = Math.min(itemStack.getMaxStackSize(), inventory.getInventoryStackLimit());
if (max > itemstack1.stackSize) {
int l = Math.min(itemStack.stackSize, max - itemstack1.stackSize);
itemStack.stackSize -= l;
if (!simulate) {
itemstack1.stackSize += l;
flag = l > 0;
}
}
}
if (flag) {
inventory.markDirty();
}
}
return itemStack;
}
public static boolean canInsertItemToInventory(IInventory inventory, ItemStack itemStack, int slot, int side) {
return inventory.isItemValidForSlot(slot, itemStack) && (!(inventory instanceof ISidedInventory) || ((ISidedInventory) inventory).canInsertItem(slot, itemStack, side));
}
public static boolean canExtractItemFromInventory(IInventory inventory, ItemStack itemStack, int slot, int side) {
return !(inventory instanceof ISidedInventory) || ((ISidedInventory) inventory).canExtractItem(slot, itemStack, side);
}
public static void dropInventory(World world, int x, int y, int z) {
TileEntity tileEntity = world.getTileEntity(x, y, z);
if (!(tileEntity instanceof IInventory)) { return; }
IInventory inventory = (IInventory) tileEntity;
for (int i = 0; i < inventory.getSizeInventory(); i++) {
ItemStack itemStack = inventory.getStackInSlot(i);
if (itemStack != null && itemStack.stackSize > 0) {
spawnItemInWorld(world, itemStack, x, y, z);
}
}
}
public static void spawnItemInWorld(World world, ItemStack itemStack, double x, double y, double z) {
if (world.isRemote) return;
float dX = world.rand.nextFloat() * 0.8F + 0.1F;
float dY = world.rand.nextFloat() * 0.8F + 0.1F;
float dZ = world.rand.nextFloat() * 0.8F + 0.1F;
EntityItem entityItem = new EntityItem(world, x + dX, y + dY, z + dZ, new ItemStack(itemStack.getItem(), itemStack.stackSize, itemStack.getItemDamage()));
if (itemStack.hasTagCompound()) {
entityItem.getEntityItem().setTagCompound((NBTTagCompound) itemStack.getTagCompound().copy());
}
float factor = 0.05F;
entityItem.motionX = world.rand.nextGaussian() * factor;
entityItem.motionY = world.rand.nextGaussian() * factor + 0.2F;
entityItem.motionZ = world.rand.nextGaussian() * factor;
world.spawnEntityInWorld(entityItem);
itemStack.stackSize = 0;
}
public static boolean canInterfaceWith(TileEntity tile, ForgeDirection direction) {
return canInterfaceWith(tile, direction, null);
}
public static boolean canInterfaceWith(TileEntity tile, ForgeDirection direction, PneumaticTube requester) {
IMultipartCompat compat = (IMultipartCompat) CompatibilityUtils.getModule(Dependencies.FMP);
PneumaticTube tube = compat.getBPPart(tile, PneumaticTube.class);
if (tube != null && tube.isConnected(direction, requester)) return true;
if (tile instanceof IInventory) { return !(tile instanceof ISidedInventory) || ((ISidedInventory) tile).getAccessibleSlotsFromSide(direction.ordinal()).length > 0; }
return false;
}
}
| 12,041 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RedstoneHelper.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/helper/RedstoneHelper.java | package net.quetzi.bluepower.helper;
import net.minecraft.block.Block;
import net.minecraft.block.BlockRedstoneWire;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.compat.CompatibilityUtils;
import net.quetzi.bluepower.compat.fmp.IMultipartCompat;
import net.quetzi.bluepower.references.Dependencies;
import net.quetzi.bluepower.util.ForgeDirectionUtils;
public class RedstoneHelper {
public static final int getInput(World w, int x, int y, int z, ForgeDirection side) {
return getInput(w, x, y, z, side, null);
}
public static final int getInput(World w, int x, int y, int z, ForgeDirection side, ForgeDirection face) {
if(w == null) return 0;
int power = 0;
Block b = w.getBlock(x + side.offsetX, y + side.offsetY, z + side.offsetZ);
if (b != null) {
boolean shouldCheck = true;
if (b instanceof BlockRedstoneWire && (face != ForgeDirection.DOWN && face != null)) shouldCheck = false;
if (shouldCheck) {
power = Math.max(power,
b.isProvidingStrongPower(w, x + side.offsetX, y + side.offsetY, z + side.offsetZ, ForgeDirectionUtils.getSide(side)));
power = Math.max(power,
b.isProvidingWeakPower(w, x + side.offsetX, y + side.offsetY, z + side.offsetZ, ForgeDirectionUtils.getSide(side)));
power = Math.max(power,
w.getIndirectPowerLevelTo(x + side.offsetX, y + side.offsetY, z + side.offsetZ, ForgeDirectionUtils.getSide(side)));
power = Math
.max(power, b instanceof BlockRedstoneWire ? w.getBlockMetadata(x + side.offsetX, y + side.offsetY, z + side.offsetZ) : 0);
}
}
power = Math.max(power, ((IMultipartCompat) CompatibilityUtils.getModule(Dependencies.FMP)).getInput(w, x, y, z, side, face));
return power;
}
public static final int setOutput(World w, int x, int y, int z, ForgeDirection side, ForgeDirection face, int p) {
if(w == null) return 0;
int power = 0;
Block b = w.getBlock(x + side.offsetX, y + side.offsetY, z + side.offsetZ);
if (b != null) {
boolean shouldOutput = true;
if (b instanceof BlockRedstoneWire && (face != ForgeDirection.DOWN && face != null)) shouldOutput = false;
if(shouldOutput)
power = p;
}
return power;
}
}
| 2,663 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
CompatModule.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/CompatModule.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.compat;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
public abstract class CompatModule {
public abstract void preInit(FMLPreInitializationEvent ev);
public abstract void init(FMLInitializationEvent ev);
public abstract void postInit(FMLPostInitializationEvent ev);
public abstract void registerBlocks();
public abstract void registerItems();
public abstract void registerRenders();
}
| 1,310 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
CompatibilityUtils.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/CompatibilityUtils.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.compat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.quetzi.bluepower.compat.cc.CompatModuleCC;
import net.quetzi.bluepower.compat.fmp.CompatModuleFMP;
import net.quetzi.bluepower.compat.fmp.CompatModuleFMPAlt;
import net.quetzi.bluepower.compat.waila.CompatModuleWaila;
import net.quetzi.bluepower.references.Dependencies;
import cpw.mods.fml.common.Loader;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
public class CompatibilityUtils {
private static Map<String, CompatModule> modules = new HashMap<String, CompatModule>();
private CompatibilityUtils() {
}
public static void registerModule(String modid, Class<? extends CompatModule> module, Class<? extends CompatModule> alternate) {
registerModule(modid, module.getName(), alternate == null ? null : alternate.getName());
}
public static void registerModule(String modid, String module, String alternate) {
if (modid == null || modid.trim().isEmpty()) return;
if (!Loader.isModLoaded(modid)) return;
if (module == null) return;
if (modules.containsKey(module)) return;
Class<?> c;
try {
c = Class.forName(module);
if (!CompatModule.class.isAssignableFrom(c)) return;
modules.put(modid, (CompatModule) c.newInstance());
return;
} catch (Exception e) {
e.printStackTrace();
}
if (alternate == null || alternate.trim().isEmpty()) return;
Class<?> c2;
try {
c2 = Class.forName(alternate);
if (!CompatModule.class.isAssignableFrom(c2)) return;
modules.put(modid, (CompatModule) c2.newInstance());
} catch (Exception e) {
e.printStackTrace();
}
}
public static List<CompatModule> getLoadedModules() {
return Collections.unmodifiableList(new ArrayList<CompatModule>(modules.values()));
}
public static CompatModule getModule(String modid) {
try {
return modules.get(modid);
} catch (Exception ex) {
}
return null;
}
public static void preInit(FMLPreInitializationEvent ev) {
for (CompatModule m : getLoadedModules())
m.preInit(ev);
}
public static void init(FMLInitializationEvent ev) {
for (CompatModule m : getLoadedModules())
m.init(ev);
}
public static void postInit(FMLPostInitializationEvent ev) {
for (CompatModule m : getLoadedModules())
m.postInit(ev);
}
/**
* Register your modules here
*/
static {
registerModule(Dependencies.FMP, CompatModuleFMP.class, CompatModuleFMPAlt.class);
registerModule(Dependencies.COMPUTER_CRAFT, CompatModuleCC.class, null);
registerModule(Dependencies.WAILA, CompatModuleWaila.class, null);
}
}
| 3,878 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
PeripheralProvider.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/cc/PeripheralProvider.java | package net.quetzi.bluepower.compat.cc;
import dan200.computercraft.api.peripheral.IPeripheral;
import dan200.computercraft.api.peripheral.IPeripheralProvider;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
public class PeripheralProvider implements IPeripheralProvider {
public static final PeripheralProvider INSTANCE = new PeripheralProvider();
private PeripheralProvider() {
}
@Override
public IPeripheral getPeripheral(World world, int x, int y, int z, int side) {
TileEntity tile = world.getTileEntity(x, y, z);
if(tile instanceof IPeripheral)
return (IPeripheral) tile;
return null;
}
}
| 691 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
CompatModuleCC.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/cc/CompatModuleCC.java | package net.quetzi.bluepower.compat.cc;
import net.quetzi.bluepower.compat.CompatModule;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import dan200.computercraft.api.ComputerCraftAPI;
public class CompatModuleCC extends CompatModule{
@Override
public void preInit(FMLPreInitializationEvent ev) {
ComputerCraftAPI.registerPeripheralProvider(PeripheralProvider.INSTANCE);
}
@Override
public void init(FMLInitializationEvent ev) {
}
@Override
public void postInit(FMLPostInitializationEvent ev) {
}
@Override
public void registerBlocks() {
}
@Override
public void registerItems() {
}
@Override
public void registerRenders() {
}
}
| 854 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
CompatModuleWaila.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/waila/CompatModuleWaila.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.compat.waila;
import mcp.mobius.waila.api.IWailaRegistrar;
import net.quetzi.bluepower.compat.CompatModule;
import net.quetzi.bluepower.compat.fmp.IMultipartCompat.MultipartCompat;
import net.quetzi.bluepower.references.Dependencies;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLInterModComms;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
/**
* @author amadornes
*
*/
public class CompatModuleWaila extends CompatModule {
@Override
public void preInit(FMLPreInitializationEvent ev) {
}
@Override
public void init(FMLInitializationEvent ev) {
FMLInterModComms.sendMessage(Dependencies.WAILA, "register", getClass().getName() + ".callbackRegister");
}
@Override
public void postInit(FMLPostInitializationEvent ev) {
}
@Override
public void registerBlocks() {
}
@Override
public void registerItems() {
}
@Override
public void registerRenders() {
}
public static void callbackRegister(IWailaRegistrar registrar) {
registrar.registerBodyProvider(new WailaProviderPart(), MultipartCompat.tile);
}
}
| 1,983 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
WailaProviderPart.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/waila/WailaProviderPart.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.compat.waila;
import java.util.ArrayList;
import java.util.List;
import mcp.mobius.waila.api.IWailaConfigHandler;
import mcp.mobius.waila.api.IWailaDataAccessor;
import mcp.mobius.waila.api.IWailaDataProvider;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.util.RayTracer;
/**
* @author amadornes
*
*/
public class WailaProviderPart implements IWailaDataProvider {
private List<String> info = new ArrayList<String>();
@Override
public List<String> getWailaBody(ItemStack item, List<String> tip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
EntityPlayer p = accessor.getPlayer();
MovingObjectPosition mop = p.rayTrace(p.capabilities.isCreativeMode ? 5 : 4.5, 0);
if (mop == null) return tip;
BPPart hovered = RayTracer.getSelectedPart(mop, p, ForgeDirection.getOrientation(mop.sideHit));
if (hovered == null) return tip;
hovered.addWailaInfo(info);
tip.addAll(info);
info.clear();
return tip;
}
@Override
public List<String> getWailaHead(ItemStack item, List<String> tip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return tip;
}
@Override
public List<String> getWailaTail(ItemStack item, List<String> tip, IWailaDataAccessor accessor, IWailaConfigHandler config) {
return tip;
}
@Override
public ItemStack getWailaStack(IWailaDataAccessor accessor, IWailaConfigHandler config) {
return null;
}
}
| 2,451 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
MultipartBPPart.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/fmp/MultipartBPPart.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.compat.fmp;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.client.renderer.texture.TextureMap;
import net.minecraft.client.renderer.tileentity.TileEntityRendererDispatcher;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.MovingObjectPosition;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.part.PartRegistry;
import net.quetzi.bluepower.api.part.redstone.IBPRedstonePart;
import net.quetzi.bluepower.references.Refs;
import org.lwjgl.opengl.GL11;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.raytracer.IndexedCuboid6;
import codechicken.lib.render.RenderUtils;
import codechicken.lib.vec.Cuboid6;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.IRedstonePart;
import codechicken.multipart.JNormalOcclusion;
import codechicken.multipart.NormalOcclusionTest;
import codechicken.multipart.TMultiPart;
public class MultipartBPPart extends TMultiPart implements IRedstonePart, JNormalOcclusion {
private BPPart part;
public MultipartBPPart(BPPart part) {
setPart(part);
}
public MultipartBPPart() {
}
public BPPart getPart() {
return part;
}
protected void setPart(BPPart part) {
this.part = part;
}
@Override
public String getType() {
return Refs.MODID + "_" + getPart().getType();
}
@Override
public Iterable<IndexedCuboid6> getSubParts() {
List<IndexedCuboid6> cubes = new ArrayList<IndexedCuboid6>();
List<AxisAlignedBB> aabbs = getPart().getSelectionBoxes();
if (aabbs == null) return cubes;
for (AxisAlignedBB aabb : aabbs)
cubes.add(new IndexedCuboid6(0, new Cuboid6(aabb)));
return cubes;
}
@Override
public Iterable<Cuboid6> getCollisionBoxes() {
List<Cuboid6> cubes = new ArrayList<Cuboid6>();
List<AxisAlignedBB> aabbs = getPart().getCollisionBoxes();
if (aabbs == null) return cubes;
for (AxisAlignedBB aabb : aabbs)
cubes.add(new Cuboid6(aabb));
return cubes;
}
@Override
public Iterable<Cuboid6> getOcclusionBoxes() {
List<Cuboid6> cubes = new ArrayList<Cuboid6>();
List<AxisAlignedBB> aabbs = getPart().getOcclusionBoxes();
if (aabbs == null) return cubes;
for (AxisAlignedBB aabb : aabbs)
cubes.add(new Cuboid6(aabb));
return cubes;
}
@Override
public boolean occlusionTest(TMultiPart part) {
return NormalOcclusionTest.apply(this, part);
}
@Override
public void writeDesc(MCDataOutput packet) {
super.writeDesc(packet);
packet.writeString(getPart().getType());
NBTTagCompound tag = new NBTTagCompound();
getPart().save(tag);
packet.writeNBTTagCompound(tag);
}
@Override
public void readDesc(MCDataInput packet) {
super.readDesc(packet);
String type = packet.readString();
if (getPart() == null) setPart(PartRegistry.createPart(type));
getPart().load(packet.readNBTTagCompound());
}
@Override
public void load(NBTTagCompound tag) {
super.load(tag);
String type = tag.getString("part_id");
if (getPart() == null) setPart(PartRegistry.createPart(type));
NBTTagCompound t = tag.getCompoundTag("partData");
getPart().load(t);
}
@Override
public void save(NBTTagCompound tag) {
super.save(tag);
tag.setString("part_id", getPart().getType());
NBTTagCompound t = new NBTTagCompound();
getPart().save(t);
tag.setTag("partData", t);
}
@Override
public int getLightValue() {
return getPart().getLightValue();
}
@Override
public Iterable<ItemStack> getDrops() {
return getPart().getDrops();
}
@Override
public ItemStack pickItem(MovingObjectPosition hit) {
return getPart().getPickedItem(hit);
}
@Override
public float getStrength(MovingObjectPosition hit, EntityPlayer player) {
float s = 50;
float h = getPart().getHardness(hit, player) * (s / 2F);
if (h == 0) return s;
return s / h;
}
// Redstone
@Override
public int strongPowerLevel(int side) {
return weakPowerLevel(side);
}
@Override
public int weakPowerLevel(int side) {
if (getPart() instanceof IBPRedstonePart) return ((IBPRedstonePart) getPart()).getWeakOutput(ForgeDirection.getOrientation(side));
return 0;
}
@Override
public boolean canConnectRedstone(int side) {
if (getPart() instanceof IBPRedstonePart) return ((IBPRedstonePart) getPart()).canConnect(ForgeDirection.getOrientation(side));
return false;
}
// Events
@Override
public void onAdded() {
getPart().onAdded();
}
@Override
public void onRemoved() {
getPart().onRemoved();
}
@Override
public void onPartChanged(TMultiPart part) {
getPart().onPartChanged();
}
@Override
public void onEntityCollision(Entity entity) {
getPart().onEntityCollision(entity);
}
@Override
public void onNeighborChanged() {
getPart().onNeighborUpdate();
}
@Override
public boolean activate(EntityPlayer player, MovingObjectPosition hit, ItemStack item) {
return getPart().onActivated(player, hit, item);
}
// Rendering
private static int emptyStaticRender = -1;
private int staticRender0 = -1;
private int staticRender1 = -1;
@Override
public boolean renderStatic(Vector3 pos, int pass) {
if (getPart().shouldRenderStaticOnPass(0)) getPart().markPartForRenderUpdate();
return false;
}
@Override
public void renderDynamic(Vector3 pos, float frame, int pass) {
getPart().renderDynamic(new net.quetzi.bluepower.api.vec.Vector3(pos.x, pos.y, pos.z), pass, frame);
if (emptyStaticRender == -1) {
emptyStaticRender = GL11.glGenLists(1);
GL11.glNewList(emptyStaticRender, GL11.GL_COMPILE);
GL11.glEndList();
}
if (staticRender0 == -1 || getPart().shouldReRender()) reRenderStatic(new Vector3(0, 0, 0), 0);
if (staticRender1 == -1 || getPart().shouldReRender()) reRenderStatic(new Vector3(0, 0, 0), 1);
if (getPart().shouldReRender()) getPart().resetRenderUpdate();
if (getPart().shouldRenderStaticOnPass(pass)) {
GL11.glPushMatrix();
{
GL11.glTranslated(pos.x, pos.y, pos.z);
if (pass == 0) {
GL11.glCallList(staticRender0);
} else {
GL11.glCallList(staticRender1);
}
}
GL11.glPopMatrix();
}
}
protected void reRenderStatic(Vector3 pos, int pass) {
if (pass == 0) {
if (staticRender0 == -1 || staticRender0 == emptyStaticRender) staticRender0 = GL11.glGenLists(1);
GL11.glNewList(staticRender0, GL11.GL_COMPILE);
} else {
if (staticRender1 == -1 || staticRender1 == emptyStaticRender) staticRender1 = GL11.glGenLists(1);
GL11.glNewList(staticRender1, GL11.GL_COMPILE);
}
GL11.glPushMatrix();
boolean result = getPart().shouldRenderStaticOnPass(pass);
if (result) {
Minecraft.getMinecraft().renderEngine.bindTexture(TextureMap.locationBlocksTexture);
Tessellator t = Tessellator.instance;
t.setTranslation(0, 0, 0);
t.startDrawingQuads();
result = getPart().renderStatic(new net.quetzi.bluepower.api.vec.Vector3(pos.x, pos.y, pos.z), pass);
t.draw();
t.setTranslation(0, 0, 0);
}
GL11.glPopMatrix();
GL11.glEndList();
if (!result) {
if (pass == 0) {
staticRender0 = emptyStaticRender;
} else {
staticRender1 = emptyStaticRender;
}
}
}
@Override
public boolean drawHighlight(MovingObjectPosition mop, EntityPlayer player, float frame) {
ForgeDirection face = ForgeDirection.getOrientation(mop.sideHit);
AxisAlignedBB c = net.quetzi.bluepower.util.RayTracer.getSelectedCuboid(mop, player, face, getSubParts(), true);
if (c == null) return true;
GL11.glPushMatrix();
{
GL11.glTranslated(x() - TileEntityRendererDispatcher.staticPlayerX, y() - TileEntityRendererDispatcher.staticPlayerY, z()
- TileEntityRendererDispatcher.staticPlayerZ);
GL11.glDisable(GL11.GL_TEXTURE_2D);
GL11.glColor4d(0, 0, 0, 0);
RenderUtils.drawCuboidOutline(new Cuboid6(c).expand(0.001));
GL11.glColor4d(1, 1, 1, 1);
GL11.glEnable(GL11.GL_TEXTURE_2D);
}
GL11.glPopMatrix();
return true;
}
@Override
public void update() {
getPart().world = world();
getPart().x = x();
getPart().y = y();
getPart().z = z();
getPart().update();
}
}
| 10,709 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
CompatModuleFMP.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/fmp/CompatModuleFMP.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.compat.fmp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.compat.CompatModule;
import net.quetzi.bluepower.init.BPBlocks;
import net.quetzi.bluepower.util.RayTracer;
import codechicken.lib.raytracer.ExtendedMOP;
import codechicken.lib.vec.Cuboid6;
import codechicken.microblock.BlockMicroMaterial;
import codechicken.microblock.MicroMaterialRegistry;
import codechicken.multipart.NormallyOccludedPart;
import codechicken.multipart.TMultiPart;
import codechicken.multipart.TileMultipart;
import codechicken.multipart.handler.MultipartProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
public class CompatModuleFMP extends CompatModule implements IMultipartCompat {
@Override
public void preInit(FMLPreInitializationEvent ev) {
MultipartCompat.tile = TileMultipart.class;
}
@Override
public void init(FMLInitializationEvent ev) {
RegisterMultiparts.register();
registerBlocksAsMicroblock();
}
@Override
public void postInit(FMLPostInitializationEvent ev) {
BPBlocks.multipart = MultipartProxy.block();
}
private void registerBlocksAsMicroblock() {
registerBlockAsMicroblock(BPBlocks.basalt);
registerBlockAsMicroblock(BPBlocks.basalt_brick);
registerBlockAsMicroblock(BPBlocks.basalt_brick_small);
registerBlockAsMicroblock(BPBlocks.basalt_cobble);
registerBlockAsMicroblock(BPBlocks.basalt_tile);
registerBlockAsMicroblock(BPBlocks.basalt_paver);
registerBlockAsMicroblock(BPBlocks.fancy_basalt);
registerBlockAsMicroblock(BPBlocks.fancy_marble);
registerBlockAsMicroblock(BPBlocks.marble);
registerBlockAsMicroblock(BPBlocks.marble_brick);
registerBlockAsMicroblock(BPBlocks.marble_brick_small);
registerBlockAsMicroblock(BPBlocks.marble_tile);
registerBlockAsMicroblock(BPBlocks.marble_paver);
registerBlockAsMicroblock(BPBlocks.amethyst_block);
registerBlockAsMicroblock(BPBlocks.ruby_block);
registerBlockAsMicroblock(BPBlocks.sapphire_block);
registerBlockAsMicroblock(BPBlocks.copper_block);
registerBlockAsMicroblock(BPBlocks.silver_block);
registerBlockAsMicroblock(BPBlocks.tin_block);
}
private void registerBlockAsMicroblock(Block b) {
MicroMaterialRegistry.registerMaterial(new BlockMicroMaterial(b, 0), b.getUnlocalizedName());
}
@Override
public void registerBlocks() {
}
@Override
public void registerItems() {
}
@Override
public void registerRenders() {
}
@Override
public BPPart getClickedPart(Vector3 loc, Vector3 subLoc, ItemStack item, EntityPlayer player) {
TileMultipart te = (TileMultipart) loc.getTileEntity();
List<ExtendedMOP> mops = new ArrayList<ExtendedMOP>();
for (int i = 0; i < te.jPartList().size(); i++) {
ExtendedMOP mop = te.jPartList().get(i).collisionRayTrace(RayTracer.getStartVec(player), RayTracer.getEndVec(player));
if (mop != null) {
mop.setData(i);
mops.add(mop);
}
}
if (mops.isEmpty()) return null;
Collections.sort(mops);
TMultiPart p = te.jPartList().get((Integer) ExtendedMOP.getData(mops.get(0)));
if (p instanceof MultipartBPPart) {
return ((MultipartBPPart) p).getPart();
} else {
return null;
}
}
@Override
public int getInput(World w, int x, int y, int z, ForgeDirection side, ForgeDirection face) {
return 0;
}
@Override
public void sendUpdatePacket(BPPart part) {
TileEntity tile = part.world.getTileEntity(part.x, part.y, part.z);
if (tile != null && tile instanceof TileMultipart) {
TileMultipart te = (TileMultipart) tile;
for (TMultiPart p : te.jPartList()) {
if (p instanceof MultipartBPPart) {
MultipartBPPart bpp = (MultipartBPPart) p;
if (bpp.getPart() == part) {
bpp.sendDescUpdate();
return;
}
}
}
}
}
@Override
public boolean isMultipart(TileEntity te) {
return te instanceof TileMultipart;
}
@Override
public boolean checkOcclusion(TileEntity tile, AxisAlignedBB box) {
if (tile != null && tile instanceof TileMultipart) {
TileMultipart te = (TileMultipart) tile;
NormallyOccludedPart noc = new NormallyOccludedPart(new Cuboid6(box));
return !te.canAddPart(noc);
}
return false;
}
@SuppressWarnings("unchecked")
@Override
public <T> T getBPPart(TileEntity te, Class<T> searchedClass) {
if (isMultipart(te)) {
Iterable<MultipartBPPart> parts = getMultiParts((TileMultipart) te, MultipartBPPart.class);
for (MultipartBPPart part : parts) {
if (searchedClass.isAssignableFrom(part.getPart().getClass())) return (T) part.getPart();
}
}
return null;
}
@SuppressWarnings("unchecked")
public static <T> T getMultiPart(TileMultipart t, Class<T> searchedClass) {
for (TMultiPart part : t.jPartList()) {
if (searchedClass.isAssignableFrom(part.getClass())) return (T) part;
}
return null;
}
@SuppressWarnings("unchecked")
public static <T> Iterable<T> getMultiParts(TileMultipart t, Class<T> searchedClass) {
List<T> parts = new ArrayList<T>();
for (TMultiPart part : t.jPartList()) {
if (searchedClass.isAssignableFrom(part.getClass())) parts.add((T) part);
}
return parts;
}
}
| 7,231 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
IMultipartCompat.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/fmp/IMultipartCompat.java | package net.quetzi.bluepower.compat.fmp;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.vec.Vector3;
public interface IMultipartCompat {
public BPPart getClickedPart(Vector3 loc, Vector3 subLoc, ItemStack item, EntityPlayer player);
public int getInput(World w, int x, int y, int z, ForgeDirection side, ForgeDirection face);
public void sendUpdatePacket(BPPart part);
public boolean isMultipart(TileEntity te);
public boolean checkOcclusion(TileEntity te, AxisAlignedBB box);
public <T> T getBPPart(TileEntity te, Class<T> searchedClass);
public static final class MultipartCompat {
public static Class<? extends TileEntity> tile = null;
}
}
| 1,032 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
MultipartFaceBPPart.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/fmp/MultipartFaceBPPart.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.compat.fmp;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.part.BPPartFace;
import net.quetzi.bluepower.api.part.FaceDirection;
import net.quetzi.bluepower.api.part.IBPFacePart;
import net.quetzi.bluepower.api.part.RedstoneConnection;
import codechicken.lib.data.MCDataInput;
import codechicken.lib.data.MCDataOutput;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.IFaceRedstonePart;
import codechicken.multipart.TFacePart;
import codechicken.multipart.TileMultipart;
public class MultipartFaceBPPart extends MultipartBPPart implements TFacePart, IFaceRedstonePart {
private IBPFacePart facePart;
public MultipartFaceBPPart(IBPFacePart part) {
super((BPPart) part);
facePart = part;
}
@Override
public int getSlotMask() {
return 1 << getFace();
}
@Override
public int redstoneConductionMap() {
return 0;
}
@Override
public boolean solid(int side) {
return false;
}
@Override
public int getFace() {
return facePart.getFace() ^ 1;
}
@Override
public void onNeighborChanged() {
if (!facePart.canStay()) {
for (ItemStack is : getPart().getDrops()) {
TileMultipart.dropItem(is, world(), Vector3.fromTileEntityCenter(tile()));
}
tile().remPart(this);
return;
}
super.onNeighborChanged();
}
@Override
public void update() {
super.update();
}
@Override
public void writeDesc(MCDataOutput packet) {
super.writeDesc(packet);
packet.writeInt(facePart.getFace());
packet.writeInt(facePart.getRotation());
for (int i = 0; i < 4; i++) {
RedstoneConnection c = ((BPPartFace) getPart()).getConnection(FaceDirection.getDirection(i));
if (c != null) {
packet.writeNBTTagCompound(c.getNBTTag());
} else {
NBTTagCompound t = new NBTTagCompound();
t.setBoolean("___error", true);
packet.writeNBTTagCompound(t);
}
}
}
@Override
public void readDesc(MCDataInput packet) {
super.readDesc(packet);
facePart.setFace(packet.readInt());
facePart.setRotation(packet.readInt());
for (int i = 0; i < 4; i++) {
RedstoneConnection c = ((BPPartFace) getPart()).getConnection(FaceDirection.getDirection(i));
NBTTagCompound t = packet.readNBTTagCompound();
if (t.hasKey("___error") && t.getBoolean("___error")) {
continue;
} else {
if (c == null) {
c = ((BPPartFace) getPart()).getConnectionOrCreate(FaceDirection.getDirection(i));
}
c.load(t);
}
}
}
@Override
public void save(NBTTagCompound tag) {
super.save(tag);
tag.setInteger("face", facePart.getFace());
tag.setInteger("rotation", facePart.getRotation());
for (int i = 0; i < 4; i++) {
RedstoneConnection c = ((BPPartFace) getPart()).getConnection(FaceDirection.getDirection(i));
if (c != null) {
tag.setTag("con_" + i, c.getNBTTag());
} else {
NBTTagCompound t = new NBTTagCompound();
t.setBoolean("___error", true);
tag.setTag("con_" + i, t);
}
}
}
@Override
public void load(NBTTagCompound tag) {
super.load(tag);
facePart.setFace(tag.getInteger("face"));
facePart.setRotation(tag.getInteger("rotation"));
for (int i = 0; i < 4; i++) {
RedstoneConnection c = ((BPPartFace) getPart()).getConnection(FaceDirection.getDirection(i));
NBTTagCompound t = tag.getCompoundTag("con_" + i);
if (t.hasKey("___error") && t.getBoolean("___error")) {
continue;
} else {
if (c == null) {
c = ((BPPartFace) getPart()).getConnectionOrCreate(FaceDirection.getDirection(i));
}
c.load(t);
}
}
}
}
| 5,092 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ItemBPMultipart.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/fmp/ItemBPMultipart.java | /*
* This file is part of Blue Power. Blue Power is free software: you can redistribute it and/or modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Blue Power is
* distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along
* with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.compat.fmp;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.Entity;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.part.PartRegistry;
import net.quetzi.bluepower.init.CustomTabs;
import net.quetzi.bluepower.part.ItemBPPart;
import net.quetzi.bluepower.references.Refs;
import codechicken.lib.vec.BlockCoord;
import codechicken.lib.vec.Vector3;
import codechicken.multipart.JItemMultiPart;
import codechicken.multipart.TMultiPart;
public class ItemBPMultipart extends JItemMultiPart {
public ItemBPMultipart() {
super();
setUnlocalizedName(Refs.MODID + ".part");
setCreativeTab(CustomTabs.tabBluePowerCircuits);
}
private BPPart p;
@Override
public TMultiPart newPart(ItemStack is, EntityPlayer player, World w, BlockCoord b, int unused, Vector3 unused1) {
MultipartBPPart part = (MultipartBPPart) RegisterMultiparts.createPart_(p);
return part;
}
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World w, int x, int y, int z, int side, float f, float f2, float f3) {
p = PartRegistry.createPart(PartRegistry.getPartIdFromItem(stack));
if (p == null) return false;
if (!p.canPlacePart(stack, player, new net.quetzi.bluepower.api.vec.Vector3(x, y, z, w),
new MovingObjectPosition(x, y, z, side, Vec3.createVectorHelper(x + f, y + f2, z + f3), true))) return false;
if (super.onItemUse(stack, player, w, x, y, z, side, f, f2, f3)) {
w.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, Block.soundTypeStone.getBreakSound(), Block.soundTypeStone.getVolume(),
Block.soundTypeStone.getPitch());
p.world = w;
p.x = x;
p.y = y;
p.z = z;
p.onAdded();
return true;
}
return false;
}
@Override
public boolean getHasSubtypes() {
return true;
}
@Override
public String getUnlocalizedName(ItemStack item) {
return ItemBPPart.getUnlocalizedName_(item);
}
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void getSubItems(Item unused, CreativeTabs tab, List l) {
// NEI
if (tab == null) for (CreativeTabs t : CreativeTabs.creativeTabArray)
for (String s : PartRegistry.getRegisteredPartsForTab(t))
l.add(PartRegistry.getItemForPart(s));
}
@Override
public int getDamage(ItemStack stack) {
return super.getDamage(stack);// PartRegistry.getStackMetadata(stack);
}
@Override
public boolean hasCustomEntity(ItemStack stack) {
return PartRegistry.hasCustomItemEntity(stack);
}
@Override
public Entity createEntity(World world, Entity location, ItemStack itemstack) {
if (PartRegistry.hasCustomItemEntity(itemstack)) {
EntityItem e = PartRegistry.createItemEntityForStack(world, location.posX, location.posY, location.posZ, itemstack);
e.delayBeforeCanPickup = 50;
return e;
}
return super.createEntity(world, location, itemstack);
}
}
| 4,361 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
CompatModuleFMPAlt.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/fmp/CompatModuleFMPAlt.java | package net.quetzi.bluepower.compat.fmp;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.vec.Vector3;
import net.quetzi.bluepower.compat.CompatModule;
import net.quetzi.bluepower.tileentities.BPTileMultipart;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
public class CompatModuleFMPAlt extends CompatModule implements IMultipartCompat {
@Override
public void preInit(FMLPreInitializationEvent ev) {
MultipartCompat.tile = BPTileMultipart.class;
}
@Override
public void init(FMLInitializationEvent ev) {
}
@Override
public void postInit(FMLPostInitializationEvent ev) {
}
@Override
public void registerBlocks() {
}
@Override
public void registerItems() {
}
@Override
public void registerRenders() {
}
@Override
public BPPart getClickedPart(Vector3 loc, Vector3 subLoc, ItemStack item, EntityPlayer player) {
return null;
}
@Override
public int getInput(World w, int x, int y, int z, ForgeDirection side, ForgeDirection face) {
return 0;
}
@Override
public void sendUpdatePacket(BPPart part) {
}
@Override
public boolean isMultipart(TileEntity te) {
return false;
}
@Override
public boolean checkOcclusion(TileEntity tile, AxisAlignedBB box) {
return false;
}
@Override
public <T> T getBPPart(TileEntity te, Class<T> searchedClass) {
return null;// TODO return non-FMP part
}
}
| 2,016 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
RegisterMultiparts.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/fmp/RegisterMultiparts.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*/
package net.quetzi.bluepower.compat.fmp;
import codechicken.multipart.MultiPartRegistry;
import codechicken.multipart.MultiPartRegistry.IPartFactory;
import codechicken.multipart.TMultiPart;
import net.quetzi.bluepower.api.part.BPPart;
import net.quetzi.bluepower.api.part.IBPFacePart;
import net.quetzi.bluepower.api.part.PartRegistry;
import net.quetzi.bluepower.references.Refs;
public class RegisterMultiparts implements IPartFactory {
private RegisterMultiparts() {
}
public static void register() {
String[] parts = PartRegistry.getRegisteredParts().toArray(new String[0]);
for (int i = 0; i < parts.length; i++)
parts[i] = Refs.MODID + "_" + parts[i];
MultiPartRegistry.registerParts(new RegisterMultiparts(), parts);
}
@Override
public TMultiPart createPart(String id, boolean client) {
return createPart_(id, client, true);
}
public static TMultiPart createPart_(String id, boolean client, boolean multipartFactory) {
BPPart part = PartRegistry.createPart(id, multipartFactory);
return createPart_(part);
}
public static TMultiPart createPart_(BPPart part) {
if (part != null) {
if (part instanceof IBPFacePart) {
return new MultipartFaceBPPart((IBPFacePart) part);
} else {
return new MultipartBPPart(part);
}
}
return null;
}
}
| 2,178 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
AlloyFurnaceHandler.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/nei/AlloyFurnaceHandler.java | package net.quetzi.bluepower.compat.nei;
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import net.quetzi.bluepower.api.recipe.IAlloyFurnaceRecipe;
import net.quetzi.bluepower.client.gui.GuiAlloyFurnace;
import net.quetzi.bluepower.recipe.AlloyFurnaceRegistry;
import net.quetzi.bluepower.recipe.AlloyFurnaceRegistry.StandardAlloyFurnaceRecipe;
import net.quetzi.bluepower.references.Refs;
import codechicken.nei.NEIClientUtils;
import codechicken.nei.PositionedStack;
import codechicken.nei.recipe.FurnaceRecipeHandler;
/**
*
* @author MineMaarten
*/
public class AlloyFurnaceHandler extends FurnaceRecipeHandler {
@Override
public String getRecipeName() {
return "Alloy Furnace";
}
@Override
public String getGuiTexture() {
return Refs.MODID + ":textures/GUI/alloy_furnace.png";
}
/**
* @return The class of the GuiContainer that this recipe would be crafted in.
*/
@Override
public Class<? extends GuiContainer> getGuiClass() {
return GuiAlloyFurnace.class;
}
/**
* Loads a rectangle that can be clicked in the Alloy Furnace GUI that will load up every recipe of the Alloy Furnace
*/
@Override
public void loadTransferRects() {
transferRects.add(new RecipeTransferRect(new Rectangle(17, 43, 18, 18), "fuel"));
transferRects.add(new RecipeTransferRect(new Rectangle(97, 24, 22, 14), getRecipesID()));
}
@Override
public void drawExtras(int recipe) {
drawProgressBar(17, 43, 177, 0, 14, 14, 48, 7);
drawProgressBar(97, 24, 177, 14, 24, 16, 48, 0);
}
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
if (outputId.equals(getRecipesID())) {
for (IAlloyFurnaceRecipe recipe : AlloyFurnaceRegistry.getInstance().getAllRecipes())
if (recipe instanceof AlloyFurnaceRegistry.StandardAlloyFurnaceRecipe) arecipes.add(new AlloyRecipe((AlloyFurnaceRegistry.StandardAlloyFurnaceRecipe) recipe));
} else if (outputId.equals("fuel")) {
} else super.loadCraftingRecipes(outputId, results);
}
private String getRecipesID() {
return "alloyFurnace";
}
@Override
public void loadCraftingRecipes(ItemStack result) {
for (IAlloyFurnaceRecipe recipe : AlloyFurnaceRegistry.getInstance().getAllRecipes())
if (recipe instanceof AlloyFurnaceRegistry.StandardAlloyFurnaceRecipe) {
if (NEIClientUtils.areStacksSameTypeCrafting(recipe.getCraftingResult(null), result)) {
arecipes.add(new AlloyRecipe((AlloyFurnaceRegistry.StandardAlloyFurnaceRecipe) recipe));
}
}
}
@Override
public void loadUsageRecipes(ItemStack ingredient) {
for (IAlloyFurnaceRecipe recipe : AlloyFurnaceRegistry.getInstance().getAllRecipes()) {
if (recipe instanceof AlloyFurnaceRegistry.StandardAlloyFurnaceRecipe) {
AlloyFurnaceRegistry.StandardAlloyFurnaceRecipe standardAlloyRecipe = (AlloyFurnaceRegistry.StandardAlloyFurnaceRecipe) recipe;
for (ItemStack input : standardAlloyRecipe.getRequiredItems()) {
if (NEIClientUtils.areStacksSameTypeCrafting(input, ingredient)) {
arecipes.add(new AlloyRecipe(standardAlloyRecipe));
break;
}
}
}
}
}
public class AlloyRecipe extends CachedRecipe {
private final PositionedStack craftingResult;
private final List<PositionedStack> requiredItems;
public AlloyRecipe(StandardAlloyFurnaceRecipe alloyRecipe) {
craftingResult = new PositionedStack(alloyRecipe.getCraftingResult(null), 129, 24);
requiredItems = new ArrayList<PositionedStack>();
int x = 0, y = 0;
for (ItemStack requiredItem : alloyRecipe.getRequiredItems()) {
requiredItems.add(new PositionedStack(requiredItem, 42 + x * 18, 6 + y * 18));
if (++x > 2) {
x = 0;
y++;
}
}
}
@Override
public PositionedStack getResult() {
return craftingResult;
}
@Override
public List<PositionedStack> getIngredients() {
return requiredItems;
}
@Override
public PositionedStack getOtherStack() {
PositionedStack stack = afuels.get(cycleticks / 48 % afuels.size()).stack;
stack = stack.copy();
stack.relx = 16;
stack.rely = 24;
return stack;
}
}
}
| 4,992 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
NEIPluginInitConfig.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/compat/nei/NEIPluginInitConfig.java | package net.quetzi.bluepower.compat.nei;
import net.quetzi.bluepower.references.Refs;
import codechicken.nei.api.API;
import codechicken.nei.api.IConfigureNEI;
/**
*
* @author MineMaarten
*/
public class NEIPluginInitConfig implements IConfigureNEI {
@Override
public void loadConfig() {
API.registerUsageHandler(new AlloyFurnaceHandler());
API.registerRecipeHandler(new AlloyFurnaceHandler());
}
@Override
public String getName() {
return "BPNEIHandler";
}
@Override
public String getVersion() {
return Refs.fullVersionString();
}
}
| 644 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
ContainerEjector.java | /FileExtraction/Java_unseen/Quetzi_BluePower/src/main/java/net/quetzi/bluepower/containers/ContainerEjector.java | /*
* This file is part of Blue Power.
*
* Blue Power is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Blue Power is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Blue Power. If not, see <http://www.gnu.org/licenses/>
*
* @author Quetzi
*/
package net.quetzi.bluepower.containers;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.quetzi.bluepower.tileentities.tier1.TileEjector;
public class ContainerEjector extends Container {
private final TileEjector tileEjector;
public ContainerEjector(InventoryPlayer invPlayer, TileEjector ejector) {
this.tileEjector = ejector;
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
this.addSlotToContainer(new Slot(ejector, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}
bindPlayerInventory(invPlayer);
}
protected void bindPlayerInventory(InventoryPlayer invPlayer) {
// Render inventory
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
}
}
// Render hotbar
for (int j = 0; j < 9; j++) {
addSlotToContainer(new Slot(invPlayer, j, 8 + j * 18, 142));
}
}
@Override public boolean canInteractWith(EntityPlayer player) {
return tileEjector.isUseableByPlayer(player);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int par2) {
ItemStack itemstack = null;
Slot slot = (Slot) inventorySlots.get(par2);
if (slot != null && slot.getHasStack()) {
ItemStack itemstack1 = slot.getStack();
itemstack = itemstack1.copy();
if (par2 < 20) {
if (!mergeItemStack(itemstack1, 9, 45, true)) return null;
} else if (!mergeItemStack(itemstack1, 0, 9, false)) { return null; }
if (itemstack1.stackSize == 0) {
slot.putStack(null);
} else {
slot.onSlotChanged();
}
if (itemstack1.stackSize != itemstack.stackSize) {
slot.onPickupFromSlot(player, itemstack1);
} else {
return null;
}
}
return itemstack;
}
}
| 3,006 | Java | .java | Quetzi/BluePower | 33 | 14 | 6 | 2014-05-20T12:41:12Z | 2014-08-25T01:35:21Z |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.