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 buildNumber = "13"
def buildNumber = "19"
// For those who want the bleeding edge
buildscript {
@ -30,7 +30,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft {
version = "13.20.0.2282"
version = "13.20.1.2393"
runDir = "run"
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
{
// 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
- Labels no longer break the model cache and cause lag
- 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.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 static final String MODID = "industrialwires";
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: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");

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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);
}

View File

@ -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) {

View File

@ -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()];
}

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