Added documentation on the key ring and fixed some bugs with it
Backported other fixes from 1.12
This commit is contained in:
parent
f8f53d2434
commit
9b9d3edc40
|
@ -95,7 +95,8 @@ public class Recipes {
|
|||
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 RecipeKeyRing());
|
||||
GameRegistry.addRecipe(new RecipeKeyRing(true));
|
||||
GameRegistry.addRecipe(new RecipeKeyRing(false));
|
||||
GameRegistry.addRecipe(new RecipeComponentCopy());
|
||||
for (int i = 0; i < IC2Wiretype.IC2_TYPES.length; i++) {
|
||||
GameRegistry.addRecipe(new RecipeCoilLength(i));
|
||||
|
@ -141,6 +142,7 @@ public class Recipes {
|
|||
"rrp", 'r', "stickSteel", 'p', "plateSteel"));
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 8),
|
||||
"wireCopper", new ItemStack(IEContent.itemTool, 1, 2)));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(key, 1, 2), " r ", "r r", " r ", 'r', "stickSteel"));
|
||||
}
|
||||
private static void addJacobs() {
|
||||
ItemStack mvTransformer = IC2Items.getItem("te", "mv_transformer");
|
||||
|
|
|
@ -213,6 +213,7 @@ public class ClientProxy extends CommonProxy {
|
|||
);
|
||||
}
|
||||
Config.manual_doubleA.put("iwJacobsUsage", IWConfig.HVStuff.jacobsUsageEU);
|
||||
Config.manual_int.put("iwKeysOnRing", IWConfig.maxKeysOnRing);
|
||||
m.addEntry("industrialwires.jacobs", "industrialwires",
|
||||
new ManualPages.CraftingMulti(m, "industrialwires.jacobs0", new ItemStack(IndustrialWires.jacobsLadder, 1, 0), new ItemStack(IndustrialWires.jacobsLadder, 1, 1), new ItemStack(IndustrialWires.jacobsLadder, 1, 2)),
|
||||
new ManualPages.Text(m, "industrialwires.jacobs1"));
|
||||
|
@ -245,6 +246,7 @@ public class ClientProxy extends CommonProxy {
|
|||
new ManualPages.Text(m, "industrialwires.toggle_switch1"),
|
||||
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)),
|
||||
new ManualPages.Crafting(m, "industrialwires.lock1", new ItemStack(IndustrialWires.key, 1, 2)),
|
||||
new ManualPages.Crafting(m, "industrialwires.panel_meter", new ItemStack(IndustrialWires.panelComponent, 1, 8))
|
||||
);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ public class RecipeCoilLength implements IRecipe {
|
|||
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);
|
||||
}
|
||||
|
|
|
@ -28,53 +28,58 @@ import net.minecraft.util.NonNullList;
|
|||
import net.minecraft.world.World;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
import static malte0811.industrialWires.items.ItemKey.*;
|
||||
|
||||
public class RecipeKeyRing implements IRecipe {
|
||||
|
||||
private final boolean addToRing;
|
||||
public RecipeKeyRing(boolean add) {
|
||||
addToRing = add;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
|
||||
return getType(inv) != null;
|
||||
return isValid(inv);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
|
||||
Boolean recipeType = getType(inv);
|
||||
if (recipeType==Boolean.TRUE) {//add key to ring
|
||||
ItemStack ring = inv.getStackInSlot(getRingPos(inv)).copy();
|
||||
NBTTagCompound nbt = ring.getTagCompound();
|
||||
ItemStack key = inv.getStackInSlot(getKeyPos(inv));
|
||||
NBTTagCompound keyNBT = key.getTagCompound();
|
||||
if (nbt==null) {
|
||||
nbt = new NBTTagCompound();
|
||||
ring.setTagCompound(nbt);
|
||||
}
|
||||
if (!nbt.hasKey(RING_KEYS)) {
|
||||
nbt.setTag(RING_KEYS, new NBTTagList());
|
||||
}
|
||||
if (keyNBT!=null) {
|
||||
NBTTagList keys = nbt.getTagList(RING_KEYS, 10);
|
||||
if (keys.tagCount()>= IWConfig.maxKeysOnRing) {
|
||||
return ItemStack.EMPTY;
|
||||
if (isValid(inv)) {
|
||||
if (addToRing) {//add key to ring
|
||||
ItemStack ring = inv.getStackInSlot(getRingPos(inv)).copy();
|
||||
NBTTagCompound nbt = ring.getTagCompound();
|
||||
ItemStack key = inv.getStackInSlot(getKeyPos(inv));
|
||||
NBTTagCompound keyNBT = key.getTagCompound();
|
||||
if (nbt == null) {
|
||||
nbt = new NBTTagCompound();
|
||||
ring.setTagCompound(nbt);
|
||||
}
|
||||
keys.appendTag(keyNBT.copy());
|
||||
nbt.setInteger(LOCK_ID, keyNBT.getInteger(LOCK_ID));
|
||||
nbt.setString(NAME, keyNBT.getString(NAME));
|
||||
}
|
||||
return ring;
|
||||
} else {//remove key from ring
|
||||
ItemStack ring = inv.getStackInSlot(getRingPos(inv)).copy();
|
||||
NBTTagCompound nbt = ring.getTagCompound();
|
||||
ItemStack key = new ItemStack(IndustrialWires.key, 1, 1);
|
||||
if (nbt!=null) {
|
||||
NBTTagList keys = nbt.getTagList(RING_KEYS, 10);
|
||||
if (keys.tagCount()>0) {
|
||||
NBTTagCompound first = keys.getCompoundTagAt(keys.tagCount()-1);
|
||||
key.setTagCompound(first);
|
||||
return key;
|
||||
if (!nbt.hasKey(RING_KEYS)) {
|
||||
nbt.setTag(RING_KEYS, new NBTTagList());
|
||||
}
|
||||
if (keyNBT != null) {
|
||||
NBTTagList keys = nbt.getTagList(RING_KEYS, 10);
|
||||
if (keys.tagCount() >= IWConfig.maxKeysOnRing) {
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
keys.appendTag(keyNBT.copy());
|
||||
nbt.setInteger(LOCK_ID, keyNBT.getInteger(LOCK_ID));
|
||||
nbt.setString(NAME, keyNBT.getString(NAME));
|
||||
}
|
||||
return ring;
|
||||
} else {//remove key from ring
|
||||
ItemStack ring = inv.getStackInSlot(getRingPos(inv)).copy();
|
||||
NBTTagCompound nbt = ring.getTagCompound();
|
||||
ItemStack key = new ItemStack(IndustrialWires.key, 1, 1);
|
||||
if (nbt != null) {
|
||||
NBTTagList keys = nbt.getTagList(RING_KEYS, 10);
|
||||
if (keys.tagCount() > 0) {
|
||||
NBTTagCompound first = keys.getCompoundTagAt(keys.tagCount() - 1);
|
||||
key.setTagCompound(first);
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -83,20 +88,20 @@ public class RecipeKeyRing implements IRecipe {
|
|||
|
||||
@Override
|
||||
public int getRecipeSize() {
|
||||
return 2;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack getRecipeOutput() {
|
||||
return ItemStack.EMPTY;
|
||||
return new ItemStack(IndustrialWires.key, 1, addToRing?2:1);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public NonNullList<ItemStack> getRemainingItems(@Nonnull InventoryCrafting inv) {
|
||||
NonNullList<ItemStack> ret = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
|
||||
if (getType(inv)==Boolean.FALSE) {
|
||||
if (!addToRing) {
|
||||
int ringId = getRingPos(inv);
|
||||
ItemStack ring = inv.getStackInSlot(ringId).copy();
|
||||
NBTTagCompound nbt = ring.getTagCompound();
|
||||
|
@ -105,6 +110,8 @@ public class RecipeKeyRing implements IRecipe {
|
|||
keys.removeTag(keys.tagCount()-1);
|
||||
if (keys.tagCount() > 0) {
|
||||
NBTTagCompound first = keys.getCompoundTagAt(0);
|
||||
keys.removeTag(0);
|
||||
keys.appendTag(first);
|
||||
nbt.setInteger(LOCK_ID, first.getInteger(LOCK_ID));
|
||||
nbt.setString(NAME, first.getString(NAME));
|
||||
} else {
|
||||
|
@ -117,8 +124,7 @@ public class RecipeKeyRing implements IRecipe {
|
|||
return ret;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private Boolean getType(@Nonnull InventoryCrafting inv) {
|
||||
private boolean isValid(@Nonnull InventoryCrafting inv) {
|
||||
boolean hasRing = false;
|
||||
boolean hasKey = false;
|
||||
for (int i = 0;i<inv.getSizeInventory();i++) {
|
||||
|
@ -131,12 +137,16 @@ public class RecipeKeyRing implements IRecipe {
|
|||
hasRing = true;
|
||||
continue;
|
||||
}
|
||||
return null;
|
||||
return false;
|
||||
} else if (!here.isEmpty()) {
|
||||
return null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return hasRing?hasKey:null;
|
||||
if (addToRing) {
|
||||
return hasKey&&hasRing;
|
||||
} else {
|
||||
return !hasKey&&hasRing;
|
||||
}
|
||||
}
|
||||
|
||||
private int getRingPos(@Nonnull InventoryCrafting inv) {
|
||||
|
|
|
@ -33,6 +33,7 @@ import net.minecraft.world.World;
|
|||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import java.util.List;
|
||||
|
||||
public class ItemKey extends Item implements INetGUIItem {
|
||||
public static final String LOCK_ID = "lockId";
|
||||
|
@ -60,15 +61,25 @@ public class ItemKey extends Item implements INetGUIItem {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void getSubItems(Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
public void getSubItems(@Nonnull Item itemIn, CreativeTabs tab, NonNullList<ItemStack> subItems) {
|
||||
subItems.add(new ItemStack(this, 1, 0));
|
||||
subItems.add(new ItemStack(this, 1, 2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List<String> tooltip, boolean advanced) {
|
||||
super.addInformation(stack, player, tooltip, advanced);
|
||||
if (stack.getMetadata()==2&&stack.getTagCompound()!=null) {
|
||||
NBTTagList keys = stack.getTagCompound().getTagList(RING_KEYS, 10);
|
||||
for (int i = 0;i< keys.tagCount()-1;i++) {
|
||||
tooltip.add(I18n.format("item."+IndustrialWires.MODID+".key.key_named.name")+" "+keys.getCompoundTagAt(i).getString(NAME));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getUnlocalizedName(ItemStack stack) {
|
||||
NBTTagCompound nbt = stack.getTagCompound();
|
||||
return "item."+IndustrialWires.MODID+".key."+types[stack.getMetadata()];
|
||||
}
|
||||
|
||||
|
|
|
@ -142,4 +142,5 @@ ie.manual.entry.industrialwires.toggle_switch=A switch to turn a signal on or of
|
|||
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.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.
|
||||
ie.manual.entry.industrialwires.lock1=Up to <config;I;iwKeysOnRing> can be combined on a key ring. Keys are added to the ring by placing both in a crafting table. Shift-right-click the key ring to cycle through the keys on the ring. The selected key can be removed from the ring by placing the ring in a crafting table. The key ring will work just as the selected key would on lock switches.
|
||||
ie.manual.entry.industrialwires.panel_meter=A panel meter can be used to show display analog redstone signals with some accuracy. Panel meters are available in two different formats, wide and narrow. The wide format gives a slightly bigger angle between redstone level 0 and 15, but is more typical for Multimeters that for panel meters.
|
Loading…
Reference in a new issue