changed wires to use different amounts of cable for different length connections
added Glass Fiber Wire changed the amount of connectors/relays produced per crafting WARNING: this commit won't work with the public IE builds currently available
This commit is contained in:
parent
d8bbbb8170
commit
1fee68c9ef
|
@ -30,7 +30,7 @@ sourceCompatibility = 1.8
|
|||
targetCompatibility = 1.8
|
||||
|
||||
minecraft {
|
||||
version = "12.18.1.2077"
|
||||
version = "12.18.1.2092"
|
||||
//"1.9.4-12.17.0.1976"
|
||||
runDir = "run"
|
||||
|
||||
|
|
|
@ -1,13 +1,20 @@
|
|||
package malte0811.industrialWires;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import blusunrize.immersiveengineering.api.tool.AssemblerHandler;
|
||||
import blusunrize.immersiveengineering.api.tool.AssemblerHandler.RecipeQuery;
|
||||
import blusunrize.immersiveengineering.common.IEContent;
|
||||
import blusunrize.immersiveengineering.common.blocks.stone.BlockTypes_StoneDecoration;
|
||||
import ic2.api.item.IC2Items;
|
||||
import malte0811.industrialWires.blocks.BlockIC2Connector;
|
||||
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorCopper;
|
||||
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorGlass;
|
||||
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorGold;
|
||||
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorHV;
|
||||
import malte0811.industrialWires.blocks.TileEntityIC2ConnectorTin;
|
||||
import malte0811.industrialWires.crafting.RecipeCoilLength;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.creativetab.CreativeTabs;
|
||||
|
@ -20,6 +27,8 @@ import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
|||
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
import net.minecraftforge.oredict.RecipeSorter;
|
||||
import net.minecraftforge.oredict.RecipeSorter.Category;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
|
||||
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies="required-after:immersiveengineering;required-after:IC2")
|
||||
|
@ -49,6 +58,7 @@ public class IndustrialWires {
|
|||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorCopper.class, "ic2ConnectorCopper");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGold.class, "ic2ConnectorGold");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorHV.class, "ic2ConnectorHV");
|
||||
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGlass.class, "ic2ConnectorGlass");
|
||||
if (IC2Wiretype.IC2_TYPES==null) {
|
||||
throw new IllegalStateException("No IC2 wires registered");
|
||||
}
|
||||
|
@ -57,25 +67,50 @@ public class IndustrialWires {
|
|||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent e) {
|
||||
//WIRES
|
||||
ItemStack tinCable = IC2Items.getItem("cable", "type:tin,insulation:0");
|
||||
ItemStack copperCable = IC2Items.getItem("cable", "type:copper,insulation:0");
|
||||
ItemStack goldCable = IC2Items.getItem("cable", "type:gold,insulation:0");
|
||||
ItemStack hvCable = IC2Items.getItem("cable", "type:iron,insulation:0");
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(coil, 2, 0), "ttt", "tst", "ttt", 't', tinCable, 's', "stickWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(coil, 2, 1), "ccc", "csc", "ccc", 'c', copperCable, 's', "stickWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(coil, 2, 2), "ggg", "gsg", "ggg", 'g', goldCable, 's', "stickWood"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(coil, 2, 3), "hhh", "hsh", "hhh", 'h', hvCable, 's', "stickWood"));
|
||||
ItemStack glassCable = IC2Items.getItem("cable", "type:glass,insulation:0");
|
||||
//CONNECTORS
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 0), " t ", "rtr", "rtr", 't', "ingotTin", 'r', "itemRubber"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 2), " c ", "rcr", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 4), " g ", "rgr", "rgr", 'g', "ingotGold", 'r', "itemRubber"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 6), " i ", "rir", "rir", 'i', "ingotIron", 'r', "itemRubber"));
|
||||
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, 1, 1), " t ", "rtr", 't', "ingotTin", 'r', "itemRubber"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 3), " c ", "rcr", 'c', "ingotCopper", 'r', "itemRubber"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 5), " g ", "rgr", 'g', "ingotGold", 'r', "itemRubber"));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(ic2conn, 1, 7), " i ", "gig", "gig", 'i', "ingotIron", 'g', new ItemStack(IEContent.blockStoneDecoration, 1, BlockTypes_StoneDecoration.INSULATING_GLASS.getMeta())));
|
||||
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 AssemblerHandler.IRecipeAdapter<RecipeCoilLength>() {
|
||||
|
||||
@Override
|
||||
public RecipeQuery[] getQueriedInputs(RecipeCoilLength recipe, ItemStack[] in) {
|
||||
List<RecipeQuery> ret = new ArrayList<>();
|
||||
for (int i = 0;i<in.length-1;i++) {
|
||||
boolean added = false;
|
||||
for (int j = 0;j<ret.size();j++) {
|
||||
if (ItemStack.areItemStacksEqual((ItemStack)ret.get(j).query, in[i])) {
|
||||
ret.get(j).querySize++;
|
||||
added = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!added) {
|
||||
ret.add(new RecipeQuery(in[i], 1));
|
||||
}
|
||||
}
|
||||
return ret.toArray(new RecipeQuery[ret.size()]);
|
||||
}
|
||||
@Override
|
||||
public RecipeQuery[] getQueriedInputs(RecipeCoilLength arg0) {
|
||||
return new RecipeQuery[0];
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
@EventHandler
|
||||
public void postInit(FMLPostInitializationEvent e) {
|
||||
|
|
|
@ -87,6 +87,10 @@ public class BlockIC2Connector extends BlockIETileProvider<BlockTypes_IC2_Connec
|
|||
return new TileEntityIC2ConnectorHV(false);
|
||||
else if (meta==7)
|
||||
return new TileEntityIC2ConnectorHV(true);
|
||||
else if (meta==8)
|
||||
return new TileEntityIC2ConnectorGlass(false);
|
||||
else if (meta==9)
|
||||
return new TileEntityIC2ConnectorGlass(true);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,9 @@ public enum BlockTypes_IC2_Connector implements IBlockEnum {
|
|||
GOLD_CONN,
|
||||
GOLD_RELAY,
|
||||
HV_CONN,
|
||||
HV_RELAY;
|
||||
HV_RELAY,
|
||||
GLASS_CONN,
|
||||
GLASS_RELAY;
|
||||
@Override
|
||||
public String getName() {
|
||||
return toString().toLowerCase();
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package malte0811.industrialWires.blocks;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
|
||||
public class TileEntityIC2ConnectorGlass extends TileEntityIC2ConnectorHV {
|
||||
public TileEntityIC2ConnectorGlass(boolean rel) {
|
||||
super(rel);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorGlass() {}
|
||||
|
||||
{
|
||||
tier = 5;
|
||||
maxStored = IC2Wiretype.IC2_TYPES[4].getTransferRate()/8;
|
||||
}
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return t==IC2Wiretype.IC2_TYPES[4];
|
||||
}
|
||||
}
|
|
@ -18,6 +18,7 @@ import blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConne
|
|||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IBlockBounds;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergyAcceptor;
|
||||
|
@ -26,6 +27,7 @@ import ic2.api.energy.tile.IEnergySink;
|
|||
import ic2.api.energy.tile.IEnergySource;
|
||||
import malte0811.industrialWires.IIC2Connector;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -209,6 +211,21 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
public int getSourceTier() {
|
||||
return tier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeCable(Connection connection) {
|
||||
WireType type = connection != null ? connection.cableType : null;
|
||||
Set<Connection> outputs = ImmersiveNetHandler.INSTANCE.getConnections(worldObj, Utils.toCC(this));
|
||||
if(outputs == null || outputs.size() == 0) {
|
||||
if(type == limitType || type == null)
|
||||
this.limitType = null;
|
||||
}
|
||||
this.markDirty();
|
||||
if(worldObj != null) {
|
||||
IBlockState state = worldObj.getBlockState(pos);
|
||||
worldObj.notifyBlockUpdate(pos, state,state, 3);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) {
|
||||
|
|
|
@ -4,6 +4,7 @@ import blusunrize.immersiveengineering.api.Lib;
|
|||
import blusunrize.immersiveengineering.client.ClientUtils;
|
||||
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
@ -20,19 +21,23 @@ public class ClientEventHandler {
|
|||
if(ClientUtils.mc().thePlayer!=null && e.getType() == RenderGameOverlayEvent.ElementType.TEXT) {
|
||||
EntityPlayer player = ClientUtils.mc().thePlayer;
|
||||
|
||||
for(EnumHand hand : EnumHand.values())
|
||||
for(EnumHand hand : EnumHand.values()) {
|
||||
if(player.getHeldItem(hand)!=null) {
|
||||
ItemStack equipped = player.getHeldItem(hand);
|
||||
if(OreDictionary.itemMatches(new ItemStack(IndustrialWires.coil, 1, OreDictionary.WILDCARD_VALUE), equipped, false)) {
|
||||
int color = IC2Wiretype.IC2_TYPES[equipped.getItemDamage()].getColour(null);
|
||||
String s = I18n.format(IndustrialWires.MODID+".desc.wireLength", ItemIC2Coil.getLength(equipped));
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth()/2 - ClientUtils.font().getStringWidth(s)/2, e.getResolution().getScaledHeight()-GuiIngameForge.left_height-40, color, true);
|
||||
if(ItemNBTHelper.hasKey(equipped, "linkingPos")) {
|
||||
int[] link = ItemNBTHelper.getIntArray(equipped, "linkingPos");
|
||||
if(link!=null&&link.length>3) {
|
||||
String s = I18n.format(Lib.DESC_INFO+"attachedTo", link[1],link[2],link[3]);
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth()/2 - ClientUtils.font().getStringWidth(s)/2, e.getResolution().getScaledHeight()-GuiIngameForge.left_height-20, IC2Wiretype.IC2_TYPES[2].getColour(null), true);
|
||||
s = I18n.format(Lib.DESC_INFO+"attachedTo", link[1],link[2],link[3]);
|
||||
ClientUtils.font().drawString(s, e.getResolution().getScaledWidth()/2 - ClientUtils.font().getStringWidth(s)/2, e.getResolution().getScaledHeight()-GuiIngameForge.left_height-20, color, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package malte0811.industrialWires.client;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
|
@ -8,6 +9,8 @@ import blusunrize.immersiveengineering.api.ManualHelper;
|
|||
import blusunrize.immersiveengineering.client.models.smart.ConnLoader;
|
||||
import blusunrize.lib.manual.ManualInstance;
|
||||
import blusunrize.lib.manual.ManualPages;
|
||||
import blusunrize.lib.manual.ManualPages.PositionedItemStack;
|
||||
import ic2.api.item.IC2Items;
|
||||
import malte0811.industrialWires.CommonProxy;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
|
@ -50,8 +53,13 @@ public class ClientProxy extends CommonProxy {
|
|||
ConnLoader.textureReplacements.put("ic2_conn_hv", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorHV",
|
||||
IndustrialWires.MODID+":blocks/ic2_connHV"));
|
||||
ConnLoader.baseModels.put("ic2_relay_hv", new ResourceLocation("immersiveengineering:block/connector/relayHV.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_relay_hv", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorHV",
|
||||
IndustrialWires.MODID+":blocks/ic2_relayHV"));
|
||||
|
||||
ConnLoader.baseModels.put("ic2_conn_glass", new ResourceLocation("immersiveengineering:block/connector/connectorHV.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_conn_glass", ImmutableMap.of("#immersiveengineering:blocks/connector_connectorHV",
|
||||
IndustrialWires.MODID+":blocks/ic2_connGlass"));
|
||||
ConnLoader.baseModels.put("ic2_relay_glass", new ResourceLocation("immersiveengineering:block/connector/relayHV.obj"));
|
||||
ConnLoader.textureReplacements.put("ic2_relay_glass", ImmutableMap.of("#immersiveengineering:blocks/connector_relayHV",
|
||||
IndustrialWires.MODID+":blocks/ic2_relayGlass"));
|
||||
|
||||
for(int meta = 0; meta < ItemIC2Coil.subNames.length; meta++) {
|
||||
ResourceLocation loc = new ResourceLocation(IndustrialWires.MODID, "ic2wireCoil/" + ItemIC2Coil.subNames[meta]);
|
||||
|
@ -82,10 +90,45 @@ public class ClientProxy extends CommonProxy {
|
|||
public void postInit() {
|
||||
super.postInit();
|
||||
ManualInstance m = ManualHelper.getManual();
|
||||
PositionedItemStack[][] wireRecipes = new PositionedItemStack[3][10];
|
||||
int xBase = 15;
|
||||
ItemStack tinCable = IC2Items.getItem("cable", "type:tin,insulation:0");
|
||||
for (int i = 0;i<3;i++) {
|
||||
for (int j = 0;j<3;j++) {
|
||||
wireRecipes[0][3*i+j] = new PositionedItemStack(tinCable.copy(), 18*i+xBase, 18*j);
|
||||
}
|
||||
}
|
||||
ItemStack tmp = new ItemStack(IndustrialWires.coil);
|
||||
ItemIC2Coil.setLength(tmp, 9);
|
||||
wireRecipes[0][9] = new PositionedItemStack(tmp, 18*4+xBase, 18);
|
||||
Random r = new Random();
|
||||
for (int i = 1;i<3;i++) {
|
||||
int lengthSum = 0;
|
||||
for (int j1 = 0;j1<3;j1++) {
|
||||
for (int j2 = 0;j2<3;j2++) {
|
||||
if (r.nextBoolean()) {
|
||||
// cable
|
||||
lengthSum++;
|
||||
wireRecipes[i][3*j1+j2] = new PositionedItemStack(tinCable.copy(), 18*j1+xBase, 18*j2);
|
||||
} else {
|
||||
// wire coil
|
||||
int length = r.nextInt(99)+1;
|
||||
tmp = new ItemStack(IndustrialWires.coil);
|
||||
ItemIC2Coil.setLength(tmp, length);
|
||||
wireRecipes[i][3*j1+j2] = new PositionedItemStack(tmp, 18*j1+xBase, 18*j2);
|
||||
lengthSum+=length;
|
||||
}
|
||||
}
|
||||
}
|
||||
tmp = new ItemStack(IndustrialWires.coil);
|
||||
ItemIC2Coil.setLength(tmp, lengthSum);
|
||||
wireRecipes[i][9] = new PositionedItemStack(tmp, 18*4+xBase, 18);
|
||||
}
|
||||
m.addEntry("industrialWires.all", "industrialWires",
|
||||
new ManualPages.CraftingMulti(m, "industrialWires.all0", new ItemStack(IndustrialWires.coil, 1, 0), new ItemStack(IndustrialWires.coil, 1, 1), new ItemStack(IndustrialWires.coil, 1, 2), new ItemStack(IndustrialWires.coil, 1, 3)),
|
||||
new ManualPages.CraftingMulti(m, "industrialWires.all1", new ItemStack(IndustrialWires.ic2conn, 1, 0), new ItemStack(IndustrialWires.ic2conn, 1, 1), new ItemStack(IndustrialWires.ic2conn, 1, 2), new ItemStack(IndustrialWires.ic2conn, 1, 3),
|
||||
new ItemStack(IndustrialWires.ic2conn, 1, 4), new ItemStack(IndustrialWires.ic2conn, 1, 5), new ItemStack(IndustrialWires.ic2conn, 1, 6), new ItemStack(IndustrialWires.ic2conn, 1, 7))
|
||||
new ManualPages.CraftingMulti(m, "industrialWires.all0", new ItemStack(IndustrialWires.ic2conn, 1, 0), new ItemStack(IndustrialWires.ic2conn, 1, 1), new ItemStack(IndustrialWires.ic2conn, 1, 2), new ItemStack(IndustrialWires.ic2conn, 1, 3),
|
||||
new ItemStack(IndustrialWires.ic2conn, 1, 4), new ItemStack(IndustrialWires.ic2conn, 1, 5), new ItemStack(IndustrialWires.ic2conn, 1, 6), new ItemStack(IndustrialWires.ic2conn, 1, 7)),
|
||||
new ManualPages.Text(m, "industrialWires.all1"),
|
||||
new ManualPages.CraftingMulti(m, "industrialWires.all2", (Object[])wireRecipes)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
package malte0811.industrialWires.crafting;
|
||||
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.crafting.IRecipe;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class RecipeCoilLength implements IRecipe {
|
||||
public final ItemStack coil;
|
||||
public final ItemStack cable;
|
||||
final int maxLength;
|
||||
public RecipeCoilLength(int meta) {
|
||||
coil = new ItemStack(IndustrialWires.coil, 1, meta);
|
||||
cable = ItemIC2Coil.getUninsulatedCable(coil);
|
||||
maxLength = ItemIC2Coil.getMaxWireLength(coil);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(InventoryCrafting inv, World worldIn) {
|
||||
int l = getLength(inv);
|
||||
return l>0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getCraftingResult(InventoryCrafting inv) {
|
||||
ItemStack ret = new ItemStack(IndustrialWires.coil, 1, coil.getItemDamage());
|
||||
ItemIC2Coil.setLength(ret, Math.min(maxLength, getLength(inv)));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
|
||||
ItemStack[] ret = new ItemStack[inv.getSizeInventory()];
|
||||
int length = Math.min(getLength(inv), maxLength);
|
||||
for (int i = 0;i<ret.length&&length>0;i++) {
|
||||
ItemStack curr = inv.getStackInSlot(i);
|
||||
if (OreDictionary.itemMatches(curr, coil, false)) {
|
||||
length-=ItemIC2Coil.getLength(curr);
|
||||
if (length<0) {
|
||||
ret[i] = new ItemStack(IndustrialWires.coil, 1);
|
||||
ItemIC2Coil.setLength(ret[i], -length);
|
||||
}
|
||||
} else if (OreDictionary.itemMatches(curr, cable, false)) {
|
||||
length--;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
private int getLength(InventoryCrafting inv) {
|
||||
int cableLength = 0;
|
||||
for (int i = 0;i<inv.getSizeInventory();i++) {
|
||||
ItemStack curr = inv.getStackInSlot(i);
|
||||
if (OreDictionary.itemMatches(curr, coil, false)) {
|
||||
cableLength+=ItemIC2Coil.getLength(curr);
|
||||
} else if (OreDictionary.itemMatches(curr, cable, false)) {
|
||||
cableLength++;
|
||||
} else if (curr!=null) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return cableLength;
|
||||
}
|
||||
}
|
|
@ -16,6 +16,7 @@ import blusunrize.immersiveengineering.common.IESaveData;
|
|||
import blusunrize.immersiveengineering.common.util.IEAchievements;
|
||||
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import ic2.api.item.IC2Items;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
|
@ -24,6 +25,7 @@ import net.minecraft.creativetab.CreativeTabs;
|
|||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagInt;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumActionResult;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -34,7 +36,8 @@ import net.minecraft.util.text.TextComponentTranslation;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemIC2Coil extends Item implements IWireCoil{
|
||||
public final static String[] subNames = {"tin", "copper", "gold", "hv"};
|
||||
public final static String[] subNames = {"tin", "copper", "gold", "hv", "glass"};
|
||||
public final static String lengthKey = "wireLength";
|
||||
|
||||
public ItemIC2Coil() {
|
||||
setUnlocalizedName(IndustrialWires.MODID+".ic2wireCoil");
|
||||
|
@ -46,7 +49,9 @@ public class ItemIC2Coil extends Item implements IWireCoil{
|
|||
@Override
|
||||
public void getSubItems(Item itemIn, CreativeTabs tab, List<ItemStack> subItems) {
|
||||
for (int i = 0;i<subNames.length;i++) {
|
||||
subItems.add(new ItemStack(this, 1, i));
|
||||
ItemStack tmp = new ItemStack(this, 1, i);
|
||||
setLength(tmp, getMaxWireLength(tmp));
|
||||
subItems.add(tmp);
|
||||
}
|
||||
}
|
||||
@Override
|
||||
|
@ -59,6 +64,8 @@ public class ItemIC2Coil extends Item implements IWireCoil{
|
|||
}
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> list, boolean adv) {
|
||||
list.add(I18n.format(IndustrialWires.MODID+".desc.wireLength", getLength(stack)));
|
||||
list.add(I18n.format(IndustrialWires.MODID+".desc.recipe"));
|
||||
if(stack.getTagCompound()!=null && stack.getTagCompound().hasKey("linkingPos")) {
|
||||
int[] link = stack.getTagCompound().getIntArray("linkingPos");
|
||||
if(link!=null&&link.length>3) {
|
||||
|
@ -67,10 +74,13 @@ public class ItemIC2Coil extends Item implements IWireCoil{
|
|||
}
|
||||
}
|
||||
|
||||
//copied from "vanilla" IE
|
||||
@Override
|
||||
public EnumActionResult onItemUseFirst(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ, EnumHand hand) {
|
||||
if(!world.isRemote) {
|
||||
if (stack.stackSize>1) {
|
||||
player.addChatMessage(new TextComponentTranslation(IndustrialWires.MODID+".chat.stackSize"));
|
||||
return EnumActionResult.FAIL;
|
||||
}
|
||||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if(tileEntity instanceof IImmersiveConnectable && ((IImmersiveConnectable)tileEntity).canConnect()) {
|
||||
TargetingInfo target = new TargetingInfo(side, hitX,hitY,hitZ);
|
||||
|
@ -125,25 +135,35 @@ public class ItemIC2Coil extends Item implements IWireCoil{
|
|||
ignore.addAll(nodeLink.getIgnored(nodeHere));
|
||||
boolean canSee = Utils.rayTraceForFirst(rtOff0, rtOff1, world, ignore)==null;
|
||||
if(canSee) {
|
||||
TargetingInfo targetLink = TargetingInfo.readFromNBT(stack.getTagCompound());
|
||||
ImmersiveNetHandler.INSTANCE.addConnection(world, Utils.toCC(nodeHere), Utils.toCC(nodeLink), (int)Math.sqrt(distanceSq), type);
|
||||
int lengthOnStack = getLength(stack);
|
||||
int length = (int)Math.sqrt(distanceSq);
|
||||
if (length<=lengthOnStack) {
|
||||
TargetingInfo targetLink = TargetingInfo.readFromNBT(stack.getTagCompound());
|
||||
ImmersiveNetHandler.INSTANCE.addConnection(world, Utils.toCC(nodeHere), Utils.toCC(nodeLink), length, type);
|
||||
|
||||
nodeHere.connectCable(type, target, nodeLink);
|
||||
nodeLink.connectCable(type, targetLink, nodeHere);
|
||||
IESaveData.setDirty(world.provider.getDimension());
|
||||
player.addStat(IEAchievements.connectWire);
|
||||
nodeHere.connectCable(type, target, nodeLink);
|
||||
nodeLink.connectCable(type, targetLink, nodeHere);
|
||||
IESaveData.setDirty(world.provider.getDimension());
|
||||
player.addStat(IEAchievements.connectWire);
|
||||
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
stack.stackSize--;
|
||||
if(!player.capabilities.isCreativeMode) {
|
||||
if (length<lengthOnStack) {
|
||||
setLength(stack, lengthOnStack-length);
|
||||
} else {
|
||||
player.setHeldItem(hand, null);
|
||||
}
|
||||
}
|
||||
((TileEntity)nodeHere).markDirty();
|
||||
world.addBlockEvent(masterPos, ((TileEntity) nodeHere).getBlockType(), -1, 0);
|
||||
IBlockState state = world.getBlockState(masterPos);
|
||||
world.notifyBlockUpdate(masterPos, state,state, 3);
|
||||
((TileEntity)nodeLink).markDirty();
|
||||
world.addBlockEvent(linkPos, ((TileEntity) nodeLink).getBlockType(), -1, 0);
|
||||
state = world.getBlockState(linkPos);
|
||||
world.notifyBlockUpdate(linkPos, state,state, 3);
|
||||
} else {
|
||||
player.addChatMessage(new TextComponentTranslation(IndustrialWires.MODID+".chat.tooLong"));
|
||||
}
|
||||
((TileEntity)nodeHere).markDirty();
|
||||
world.addBlockEvent(masterPos, ((TileEntity) nodeHere).getBlockType(), -1, 0);
|
||||
IBlockState state = world.getBlockState(masterPos);
|
||||
world.notifyBlockUpdate(masterPos, state,state, 3);
|
||||
((TileEntity)nodeLink).markDirty();
|
||||
world.addBlockEvent(linkPos, ((TileEntity) nodeLink).getBlockType(), -1, 0);
|
||||
state = world.getBlockState(linkPos);
|
||||
world.notifyBlockUpdate(linkPos, state,state, 3);
|
||||
} else {
|
||||
player.addChatMessage(new TextComponentTranslation(Lib.CHAT_WARN+"cantSee"));
|
||||
}
|
||||
|
@ -160,4 +180,35 @@ public class ItemIC2Coil extends Item implements IWireCoil{
|
|||
}
|
||||
return EnumActionResult.PASS;
|
||||
}
|
||||
@Override
|
||||
public int getItemStackLimit(ItemStack stack) {
|
||||
return 64;
|
||||
}
|
||||
public static void setLength(ItemStack i, int blocks) {
|
||||
i.setTagInfo(lengthKey, new NBTTagInt(blocks));
|
||||
}
|
||||
public static int getLength(ItemStack i) {
|
||||
if (i.getTagCompound()==null) {
|
||||
setLength(i, 4);
|
||||
}
|
||||
return i.getTagCompound().getInteger(lengthKey);
|
||||
}
|
||||
public static int getMaxWireLength(ItemStack i) {
|
||||
return 64*IC2Wiretype.IC2_TYPES[i.getItemDamage()].getMaxLength();
|
||||
}
|
||||
public static ItemStack getUninsulatedCable(ItemStack i) {
|
||||
switch (i.getMetadata()) {
|
||||
case 0:
|
||||
return IC2Items.getItem("cable", "type:tin,insulation:0");
|
||||
case 1:
|
||||
return IC2Items.getItem("cable", "type:copper,insulation:0");
|
||||
case 2:
|
||||
return IC2Items.getItem("cable", "type:gold,insulation:0");
|
||||
case 3:
|
||||
return IC2Items.getItem("cable", "type:iron,insulation:0");
|
||||
case 4:
|
||||
return IC2Items.getItem("cable", "type:glass,insulation:0");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package malte0811.industrialWires.wires;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
@ -10,12 +12,12 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
public class IC2Wiretype extends WireType{
|
||||
final int type;
|
||||
final int[] ic2Rates = {32*8, 128*8, 512*8, 2048*8};
|
||||
final int[] ic2Colors = {0xa5bcc7, 0xbc7945, 0xfeff73, 0xb9d6d9};
|
||||
final String[] ic2Names = {"ic2Tin", "ic2Copper", "ic2Gold", "ic2Hv"};
|
||||
final double[] lossPerBlock = {.2, .2, .4, .8};
|
||||
final double[] ic2RenderDiameter = {.03125, .03125, .046875, .0625};
|
||||
public static final IC2Wiretype[] IC2_TYPES = {new IC2Wiretype(0), new IC2Wiretype(1), new IC2Wiretype(2), new IC2Wiretype(3)};
|
||||
final int[] ic2Rates = {32*8, 128*8, 512*8, 2048*8, 8192*8};
|
||||
final int[] ic2Colors = {0xa5bcc7, 0xbc7945, 0xfeff73, 0xb9d6d9, 0xf1f1f1};
|
||||
final String[] ic2Names = {"ic2Tin", "ic2Copper", "ic2Gold", "ic2Hv", "ic2Glass"};
|
||||
final double[] lossPerBlock = {.2, .2, .4, .8, .025};
|
||||
final double[] ic2RenderDiameter = {.03125, .03125, .046875, .0625, .75*.03125};
|
||||
public static final IC2Wiretype[] IC2_TYPES = {new IC2Wiretype(0), new IC2Wiretype(1), new IC2Wiretype(2), new IC2Wiretype(3), new IC2Wiretype(4)};
|
||||
public IC2Wiretype(int ordinal) {
|
||||
super();
|
||||
this.type = ordinal;
|
||||
|
@ -49,6 +51,12 @@ public class IC2Wiretype extends WireType{
|
|||
return type==3?32:16;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getWireCoil(ImmersiveNetHandler.Connection con) {
|
||||
ItemStack ret = getWireCoil();
|
||||
ItemIC2Coil.setLength(ret, con.length);
|
||||
return ret;
|
||||
}
|
||||
@Override
|
||||
public ItemStack getWireCoil() {
|
||||
return new ItemStack(IndustrialWires.coil,1,type);
|
||||
}
|
||||
|
|
|
@ -132,8 +132,39 @@
|
|||
"inventory,type=hv_relay": [
|
||||
{
|
||||
"model": "immersiveengineering:connector/relayHV.obj",
|
||||
"transform": {
|
||||
"scale": [ 0.5, 0.5, 0.5 ],
|
||||
"firstperson_righthand": { "translation": [ 0, 0.25, 0.125 ]},
|
||||
"firstperson_lefthand": { "translation": [ 0, 0.25, 0.125 ]},
|
||||
"thirdperson_righthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
|
||||
"thirdperson_lefthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
|
||||
"fixed": {"scale": [ 2,2,2 ], "translation": [ 0, 0, 0 ], "rotation": [{ "y": -90 }]},
|
||||
"gui": { "translation": [ 0, 0.125, 0 ], "rotation": [{ "x": 30 },{ "y": 135 },{ "z": 0 }], "scale": [ 1.5, 1.5, 1.5 ] }
|
||||
}
|
||||
}
|
||||
],
|
||||
"inventory,type=glass_conn": [
|
||||
{
|
||||
"model": "immersiveengineering:connector/connectorHV.obj",
|
||||
"textures": {
|
||||
"#immersiveengineering:blocks/connector_relayHV": "industrialwires:blocks/ic2_relayHV"
|
||||
"#immersiveengineering:blocks/connector_connectorHV": "industrialwires:blocks/ic2_connGlass"
|
||||
},
|
||||
"transform": {
|
||||
"scale": [ 0.5, 0.5, 0.5 ],
|
||||
"firstperson_righthand": { "translation": [ 0, 0.25, 0.125 ]},
|
||||
"firstperson_lefthand": { "translation": [ 0, 0.25, 0.125 ]},
|
||||
"thirdperson_righthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
|
||||
"thirdperson_lefthand": { "translation": [ -0.0625, 0.125, 0.1875 ], "rotation": [{ "x": 70 }, { "y": 70 }]},
|
||||
"fixed": {"scale": [ 2,2,2 ], "translation": [ 0, 0, 0 ], "rotation": [{ "y": -90 }]},
|
||||
"gui": { "translation": [ 0, 0.125, 0 ], "rotation": [{ "x": 30 },{ "y": 135 },{ "z": 0 }], "scale": [ 1.5, 1.5, 1.5 ] }
|
||||
}
|
||||
}
|
||||
],
|
||||
"inventory,type=glass_relay": [
|
||||
{
|
||||
"model": "immersiveengineering:connector/relayHV.obj",
|
||||
"textures": {
|
||||
"#immersiveengineering:blocks/connector_relayHV": "industrialwires:blocks/ic2_relayGlass"
|
||||
},
|
||||
"transform": {
|
||||
"scale": [ 0.5, 0.5, 0.5 ],
|
||||
|
@ -170,6 +201,12 @@
|
|||
},
|
||||
"hv_relay": {
|
||||
"model": "immersiveengineering:smartmodel/conn_ic2_relay_hv"
|
||||
},
|
||||
"glass_conn": {
|
||||
"model": "immersiveengineering:smartmodel/conn_ic2_conn_glass"
|
||||
},
|
||||
"glass_relay": {
|
||||
"model": "immersiveengineering:smartmodel/conn_ic2_relay_glass"
|
||||
}
|
||||
},
|
||||
"facing": {
|
||||
|
|
|
@ -6,13 +6,25 @@ tile.industrialwires.ic2Connector.gold_conn.name=Gold Wire Connector
|
|||
tile.industrialwires.ic2Connector.gold_relay.name=Gold Wire Relay
|
||||
tile.industrialwires.ic2Connector.hv_conn.name=IC2 HV Wire Connector
|
||||
tile.industrialwires.ic2Connector.hv_relay.name=IC2 HV Wire Relay
|
||||
tile.industrialwires.ic2Connector.glass_conn.name=Glass Fiber Wire Connector
|
||||
tile.industrialwires.ic2Connector.glass_relay.name=Glass Fiber Wire Relay
|
||||
|
||||
item.industrialwires.ic2wireCoil.tin.name=Tin Wire Coil
|
||||
item.industrialwires.ic2wireCoil.copper.name=Copper Wire Coil
|
||||
item.industrialwires.ic2wireCoil.gold.name=Gold Wire Coil
|
||||
item.industrialwires.ic2wireCoil.hv.name=IC2 HV Wire Coil
|
||||
item.industrialwires.ic2wireCoil.glass.name=Glass Fiber Wire Coil
|
||||
|
||||
industrialwires.desc.wireLength=Wire length: %1s block(s)
|
||||
industrialwires.desc.recipe=Please check the Engineer's manual for recipe details
|
||||
|
||||
industrialwires.chat.tooLong=This coil does not contain enough wire for this connection
|
||||
industrialwires.chat.stackSize=Linking is only possible with a stack of size 1
|
||||
|
||||
|
||||
ie.manual.category.industrialWires.name=Industrial Wires
|
||||
ie.manual.entry.industrialWires.all.name=Industrial Wires
|
||||
ie.manual.entry.industrialWires.all.subtext=Everything you need to know
|
||||
ie.manual.entry.industrialWires.all0=Wires from the IndustrialWires company allow you to transfer energy like you can with cables from the IndustrialCraft2 company.<br>You use them exactly as you would use wires from Immersive Engineering. Each wire transfers as much EU as the corresponding cable would,
|
||||
ie.manual.entry.industrialWires.all1=so attaching a connector to a power source that would destroy the cable will destroy the connector.
|
||||
ie.manual.entry.industrialWires.all0=Wires from the IndustrialWires company allow you to transfer energy like you can with cables from the IndustrialCraft2 company.<br>You use them exactly as you would use wires from Immersive Engineering. Each wire transfers as much EU as the corresponding cable would, so
|
||||
ie.manual.entry.industrialWires.all1=attaching a connector to a power source that would destroy the cable will destroy the connector.<br>The wire coils for the IC2 cable are different from the Immersive Engineering wire coils in that longer connections use up more wire: The coils are crafted by placing any combination of uninsulated IC2 cables and the corresponding wire coils in a crafting grid. The next page shows some examples of valid recipes and their outputs. The uninsulated
|
||||
ie.manual.entry.industrialWires.all2=tin cables can be replaced by uninsulated copper, gold or HV cables or by glass fiber cable to craft the other coils.
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"parent":"item/generated",
|
||||
"textures": {
|
||||
"layer0":"industrialwires:items/ic2_wireGlass"
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 444 B |
Binary file not shown.
After Width: | Height: | Size: 622 B |
Binary file not shown.
Before Width: | Height: | Size: 609 B |
Binary file not shown.
After Width: | Height: | Size: 664 B |
Binary file not shown.
Before Width: | Height: | Size: 649 B After Width: | Height: | Size: 688 B |
Loading…
Reference in New Issue