IC2 is an optional dependency now, probably still buggy

Fix the TE names
This commit is contained in:
malte0811 2017-08-22 18:33:05 +02:00
parent bf74920482
commit ccc3c7ab12
42 changed files with 604 additions and 114 deletions

View file

@ -30,7 +30,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
minecraft {
version = "14.21.1.2404"
version = "14.21.1.2443"
runDir = "run"
replace '${version}', project.version
@ -42,15 +42,30 @@ repositories {
name 'ic2'
url 'http://maven.ic2.player.to/'
}
maven {
name 'tr'
url 'http://maven.modmuss50.me'
}
maven {
name 'jared maven'
url 'http://blamejared.com/maven'
}
// dependencies of TR...
maven {
url 'http://maven.epoxide.xyz'
}
maven {
// HWYLA
name "TehNut"
url "http://tehnut.info/maven/"
}
}
dependencies {
compile "net.industrial-craft:industrialcraft-2:2.8.+"
deobfCompile 'net.industrial-craft:industrialcraft-2:2.8.+'
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+:deobf"
compileOnly "TechReborn:TechReborn-1.12:2.6.+:dev"
compileOnly "RebornCore:RebornCore-1.12:3.2.+:dev"
}
jar {

View file

@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip

View file

@ -41,6 +41,8 @@ import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraftforge.event.RegistryEvent;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.Mod.EventHandler;
import net.minecraftforge.fml.common.SidedProxy;
@ -57,7 +59,7 @@ import org.apache.logging.log4j.Logger;
import java.util.ArrayList;
import java.util.List;
@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,);after:ic2")
@Mod.EventBusSubscriber
public class IndustrialWires {
public static final String MODID = "industrialwires";
@ -89,15 +91,21 @@ public class IndustrialWires {
};
@SidedProxy(clientSide = "malte0811.industrialWires.client.ClientProxy", serverSide = "malte0811.industrialWires.CommonProxy")
public static CommonProxy proxy;
public static boolean hasIC2;
public static boolean hasTechReborn;
@EventHandler
public void preInit(FMLPreInitializationEvent e) {
hasIC2 = Loader.isModLoaded("ic2");
hasTechReborn = Loader.isModLoaded("techreborn");
logger = e.getModLog();
new IWConfig();
if (IWConfig.enableConversion) {
if (IWConfig.enableConversion&&hasIC2) {
mechConv = new BlockMechanicalConverter();
}
if (hasIC2||hasTechReborn) {
ic2conn = new BlockIC2Connector();
}
jacobsLadder = new BlockJacobsLadder();
panel = new BlockPanel();
@ -105,22 +113,32 @@ public class IndustrialWires {
panelComponent = new ItemPanelComponent();
key = new ItemKey();
GameRegistry.registerTileEntity(TileEntityIC2ConnectorTin.class, MODID + "ic2ConnectorTin");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorCopper.class, MODID + "ic2ConnectorCopper");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGold.class, MODID + "ic2ConnectorGold");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorHV.class, MODID + "ic2ConnectorHV");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGlass.class, MODID + "ic2ConnectorGlass");
if (hasIC2) {
//TODO
GameRegistry.registerTileEntity(TileEntityIC2ConnectorTin.class, MODID + ":ic2ConnectorTin");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorCopper.class, MODID + ":ic2ConnectorCopper");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGold.class, MODID + ":ic2ConnectorGold");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorHV.class, MODID + ":ic2ConnectorHV");
GameRegistry.registerTileEntity(TileEntityIC2ConnectorGlass.class, MODID + ":ic2ConnectorGlass");
// Dummy TE's with bad names used to update old TE's to the proper names
GameRegistry.registerTileEntity(DummyTEs.TinDummy.class, MODID + "ic2ConnectorTin");
GameRegistry.registerTileEntity(DummyTEs.CopperDummy.class, MODID + "ic2ConnectorCopper");
GameRegistry.registerTileEntity(DummyTEs.GoldDummy.class, MODID + "ic2ConnectorGold");
GameRegistry.registerTileEntity(DummyTEs.HVDummy.class, MODID + "ic2ConnectorHV");
GameRegistry.registerTileEntity(DummyTEs.GlassDummy.class, MODID + "ic2ConnectorGlass");
if (IWConfig.enableConversion) {
GameRegistry.registerTileEntity(TileEntityIEMotor.class, MODID + ":ieMotor");
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, MODID + ":mechIcToIe");
GameRegistry.registerTileEntity(TileEntityMechIEtoIC.class, MODID + ":mechIeToIc");
}
}
GameRegistry.registerTileEntity(TileEntityJacobsLadder.class, MODID + ":jacobsLadder");
GameRegistry.registerTileEntity(TileEntityPanel.class, MODID + ":control_panel");
GameRegistry.registerTileEntity(TileEntityRSPanelConn.class, MODID + ":control_panel_rs");
GameRegistry.registerTileEntity(TileEntityPanelCreator.class, MODID + ":panel_creator");
GameRegistry.registerTileEntity(TileEntityUnfinishedPanel.class, MODID + ":unfinished_panel");
GameRegistry.registerTileEntity(TileEntityComponentPanel.class, MODID + ":single_component_panel");
if (IWConfig.enableConversion) {
GameRegistry.registerTileEntity(TileEntityIEMotor.class, MODID + ":ieMotor");
GameRegistry.registerTileEntity(TileEntityMechICtoIE.class, MODID + ":mechIcToIe");
GameRegistry.registerTileEntity(TileEntityMechIEtoIC.class, MODID + ":mechIeToIc");
}
proxy.preInit();
}
@ -149,7 +167,9 @@ public class IndustrialWires {
@EventHandler
public void init(FMLInitializationEvent e) {
if (hasIC2) {
ExtraIC2Compat.addToolConmpat();
}
packetHandler.registerMessage(MessageTileSyncIW.HandlerClient.class, MessageTileSyncIW.class, 0, Side.CLIENT);
packetHandler.registerMessage(MessagePanelInteract.HandlerServer.class, MessagePanelInteract.class, 1, Side.SERVER);

View file

@ -57,7 +57,6 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
public boolean firstTick = true;
// non-rendered properties
private Set<TileEntityRSPanelConn> rsPorts = new HashSet<>();
private boolean renderUpdate;
{
int[] colors = {
@ -100,13 +99,6 @@ 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;
}
}
}
@ -289,7 +281,9 @@ public class TileEntityPanel extends TileEntityIWBase implements IDirectionalTil
}
public void triggerRenderUpdate() {
renderUpdate = true;
IBlockState state = world.getBlockState(pos);
world.notifyBlockUpdate(pos, state, state, 3);
world.addBlockEvent(pos, state.getBlock(), 255, 0);
}
public void registerRS(TileEntityRSPanelConn te) {

View file

@ -30,8 +30,6 @@ import net.minecraft.block.state.IBlockState;
import net.minecraft.client.resources.I18n;
import net.minecraft.client.util.ITooltipFlag;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.BlockRenderLayer;
@ -63,7 +61,7 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
TileEntity te = world.getTileEntity(pos);
if (te instanceof TileEntityIC2ConnectorTin) {
TileEntityIC2ConnectorTin connector = (TileEntityIC2ConnectorTin) te;
if (world.isAirBlock(pos.offset(connector.f))) {
if (world.isAirBlock(pos.offset(connector.facing))) {
this.dropBlockAsItem(connector.getWorld(), pos, world.getBlockState(pos), 0);
connector.getWorld().setBlockToAir(pos);
}

View file

@ -0,0 +1,44 @@
package malte0811.industrialWires.blocks.wire;
public final class DummyTEs {
public static class TinDummy extends TileEntityIC2ConnectorTin {
@Override
public void update() {
TileEntityIC2ConnectorTin newTe = getRaw();
newTe.inBuffer = inBuffer;
newTe.outBuffer = outBuffer;
newTe.maxToNet = maxToNet;
newTe.maxToMachine = maxToMachine;
newTe.relay = relay;
newTe.facing = facing;
world.setTileEntity(pos, newTe);
}
protected TileEntityIC2ConnectorTin getRaw() {
return new TileEntityIC2ConnectorTin();
}
}
public static class CopperDummy extends TinDummy {
@Override
protected TileEntityIC2ConnectorTin getRaw() {
return new TileEntityIC2ConnectorCopper();
}
}
public static class GoldDummy extends TinDummy {
@Override
protected TileEntityIC2ConnectorTin getRaw() {
return new TileEntityIC2ConnectorGold();
}
}
public static class HVDummy extends TinDummy {
@Override
protected TileEntityIC2ConnectorTin getRaw() {
return new TileEntityIC2ConnectorHV();
}
}
public static class GlassDummy extends TinDummy {
@Override
protected TileEntityIC2ConnectorTin getRaw() {
return new TileEntityIC2ConnectorGlass();
}
}
}

View file

@ -45,13 +45,13 @@ public class TileEntityIC2ConnectorGold extends TileEntityIC2ConnectorTin {
@Override
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
EnumFacing side = f.getOpposite();
EnumFacing side = facing.getOpposite();
return new Vec3d(.5 + side.getFrontOffsetX() * .125, .5 + side.getFrontOffsetY() * .125, .5 + side.getFrontOffsetZ() * .125);
}
@Override
public Vec3d getConnectionOffset(Connection con) {
EnumFacing side = f.getOpposite();
EnumFacing side = facing.getOpposite();
double conRadius = con.cableType.getRenderDiameter() / 2;
return new Vec3d(.5 + side.getFrontOffsetX() * (.0625 - conRadius), .5 + side.getFrontOffsetY() * (.0625 - conRadius), .5 + side.getFrontOffsetZ() * (.0625 - conRadius));
}

View file

@ -45,7 +45,7 @@ public class TileEntityIC2ConnectorHV extends TileEntityIC2ConnectorTin {
@Override
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
EnumFacing side = f.getOpposite();
EnumFacing side = facing.getOpposite();
if (relay) {
return new Vec3d(.5 + side.getFrontOffsetX() * .4375, .5 + side.getFrontOffsetY() * .4375, .5 + side.getFrontOffsetZ() * .4375);
} else {
@ -55,7 +55,7 @@ public class TileEntityIC2ConnectorHV extends TileEntityIC2ConnectorTin {
@Override
public Vec3d getConnectionOffset(Connection con) {
EnumFacing side = f.getOpposite();
EnumFacing side = facing.getOpposite();
double conRadius = con.cableType.getRenderDiameter() / 2;
if (relay) {
return new Vec3d(.5 + side.getFrontOffsetX() * (.375 - conRadius), .5 + side.getFrontOffsetY() * (.375 - conRadius), .5 + side.getFrontOffsetZ() * (.375 - conRadius));

View file

@ -26,6 +26,7 @@ import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Conn
import blusunrize.immersiveengineering.api.energy.wires.TileEntityImmersiveConnectable;
import blusunrize.immersiveengineering.api.energy.wires.WireType;
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;
@ -33,17 +34,22 @@ import ic2.api.energy.tile.IEnergyEmitter;
import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import malte0811.industrialWires.IIC2Connector;
import malte0811.industrialWires.IndustrialWires;
import malte0811.industrialWires.blocks.IBlockBoundsIW;
import malte0811.industrialWires.wires.IC2Wiretype;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraft.util.math.AxisAlignedBB;
import net.minecraft.util.math.Vec3d;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.fml.common.Optional;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import reborncore.api.power.EnumPowerTier;
import reborncore.api.power.IEnergyInterfaceTile;
import javax.annotation.Nonnull;
import java.util.HashMap;
@ -51,20 +57,25 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable implements IEnergySource, IEnergySink, IDirectionalTile, ITickable, IIC2Connector, IBlockBoundsIW {
EnumFacing f = EnumFacing.NORTH;
@Optional.InterfaceList({
@Optional.Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "ic2"),
@Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "ic2")//TODO tech reborn
})
public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable implements IEnergySource, IEnergySink, IDirectionalTile,
ITickable, IIC2Connector, IBlockBoundsIW {
EnumFacing facing = EnumFacing.NORTH;
boolean relay;
private boolean first = true;
//IC2 net to IE net buffer
private double inBuffer = 0;
private double maxToNet = 0;
double inBuffer = 0;
double maxToNet = 0;
//IE net to IC2 net buffer
private double outBuffer = 0;
private double maxToMachine = 0;
protected double maxStored = IC2Wiretype.IC2_TYPES[0].getTransferRate() / 8;
double outBuffer = 0;
double maxToMachine = 0;
double maxStored = IC2Wiretype.IC2_TYPES[0].getTransferRate() / 8;
int tier = 1;
public TileEntityIC2ConnectorTin(boolean rel) {
TileEntityIC2ConnectorTin(boolean rel) {
relay = rel;
}
@ -74,15 +85,27 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
@Override
public void update() {
if (first) {
if (!world.isRemote)
if (!world.isRemote&& IndustrialWires.hasIC2)
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
first = false;
}
if (!world.isRemote && inBuffer > .1)
if (!world.isRemote) {
if (inBuffer > .1) {
transferPower();
}
if (outBuffer>.1&&IndustrialWires.hasTechReborn) {
TileEntity output = Utils.getExistingTileEntity(world, pos.offset(facing));
if (output instanceof IEnergyInterfaceTile) {
IEnergyInterfaceTile out = (IEnergyInterfaceTile) output;
if (out.canAcceptEnergy(facing.getOpposite())) {
outBuffer -= out.addEnergy(Math.min(outBuffer, maxToMachine));
}
}
}
}
}
public void transferPower() {
private void transferPower() {
Set<AbstractConnection> conns = new HashSet<>(ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, world));
Map<AbstractConnection, Pair<IIC2Connector, Double>> maxOutputs = new HashMap<>();
double outputMax = Math.min(inBuffer, maxToNet);
@ -125,7 +148,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
}
}
public double getAverageLossRate(AbstractConnection conn) {
private double getAverageLossRate(AbstractConnection conn) {
double f = 0;
for (Connection c : conn.subConnections) {
f += c.length * c.cableType.getLossRatio();
@ -169,13 +192,13 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
@Override
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
EnumFacing side = f.getOpposite();
EnumFacing side = facing.getOpposite();
return new Vec3d(.5 + side.getFrontOffsetX() * .0625, .5 + side.getFrontOffsetY() * .0625, .5 + side.getFrontOffsetZ() * .0625);
}
@Override
public Vec3d getConnectionOffset(Connection con) {
EnumFacing side = f.getOpposite();
EnumFacing side = facing.getOpposite();
double conRadius = con.cableType.getRenderDiameter() / 2;
return new Vec3d(.5 - conRadius * side.getFrontOffsetX(), .5 - conRadius * side.getFrontOffsetY(), .5 - conRadius * side.getFrontOffsetZ());
}
@ -205,16 +228,19 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
}
@Override
@Optional.Method(modid="ic2")
public boolean emitsEnergyTo(IEnergyAcceptor receiver, EnumFacing side) {
return !relay && side == f;
return !relay && side == facing;
}
@Override
@Optional.Method(modid="ic2")
public boolean acceptsEnergyFrom(IEnergyEmitter emitter, EnumFacing side) {
return !relay && side == f;
return !relay && side == facing;
}
@Override
@Optional.Method(modid="ic2")
public double getDemandedEnergy() {
double ret = maxStored + .5 - inBuffer;
if (ret < .1)
@ -223,20 +249,16 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
}
@Override
@Optional.Method(modid="ic2")
public int getSinkTier() {
return tier;
}
@Override
@Optional.Method(modid="ic2")
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
if (inBuffer < maxStored) {
if (inBuffer < maxToNet) {
maxToNet = inBuffer;
}
inBuffer += amount;
if (amount > maxToNet) {
maxToNet = amount;
}
addToIn(amount);
markDirty();
return 0;
}
@ -244,25 +266,38 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
}
@Override
@Optional.Method(modid="ic2")
public double getOfferedEnergy() {
return Math.min(maxToMachine, outBuffer);
}
@Override
@Optional.Method(modid="ic2")
public void drawEnergy(double amount) {
outBuffer -= amount;
markDirty();
}
@Override
@Optional.Method(modid="ic2")
public int getSourceTier() {
return tier;
}
private void addToIn(double amount) {
if (inBuffer < maxToNet) {
maxToNet = inBuffer;
}
inBuffer += amount;
if (amount > maxToNet) {
maxToNet = amount;
}
}
@Override
public void readCustomNBT(NBTTagCompound nbt, boolean descPacket) {
super.readCustomNBT(nbt, descPacket);
f = EnumFacing.getFront(nbt.getInteger("facing"));
facing = EnumFacing.getFront(nbt.getInteger("facing"));
relay = nbt.getBoolean("relay");
inBuffer = nbt.getDouble("inBuffer");
outBuffer = nbt.getDouble("outBuffer");
@ -281,7 +316,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
@Override
public void writeCustomNBT(NBTTagCompound nbt, boolean descPacket) {
super.writeCustomNBT(nbt, descPacket);
nbt.setInteger("facing", f.getIndex());
nbt.setInteger("facing", facing.getIndex());
nbt.setBoolean("relay", relay);
nbt.setDouble("inBuffer", inBuffer);
nbt.setDouble("outBuffer", outBuffer);
@ -292,12 +327,12 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
@Nonnull
@Override
public EnumFacing getFacing() {
return f;
return facing;
}
@Override
public void setFacing(@Nonnull EnumFacing facing) {
f = facing;
this.facing = facing;
}
@Override
@ -320,7 +355,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
float length = this instanceof TileEntityIC2ConnectorHV ? (relay ? .875f : .75f) : this instanceof TileEntityIC2ConnectorGold ? .5625f : .5f;
float wMin = .3125f;
float wMax = .6875f;
switch (f.getOpposite()) {
switch (facing.getOpposite()) {
case UP:
return new AxisAlignedBB(wMin, 0, wMin, wMax, length, wMax);
case DOWN:

View file

@ -41,6 +41,7 @@ import malte0811.industrialWires.client.gui.GuiRenameKey;
import malte0811.industrialWires.client.panelmodel.PanelModelLoader;
import malte0811.industrialWires.client.render.TileRenderJacobsLadder;
import malte0811.industrialWires.controlpanel.PanelComponent;
import malte0811.industrialWires.crafting.IC2TRHelper;
import malte0811.industrialWires.items.ItemIC2Coil;
import malte0811.industrialWires.items.ItemKey;
import malte0811.industrialWires.items.ItemPanelComponent;
@ -54,6 +55,7 @@ import net.minecraft.client.renderer.block.model.ModelResourceLocation;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumHand;
import net.minecraft.util.ResourceLocation;
@ -69,9 +71,7 @@ import net.minecraftforge.fml.client.registry.ClientRegistry;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.relauncher.Side;
import java.util.Locale;
import java.util.Random;
import java.util.WeakHashMap;
import java.util.*;
public class ClientProxy extends CommonProxy {
@Override
@ -122,10 +122,11 @@ public class ClientProxy extends CommonProxy {
ManualInstance m = ManualHelper.getManual();
PositionedItemStack[][] wireRecipes = new PositionedItemStack[3][10];
int xBase = 15;
ItemStack tinCable = IC2Items.getItem("cable", "type:tin,insulation:0");
Ingredient tinCable = IC2TRHelper.getStack("cable", "type:tin,insulation:0");
List<ItemStack> tinCableList = Arrays.asList(tinCable.getMatchingStacks());
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);
wireRecipes[0][3 * i + j] = new PositionedItemStack(tinCableList, 18 * i + xBase, 18 * j);
}
}
ItemStack tmp = new ItemStack(IndustrialWires.coil);
@ -139,7 +140,7 @@ public class ClientProxy extends CommonProxy {
if (r.nextBoolean()) {
// cable
lengthSum++;
wireRecipes[i][3 * j1 + j2] = new PositionedItemStack(tinCable.copy(), 18 * j1 + xBase, 18 * j2);
wireRecipes[i][3 * j1 + j2] = new PositionedItemStack(tinCableList, 18 * j1 + xBase, 18 * j2);
} else {
// wire coil
int length = r.nextInt(99) + 1;

View file

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

View file

@ -124,6 +124,7 @@ 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

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

View file

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

View file

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

View file

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

View file

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

View file

@ -0,0 +1,107 @@
package malte0811.industrialWires.crafting;
import blusunrize.immersiveengineering.common.IEContent;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.IndustrialWires;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.Ingredient;
import net.minecraftforge.fml.common.Loader;
import net.minecraftforge.oredict.OreIngredient;
import techreborn.api.TechRebornAPI;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
public final class IC2TRHelper {
public static Ingredient getStack(String type, String variant) {
Set<ItemStack> stacks = new HashSet<>();
if (IndustrialWires.hasIC2) {
stacks.add(IC2Items.getItem(type, variant));
}
if (Loader.isModLoaded("techreborn")) {
switch (type) {
case "cable":
stacks.add(getTRCable(variant));
break;
case "crafting":
switch (variant) {
case "coil":
stacks.add(new ItemStack(IEContent.blockMetalDecoration0));
break;
case "alloy":
stacks.add(TechRebornAPI.subItemRetriever.getPlateByName("advanced_alloy"));
}
break;
case "te":
if (variant.equals("mv_transformer")) {
stacks.add(new ItemStack(TechRebornAPI.getBlock("MV_TRANSFORMER")));
}
}
}
stacks.removeIf(ItemStack::isEmpty);
if (stacks.isEmpty()) {
switch (type) {
case "cable":
return getIECable(variant.substring("type:".length(), variant.indexOf(',')));
case "crafting":
switch (variant) {
case "alloy":
return new OreIngredient("plateConstantan");
case "electric_motor":
stacks.add(new ItemStack(IEContent.itemMaterial, 1, 27));
}
break;
case "te":
if (variant.equals("mv_transformer")) {
stacks.add(new ItemStack(IEContent.blockConnectors, 1, 7));
}
}
}
return Ingredient.fromStacks(stacks.toArray(new ItemStack[stacks.size()]));
}
public static ItemStack getTRCable(String variant) {
String cableType = variant.substring("type:".length(), variant.indexOf(','));
int meta = -1;
switch (cableType) {
case "copper":
meta = 0;
break;
case "tin":
meta = 1;
break;
case "glass":
meta = 4;
break;
case "gold":
meta = 2;
break;
case "iron":
meta = 3;
break;
}
if (meta>=0&&variant.charAt(variant.length()-1)=='0') {
return new ItemStack(TechRebornAPI.getBlock("CABLE"), 1, meta);
}
return ItemStack.EMPTY;
}
public static Ingredient getIECable(String type) {
switch (type) {
case "gold":
type = "electrum";
break;
case "iron":
type = "steel";
break;
case "tin":
type = "aluminum";
break;
case "glass":
throw new IllegalArgumentException(type+" is not a valid IE wire type");
}
type = Character.toUpperCase(type.charAt(0))+type.substring(1);
return new OreIngredient("wire"+type);
}
}

View file

@ -48,8 +48,8 @@ public class RecipeCoilLength extends IForgeRegistryEntry.Impl<IRecipe> implemen
}
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
int l = getLength(inv);
public boolean matches(@Nonnull InventoryCrafting inv, World worldIn) {
int l = 0;//getLength(inv);
return l > 0;
}

View file

@ -34,7 +34,7 @@ import javax.annotation.Nullable;
public class RecipeComponentCopy extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
public boolean matches(@Nonnull InventoryCrafting inv, World worldIn) {
boolean found = false;
int foundX = -1;
int foundY = -1;

View file

@ -36,7 +36,7 @@ import javax.annotation.Nonnull;
public class RecipeKeyLock extends IForgeRegistryEntry.Impl<IRecipe> implements IRecipe {
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
public boolean matches(@Nonnull InventoryCrafting inv, World worldIn) {
return getLockId(inv) != 0;
}

View file

@ -41,7 +41,7 @@ public class RecipeKeyRing extends IForgeRegistryEntry.Impl<IRecipe> implements
}
@Override
public boolean matches(@Nonnull InventoryCrafting inv, @Nonnull World worldIn) {
public boolean matches(@Nonnull InventoryCrafting inv, World worldIn) {
return isValid(inv);
}

View file

@ -1,10 +1,12 @@
package malte0811.industrialWires.crafting.factories;
import blusunrize.immersiveengineering.common.crafting.IngredientFactoryStackableNBT;
import com.google.gson.JsonObject;
import ic2.api.item.IC2Items;
import malte0811.industrialWires.crafting.IC2TRHelper;
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 +17,13 @@ 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 new IngredientFactoryStackableNBT.IngredientStackableNBT(IC2Items.getItem(name, variant));
return IC2TRHelper.getStack(name, variant);
}
//TODO NBT sensitivity?
private class MyNBTIngredient extends IngredientNBT {
public MyNBTIngredient(ItemStack stack) {
super(stack);
}
}
}

View file

@ -12,10 +12,27 @@
"type": "forge:ore_shaped",
"key": {
"r": {
"type": "forge:ore_dict", "ore": "itemRubber"
"type": "forge:ore_dict",
"ore": "itemRubber"
},
"c": {
"type": "forge:ore_dict", "ore": "ingotCopper"
"type": "forge:ore_dict",
"ore": "ingotCopper"
}
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -16,5 +16,20 @@
"c": {
"type": "forge:ore_dict", "ore": "ingotCopper"
}
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -19,5 +19,20 @@
"name": "cable",
"variant": "type:glass,insulation:0"
}
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -23,5 +23,20 @@
"item": "immersiveengineering:stone_decoration",
"data": 8
}
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -17,5 +17,20 @@
"g": {
"type": "forge:ore_dict", "ore": "ingotGold"
}
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -16,5 +16,20 @@
"g": {
"type": "forge:ore_dict", "ore": "ingotGold"
}
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -17,5 +17,20 @@
"i": {
"type": "forge:ore_dict", "ore": "ingotIron"
}
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -18,5 +18,20 @@
"i": {
"type": "forge:ore_dict", "ore": "ingotIron"
}
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -19,5 +19,20 @@
"type": "forge:ore_dict",
"ore": "ingotTin"
}
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -16,5 +16,20 @@
"t": {
"type": "forge:ore_dict", "ore": "ingotTin"
}
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -11,19 +11,24 @@
"type": "forge:ore_shaped",
"key": {
"b": {
"type": "forge:ore_dict", "ore": "ingotBronze"
"type": "forge:ore_dict",
"ore": "ingotBronze"
},
"r": {
"type": "forge:ore_dict", "ore": "stickSteel"
"type": "forge:ore_dict",
"ore": "stickSteel"
},
"s": {
"type": "forge:ore_dict", "ore": "blockSheetmetalIron"
"type": "forge:ore_dict",
"ore": "blockSheetmetalIron"
},
"S": {
"type": "forge:ore_dict", "ore": "blockSheetmetalSteel"
"type": "forge:ore_dict",
"ore": "blockSheetmetalSteel"
},
"i": {
"type": "forge:ore_dict", "ore": "plateIron"
"type": "forge:ore_dict",
"ore": "plateIron"
},
"I": {
"type": "industrialwires:ic2_item",
@ -35,7 +40,13 @@
"data": 9
}
},
"conditions": [{
"conditions": [
{
"type": "industrialwires:conversion"
}]
},
{
"type": "forge:mod_loaded",
"modid": "ic2"
}
]
}

View file

@ -31,7 +31,13 @@
"data": 8
}
},
"conditions": [{
"conditions": [
{
"type": "industrialwires:conversion"
}]
},
{
"type": "forge:mod_loaded",
"modid": "ic2"
}
]
}

View file

@ -11,19 +11,24 @@
"type": "forge:ore_shaped",
"key": {
"b": {
"type": "forge:ore_dict", "ore": "ingotBronze"
"type": "forge:ore_dict",
"ore": "ingotBronze"
},
"r": {
"type": "forge:ore_dict", "ore": "stickIron"
"type": "forge:ore_dict",
"ore": "stickIron"
},
"s": {
"type": "forge:ore_dict", "ore": "blockSheetmetalIron"
"type": "forge:ore_dict",
"ore": "blockSheetmetalIron"
},
"S": {
"type": "forge:ore_dict", "ore": "blockSheetmetalSteel"
"type": "forge:ore_dict",
"ore": "blockSheetmetalSteel"
},
"i": {
"type": "forge:ore_dict", "ore": "plateSteel"
"type": "forge:ore_dict",
"ore": "plateSteel"
},
"I": {
"type": "industrialwires:ic2_item",
@ -35,7 +40,13 @@
"data": 8
}
},
"conditions": [{
"conditions": [
{
"type": "industrialwires:conversion"
}]
},
{
"type": "forge:mod_loaded",
"modid": "ic2"
}
]
}

View file

@ -8,5 +8,20 @@
"coil": {
"item": "industrialwires:ic2_wire_coil",
"data": 1
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -8,5 +8,20 @@
"coil": {
"item": "industrialwires:ic2_wire_coil",
"data": 4
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -8,5 +8,20 @@
"coil": {
"item": "industrialwires:ic2_wire_coil",
"data": 2
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -8,5 +8,20 @@
"coil": {
"item": "industrialwires:ic2_wire_coil",
"data": 3
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}

View file

@ -8,5 +8,20 @@
"coil": {
"item": "industrialwires:ic2_wire_coil",
"data": 0
},
"conditions": [
{
"type": "forge:or",
"values": [
{
"type": "forge:mod_loaded",
"modid": "ic2"
},
{
"type": "forge:mod_loaded",
"modid": "techreborn"
}
]
}
]
}