IW's items show up in the creative search now

Coil length crafting now leaves the correct coil behind if the length is over the maximum
This commit is contained in:
malte0811 2017-07-10 20:30:18 +02:00
parent 9ee44021bc
commit 6f6edab7b1
11 changed files with 30 additions and 44 deletions

View file

@ -72,9 +72,9 @@ public class IndustrialWires {
public static BlockPanel panel;
public static final ItemIC2Coil coil = new ItemIC2Coil();
public static final ItemPanelComponent panelComponent = new ItemPanelComponent();
public static final ItemKey key = new ItemKey();
public static ItemIC2Coil coil;
public static ItemPanelComponent panelComponent;
public static ItemKey key;
public static final SimpleNetworkWrapper packetHandler = NetworkRegistry.INSTANCE.newSimpleChannel(MODID);
public static Logger logger;
@ -101,6 +101,10 @@ public class IndustrialWires {
jacobsLadder = new BlockJacobsLadder();
panel = new BlockPanel();
coil = new ItemIC2Coil();
panelComponent = new ItemPanelComponent();
key = new ItemKey();
GameRegistry.registerTileEntity(TileEntityIC2ConnectorTin.class, MODID + "ic2ConnectorTin");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorCopper.class, MODID + "ic2ConnectorCopper");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGold.class, MODID + "ic2ConnectorGold");
@ -122,7 +126,6 @@ public class IndustrialWires {
@SubscribeEvent
public static void registerBlocks(RegistryEvent.Register<Block> event) {
for (BlockIWBase b: blocks) {
logger.info(b.getRegistryName());
event.getRegistry().register(b);
}
}

View file

@ -81,10 +81,8 @@ public class BlockJacobsLadder extends BlockIWBase implements IMetaEnum, IPlacem
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
if (tab== IndustrialWires.creativeTab) {
for (int i = 0; i < LadderSize.values().length; i++) {
list.add(new ItemStack(this, 1, i));
}
for (int i = 0; i < LadderSize.values().length; i++) {
list.add(new ItemStack(this, 1, i));
}
}

View file

@ -18,6 +18,7 @@
package malte0811.industrialWires.blocks;
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces;
import malte0811.industrialWires.IndustrialWires;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
@ -42,6 +43,7 @@ public class ItemBlockIW extends ItemBlock {
}
hasSubtypes = true;
setRegistryName(b.getRegistryName());
setCreativeTab(IndustrialWires.creativeTab);
}
@Nonnull

View file

@ -155,10 +155,8 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
if (tab==IndustrialWires.creativeTab) {
for (int i = 0; i < BlockTypes_Panel.values().length; i++) {
list.add(new ItemStack(this, 1, i));
}
for (int i = 0; i < BlockTypes_Panel.values().length; i++) {
list.add(new ItemStack(this, 1, i));
}
}

View file

@ -49,10 +49,8 @@ public class BlockMechanicalConverter extends BlockIWBase implements IMetaEnum {
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
if (tab== IndustrialWires.creativeTab) {
for (int i = 0; i < 3; i++) {
list.add(new ItemStack(this, 1, i));
}
for (int i = 0; i < 3; i++) {
list.add(new ItemStack(this, 1, i));
}
}

View file

@ -72,10 +72,8 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
@Override
public void getSubBlocks(CreativeTabs tab, NonNullList<ItemStack> list) {
if (tab==IndustrialWires.creativeTab) {
for (int i = 0; i < type.getAllowedValues().size(); i++) {
list.add(new ItemStack(this, 1, i));
}
for (int i = 0; i < type.getAllowedValues().size(); i++) {
list.add(new ItemStack(this, 1, i));
}
}

View file

@ -82,7 +82,7 @@ public class RecipeCoilLength extends IForgeRegistryEntry.Impl<IRecipe> implemen
if (OreDictionary.itemMatches(curr, coil, false)) {
length -= ItemIC2Coil.getLength(curr);
if (length < 0) {
ItemStack currStack = new ItemStack(IndustrialWires.coil, 1);
ItemStack currStack = coil.copy();
ret.set(i, currStack);
ItemIC2Coil.setLength(currStack, -length);
}
@ -145,7 +145,6 @@ public class RecipeCoilLength extends IForgeRegistryEntry.Impl<IRecipe> implemen
}
@Override
public boolean apply(@Nullable ItemStack input) {
IndustrialWires.logger.info(input);
if (input == null)
return false;
for (ItemStack stack:getMatchingStacks()) {

View file

@ -2,9 +2,10 @@ package malte0811.industrialWires.crafting.factories;
import com.google.gson.JsonObject;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.IndustrialWires;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.common.crafting.IIngredientFactory;
import net.minecraftforge.common.crafting.IngredientNBT;
import net.minecraftforge.common.crafting.JsonContext;
import javax.annotation.Nonnull;
@ -15,6 +16,12 @@ public class IC2ItemFactory implements IIngredientFactory {
public Ingredient parse(JsonContext context, JsonObject json) {
String name = json.get("name").getAsString();
String variant = json.get("variant").getAsString();
return Ingredient.fromStacks(IC2Items.getItem(name, variant));
return new MyNBTIngredient(IC2Items.getItem(name, variant));
}
private class MyNBTIngredient extends IngredientNBT {
public MyNBTIngredient(ItemStack stack) {
super(stack);
}
}
}

View file

@ -68,7 +68,7 @@ public class ItemIC2Coil extends Item implements IWireCoil {
@Override
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
if (tab==IndustrialWires.creativeTab) {
if (isInCreativeTab(tab)) {
for (int i = 0; i < subNames.length; i++) {
ItemStack tmp = new ItemStack(this, 1, i);
setLength(tmp, getMaxWireLength(tmp));
@ -228,21 +228,4 @@ public class ItemIC2Coil extends Item implements IWireCoil {
public static int getMaxWireLength(ItemStack i) {
return IWConfig.maxLengthOnCoil[i.getItemDamage()];
}
public static ItemStack getUninsulatedCable(String name) {
return IC2Items.getItem("cable", "type:"+name+",insulation:0");
/*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;*/
}
}

View file

@ -61,7 +61,7 @@ public class ItemKey extends Item implements INetGUIItem {
@Override
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
if (tab==IndustrialWires.creativeTab) {
if (isInCreativeTab(tab)) {
subItems.add(new ItemStack(this, 1, 0));
subItems.add(new ItemStack(this, 1, 2));
}

View file

@ -87,7 +87,7 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
@Override
public void getSubItems(@Nonnull CreativeTabs tab, @Nonnull NonNullList<ItemStack> subItems) {
if (tab==IndustrialWires.creativeTab) {
if (isInCreativeTab(tab)) {
for (int i = 0; i < types.length; i++) {
subItems.add(new ItemStack(this, 1, i));
}