Finished up the lock switch, just missing textures now

Added a recipe to copy settings from one panel component to another
Some internal changes
This commit is contained in:
malte0811 2017-05-19 17:45:30 +02:00
parent 5165d55218
commit 6a2ce4685b
16 changed files with 407 additions and 152 deletions

View file

@ -67,7 +67,7 @@ repositories {
}
dependencies {
deobfCompile "net.industrial-craft:industrialcraft-2:2.7.+:dev"
deobfCompile "net.industrial-craft:industrialcraft-2:2.7.+:api"
deobfCompile "blusunrize:ImmersiveEngineering:0.11-+:deobf"
}

View file

@ -17,25 +17,17 @@
*/
package malte0811.industrialWires;
import blusunrize.immersiveengineering.api.tool.AssemblerHandler;
import blusunrize.immersiveengineering.api.tool.AssemblerHandler.IRecipeAdapter;
import blusunrize.immersiveengineering.api.tool.AssemblerHandler.RecipeQuery;
import blusunrize.immersiveengineering.common.IEContent;
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_Connector;
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0;
import blusunrize.immersiveengineering.common.blocks.stone.BlockTypes_StoneDecoration;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.blocks.BlockJacobsLadder;
import malte0811.industrialWires.blocks.TileEntityJacobsLadder;
import malte0811.industrialWires.blocks.controlpanel.*;
import malte0811.industrialWires.blocks.controlpanel.BlockPanel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.blocks.controlpanel.TileEntityPanelCreator;
import malte0811.industrialWires.blocks.controlpanel.TileEntityRSPanelConn;
import malte0811.industrialWires.blocks.converter.BlockMechanicalConverter;
import malte0811.industrialWires.blocks.converter.TileEntityIEMotor;
import malte0811.industrialWires.blocks.converter.TileEntityMechICtoIE;
import malte0811.industrialWires.blocks.converter.TileEntityMechIEtoIC;
import malte0811.industrialWires.blocks.wire.*;
import malte0811.industrialWires.controlpanel.PanelUtils;
import malte0811.industrialWires.crafting.RecipeCoilLength;
import malte0811.industrialWires.crafting.RecipeKeyLock;
import malte0811.industrialWires.items.ItemIC2Coil;
import malte0811.industrialWires.items.ItemKey;
import malte0811.industrialWires.items.ItemPanelComponent;
@ -45,10 +37,8 @@ import malte0811.industrialWires.network.MessagePanelInteract;
import malte0811.industrialWires.network.MessageTileSyncIW;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.init.Blocks;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
@ -60,13 +50,6 @@ import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.RecipeSorter.Category;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import java.util.ArrayList;
import java.util.List;
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies = "required-after:immersiveengineering@[0.10-58,);required-after:ic2")
public class IndustrialWires {
@ -127,81 +110,7 @@ public class IndustrialWires {
@EventHandler
public void init(FMLInitializationEvent e) {
ItemStack glassCable = IC2Items.getItem("cable", "type:glass,insulation:0");
//CONNECTORS
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 0), " t ", "rtr", "rtr", 't', "ingotTin", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 2), " c ", "rcr", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 4), " g ", "rgr", "rgr", 'g', "ingotGold", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 6), " i ", "rir", "rir", 'i', "ingotIron", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 8), " c ", "rcr", "rcr", 'c', glassCable, 'r', "itemRubber"));
//RELAYS
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 1), " t ", "rtr", 't', "ingotTin", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 3), " c ", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 5), " g ", "rgr", 'g', "ingotGold", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 7), " i ", "gig", "gig", 'i', "ingotIron", 'g', new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.INSULATING_GLASS.getMeta())));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 2, 9), " c ", "grg", "grg", 'r', "itemRubber", 'c', glassCable, 'g', new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.INSULATING_GLASS.getMeta())));
//WIRES
RecipeSorter.register("industrialwires:coilLength", RecipeCoilLength.class, Category.SHAPELESS, "after:forge:shapelessore");
for (int i = 0; i < IC2Wiretype.IC2_TYPES.length; i++) {
GameRegistry.addRecipe(new RecipeCoilLength(i));
}
AssemblerHandler.registerRecipeAdapter(RecipeCoilLength.class, new CoilLengthAdapter());
// MECH CONVERTERS
if (mechConv != null) {
ItemStack shaftIron = IC2Items.getItem("crafting", "iron_shaft");
ItemStack shaftSteel = IC2Items.getItem("crafting", "steel_shaft");
ItemStack ironMechComponent = new ItemStack(IEContent.itemMaterial, 1, 8);
ItemStack steelMechComponent = new ItemStack(IEContent.itemMaterial, 1, 9);
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 0), " s ", "ici", "mum", 's', "stickIron",
'i', "ingotIron", 'c', new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.COIL_LV.getMeta()),
'u', "ingotCopper", 'm', ironMechComponent));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 2), "iIi", "sbS", "mrm", 's', "blockSheetmetalIron",
'i', "plateIron", 'I', shaftIron,
'b', "ingotBronze", 'm', steelMechComponent,
'S', "blockSheetmetalSteel", 'r', "stickSteel"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 1), "mrm", "sbS", "iIi", 's', "blockSheetmetalIron",
'i', "plateSteel", 'I', shaftSteel,
'b', "ingotBronze", 'm', ironMechComponent,
'S', "blockSheetmetalSteel", 'r', "stickIron"));
}
// JACOB'S LADDERS
ItemStack mvTransformer = IC2Items.getItem("te", "mv_transformer");
ItemStack copperCable = IC2Items.getItem("cable", "type:copper,insulation:0");
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(jacobsLadder, 1, 0), "c c", " h ", "sts", 'c', copperCable, 'h', Blocks.HARDENED_CLAY,
's', "ingotSteel", 't', mvTransformer));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(jacobsLadder, 1, 1), "c c", "h h", "sts", 'c', "ingotCopper", 'h', Blocks.HARDENED_CLAY,
's', "ingotSteel", 't', new ItemStack(IEContent.blockConnectors, 1, BlockTypes_Connector.TRANSFORMER.ordinal())));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(jacobsLadder, 1, 2), "c c", "hhh", "sts", 'c', "blockCopper", 'h', Blocks.HARDENED_CLAY,
's', "ingotSteel", 't', new ItemStack(IEContent.blockConnectors, 1, BlockTypes_Connector.TRANSFORMER_HV.ordinal())));
// CONTROL PANELS
ItemStack drillHeadIron = new ItemStack(IEContent.itemDrillhead, 1, 1);
ItemStack motor = IC2Items.getItem("crafting", "electric_motor");
ItemStack advAlloy = IC2Items.getItem("crafting", "alloy");
ItemStack coil = IC2Items.getItem("crafting", "coil");
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panel, 1, BlockTypes_Panel.CREATOR.ordinal()),
"rmr", "rdr", "rar", 'r', "stickSteel", 'm', motor, 'd', drillHeadIron, 'a', advAlloy));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panel, 8, BlockTypes_Panel.DUMMY.ordinal()),
" r ", "rmr", " r ", 'r', "dustRedstone", 'm', PanelUtils.getPanelBase()));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panel, 1, BlockTypes_Panel.RS_WIRE.ordinal()),
"c", "d", 'd', new ItemStack(panel, 1, BlockTypes_Panel.DUMMY.ordinal()), 'c',
new ItemStack(IEContent.blockConnectors, 1, BlockTypes_Connector.CONNECTOR_REDSTONE.ordinal())));
// PANEL COMPONENTS
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 0),
"dustGlowstone", Blocks.STONE_BUTTON, "wireCopper"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 4, 1),
"paper", "plateIron"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 2),
"dustGlowstone", "dustRedstone", "wireCopper"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 3),
Blocks.STONE_BUTTON, new ItemStack(IEContent.itemWireCoil, 1, 2), "wireCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panelComponent, 1, 4),
"r", "g", "c", 'r', "itemRubber", 'g', "ingotHOPGraphite", 'c', coil));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 5),
"stickIron", Blocks.LEVER, "wireCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panelComponent, 1, 6),
"aaa", "asa", 'a', "plateAluminum", 's', new ItemStack(panelComponent, 2, 5)));
RecipeSorter.register("industrialwires:key_lock", RecipeKeyLock.class, Category.SHAPELESS, "after:forge:shapelessore");
GameRegistry.addRecipe(new RecipeKeyLock());
Recipes.addRecipes();
ExtraIC2Compat.addToolConmpat();
@ -230,30 +139,4 @@ public class IndustrialWires {
}
}
}
private class CoilLengthAdapter implements IRecipeAdapter<RecipeCoilLength> {
@Override
public RecipeQuery[] getQueriedInputs(RecipeCoilLength recipe, NonNullList<ItemStack> in) {
List<RecipeQuery> ret = new ArrayList<>();
for (int i = 0; i < in.size() - 1; i++) {
boolean added = false;
for (RecipeQuery aRet : ret) {
if (ItemStack.areItemStacksEqual((ItemStack) aRet.query, in.get(i))) {
aRet.querySize++;
added = true;
break;
}
}
if (!added) {
ret.add(new RecipeQuery(in.get(i), 1));
}
}
return ret.toArray(new RecipeQuery[ret.size()]);
}
@Override
public RecipeQuery[] getQueriedInputs(RecipeCoilLength arg0) {
return new RecipeQuery[0];
}
}
}

View file

@ -0,0 +1,176 @@
/*
* This file is part of Industrial Wires.
* Copyright (C) 2016-2017 malte0811
*
* Industrial Wires 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.
*
* Industrial Wires 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 Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*/
package malte0811.industrialWires;
import blusunrize.immersiveengineering.api.tool.AssemblerHandler;
import blusunrize.immersiveengineering.common.IEContent;
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_Connector;
import blusunrize.immersiveengineering.common.blocks.metal.BlockTypes_MetalDecoration0;
import blusunrize.immersiveengineering.common.blocks.stone.BlockTypes_StoneDecoration;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.blocks.controlpanel.BlockTypes_Panel;
import malte0811.industrialWires.controlpanel.PanelUtils;
import malte0811.industrialWires.crafting.RecipeCoilLength;
import malte0811.industrialWires.crafting.RecipeComponentCopy;
import malte0811.industrialWires.crafting.RecipeInitPC;
import malte0811.industrialWires.crafting.RecipeKeyLock;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.oredict.RecipeSorter;
import net.minecraftforge.oredict.ShapedOreRecipe;
import net.minecraftforge.oredict.ShapelessOreRecipe;
import java.util.ArrayList;
import java.util.List;
import static malte0811.industrialWires.IndustrialWires.*;
public class Recipes {
public static void addRecipes() {
addCustomRecipes();
addConnectors();
if (mechConv != null) {
addMechConverters();
}
addJacobs();
registerPanels();
}
private static void addConnectors() {
ItemStack glassCable = IC2Items.getItem("cable", "type:glass,insulation:0");
//CONNECTORS
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 0), " t ", "rtr", "rtr", 't', "ingotTin", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 2), " c ", "rcr", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 4), " g ", "rgr", "rgr", 'g', "ingotGold", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 6), " i ", "rir", "rir", 'i', "ingotIron", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 8), " c ", "rcr", "rcr", 'c', glassCable, 'r', "itemRubber"));
//RELAYS
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 1), " t ", "rtr", 't', "ingotTin", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 3), " c ", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 5), " g ", "rgr", 'g', "ingotGold", 'r', "itemRubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 4, 7), " i ", "gig", "gig", 'i', "ingotIron", 'g', new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.INSULATING_GLASS.getMeta())));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 2, 9), " c ", "grg", "grg", 'r', "itemRubber", 'c', glassCable, 'g', new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.INSULATING_GLASS.getMeta())));
}
private static void addMechConverters() {
ItemStack shaftIron = IC2Items.getItem("crafting", "iron_shaft");
ItemStack shaftSteel = IC2Items.getItem("crafting", "steel_shaft");
ItemStack ironMechComponent = new ItemStack(IEContent.itemMaterial, 1, 8);
ItemStack steelMechComponent = new ItemStack(IEContent.itemMaterial, 1, 9);
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 0), " s ", "ici", "mum", 's', "stickIron",
'i', "ingotIron", 'c', new ItemStack(IEContent.blockMetalDecoration0, 1, BlockTypes_MetalDecoration0.COIL_LV.getMeta()),
'u', "ingotCopper", 'm', ironMechComponent));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 2), "iIi", "sbS", "mrm", 's', "blockSheetmetalIron",
'i', "plateIron", 'I', shaftIron,
'b', "ingotBronze", 'm', steelMechComponent,
'S', "blockSheetmetalSteel", 'r', "stickSteel"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(mechConv, 1, 1), "mrm", "sbS", "iIi", 's', "blockSheetmetalIron",
'i', "plateSteel", 'I', shaftSteel,
'b', "ingotBronze", 'm', ironMechComponent,
'S', "blockSheetmetalSteel", 'r', "stickIron"));
}
private static void addCustomRecipes() {
RecipeSorter.register("industrialwires:key_lock", RecipeKeyLock.class, RecipeSorter.Category.SHAPELESS, "after:forge:shapelessore");
RecipeSorter.register("industrialwires:cmp_copy", RecipeComponentCopy.class, RecipeSorter.Category.SHAPED, "after:forge:shapelessore");
RecipeSorter.register("industrialwires:coilLength", RecipeCoilLength.class, RecipeSorter.Category.SHAPELESS, "after:forge:shapelessore");
RecipeSorter.register("industrialwires:init_pc", RecipeInitPC.class, RecipeSorter.Category.SHAPED, "after:forge:shapedore");
GameRegistry.addRecipe(new RecipeKeyLock());
GameRegistry.addRecipe(new RecipeComponentCopy());
for (int i = 0; i < IC2Wiretype.IC2_TYPES.length; i++) {
GameRegistry.addRecipe(new RecipeCoilLength(i));
}
AssemblerHandler.registerRecipeAdapter(RecipeCoilLength.class, new AllRecipeAdapter<>());
AssemblerHandler.registerRecipeAdapter(RecipeComponentCopy.class, new AllRecipeAdapter<>());
AssemblerHandler.registerRecipeAdapter(RecipeKeyLock.class, new AllRecipeAdapter<>());
}
private static void registerPanels() {
// CONTROL PANELS
ItemStack drillHeadIron = new ItemStack(IEContent.itemDrillhead, 1, 1);
ItemStack motor = IC2Items.getItem("crafting", "electric_motor");
ItemStack advAlloy = IC2Items.getItem("crafting", "alloy");
ItemStack coil = IC2Items.getItem("crafting", "coil");
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panel, 1, BlockTypes_Panel.CREATOR.ordinal()),
"rmr", "rdr", "rar", 'r', "stickSteel", 'm', motor, 'd', drillHeadIron, 'a', advAlloy));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panel, 8, BlockTypes_Panel.DUMMY.ordinal()),
" r ", "rmr", " r ", 'r', "dustRedstone", 'm', PanelUtils.getPanelBase()));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panel, 1, BlockTypes_Panel.RS_WIRE.ordinal()),
"c", "d", 'd', new ItemStack(panel, 1, BlockTypes_Panel.DUMMY.ordinal()), 'c',
new ItemStack(IEContent.blockConnectors, 1, BlockTypes_Connector.CONNECTOR_REDSTONE.ordinal())));
// PANEL COMPONENTS
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 0),
"dustGlowstone", Blocks.STONE_BUTTON, "wireCopper"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 4, 1),
"paper", "plateIron"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 2),
"dustGlowstone", "dustRedstone", "wireCopper"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 3),
Blocks.STONE_BUTTON, new ItemStack(IEContent.itemWireCoil, 1, 2), "wireCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panelComponent, 1, 4),
"r", "g", "c", 'r', "itemRubber", 'g', "ingotHOPGraphite", 'c', coil));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 5),
"stickIron", Blocks.LEVER, "wireCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(panelComponent, 1, 6),
"aaa", "asa", 'a', "plateAluminum", 's', new ItemStack(panelComponent, 2, 5)));
GameRegistry.addRecipe(new RecipeInitPC(new ItemStack(panelComponent, 1, 7),
"rdr", " w ", 'r', "stickSteel", 'd', Items.IRON_DOOR, 'w', "wireCopper"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(key, 1, 0),
"rrp", 'r', "stickSteel", 'p', "plateSteel"));
}
private static void addJacobs() {
ItemStack mvTransformer = IC2Items.getItem("te", "mv_transformer");
ItemStack copperCable = IC2Items.getItem("cable", "type:copper,insulation:0");
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(jacobsLadder, 1, 0), "c c", " h ", "sts", 'c', copperCable, 'h', Blocks.HARDENED_CLAY,
's', "ingotSteel", 't', mvTransformer));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(jacobsLadder, 1, 1), "c c", "h h", "sts", 'c', "ingotCopper", 'h', Blocks.HARDENED_CLAY,
's', "ingotSteel", 't', new ItemStack(IEContent.blockConnectors, 1, BlockTypes_Connector.TRANSFORMER.ordinal())));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(jacobsLadder, 1, 2), "c c", "hhh", "sts", 'c', "blockCopper", 'h', Blocks.HARDENED_CLAY,
's', "ingotSteel", 't', new ItemStack(IEContent.blockConnectors, 1, BlockTypes_Connector.TRANSFORMER_HV.ordinal())));
}
private static class AllRecipeAdapter<T extends IRecipe> implements AssemblerHandler.IRecipeAdapter<T> {
@Override
public AssemblerHandler.RecipeQuery[] getQueriedInputs(T recipe, NonNullList<ItemStack> in) {
List<AssemblerHandler.RecipeQuery> ret = new ArrayList<>();
for (int i = 0; i < in.size() - 1; i++) {
boolean added = false;
for (AssemblerHandler.RecipeQuery aRet : ret) {
if (ItemStack.areItemStacksEqual((ItemStack) aRet.query, in.get(i))) {
aRet.querySize++;
added = true;
break;
}
}
if (!added) {
ret.add(new AssemblerHandler.RecipeQuery(in.get(i), 1));
}
}
return ret.toArray(new AssemblerHandler.RecipeQuery[ret.size()]);
}
@Override
public AssemblerHandler.RecipeQuery[] getQueriedInputs(T arg0) {
return new AssemblerHandler.RecipeQuery[0];
}
}
}

View file

@ -22,6 +22,7 @@ import blusunrize.immersiveengineering.api.IEProperties;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.BlockIWBase;
import malte0811.industrialWires.blocks.IMetaEnum;
import malte0811.industrialWires.controlpanel.PanelComponent;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
@ -169,11 +170,6 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
return false;
}
/* @Override TODO do I not need this any more?
public boolean isVisuallyOpaque() {
return false;
}
*/
@Override
public boolean onBlockActivated(World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumHand hand, EnumFacing side, float hitX, float hitY, float hitZ) {
if (!super.onBlockActivated(world, pos, state, player, hand, side, hitX, hitY, hitZ) && hand == EnumHand.MAIN_HAND) {
@ -206,4 +202,14 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
}
return super.getPickBlock(state, target, world, pos, player);
}
@Override
public void harvestBlock(@Nonnull World worldIn, EntityPlayer player, @Nonnull BlockPos pos, @Nonnull IBlockState state, TileEntity te, ItemStack stack) {
super.harvestBlock(worldIn, player, pos, state, te, stack);
if (te instanceof TileEntityPanel) {
for (PanelComponent pc:((TileEntityPanel) te).getComponents()) {
pc.dropItems((TileEntityPanel)te);
}
}
}
}

View file

@ -21,7 +21,6 @@ import blusunrize.immersiveengineering.api.ManualHelper;
import blusunrize.immersiveengineering.client.ClientUtils;
import blusunrize.immersiveengineering.client.models.smart.ConnLoader;
import blusunrize.immersiveengineering.common.Config;
import blusunrize.immersiveengineering.common.util.IELogger;
import blusunrize.lib.manual.ManualInstance;
import blusunrize.lib.manual.ManualPages;
import blusunrize.lib.manual.ManualPages.PositionedItemStack;
@ -132,7 +131,6 @@ public class ClientProxy extends CommonProxy {
String location = loc.toString();
String prop = "inventory,type=" + v[meta].toString().toLowerCase(Locale.US);
try {
IELogger.info(location + ", " + prop);
ModelLoader.setCustomModelResourceLocation(blockItem, meta, new ModelResourceLocation(location, prop));
} catch (NullPointerException npe) {
throw new RuntimeException(b + " lacks an item!", npe);
@ -230,13 +228,15 @@ public class ClientProxy extends CommonProxy {
new ManualPages.Text(m, "industrialwires.redstone1")
);
m.addEntry("industrialwires.components", "control_panels",
new ManualPages.Text(m, "industrialwires.components.general"),
new ManualPages.Crafting(m, "industrialwires.button", new ItemStack(IndustrialWires.panelComponent, 1, 0)),
new ManualPages.Crafting(m, "industrialwires.label", new ItemStack(IndustrialWires.panelComponent, 1, 1)),
new ManualPages.Crafting(m, "industrialwires.indicator_light", new ItemStack(IndustrialWires.panelComponent, 1, 2)),
new ManualPages.Crafting(m, "industrialwires.slider", new ItemStack(IndustrialWires.panelComponent, 1, 3)),
new ManualPages.CraftingMulti(m, "industrialwires.toggle_switch", new ItemStack(IndustrialWires.panelComponent, 1, 5), new ItemStack(IndustrialWires.panelComponent, 1, 6)),
new ManualPages.Text(m, "industrialwires.toggle_switch1"),
new ManualPages.Crafting(m, "industrialwires.variac", new ItemStack(IndustrialWires.panelComponent, 1, 4))
new ManualPages.Crafting(m, "industrialwires.variac", new ItemStack(IndustrialWires.panelComponent, 1, 4)),
new ManualPages.CraftingMulti(m, "industrialwires.lock", new ItemStack(IndustrialWires.panelComponent, 1, 7), new ItemStack(IndustrialWires.key))
);
}

View file

@ -51,8 +51,8 @@ public class GuiRenameKey extends GuiContainer {
if (nbt!=null&&nbt.hasKey("name")) {
field.setText(nbt.getString("name"));
}
xSize = 64;
ySize = 64;
xSize = 68;
ySize = 22;
guiLeft = (width - xSize) / 2;
guiTop = (height - ySize) / 2;
}
@ -66,13 +66,13 @@ public class GuiRenameKey extends GuiContainer {
RenderHelper.enableStandardItemLighting();
}
private ResourceLocation textureLoc = new ResourceLocation(IndustrialWires.MODID, "textures/gui/rs_wire_controller.png");
private ResourceLocation textureLoc = new ResourceLocation(IndustrialWires.MODID, "textures/gui/key_rename.png");
@Override
protected void drawGuiContainerBackgroundLayer(float partialTicks, int mouseX, int mouseY) {
GlStateManager.color(1, 1, 1, 1);
mc.getTextureManager().bindTexture(textureLoc);
Gui.drawModalRectWithCustomSizedTexture(guiLeft, guiTop, 0, 0, xSize, ySize, 64, 64);
Gui.drawModalRectWithCustomSizedTexture(guiLeft, guiTop, 0, 0, xSize, ySize, 68, 22);
}
@Override

View file

@ -24,6 +24,8 @@ import malte0811.industrialWires.blocks.controlpanel.TileEntityPanel;
import malte0811.industrialWires.client.RawQuad;
import malte0811.industrialWires.client.gui.GuiPanelCreator;
import malte0811.industrialWires.items.ItemKey;
import net.minecraft.block.Block;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
@ -42,7 +44,6 @@ import javax.annotation.Nullable;
import java.util.*;
import java.util.function.BiConsumer;
//TODO drop key when broken
public class Lock extends PanelComponent implements IConfigurableComponent {
private final static Random rand = new Random();
@Nullable
@ -57,6 +58,9 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
public Lock() {
super("lock");
while (lockID==0) {
lockID = rand.nextInt();
}
}
public Lock(boolean latching, int rsOutputId, int rsOutputChannel) {
@ -64,9 +68,6 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
this.latching = latching;
this.rsOutputChannel = rsOutputChannel;
this.rsOutputId = rsOutputId;
while (lockID==0) {
lockID = rand.nextInt();
}
}
@Override
@ -106,9 +107,10 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
private final static float yOffset = size / 2 + .0001F;
private final static float xOffset = (size - keyWidth) / 2;
private final static float[] DARK_GRAY = {.4F, .4F, .4F};
private final static int DARK_GRAY_INT = 0xFF686868;
private final static float zOffset = keyWidth / 2;
private final static float keyOffset = keyWidth;
private final static float zOffsetLowerKey = size / 3;
private final static float zOffsetLowerKey = size / 4;
@Override
@ -125,15 +127,15 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
}
addKey(ret, mat);
} else {
PanelUtils.addColoredQuad(ret, new Vector3f(xOffset + keyWidth, yOffset, zOffset), new Vector3f(xOffset, yOffset, zOffset),
new Vector3f(xOffset, yOffset, size - zOffset), new Vector3f(xOffset + keyWidth, yOffset, size - zOffset),
PanelUtils.addColoredQuad(ret, new Vector3f(xOffset + keyWidth, yOffset, zOffsetLowerKey), new Vector3f(xOffset, yOffset, zOffsetLowerKey),
new Vector3f(xOffset, yOffset, size - zOffsetLowerKey), new Vector3f(xOffset + keyWidth, yOffset, size - zOffsetLowerKey),
EnumFacing.UP, DARK_GRAY);
}
return ret;
}
private void addKey(List<RawQuad> out, Matrix4 mat) {
PanelUtils.addColoredBox(DARK_GRAY, DARK_GRAY, null, new Vector3f(xOffset, size / 2, zOffsetLowerKey), new Vector3f(keyWidth, keyOffset, size / 3), out, false, mat);
PanelUtils.addColoredBox(DARK_GRAY, DARK_GRAY, null, new Vector3f(xOffset, size / 2, zOffsetLowerKey), new Vector3f(keyWidth, keyOffset, size / 2), out, false, mat);
PanelUtils.addColoredBox(DARK_GRAY, DARK_GRAY, null, new Vector3f(xOffset, size / 2 + keyOffset, zOffset), new Vector3f(keyWidth, size, size - 2 * zOffset), out, false, mat);
}
@ -233,8 +235,13 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
@Override
public void renderInGUI(GuiPanelCreator gui) {
//TODO somethin more fancy?
renderInGUIDefault(gui, GRAY_INT);
AxisAlignedBB aabb = getBlockRelativeAABB();
int left = (int) (gui.getX0() + (aabb.minX+xOffset) * gui.panelSize);
int top = (int) (gui.getY0() + (aabb.minZ+zOffsetLowerKey) * gui.panelSize);
int right = (int) (gui.getX0() + (aabb.maxX-xOffset) * gui.panelSize);
int bottom = (int) (gui.getY0() + (aabb.maxZ-zOffsetLowerKey) * gui.panelSize);
Gui.drawRect(left, top, right, bottom, DARK_GRAY_INT);
}
@Override
@ -250,6 +257,14 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
}
}
@Override
public void dropItems(TileEntityPanel te) {
super.dropItems(te);
if (keyNBT!=null) {
Block.spawnAsEntity(te.getWorld(), te.getPos(), new ItemStack(keyNBT));
}
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
@ -264,7 +279,6 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
if (rsOutputChannel != lock.rsOutputChannel) return false;
if (ticksTillOff != lock.ticksTillOff) return false;
if (lockID != lock.lockID) return false;
if (true) return false;
return keyNBT != null ? keyNBT.equals(lock.keyNBT) : lock.keyNBT == null;
}

View file

@ -103,6 +103,9 @@ public abstract class PanelComponent {
public void unregisterRSOutput(int id, @Nonnull BiConsumer<Integer, Byte> out) {
}
public void dropItems(TileEntityPanel te) {
}
public void invalidate(TileEntityPanel te) {
}

View file

@ -286,6 +286,12 @@ public final class PanelUtils {
case 6://Covered toggle switch
addCommonInfo(data, list, true, true);
break;
case 7://Lock
addCommonInfo(data, list, false, true);
if (data.hasKey(LATCHING)) {
list.add(I18n.format(IndustrialWires.MODID + ".tooltip." + (data.getBoolean(LATCHING) ? "latching" : "instantaneous")));
}
break;
}
}

View file

@ -0,0 +1,109 @@
/*
* This file is part of Industrial Wires.
* Copyright (C) 2016-2017 malte0811
*
* Industrial Wires 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.
*
* Industrial Wires 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 Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*/
package malte0811.industrialWires.crafting;
import blusunrize.immersiveengineering.api.ApiUtils;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.controlpanel.PanelComponent;
import malte0811.industrialWires.items.ItemPanelComponent;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
public class RecipeComponentCopy implements IRecipe {
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
boolean found = false;
int foundX = -1;
int foundY = -1;
for (int x = 0; x < inv.getWidth(); x++) {
for (int y = 0; y < inv.getHeight(); y++) {
ItemStack here = inv.getStackInRowAndColumn(x, y);
PanelComponent pc1 = ItemPanelComponent.componentFromStack(here);
if (pc1!=null) {
if (x==foundX&&y==foundY) {
continue;
}
if (found) {
return false;
}
if (y+1<inv.getHeight()) {
ItemStack below = inv.getStackInRowAndColumn(x, y + 1);
PanelComponent pc2 = ItemPanelComponent.componentFromStack(below);
if (pc2 == null || pc2.getClass() != pc1.getClass()) {
return false;
}
found = true;
foundX = x;
foundY = y + 1;
} else {
return false;
}
}
}
}
return found;
}
@Nonnull
@Override
public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
int[] pos = getTopComponent(inv);
if (pos != null) {
return ApiUtils.copyStackWithAmount(inv.getStackInRowAndColumn(pos[0], pos[1]), 2);
} else {
return ItemStack.EMPTY;
}
}
@Override
public int getRecipeSize() {
return 2;
}
@Nonnull
@Override
public ItemStack getRecipeOutput() {
return ItemStack.EMPTY;
}
@Nonnull
@Override
public NonNullList<ItemStack> getRemainingItems(@Nonnull InventoryCrafting inv) {
return NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
}
@Nullable
private int[] getTopComponent(@Nonnull InventoryCrafting inv) {
for (int x = 0; x < inv.getWidth(); x++) {
for (int y = 0; y < inv.getHeight() - 1; y++) {
ItemStack here = inv.getStackInRowAndColumn(x, y);
if (!here.isEmpty() && here.getItem() == IndustrialWires.panelComponent) {
return new int[]{x, y};
}
}
}
return null;
}
}

View file

@ -0,0 +1,51 @@
/*
* This file is part of Industrial Wires.
* Copyright (C) 2016-2017 malte0811
*
* Industrial Wires 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.
*
* Industrial Wires 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 Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
*/
package malte0811.industrialWires.crafting;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.items.ItemPanelComponent;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.oredict.ShapedOreRecipe;
import javax.annotation.Nonnull;
public class RecipeInitPC extends ShapedOreRecipe {
public RecipeInitPC(ItemStack result, Object... recipe) {
super(result, recipe);
}
@Nonnull
@Override
public ItemStack getCraftingResult(@Nonnull InventoryCrafting var1) {
ItemStack ret = super.getCraftingResult(var1);
if (ret.getItem()== IndustrialWires.panelComponent) {
//implicitely initialize the component, relevant for locks with random ID's
ItemPanelComponent.getTagCompound(ret);
}
return ret;
}
@Override
public boolean matches(InventoryCrafting inv, World world) {
return super.matches(inv, world);
}
}

View file

@ -17,6 +17,7 @@
*/
package malte0811.industrialWires.crafting;
import blusunrize.immersiveengineering.api.ApiUtils;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.controlpanel.Lock;
import malte0811.industrialWires.controlpanel.PanelComponent;
@ -29,7 +30,7 @@ import net.minecraft.util.NonNullList;
import net.minecraft.world.World;
import javax.annotation.Nonnull;
//TODO JEI
public class RecipeKeyLock implements IRecipe {
@Override
@ -63,7 +64,7 @@ public class RecipeKeyLock implements IRecipe {
for (int i = 0; i < ret.size(); i++) {
ItemStack here = inv.getStackInSlot(i);
if (here.getItem() == IndustrialWires.panelComponent) {
ret.set(i, here);
ret.set(i, ApiUtils.copyStackWithAmount(here, 1));
}
}
return ret;

View file

@ -51,7 +51,7 @@ public class ItemKey extends Item implements INetGUIItem {
public String getItemStackDisplayName(@Nonnull ItemStack stack) {
NBTTagCompound nbt = stack.getTagCompound();
if (nbt!=null&&nbt.hasKey("name")) {
return I18n.format("item."+IndustrialWires.MODID+".key_named.name")+nbt.getString("name");
return I18n.format("item."+IndustrialWires.MODID+".key_named.name")+" "+nbt.getString("name");
}
return super.getItemStackDisplayName(stack);
}
@ -61,7 +61,7 @@ public class ItemKey extends Item implements INetGUIItem {
public String getUnlocalizedName(ItemStack stack) {
NBTTagCompound nbt = stack.getTagCompound();
if (nbt==null||!nbt.hasKey(lockId)) {
return I18n.format("item."+IndustrialWires.MODID+".key_raw.name");
return "item."+IndustrialWires.MODID+".key_raw";
}
return super.getUnlocalizedName(stack);
}
@ -89,7 +89,7 @@ public class ItemKey extends Item implements INetGUIItem {
@Override
@Nonnull
public ActionResult<ItemStack> onItemRightClick(World worldIn, EntityPlayer playerIn, @Nonnull EnumHand hand) {
if (!worldIn.isRemote) {
if (!worldIn.isRemote&&idForKey(playerIn.getHeldItem(hand))!=0) {
playerIn.openGui(IndustrialWires.MODID, 1, worldIn, 0, 0, hand == EnumHand.MAIN_HAND ? 1 : 0);
}
return new ActionResult<>(EnumActionResult.SUCCESS, playerIn.getHeldItem(hand));

View file

@ -93,6 +93,9 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
@Nullable
public static PanelComponent componentFromStack(ItemStack stack) {
if (stack.getItem()!=IndustrialWires.panelComponent) {
return null;
}
NBTTagCompound loadFrom = getTagCompound(stack).getCompoundTag("data").copy();
loadFrom.setString("type", types[stack.getMetadata()]);
return PanelComponent.read(loadFrom);

View file

@ -35,6 +35,7 @@ item.industrialwires.panel_component.slider.name=Slider
item.industrialwires.panel_component.variac.name=Variac®
item.industrialwires.panel_component.toggle_switch.name=Toggle Switch
item.industrialwires.panel_component.toggle_switch_covered.name=Covered Toggle Switch
item.industrialwires.panel_component.lock.name=Lock Switch
item.industrialwires.key.name=Key
item.industrialwires.key_named.name=Key for
item.industrialwires.key_raw.name=Blank Key
@ -56,7 +57,7 @@ industrialwires.desc.red=Red
industrialwires.desc.green=Green
industrialwires.desc.blue=Blue
industrialwires.desc.length=Length
industrialwires.tooltip.rsChannel_info=The color of the channel to output the signal to
industrialwires.tooltip.rschannel_info=The color of the channel to output the signal to
industrialwires.tooltip.horizontal=Horizontal
industrialwires.tooltip.vertical=Vertical
@ -121,10 +122,12 @@ ie.manual.entry.industrialwires.redstone1=connectors from Immersive Engineering.
ie.manual.entry.industrialwires.components.name=Panel Components
ie.manual.entry.industrialwires.components.subtext=More than just two
ie.manual.entry.industrialwires.components.general=The settings of any component can be copied to a component of the same type by placing the components directly above each other in a crafting bench. The settings of the upper component will be copied to the lower.
ie.manual.entry.industrialwires.button=A simple button that activates a redstone signal when pressed. Its color can be changed. The button either stays on until clicked again (latching) or tuns off after half a second (non-latching).
ie.manual.entry.industrialwires.label=A text that can be placed on the control panel, for example to indicate the purpose of some other component. The color and obviously the text can be edited.
ie.manual.entry.industrialwires.indicator_light=A small indicator that brightens as the input redstone signal is increased. The color can be changed.
ie.manual.entry.industrialwires.slider=A sliding switch that can set an output redstone signal to any desired signal strength. It can be either vertically or horizontally aligned and can have any length between one eighth of a block and one block. The color of the sliding knob can be changed.
ie.manual.entry.industrialwires.toggle_switch=A switch to turn a signal on or off. The covered version includes a cover to prevent accidental activation: When clicked for the first time the cover will open, the signal will be turned on by clicking once again. Another click will close the cover and turn off the output signal. If the cover was opened by accident it can be closed by shift-right-clicking
ie.manual.entry.industrialwires.toggle_switch1=the switch. The color of the cover can be configured.
ie.manual.entry.industrialwires.variac=A Variac® is a variable autotransformer. The output signal of the transformer increases as the knob is turned to the right. The signal strenght can only be increased by one unit per click.
ie.manual.entry.industrialwires.variac=A Variac® is a variable autotransformer. The output signal of the transformer increases as the knob is turned to the right. The signal strenght can only be increased by one unit per click.
ie.manual.entry.industrialwires.lock=A lock switch activates a redstone signal when a key is inserted and turned. A newly crafted lock will have a unique key configuration. By placing a blank key and a lock in a crafting table a key for the lock can be created. Multiple locks fitting the same key can be created using component copying (see page 1). Keys can be named in a GUI opened by right-clicking with them.

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 B