Compare commits

...

5 commits

Author SHA1 Message Date
malte0811 e500ba0a7c Build 1.4-19 2017-08-14 18:52:33 +02:00
malte0811 baa091b9a4 Don't interact with other TE's in onChunkUnload, closes #12 2017-08-13 22:14:56 +02:00
malte0811 a42a662a06 Build 15-17 2017-08-04 19:18:12 +02:00
malte0811 9b9d3edc40 Added documentation on the key ring and fixed some bugs with it
Backported other fixes from 1.12
2017-08-04 18:18:50 +02:00
malte0811 f8f53d2434 One more fix for connecting panels using connectors after the panel and the controller have been placed 2017-08-04 18:00:28 +02:00
19 changed files with 122 additions and 75 deletions

View file

@ -1,5 +1,5 @@
def mainVersion = "1.5" def mainVersion = "1.5"
def buildNumber = "13" def buildNumber = "19"
// For those who want the bleeding edge // For those who want the bleeding edge
buildscript { buildscript {
@ -30,7 +30,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8 targetCompatibility = 1.8
minecraft { minecraft {
version = "13.20.0.2282" version = "13.20.1.2393"
runDir = "run" runDir = "run"
replace '${version}', project.version replace '${version}', project.version
@ -60,6 +60,23 @@ jar {
} }
} }
task signMain(type: SignJar) {
onlyIf {
project.hasProperty('keyStore')
}
dependsOn reobfJar
if (project.hasProperty('keyStore')) {
keyStore = project.keyStore
alias = project.storeAlias
storePass = project.storePass
keyPass = project.storePass
inputFile = jar.archivePath
outputFile = jar.archivePath
}
}
build.dependsOn signMain
processResources processResources
{ {
// this will ensure that this task is redone when the versions change. // this will ensure that this task is redone when the versions change.

View file

@ -1,3 +1,10 @@
#####Version 1.4-19
- Fixed a crash with SpongeForge, chunk loading issues without
- Fixed some components resetting on chunk unload
#####Version 1.5-17
- Backported some fixes from 1.12
#####Version 1.5-13 #####Version 1.5-13
- Labels no longer break the model cache and cause lag - Labels no longer break the model cache and cause lag
- Labels don't break on dedicated servers any more - Labels don't break on dedicated servers any more

View file

@ -48,7 +48,8 @@ import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.Side;
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies = "required-after:immersiveengineering@[0.10-58,);required-after:ic2") @Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies = "required-after:immersiveengineering@[0.10-58,);required-after:ic2",
certificateFingerprint = "7e11c175d1e24007afec7498a1616bef0000027d")
public class IndustrialWires { public class IndustrialWires {
public static final String MODID = "industrialwires"; public static final String MODID = "industrialwires";
public static final String VERSION = "${version}"; public static final String VERSION = "${version}";

View file

@ -95,7 +95,8 @@ public class Recipes {
RecipeSorter.register("industrialwires:coilLength", RecipeCoilLength.class, RecipeSorter.Category.SHAPELESS, "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"); RecipeSorter.register("industrialwires:init_pc", RecipeInitPC.class, RecipeSorter.Category.SHAPED, "after:forge:shapedore");
GameRegistry.addRecipe(new RecipeKeyLock()); GameRegistry.addRecipe(new RecipeKeyLock());
GameRegistry.addRecipe(new RecipeKeyRing()); GameRegistry.addRecipe(new RecipeKeyRing(true));
GameRegistry.addRecipe(new RecipeKeyRing(false));
GameRegistry.addRecipe(new RecipeComponentCopy()); GameRegistry.addRecipe(new RecipeComponentCopy());
for (int i = 0; i < IC2Wiretype.IC2_TYPES.length; i++) { for (int i = 0; i < IC2Wiretype.IC2_TYPES.length; i++) {
GameRegistry.addRecipe(new RecipeCoilLength(i)); GameRegistry.addRecipe(new RecipeCoilLength(i));
@ -141,6 +142,7 @@ public class Recipes {
"rrp", 'r', "stickSteel", 'p', "plateSteel")); "rrp", 'r', "stickSteel", 'p', "plateSteel"));
GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 8), GameRegistry.addRecipe(new ShapelessOreRecipe(new ItemStack(panelComponent, 1, 8),
"wireCopper", new ItemStack(IEContent.itemTool, 1, 2))); "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() { private static void addJacobs() {
ItemStack mvTransformer = IC2Items.getItem("te", "mv_transformer"); ItemStack mvTransformer = IC2Items.getItem("te", "mv_transformer");

View file

@ -57,6 +57,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
public boolean firstTick = true; public boolean firstTick = true;
// non-rendered properties // non-rendered properties
private Set<TileEntityRSPanelConn> rsPorts = new HashSet<>(); private Set<TileEntityRSPanelConn> rsPorts = new HashSet<>();
private boolean renderUpdate;
{ {
for (int i = 2; i < 14; i++) { for (int i = 2; i < 14; i++) {
@ -95,6 +96,13 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
} }
firstTick = false; firstTick = false;
} }
if (renderUpdate) {
IBlockState state = world.getBlockState(pos);
world.notifyBlockUpdate(pos, state, state, 3);
world.addBlockEvent(pos, state.getBlock(), 255, 0);
markDirty();
renderUpdate = false;
}
} }
} }
@ -277,9 +285,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
} }
public void triggerRenderUpdate() { public void triggerRenderUpdate() {
IBlockState state = world.getBlockState(pos); renderUpdate = true;
world.notifyBlockUpdate(pos, state, state, 3);
world.addBlockEvent(pos, state.getBlock(), 255, 0);
} }
public void registerRS(TileEntityRSPanelConn te) { public void registerRS(TileEntityRSPanelConn te) {
@ -303,7 +309,7 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
public void removeAllRSCons() { public void removeAllRSCons() {
for (TileEntityRSPanelConn rs : rsPorts) { for (TileEntityRSPanelConn rs : rsPorts) {
rs.unregisterPanel(this, true); rs.unregisterPanel(this, true, false);
} }
rsPorts.clear(); rsPorts.clear();
firstTick = true; firstTick = true;

View file

@ -166,7 +166,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
Consumer<byte[]> listener = pc.getRSInputHandler(id, panel); Consumer<byte[]> listener = pc.getRSInputHandler(id, panel);
if (listener != null) { if (listener != null) {
changeListeners.add(listener); changeListeners.add(listener);
listener.accept(out); listener.accept(network.channelValues);
} }
pc.registerRSOutput(id, rsOut); pc.registerRSOutput(id, rsOut);
} }
@ -174,19 +174,21 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
connectedPanels.add(panel); connectedPanels.add(panel);
} }
public void unregisterPanel(TileEntityPanel panel, boolean remove) { public void unregisterPanel(TileEntityPanel panel, boolean remove, boolean callPanel) {
out = new byte[16]; out = new byte[16];
PropertyComponents.PanelRenderProperties p = panel.getComponents(); PropertyComponents.PanelRenderProperties p = panel.getComponents();
for (PanelComponent pc : p) { for (PanelComponent pc : p) {
Consumer<byte[]> listener = pc.getRSInputHandler(id, panel); Consumer<byte[]> listener = pc.getRSInputHandler(id, panel);
if (listener != null) { if (listener != null) {
listener.accept(out); listener.accept(new byte[16]);
changeListeners.remove(listener); changeListeners.remove(listener);
} }
pc.unregisterRSOutput(id, rsOut); pc.unregisterRSOutput(id, rsOut);
outputs.remove(new PCWrapper(pc)); outputs.remove(new PCWrapper(pc));
} }
panel.unregisterRS(this); if (callPanel) {
panel.unregisterRS(this);
}
if (remove) { if (remove) {
connectedPanels.remove(panel); connectedPanels.remove(panel);
} }
@ -282,7 +284,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
public void onChunkUnload() { public void onChunkUnload() {
super.onChunkUnload(); super.onChunkUnload();
for (TileEntityPanel panel : connectedPanels) { for (TileEntityPanel panel : connectedPanels) {
unregisterPanel(panel, false); unregisterPanel(panel, false, true);
} }
} }
@ -290,7 +292,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
public void invalidate() { public void invalidate() {
super.invalidate(); super.invalidate();
for (TileEntityPanel panel : connectedPanels) { for (TileEntityPanel panel : connectedPanels) {
unregisterPanel(panel, false); unregisterPanel(panel, false, true);
} }
} }
@ -303,7 +305,7 @@ public class TileEntityRSPanelConn extends TileEntityImmersiveConnectable implem
TileEntity te = world.getTileEntity(bp); TileEntity te = world.getTileEntity(bp);
if (te instanceof TileEntityPanel) { if (te instanceof TileEntityPanel) {
tes.add((TileEntityPanel) te); tes.add((TileEntityPanel) te);
unregisterPanel((TileEntityPanel) te, true); unregisterPanel((TileEntityPanel) te, true, true);
} }
} }
id = nbt.getInteger("rsId"); id = nbt.getInteger("rsId");

View file

@ -213,6 +213,7 @@ public class ClientProxy extends CommonProxy {
); );
} }
Config.manual_doubleA.put("iwJacobsUsage", IWConfig.HVStuff.jacobsUsageEU); Config.manual_doubleA.put("iwJacobsUsage", IWConfig.HVStuff.jacobsUsageEU);
Config.manual_int.put("iwKeysOnRing", IWConfig.maxKeysOnRing);
m.addEntry("industrialwires.jacobs", "industrialwires", 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.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")); new ManualPages.Text(m, "industrialwires.jacobs1"));
@ -245,6 +246,7 @@ public class ClientProxy extends CommonProxy {
new ManualPages.Text(m, "industrialwires.toggle_switch1"), 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)), 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)) new ManualPages.Crafting(m, "industrialwires.panel_meter", new ItemStack(IndustrialWires.panelComponent, 1, 8))
); );
} }

View file

@ -67,7 +67,6 @@ public class CoveredToggleSwitch extends ToggleSwitch {
state = state.next(); state = state.next();
} }
setOut(state.active, tile); setOut(state.active, tile);
tile.markDirty();
tile.triggerRenderUpdate(); tile.triggerRenderUpdate();
} }

View file

@ -124,7 +124,6 @@ public class IndicatorLight extends PanelComponent implements IConfigurableCompo
private Consumer<byte[]> handler = (input) -> { private Consumer<byte[]> handler = (input) -> {
if (input[rsInputChannel] != rsInput) { if (input[rsInputChannel] != rsInput) {
rsInput = input[rsInputChannel]; rsInput = input[rsInputChannel];
panel.markDirty();
panel.triggerRenderUpdate(); panel.triggerRenderUpdate();
} }
}; };

View file

@ -122,7 +122,6 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
if (!latching) { if (!latching) {
ticksTillOff = 10; ticksTillOff = 10;
} }
tile.markDirty();
tile.triggerRenderUpdate(); tile.triggerRenderUpdate();
} }
@ -157,12 +156,11 @@ public class LightedButton extends PanelComponent implements IConfigurableCompon
@Override @Override
public void invalidate(TileEntityPanel te) { public void invalidate(TileEntityPanel te) {
setOut(false, te); setOut(rsOutputChannel, 0);
} }
private void setOut(boolean on, TileEntityPanel tile) { private void setOut(boolean on, TileEntityPanel tile) {
active = on; active = on;
tile.markDirty();
tile.triggerRenderUpdate(); tile.triggerRenderUpdate();
setOut(rsOutputChannel, active ? 15 : 0); setOut(rsOutputChannel, active ? 15 : 0);
} }

View file

@ -197,7 +197,6 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
ticksTillOff = 10; ticksTillOff = 10;
} }
} }
tile.markDirty();
tile.triggerRenderUpdate(); tile.triggerRenderUpdate();
} }
@ -208,7 +207,6 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
tile.markDirty(); tile.markDirty();
if (ticksTillOff == 0) { if (ticksTillOff == 0) {
turned = false; turned = false;
tile.markDirty();
tile.triggerRenderUpdate(); tile.triggerRenderUpdate();
setOut(tile); setOut(tile);
} }
@ -241,11 +239,10 @@ public class Lock extends PanelComponent implements IConfigurableComponent {
@Override @Override
public void invalidate(TileEntityPanel te) { public void invalidate(TileEntityPanel te) {
setOut(te); setOut(rsOutputChannel, 0);
} }
private void setOut(TileEntityPanel tile) { private void setOut(TileEntityPanel tile) {
tile.markDirty();
tile.triggerRenderUpdate(); tile.triggerRenderUpdate();
setOut(rsOutputChannel, turned ? 15 : 0); setOut(rsOutputChannel, turned ? 15 : 0);
} }

View file

@ -191,7 +191,6 @@ public class PanelMeter extends PanelComponent implements IConfigurableComponent
private Consumer<byte[]> handler = (input) -> { private Consumer<byte[]> handler = (input) -> {
if (input[rsInputChannel] != rsInput) { if (input[rsInputChannel] != rsInput) {
rsInput = input[rsInputChannel]; rsInput = input[rsInputChannel];
panel.markDirty();
panel.triggerRenderUpdate(); panel.triggerRenderUpdate();
} }
}; };

View file

@ -134,7 +134,6 @@ public class Slider extends PanelComponent implements IConfigurableComponent {
if (newLevel != out) { if (newLevel != out) {
setOut(rsChannel, newLevel); setOut(rsChannel, newLevel);
out = newLevel; out = newLevel;
tile.markDirty();
tile.triggerRenderUpdate(); tile.triggerRenderUpdate();
} }
} }

View file

@ -119,7 +119,6 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
@Override @Override
public void interactWith(Vec3d hitRel, TileEntityPanel tile, EntityPlayerMP player) { public void interactWith(Vec3d hitRel, TileEntityPanel tile, EntityPlayerMP player) {
setOut(!active, tile); setOut(!active, tile);
tile.markDirty();
tile.triggerRenderUpdate(); tile.triggerRenderUpdate();
} }
@ -161,12 +160,11 @@ public class ToggleSwitch extends PanelComponent implements IConfigurableCompone
@Override @Override
public void invalidate(TileEntityPanel te) { public void invalidate(TileEntityPanel te) {
setOut(false, te); setOut(rsOutputChannel, 0);
} }
protected void setOut(boolean on, TileEntityPanel tile) { protected void setOut(boolean on, TileEntityPanel tile) {
active = on; active = on;
tile.markDirty();
tile.triggerRenderUpdate(); tile.triggerRenderUpdate();
setOut(rsOutputChannel, active ? 15 : 0); setOut(rsOutputChannel, active ? 15 : 0);
} }

View file

@ -152,7 +152,6 @@ public class Variac extends PanelComponent implements IConfigurableComponent {
if (newLevel != out) { if (newLevel != out) {
setOut(rsChannel, newLevel); setOut(rsChannel, newLevel);
out = newLevel; out = newLevel;
tile.markDirty();
tile.triggerRenderUpdate(); tile.triggerRenderUpdate();
} }
} }

View file

@ -74,7 +74,7 @@ public class RecipeCoilLength implements IRecipe {
if (OreDictionary.itemMatches(curr, coil, false)) { if (OreDictionary.itemMatches(curr, coil, false)) {
length -= ItemIC2Coil.getLength(curr); length -= ItemIC2Coil.getLength(curr);
if (length < 0) { if (length < 0) {
ItemStack currStack = new ItemStack(IndustrialWires.coil, 1); ItemStack currStack = coil.copy();
ret.set(i, currStack); ret.set(i, currStack);
ItemIC2Coil.setLength(currStack, -length); ItemIC2Coil.setLength(currStack, -length);
} }

View file

@ -28,53 +28,58 @@ import net.minecraft.util.NonNullList;
import net.minecraft.world.World; import net.minecraft.world.World;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static malte0811.industrialWires.items.ItemKey.*; import static malte0811.industrialWires.items.ItemKey.*;
public class RecipeKeyRing implements IRecipe { public class RecipeKeyRing implements IRecipe {
private final boolean addToRing;
public RecipeKeyRing(boolean add) {
addToRing = add;
}
@Override @Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) { public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
return getType(inv) != null; return isValid(inv);
} }
@Nonnull @Nonnull
@Override @Override
public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) { public ItemStack getCraftingResult(@Nonnull InventoryCrafting inv) {
Boolean recipeType = getType(inv); if (isValid(inv)) {
if (recipeType==Boolean.TRUE) {//add key to ring if (addToRing) {//add key to ring
ItemStack ring = inv.getStackInSlot(getRingPos(inv)).copy(); ItemStack ring = inv.getStackInSlot(getRingPos(inv)).copy();
NBTTagCompound nbt = ring.getTagCompound(); NBTTagCompound nbt = ring.getTagCompound();
ItemStack key = inv.getStackInSlot(getKeyPos(inv)); ItemStack key = inv.getStackInSlot(getKeyPos(inv));
NBTTagCompound keyNBT = key.getTagCompound(); NBTTagCompound keyNBT = key.getTagCompound();
if (nbt==null) { if (nbt == null) {
nbt = new NBTTagCompound(); nbt = new NBTTagCompound();
ring.setTagCompound(nbt); 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;
} }
keys.appendTag(keyNBT.copy()); if (!nbt.hasKey(RING_KEYS)) {
nbt.setInteger(LOCK_ID, keyNBT.getInteger(LOCK_ID)); nbt.setTag(RING_KEYS, new NBTTagList());
nbt.setString(NAME, keyNBT.getString(NAME)); }
} if (keyNBT != null) {
return ring; NBTTagList keys = nbt.getTagList(RING_KEYS, 10);
} else {//remove key from ring if (keys.tagCount() >= IWConfig.maxKeysOnRing) {
ItemStack ring = inv.getStackInSlot(getRingPos(inv)).copy(); return ItemStack.EMPTY;
NBTTagCompound nbt = ring.getTagCompound(); }
ItemStack key = new ItemStack(IndustrialWires.key, 1, 1); keys.appendTag(keyNBT.copy());
if (nbt!=null) { nbt.setInteger(LOCK_ID, keyNBT.getInteger(LOCK_ID));
NBTTagList keys = nbt.getTagList(RING_KEYS, 10); nbt.setString(NAME, keyNBT.getString(NAME));
if (keys.tagCount()>0) { }
NBTTagCompound first = keys.getCompoundTagAt(keys.tagCount()-1); return ring;
key.setTagCompound(first); } else {//remove key from ring
return key; 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 @Override
public int getRecipeSize() { public int getRecipeSize() {
return 2; return 1;
} }
@Nonnull @Nonnull
@Override @Override
public ItemStack getRecipeOutput() { public ItemStack getRecipeOutput() {
return ItemStack.EMPTY; return new ItemStack(IndustrialWires.key, 1, addToRing?2:1);
} }
@Nonnull @Nonnull
@Override @Override
public NonNullList<ItemStack> getRemainingItems(@Nonnull InventoryCrafting inv) { public NonNullList<ItemStack> getRemainingItems(@Nonnull InventoryCrafting inv) {
NonNullList<ItemStack> ret = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY); NonNullList<ItemStack> ret = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);
if (getType(inv)==Boolean.FALSE) { if (!addToRing) {
int ringId = getRingPos(inv); int ringId = getRingPos(inv);
ItemStack ring = inv.getStackInSlot(ringId).copy(); ItemStack ring = inv.getStackInSlot(ringId).copy();
NBTTagCompound nbt = ring.getTagCompound(); NBTTagCompound nbt = ring.getTagCompound();
@ -105,6 +110,8 @@ public class RecipeKeyRing implements IRecipe {
keys.removeTag(keys.tagCount()-1); keys.removeTag(keys.tagCount()-1);
if (keys.tagCount() > 0) { if (keys.tagCount() > 0) {
NBTTagCompound first = keys.getCompoundTagAt(0); NBTTagCompound first = keys.getCompoundTagAt(0);
keys.removeTag(0);
keys.appendTag(first);
nbt.setInteger(LOCK_ID, first.getInteger(LOCK_ID)); nbt.setInteger(LOCK_ID, first.getInteger(LOCK_ID));
nbt.setString(NAME, first.getString(NAME)); nbt.setString(NAME, first.getString(NAME));
} else { } else {
@ -117,8 +124,7 @@ public class RecipeKeyRing implements IRecipe {
return ret; return ret;
} }
@Nullable private boolean isValid(@Nonnull InventoryCrafting inv) {
private Boolean getType(@Nonnull InventoryCrafting inv) {
boolean hasRing = false; boolean hasRing = false;
boolean hasKey = false; boolean hasKey = false;
for (int i = 0;i<inv.getSizeInventory();i++) { for (int i = 0;i<inv.getSizeInventory();i++) {
@ -131,12 +137,16 @@ public class RecipeKeyRing implements IRecipe {
hasRing = true; hasRing = true;
continue; continue;
} }
return null; return false;
} else if (!here.isEmpty()) { } 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) { private int getRingPos(@Nonnull InventoryCrafting inv) {

View file

@ -33,6 +33,7 @@ import net.minecraft.world.World;
import net.minecraftforge.fml.common.registry.GameRegistry; import net.minecraftforge.fml.common.registry.GameRegistry;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import java.util.List;
public class ItemKey extends Item implements INetGUIItem { public class ItemKey extends Item implements INetGUIItem {
public static final String LOCK_ID = "lockId"; public static final String LOCK_ID = "lockId";
@ -60,15 +61,25 @@ public class ItemKey extends Item implements INetGUIItem {
} }
@Override @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, 0));
subItems.add(new ItemStack(this, 1, 2)); 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 @Nonnull
@Override @Override
public String getUnlocalizedName(ItemStack stack) { public String getUnlocalizedName(ItemStack stack) {
NBTTagCompound nbt = stack.getTagCompound();
return "item."+IndustrialWires.MODID+".key."+types[stack.getMetadata()]; return "item."+IndustrialWires.MODID+".key."+types[stack.getMetadata()];
} }

View file

@ -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.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. 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. 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.