The wires now work with both FE and EU, but not at the same time
This commit is contained in:
parent
f48d277280
commit
1c24abda2c
|
@ -84,7 +84,7 @@ repositories {
|
|||
dependencies {
|
||||
deobfCompile 'net.industrial-craft:industrialcraft-2:2.8.+'
|
||||
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+"
|
||||
deobfCompile "pl.asie.charset:charset:0.5.4.2.3:full"
|
||||
compileOnly "pl.asie.charset:charset:0.5.4.2.3:full"
|
||||
//Project red and runtime dependencies
|
||||
compileOnly "project-red-base:ProjectRed-1.12.2:4.9.1.92:Base"
|
||||
//runtime "project-red-integration:ProjectRed-1.12.2:4.9.1.92:integration"
|
||||
|
|
|
@ -32,7 +32,6 @@ public class EventHandler {
|
|||
InventoryPlayer playerInv = ev.getEntityPlayer().inventory;
|
||||
boolean changed = false;
|
||||
int lengthOnEntity = ItemIC2Coil.getLength(stack);
|
||||
IndustrialWires.logger.info(lengthOnEntity+", "+stack);
|
||||
final int lengthPerCoilOrig = lengthOnEntity/stack.getCount();
|
||||
for (int i = 0;i<playerInv.getSizeInventory();i++) {
|
||||
ItemStack inInv = playerInv.getStackInSlot(i);
|
||||
|
|
|
@ -16,18 +16,20 @@ package malte0811.industrialWires;
|
|||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import malte0811.industrialWires.util.ConversionUtil;
|
||||
import malte0811.industrialWires.wires.EnergyType;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public interface IIC2Connector extends IImmersiveConnectable {
|
||||
public interface IMixedConnector extends IImmersiveConnectable {
|
||||
/**
|
||||
* @return leftover energy.
|
||||
*/
|
||||
double insertEnergy(double eu, boolean simulate);
|
||||
double insertEnergy(double joules, boolean simulate, EnergyType type);
|
||||
|
||||
@Override
|
||||
default float getDamageAmount(Entity e, ImmersiveNetHandler.Connection c)
|
||||
{
|
||||
return (float) Math.ceil(IImmersiveConnectable.super.getDamageAmount(e, c));//Same as IC2 uses
|
||||
//TODO different damage for EU anf FE
|
||||
return (float) Math.ceil(IImmersiveConnectable.super.getDamageAmount(e, c) * ConversionUtil.euPerJoule());//Same as IC2 uses
|
||||
}
|
||||
|
||||
}
|
|
@ -79,7 +79,7 @@ package malte0811.industrialWires;
|
|||
import static malte0811.industrialWires.entities.EntityBrokenPart.MARKER_TEXTURE;
|
||||
import static malte0811.industrialWires.entities.EntityBrokenPart.RES_LOC_SERIALIZER;
|
||||
import static malte0811.industrialWires.mech_mb.MechMBPart.EXAMPLE_MECHMB_LOC;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.*;
|
||||
import static malte0811.industrialWires.wires.MixedWireType.*;
|
||||
|
||||
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies = "required-after:immersiveengineering@[0.12-77,);after:ic2;required-after:forge@[14.23.3.2694,)",
|
||||
certificateFingerprint = "7e11c175d1e24007afec7498a1616bef0000027d",
|
||||
|
|
|
@ -268,7 +268,7 @@ public class BlockPanel extends BlockIWBase implements IMetaEnum {
|
|||
public void neighborChanged(IBlockState state, World worldIn, BlockPos pos, Block blockIn, BlockPos fromPos) {
|
||||
super.neighborChanged(state, worldIn, pos, blockIn, fromPos);
|
||||
if (!worldIn.isRemote) {
|
||||
TileEntityGeneralCP panel = MiscUtils.getExistingTE(worldIn, pos, TileEntityGeneralCP.class);
|
||||
TileEntityGeneralCP panel = MiscUtils.getLoadedTE(worldIn, pos, TileEntityGeneralCP.class);
|
||||
if (panel instanceof TileEntityComponentPanel) {
|
||||
((TileEntityComponentPanel) panel).updateRSInput();
|
||||
} else if (panel instanceof TileEntityRSPanelOthers) {
|
||||
|
|
|
@ -41,7 +41,7 @@ public class TileEntityGeneralCP extends TileEntityIWBase implements IOwner {
|
|||
if (canJoinNetwork()) {
|
||||
for (EnumFacing side : EnumFacing.VALUES) {
|
||||
BlockPos posSide = pos.offset(side);
|
||||
TileEntityGeneralCP neighbour = MiscUtils.getExistingTE(world, posSide, TileEntityGeneralCP.class);
|
||||
TileEntityGeneralCP neighbour = MiscUtils.getLoadedTE(world, posSide, TileEntityGeneralCP.class);
|
||||
if (neighbour != null && neighbour.canJoinNetwork()) {
|
||||
if (!isFinalNet) {
|
||||
panelNetwork = neighbour.panelNetwork;
|
||||
|
|
|
@ -40,7 +40,8 @@ import malte0811.industrialWires.network.MessageTileSyncIW;
|
|||
import malte0811.industrialWires.util.ConversionUtil;
|
||||
import malte0811.industrialWires.util.JouleEnergyStorage;
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import malte0811.industrialWires.wires.EnergyType;
|
||||
import malte0811.industrialWires.wires.MixedWireType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
@ -74,7 +75,7 @@ import static malte0811.industrialWires.blocks.hv.TileEntityMarx.FiringState.FIR
|
|||
import static malte0811.industrialWires.util.MiscUtils.getOffset;
|
||||
import static malte0811.industrialWires.util.MiscUtils.offset;
|
||||
import static malte0811.industrialWires.util.NBTKeys.*;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_HV_CAT;
|
||||
import static malte0811.industrialWires.wires.MixedWireType.IC2_HV_CAT;
|
||||
import static net.minecraft.item.EnumDyeColor.*;
|
||||
|
||||
/**
|
||||
|
@ -88,7 +89,7 @@ import static net.minecraft.item.EnumDyeColor.*;
|
|||
* Pink: Fine top cap voltage
|
||||
*/
|
||||
@Mod.EventBusSubscriber
|
||||
public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable, ISyncReceiver, IBlockBoundsIW, IImmersiveConnectable, IIC2Connector,
|
||||
public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable, ISyncReceiver, IBlockBoundsIW, IImmersiveConnectable, IMixedConnector,
|
||||
IRedstoneConnector {
|
||||
//Only relevant client-side.
|
||||
private static final Set<TileEntityMarx> FIRING_GENERATORS = Collections.newSetFromMap(new WeakHashMap<>());
|
||||
|
@ -532,12 +533,12 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
}
|
||||
|
||||
@Override
|
||||
public double insertEnergy(double eu, boolean simulate) {
|
||||
public double insertEnergy(double joules, boolean simulate, EnergyType type) {
|
||||
TileEntityMarx master = master(this);
|
||||
if (master!=null) {
|
||||
double ret = master.storage.insert(eu, ConversionUtil.joulesPerEu(), simulate, master.leftover);
|
||||
double ret = master.storage.insert(joules, ConversionUtil.joulesPerEu(), simulate, master.leftover);
|
||||
master.leftover -= ret;
|
||||
return eu-ret;
|
||||
return joules -ret;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
|
@ -567,7 +568,7 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
|
||||
@Override
|
||||
public WireType getCableLimiter(TargetingInfo target) {
|
||||
return getRight()==0?WireType.REDSTONE:IC2Wiretype.HV;
|
||||
return getRight()==0?WireType.REDSTONE:MixedWireType.HV;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,7 +18,7 @@ import blusunrize.immersiveengineering.api.IEProperties;
|
|||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.BlockIWBase;
|
||||
import malte0811.industrialWires.blocks.IMetaEnum;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import malte0811.industrialWires.wires.MixedWireType;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.material.Material;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
|
@ -62,7 +62,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.facing))) {
|
||||
if (world.isAirBlock(pos.offset(connector.getFacing()))) {
|
||||
this.dropBlockAsItem(connector.getWorld(), pos, world.getBlockState(pos), 0);
|
||||
connector.getWorld().setBlockToAir(pos);
|
||||
}
|
||||
|
@ -122,10 +122,11 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
public TileEntity createTileEntity(@Nonnull World world, @Nonnull IBlockState state) {
|
||||
TileEntityIC2ConnectorTin base = getBaseTE(state.getValue(TYPE));
|
||||
if (base!=null) {
|
||||
base.facing = state.getValue(IEProperties.FACING_ALL);
|
||||
base.setFacing(state.getValue(IEProperties.FACING_ALL));
|
||||
}
|
||||
return base;
|
||||
}
|
||||
|
||||
private TileEntityIC2ConnectorTin getBaseTE(BlockTypes_IC2_Connector type) {
|
||||
switch (type) {
|
||||
case TIN_CONN:
|
||||
|
@ -159,7 +160,7 @@ public class BlockIC2Connector extends BlockIWBase implements IMetaEnum {
|
|||
if (!stack.isEmpty() && stack.getMetadata() % 2 == 0) {
|
||||
int type = stack.getMetadata() / 2;
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.power_tier", (type%5) + 1));
|
||||
IC2Wiretype wire = IC2Wiretype.ALL[type];
|
||||
MixedWireType wire = MixedWireType.ALL[type];
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.eu_per_tick",
|
||||
wire.getTransferRate() / wire.getFactor()));
|
||||
}
|
||||
|
|
|
@ -14,28 +14,15 @@
|
|||
*/
|
||||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.COPPER_IC2;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_COPPER_CAT;
|
||||
import static malte0811.industrialWires.wires.MixedWireType.COPPER_IC2;
|
||||
|
||||
public class TileEntityIC2ConnectorCopper extends TileEntityIC2ConnectorTin {
|
||||
|
||||
public TileEntityIC2ConnectorCopper(boolean rel) {
|
||||
super(rel);
|
||||
super(rel, COPPER_IC2, 2, .5, .5);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorCopper() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
{
|
||||
tier = 2;
|
||||
maxStored = COPPER_IC2.getTransferRate() / COPPER_IC2.getFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return IC2_COPPER_CAT.equals(t.getCategory());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,26 +14,14 @@
|
|||
*/
|
||||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import static malte0811.industrialWires.wires.MixedWireType.GLASS;
|
||||
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.GLASS;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_GLASS_CAT;
|
||||
|
||||
public class TileEntityIC2ConnectorGlass extends TileEntityIC2ConnectorHV {
|
||||
public class TileEntityIC2ConnectorGlass extends TileEntityIC2ConnectorTin {
|
||||
public TileEntityIC2ConnectorGlass(boolean rel) {
|
||||
super(rel);
|
||||
super(rel, GLASS, 5, .875, .75);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorGlass() {
|
||||
}
|
||||
|
||||
{
|
||||
tier = 5;
|
||||
maxStored = GLASS.getTransferRate() / GLASS.getFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return IC2_GLASS_CAT.equals(t.getCategory());
|
||||
this(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,44 +14,15 @@
|
|||
*/
|
||||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.GOLD;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_GOLD_CAT;
|
||||
import static malte0811.industrialWires.wires.MixedWireType.GOLD;
|
||||
|
||||
public class TileEntityIC2ConnectorGold extends TileEntityIC2ConnectorTin {
|
||||
|
||||
public TileEntityIC2ConnectorGold(boolean rel) {
|
||||
super(rel);
|
||||
super(rel, GOLD, 3, .5625, .5625);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorGold() {
|
||||
}
|
||||
|
||||
{
|
||||
tier = 3;
|
||||
maxStored = GOLD.getTransferRate() / GOLD.getFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return IC2_GOLD_CAT.equals(t.getCategory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
|
||||
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 = 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));
|
||||
this(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,52 +14,15 @@
|
|||
*/
|
||||
package malte0811.industrialWires.blocks.wire;
|
||||
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.HV;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_HV_CAT;
|
||||
import static malte0811.industrialWires.wires.MixedWireType.HV;
|
||||
|
||||
public class TileEntityIC2ConnectorHV extends TileEntityIC2ConnectorTin {
|
||||
|
||||
public TileEntityIC2ConnectorHV(boolean rel) {
|
||||
super(rel);
|
||||
super(rel, HV, 4, .875, .75);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorHV() {
|
||||
}
|
||||
|
||||
{
|
||||
tier = 4;
|
||||
maxStored = HV.getTransferRate() / HV.getFactor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnect(WireType t) {
|
||||
return IC2_HV_CAT.equals(t.getCategory());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getRaytraceOffset(IImmersiveConnectable link) {
|
||||
EnumFacing side = facing.getOpposite();
|
||||
if (relay) {
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .4375, .5 + side.getFrontOffsetY() * .4375, .5 + side.getFrontOffsetZ() * .4375);
|
||||
} else {
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * .3125, .5 + side.getFrontOffsetY() * .3125, .5 + side.getFrontOffsetZ() * .3125);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(Connection con) {
|
||||
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));
|
||||
} else {
|
||||
return new Vec3d(.5 + side.getFrontOffsetX() * (.25 - conRadius), .5 + side.getFrontOffsetY() * (.25 - conRadius), .5 + side.getFrontOffsetZ() * (.25 - conRadius));
|
||||
}
|
||||
this(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,114 +20,167 @@ import blusunrize.immersiveengineering.api.energy.wires.*;
|
|||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.AbstractConnection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.common.blocks.IEBlockInterfaces.IDirectionalTile;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergyAcceptor;
|
||||
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.IMixedConnector;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
||||
import net.minecraft.entity.Entity;
|
||||
import malte0811.industrialWires.compat.Compat;
|
||||
import malte0811.industrialWires.util.ConversionUtil;
|
||||
import malte0811.industrialWires.util.MiscUtils;
|
||||
import malte0811.industrialWires.wires.EnergyType;
|
||||
import malte0811.industrialWires.wires.MixedWireType;
|
||||
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.minecraft.util.math.Vec3i;
|
||||
import net.minecraft.util.math.*;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import net.minecraftforge.fml.common.Optional;
|
||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_TIN_CAT;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.TIN;
|
||||
import static malte0811.industrialWires.wires.EnergyType.*;
|
||||
import static malte0811.industrialWires.wires.MixedWireType.TIN;
|
||||
|
||||
@Optional.InterfaceList({
|
||||
@Optional.Interface(iface = "ic2.api.energy.tile.IEnergySource", modid = "ic2"),
|
||||
@Optional.Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "ic2")
|
||||
})
|
||||
public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable implements IEnergySource, IEnergySink, IDirectionalTile,
|
||||
ITickable, IIC2Connector, IBlockBoundsIW {
|
||||
ITickable, IMixedConnector, IBlockBoundsIW {
|
||||
private static final double EPS = .1;
|
||||
EnumFacing facing = EnumFacing.NORTH;
|
||||
boolean relay;
|
||||
private EnumFacing facing = EnumFacing.NORTH;
|
||||
private boolean relay;
|
||||
private boolean first = true;
|
||||
//IC2 net to IE net buffer
|
||||
double bufferToNet = 0;
|
||||
// external net to IE net buffer
|
||||
private double bufferToNet = 0;
|
||||
private double ieInputInTick = 0;
|
||||
double maxToNet = 0;
|
||||
//IE net to IC2 net buffer
|
||||
double bufferToMachine = 0;
|
||||
private double ic2inputInTick = 0;
|
||||
double maxToMachine = 0;
|
||||
double maxStored = TIN.getTransferRate() / TIN.getFactor();
|
||||
int tier = 1;
|
||||
private double maxToNet = 0;
|
||||
//IE net to external net buffer
|
||||
private double bufferToMachine = 0;
|
||||
private double externalInputInTick = 0;
|
||||
private double maxToMachine = 0;
|
||||
private EnergyType energyType = NONE;
|
||||
private boolean shouldBreak = false;
|
||||
private final double maxStored;
|
||||
private final MixedWireType wireType;
|
||||
private final int tier;
|
||||
private final double relayOffset;
|
||||
private final double connOffset;
|
||||
|
||||
TileEntityIC2ConnectorTin(boolean rel) {
|
||||
relay = rel;
|
||||
protected TileEntityIC2ConnectorTin(boolean relay, MixedWireType type, int tier, double relayLength, double connLength) {
|
||||
this.relay = relay;
|
||||
wireType = type;
|
||||
maxStored = type.getIORate();
|
||||
this.tier = tier;
|
||||
this.relayOffset = relayLength-.5;
|
||||
this.connOffset = connLength-.5;
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorTin(boolean relay) {
|
||||
this(relay, TIN, 1, .5, .5);
|
||||
}
|
||||
|
||||
public TileEntityIC2ConnectorTin() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
super.onLoad();
|
||||
if (!world.isRemote&& IndustrialWires.hasIC2)
|
||||
Compat.loadIC2Tile.accept(this);
|
||||
ImmersiveNetHandler.INSTANCE.onTEValidated(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (first) {
|
||||
if (!world.isRemote&& IndustrialWires.hasIC2)
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
ImmersiveNetHandler.INSTANCE.onTEValidated(this);
|
||||
first = false;
|
||||
}
|
||||
if (bufferToNet < maxToNet) {
|
||||
maxToNet = bufferToNet;
|
||||
}
|
||||
if (ic2inputInTick >maxToNet) {
|
||||
maxToNet = ic2inputInTick;
|
||||
}
|
||||
ic2inputInTick = 0;
|
||||
|
||||
if (bufferToMachine < maxToMachine) {
|
||||
maxToMachine = bufferToMachine;
|
||||
}
|
||||
if (ieInputInTick >maxToMachine) {
|
||||
maxToMachine = ieInputInTick;
|
||||
}
|
||||
ieInputInTick = 0;
|
||||
|
||||
if (!world.isRemote) {
|
||||
if (shouldBreak) {
|
||||
Deque<BlockPos> open = new ArrayDeque<>();
|
||||
open.push(pos);
|
||||
Set<BlockPos> closed = new HashSet<>();
|
||||
closed.add(pos);
|
||||
while (!open.isEmpty()) {
|
||||
BlockPos next = open.pop();
|
||||
Set<Connection> conns = ImmersiveNetHandler.INSTANCE.getConnections(world, next);
|
||||
if (conns!=null) {
|
||||
for (Connection c:conns) {
|
||||
ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension())
|
||||
.put(c, 2*c.cableType.getTransferRate());
|
||||
if (closed.add(c.end)) {
|
||||
open.push(c.end);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (BlockPos p:closed) {
|
||||
TileEntity tile = world.getTileEntity(p);
|
||||
if (tile instanceof IImmersiveConnectable && ((IImmersiveConnectable) tile).isEnergyOutput()) {
|
||||
world.createExplosion(null, p.getX()+.5, p.getY()+.5, p.getZ()+.5,
|
||||
3, true);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (externalInputInTick==0 && ieInputInTick == 0 && bufferToNet == 0 && bufferToMachine == 0) {
|
||||
energyType = NONE;
|
||||
}
|
||||
if (bufferToNet > EPS) {
|
||||
transferPower();
|
||||
transferPowerToNet();
|
||||
}
|
||||
if (bufferToNet >EPS) {
|
||||
notifyAvailableEnergy(bufferToNet);
|
||||
}
|
||||
if (bufferToMachine > EPS && energyType==FE_AC) {
|
||||
transferPowerToFEMachine();
|
||||
}
|
||||
if (bufferToNet < maxToNet) {
|
||||
maxToNet = bufferToNet;
|
||||
}
|
||||
if (externalInputInTick > maxToNet) {
|
||||
maxToNet = externalInputInTick;
|
||||
}
|
||||
externalInputInTick = 0;
|
||||
|
||||
if (bufferToMachine < maxToMachine) {
|
||||
maxToMachine = bufferToMachine;
|
||||
}
|
||||
if (ieInputInTick > maxToMachine) {
|
||||
maxToMachine = ieInputInTick;
|
||||
}
|
||||
ieInputInTick = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void transferPower() {
|
||||
//TODO push FE
|
||||
|
||||
private void transferPowerToNet() {
|
||||
Set<AbstractConnection> conns = ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, world, true);
|
||||
Map<AbstractConnection, Pair<IIC2Connector, Double>> maxOutputs = new HashMap<>();
|
||||
Map<AbstractConnection, Pair<IMixedConnector, Double>> maxOutputs = new HashMap<>();
|
||||
double outputMax = Math.min(bufferToNet, maxToNet);
|
||||
double sum = 0;
|
||||
for (AbstractConnection c : conns) {
|
||||
if (c.isEnergyOutput) {
|
||||
IImmersiveConnectable iic = ApiUtils.toIIC(c.end, world);
|
||||
if (iic instanceof IIC2Connector) {
|
||||
if (iic instanceof IMixedConnector) {
|
||||
double extract =
|
||||
outputMax - ((IIC2Connector) iic).insertEnergy(outputMax, true);
|
||||
outputMax - ((IMixedConnector) iic).insertEnergy(outputMax, true, energyType);
|
||||
if (extract > EPS) {
|
||||
maxOutputs.put(c, new ImmutablePair<>((IIC2Connector) iic, extract));
|
||||
maxOutputs.put(c, new ImmutablePair<>((IMixedConnector) iic, extract));
|
||||
sum += extract;
|
||||
}
|
||||
}
|
||||
|
@ -135,15 +188,15 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
}
|
||||
if (sum > EPS) {
|
||||
HashMap<Connection, Integer> transferedPerConn = ImmersiveNetHandler.INSTANCE.getTransferedRates(world.provider.getDimension());
|
||||
for (Map.Entry<AbstractConnection, Pair<IIC2Connector, Double>> entry : maxOutputs.entrySet()) {
|
||||
Pair<IIC2Connector, Double> p = entry.getValue();
|
||||
for (Map.Entry<AbstractConnection, Pair<IMixedConnector, Double>> entry : maxOutputs.entrySet()) {
|
||||
Pair<IMixedConnector, Double> p = entry.getValue();
|
||||
AbstractConnection c = entry.getKey();
|
||||
double out = outputMax * p.getRight() / sum;
|
||||
double loss = getAverageLossRate(c);
|
||||
double loss = energyType.getLoss(getAverageLossRate(c), bufferToNet, out);
|
||||
out = Math.min(out, bufferToNet -loss);
|
||||
if (out<=0)
|
||||
continue;
|
||||
double inserted = out - p.getLeft().insertEnergy(out, false);
|
||||
double inserted = out - p.getLeft().insertEnergy(out, false, energyType);
|
||||
double energyAtConn = inserted + loss;
|
||||
bufferToNet -= energyAtConn;
|
||||
float intermediaryLoss = 0;
|
||||
|
@ -163,6 +216,19 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
}
|
||||
}
|
||||
|
||||
private void transferPowerToFEMachine() {
|
||||
BlockPos outPos = pos.offset(facing);
|
||||
TileEntity te = MiscUtils.getLoadedTE(world, outPos, TileEntity.class);
|
||||
if (te!=null && te.hasCapability(CapabilityEnergy.ENERGY, facing.getOpposite())) {
|
||||
IEnergyStorage handler = te.getCapability(CapabilityEnergy.ENERGY, facing.getOpposite());
|
||||
assert handler!=null;
|
||||
double outJoules = Math.min(bufferToMachine, maxToMachine);
|
||||
int outFE = MathHelper.floor(outJoules*ConversionUtil.ifPerJoule());
|
||||
int received = handler.receiveEnergy(outFE, false);
|
||||
bufferToMachine -= received*ConversionUtil.joulesPerIf();
|
||||
}
|
||||
}
|
||||
|
||||
private void notifyAvailableEnergy(double storedNew)
|
||||
{
|
||||
Set<AbstractConnection> outputs = ImmersiveNetHandler.INSTANCE.getIndirectEnergyConnections(pos, world, true);
|
||||
|
@ -182,17 +248,10 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
{
|
||||
float loss = c!=null?c.getAverageLossRate():0;
|
||||
float max = (float) (storedNew-loss);
|
||||
Consumer<Float> extract = (energy)->{
|
||||
bufferToNet -= energy+loss;
|
||||
};
|
||||
Consumer<Float> extract = (energy)-> bufferToNet -= energy+loss;
|
||||
return new ImmutablePair<>(max, extract);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDamageAmount(Entity e, Connection c) {
|
||||
return (float) Math.ceil(super.getDamageAmount(e, c));
|
||||
}
|
||||
|
||||
private double getAverageLossRate(AbstractConnection conn) {
|
||||
double f = 0;
|
||||
for (Connection c : conn.subConnections) {
|
||||
|
@ -203,38 +262,45 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
|
||||
//Input through the net
|
||||
@Override
|
||||
public double insertEnergy(double eu, boolean simulate) {
|
||||
final double insert = Math.min(maxStored - bufferToMachine, eu);
|
||||
public double insertEnergy(double joules, boolean simulate, EnergyType type) {
|
||||
if (energyType==NONE) {
|
||||
energyType = type;
|
||||
} else if (energyType!=type) {
|
||||
shouldBreak = true;
|
||||
return 0;
|
||||
}
|
||||
final double insert = Math.min(maxStored - bufferToMachine, joules);
|
||||
if (!simulate) {
|
||||
bufferToMachine += insert;
|
||||
} else {
|
||||
//Yes, this is weird. But it works, otherwise the system can get stuck at a lower output rate with a full buffer
|
||||
ieInputInTick += insert;
|
||||
}
|
||||
return eu - insert;
|
||||
return joules - insert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate() {
|
||||
if (!world.isRemote && !first)
|
||||
if (!world.isRemote)
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
first = true;
|
||||
super.invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChunkUnload() {
|
||||
super.onChunkUnload();
|
||||
if (!world.isRemote && !first)
|
||||
if (!world.isRemote)
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
first = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vec3d getConnectionOffset(Connection con) {
|
||||
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());
|
||||
double length = relay?relayOffset:connOffset;
|
||||
return new Vec3d(.5 + ( length - conRadius) * side.getFrontOffsetX(),
|
||||
.5 + (length - conRadius) * side.getFrontOffsetY(),
|
||||
.5 + (length - conRadius) * side.getFrontOffsetZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -249,11 +315,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
|
||||
@Override
|
||||
public boolean canConnectCable(WireType cableType, TargetingInfo target, Vec3i offset) {
|
||||
return (limitType == null || (this.isRelay() && WireApi.canMix(cableType, limitType))) && canConnect(cableType);
|
||||
}
|
||||
|
||||
public boolean canConnect(WireType t) {
|
||||
return IC2_TIN_CAT.equals(t.getCategory());
|
||||
return (limitType == null || this.isRelay()) && WireApi.canMix(cableType, wireType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -276,7 +338,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public double getDemandedEnergy() {
|
||||
double ret = maxStored + .5 - bufferToNet;
|
||||
double ret = (maxStored - bufferToNet) *ConversionUtil.euPerJoule() + .5;
|
||||
if (ret < .1)
|
||||
ret = 0;
|
||||
return ret;
|
||||
|
@ -291,24 +353,19 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public double injectEnergy(EnumFacing directionFrom, double amount, double voltage) {
|
||||
if (bufferToNet < maxStored) {
|
||||
addToIn(amount);
|
||||
markDirty();
|
||||
return 0;
|
||||
}
|
||||
return amount;
|
||||
return amount-ConversionUtil.euPerJoule()*addToIn(ConversionUtil.joulesPerEu()*amount, false, EU_DC);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public double getOfferedEnergy() {
|
||||
return Math.min(maxToMachine, bufferToMachine);
|
||||
return Math.min(maxToMachine, bufferToMachine) * ConversionUtil.euPerJoule();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Optional.Method(modid="ic2")
|
||||
public void drawEnergy(double amount) {
|
||||
bufferToMachine -= amount;
|
||||
bufferToMachine -= amount*ConversionUtil.joulesPerEu();
|
||||
markDirty();
|
||||
}
|
||||
|
||||
|
@ -330,10 +387,23 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
return tier;
|
||||
}
|
||||
|
||||
private void addToIn(double amount) {
|
||||
bufferToNet += amount;
|
||||
ic2inputInTick += amount;
|
||||
notifyAvailableEnergy(amount);
|
||||
// Returns amount of energy consumed
|
||||
private double addToIn(double joules, boolean simulate, EnergyType type) {
|
||||
if (energyType==NONE) {
|
||||
energyType = type;
|
||||
} else if (energyType!=type) {
|
||||
shouldBreak = true;
|
||||
}
|
||||
if (bufferToNet < maxStored) {
|
||||
if (!simulate) {
|
||||
bufferToNet += joules;
|
||||
externalInputInTick += joules;
|
||||
notifyAvailableEnergy(joules);
|
||||
}
|
||||
markDirty();
|
||||
return joules;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -341,6 +411,7 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
super.readCustomNBT(nbt, descPacket);
|
||||
facing = EnumFacing.getFront(nbt.getInteger("facing"));
|
||||
relay = nbt.getBoolean("relay");
|
||||
int version = nbt.getInteger("version");
|
||||
bufferToNet = nbt.getDouble("inBuffer");
|
||||
bufferToMachine = nbt.getDouble("outBuffer");
|
||||
if (nbt.hasKey("maxToNet")) {
|
||||
|
@ -353,6 +424,13 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
} else {
|
||||
maxToMachine = bufferToMachine;
|
||||
}
|
||||
energyType = EnergyType.values()[nbt.getInteger("energyType")];
|
||||
if (version==0) {
|
||||
bufferToNet *= ConversionUtil.joulesPerEu();
|
||||
bufferToMachine *= ConversionUtil.joulesPerEu();
|
||||
maxToNet *= ConversionUtil.joulesPerEu();
|
||||
maxToMachine *= ConversionUtil.joulesPerEu();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -364,6 +442,8 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
nbt.setDouble("outBuffer", bufferToMachine);
|
||||
nbt.setDouble("maxToNet", maxToNet);
|
||||
nbt.setDouble("maxToMachine", maxToMachine);
|
||||
nbt.setInteger("energyType", energyType.ordinal());
|
||||
nbt.setInteger("version", 1);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -394,9 +474,9 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
|
||||
@Override
|
||||
public AxisAlignedBB getBoundingBox() {
|
||||
float length = this instanceof TileEntityIC2ConnectorHV ? (relay ? .875f : .75f) : this instanceof TileEntityIC2ConnectorGold ? .5625f : .5f;
|
||||
float wMin = .3125f;
|
||||
float wMax = .6875f;
|
||||
double length = .5+(relay?relayOffset:connOffset);
|
||||
double wMin = .3125;
|
||||
double wMax = .6875;
|
||||
switch (facing.getOpposite()) {
|
||||
case UP:
|
||||
return new AxisAlignedBB(wMin, 0, wMin, wMax, length, wMax);
|
||||
|
@ -414,6 +494,25 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
return new AxisAlignedBB(0, 0, 0, 1, 1, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing) {
|
||||
if (capability==CapabilityEnergy.ENERGY) {
|
||||
return !isRelay() && facing == this.facing;
|
||||
}
|
||||
return super.hasCapability(capability, facing);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing) {
|
||||
if (capability==CapabilityEnergy.ENERGY) {
|
||||
if (!isRelay() && facing == this.facing) {
|
||||
return CapabilityEnergy.ENERGY.cast(energyHandler);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return super.getCapability(capability, facing);
|
||||
}
|
||||
|
||||
/*
|
||||
* regarding equals+hashCode
|
||||
* TE's are considered equal if they have the same pos+dimension id
|
||||
|
@ -454,4 +553,54 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
public boolean canRotate(@Nonnull EnumFacing axis) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private EnergyHandler energyHandler = new EnergyHandler();
|
||||
|
||||
private class EnergyHandler implements IEnergyStorage {
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(int maxReceive, boolean simulate) {
|
||||
double joules = maxReceive*ConversionUtil.joulesPerIf();
|
||||
double accepted = addToIn(joules, simulate, FE_AC);
|
||||
return MathHelper.ceil(accepted*ConversionUtil.ifPerJoule());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int extractEnergy(int maxExtract, boolean simulate) {
|
||||
if (energyType!=FE_AC) {
|
||||
return 0;
|
||||
}
|
||||
double joules = maxExtract*ConversionUtil.joulesPerIf();
|
||||
if (joules>maxToMachine) {
|
||||
joules = maxToMachine;
|
||||
}
|
||||
if (joules>bufferToMachine) {
|
||||
joules = bufferToMachine;
|
||||
}
|
||||
if (!simulate) {
|
||||
bufferToMachine -= joules;
|
||||
}
|
||||
return MathHelper.floor(ConversionUtil.ifPerJoule()*joules);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEnergyStored() {
|
||||
return (int)((bufferToMachine+bufferToNet)*ConversionUtil.ifPerJoule());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored() {
|
||||
return (int) (2*maxStored*ConversionUtil.ifPerJoule());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtract() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canReceive() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ import malte0811.industrialWires.items.ItemIC2Coil;
|
|||
import malte0811.industrialWires.items.ItemKey;
|
||||
import malte0811.industrialWires.items.ItemPanelComponent;
|
||||
import malte0811.industrialWires.mech_mb.MechMBPart;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import malte0811.industrialWires.wires.MixedWireType;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -82,7 +82,7 @@ public class ClientEventHandler {
|
|||
if (!player.getHeldItem(hand).isEmpty()) {
|
||||
ItemStack equipped = player.getHeldItem(hand);
|
||||
if (OreDictionary.itemMatches(new ItemStack(IndustrialWires.coil, 1, OreDictionary.WILDCARD_VALUE), equipped, false)) {
|
||||
IC2Wiretype type = IC2Wiretype.ALL[equipped.getItemDamage()];
|
||||
MixedWireType type = MixedWireType.ALL[equipped.getItemDamage()];
|
||||
int color = type.getColour(null);
|
||||
final int threshold = 0x40-1;
|
||||
for (int i = 0;i<3;i++) {
|
||||
|
|
|
@ -137,7 +137,7 @@ public class ControlPanelNetwork {
|
|||
private void replaceWith(ControlPanelNetwork newNet, World w, Collection<BlockPos> toReplace) {
|
||||
removeAllMembers(ImmutableList.copyOf(toReplace));
|
||||
for (BlockPos member:toReplace) {
|
||||
TileEntityGeneralCP te = MiscUtils.getExistingTE(w, member, TileEntityGeneralCP.class);
|
||||
TileEntityGeneralCP te = MiscUtils.getLoadedTE(w, member, TileEntityGeneralCP.class);
|
||||
if (te!=null) {
|
||||
newNet.addMember(te);
|
||||
}
|
||||
|
|
|
@ -28,7 +28,8 @@ import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
|
|||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.wires.IC2Wiretype;
|
||||
import malte0811.industrialWires.util.ConversionUtil;
|
||||
import malte0811.industrialWires.wires.MixedWireType;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.client.util.ITooltipFlag;
|
||||
|
@ -89,19 +90,21 @@ public class ItemIC2Coil extends Item implements IWireCoil {
|
|||
}
|
||||
|
||||
@Override
|
||||
public IC2Wiretype getWireType(ItemStack stack) {
|
||||
return IC2Wiretype.ALL[stack.getMetadata()];
|
||||
public MixedWireType getWireType(ItemStack stack) {
|
||||
return MixedWireType.ALL[stack.getMetadata()];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".desc.wireLength", getLength(stack)));
|
||||
IC2Wiretype wireType = IC2Wiretype.ALL[stack.getMetadata()];
|
||||
int transferRate = wireType.getTransferRate();
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.transfer_rate", transferRate));
|
||||
MixedWireType wireType = MixedWireType.ALL[stack.getMetadata()];
|
||||
double ioRate = wireType.getIORate();
|
||||
double transferRate = ioRate*wireType.getFactor();
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.transfer_rate",
|
||||
transferRate*ConversionUtil.euPerJoule(), transferRate*ConversionUtil.ifPerJoule()));
|
||||
tooltip.add(I18n.format(IndustrialWires.MODID + ".tooltip.input_rate",
|
||||
transferRate / wireType.getFactor()));
|
||||
ioRate*ConversionUtil.euPerJoule(), ioRate*ConversionUtil.ifPerJoule()));
|
||||
if (stack.getTagCompound() != null && stack.getTagCompound().hasKey("linkingPos")) {
|
||||
int[] link = stack.getTagCompound().getIntArray("linkingPos");
|
||||
if (link.length > 3) {
|
||||
|
@ -124,7 +127,7 @@ public class ItemIC2Coil extends Item implements IWireCoil {
|
|||
TileEntity tileEntity = world.getTileEntity(pos);
|
||||
if (tileEntity instanceof IImmersiveConnectable && ((IImmersiveConnectable) tileEntity).canConnect()) {
|
||||
TargetingInfo target = new TargetingInfo(side, hitX, hitY, hitZ);
|
||||
IC2Wiretype wire = getWireType(stack);
|
||||
MixedWireType wire = getWireType(stack);
|
||||
BlockPos masterPos = ((IImmersiveConnectable) tileEntity).getConnectionMaster(wire, target);
|
||||
Vec3i offset = pos.subtract(masterPos);
|
||||
tileEntity = world.getTileEntity(masterPos);
|
||||
|
|
|
@ -200,7 +200,7 @@ public class ItemPanelComponent extends Item implements INetGUIItem {
|
|||
private void placeBlockAt(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) {
|
||||
IBlockState state = IndustrialWires.panel.getStateFromMeta(BlockTypes_Panel.SINGLE_COMP.ordinal());
|
||||
world.setBlockState(pos, state);
|
||||
TileEntityComponentPanel te = MiscUtils.getExistingTE(world, pos, TileEntityComponentPanel.class);
|
||||
TileEntityComponentPanel te = MiscUtils.getLoadedTE(world, pos, TileEntityComponentPanel.class);
|
||||
if (te!=null) {
|
||||
EnumFacing dir = te.getFacingForPlacement(player, pos, side, hitX, hitY, hitZ);
|
||||
te.setFacing(dir);
|
||||
|
|
|
@ -326,7 +326,7 @@ public final class MiscUtils {
|
|||
return MultiblockMarx.INSTANCE;
|
||||
}
|
||||
|
||||
public static <T extends TileEntity> T getExistingTE(World w, BlockPos pos, Class<T> clazz) {
|
||||
public static <T extends TileEntity> T getLoadedTE(World w, BlockPos pos, Class<T> clazz) {
|
||||
if (w.isBlockLoaded(pos)) {
|
||||
TileEntity te = w.getTileEntity(pos);
|
||||
if (te!=null && clazz.isAssignableFrom(te.getClass())) {
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* This file is part of Industrial Wires.
|
||||
* Copyright (C) 2016-2018 malte0811
|
||||
* Industrial Wires is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Industrial Wires is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Industrial Wires. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package malte0811.industrialWires.wires;
|
||||
|
||||
import malte0811.industrialWires.util.ConversionUtil;
|
||||
|
||||
public enum EnergyType {
|
||||
FE_AC() {
|
||||
@Override
|
||||
public double getLoss(double averageLossRate, double available, double outMax) {
|
||||
return Math.min(averageLossRate, 1)*outMax;//TODO fix this
|
||||
}
|
||||
},
|
||||
EU_DC() {
|
||||
@Override
|
||||
public double getLoss(double averageLossRate, double available, double outMax) {
|
||||
return averageLossRate * ConversionUtil.joulesPerEu();
|
||||
}
|
||||
},
|
||||
NONE;
|
||||
|
||||
public double getLoss(double averageLossRate, double available, double outMax) {
|
||||
return available;
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
|||
import malte0811.industrialWires.IWConfig;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.items.ItemIC2Coil;
|
||||
import malte0811.industrialWires.util.ConversionUtil;
|
||||
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
|
@ -28,14 +29,14 @@ import net.minecraftforge.fml.relauncher.SideOnly;
|
|||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class IC2Wiretype extends WireType {
|
||||
public class MixedWireType extends WireType {
|
||||
public static final String IC2_TIN_CAT = "IC_TIN";
|
||||
public static final String IC2_COPPER_CAT = "IC_COPPER";
|
||||
public static final String IC2_GOLD_CAT = "IC_GOLD";
|
||||
public static final String IC2_HV_CAT = "IC_HV";
|
||||
public static final String IC2_GLASS_CAT = "IC_GLASS";
|
||||
private final int type;
|
||||
private final int[] ic2Rates = {32, 128, 512, 2048, 8192};
|
||||
private final int[] ratesEU = {32, 128, 512, 2048, 8192};
|
||||
private final int[] ic2Colors = {0xa5bcc7, 0xbc7945, 0xfeff73, 0xb9d6d9, 0xf1f1f1};
|
||||
private final String[] ic2Names = {"ic2Tin", "ic2Copper", "ic2Gold", "ic2Hv", "ic2Glass",
|
||||
"ic2TinIns", "ic2CopperIns", "ic2GoldIns"};
|
||||
|
@ -44,19 +45,19 @@ public class IC2Wiretype extends WireType {
|
|||
.03125, .03125, .046875, .0625, .75 * .03125, .0625, .0625, 2*.046875
|
||||
};
|
||||
|
||||
public static final IC2Wiretype TIN = new IC2Wiretype(0);
|
||||
public static final IC2Wiretype COPPER_IC2 = new IC2Wiretype(1);
|
||||
public static final IC2Wiretype GOLD = new IC2Wiretype(2);
|
||||
public static final IC2Wiretype HV = new IC2Wiretype(3);
|
||||
public static final IC2Wiretype GLASS = new IC2Wiretype(4);
|
||||
public static final IC2Wiretype TIN_INSULATED = new IC2Wiretype(5);
|
||||
public static final IC2Wiretype COPPER_IC2_INSULATED = new IC2Wiretype(6);
|
||||
public static final IC2Wiretype GOLD_INSULATED = new IC2Wiretype(7);
|
||||
public static final IC2Wiretype[] ALL = {
|
||||
public static final MixedWireType TIN = new MixedWireType(0);
|
||||
public static final MixedWireType COPPER_IC2 = new MixedWireType(1);
|
||||
public static final MixedWireType GOLD = new MixedWireType(2);
|
||||
public static final MixedWireType HV = new MixedWireType(3);
|
||||
public static final MixedWireType GLASS = new MixedWireType(4);
|
||||
public static final MixedWireType TIN_INSULATED = new MixedWireType(5);
|
||||
public static final MixedWireType COPPER_IC2_INSULATED = new MixedWireType(6);
|
||||
public static final MixedWireType GOLD_INSULATED = new MixedWireType(7);
|
||||
public static final MixedWireType[] ALL = {
|
||||
TIN, COPPER_IC2, GOLD, HV, GLASS, TIN_INSULATED, COPPER_IC2_INSULATED, GOLD_INSULATED
|
||||
};
|
||||
|
||||
public IC2Wiretype(int ordinal) {
|
||||
public MixedWireType(int ordinal) {
|
||||
super();
|
||||
this.type = ordinal;
|
||||
WireApi.registerWireType(this);
|
||||
|
@ -72,7 +73,11 @@ public class IC2Wiretype extends WireType {
|
|||
|
||||
@Override
|
||||
public int getTransferRate() {
|
||||
return ic2Rates[type%5]*getFactor();
|
||||
return (int) (getIORate()*getFactor());
|
||||
}
|
||||
|
||||
public double getIORate() {
|
||||
return ratesEU[type%5] * ConversionUtil.joulesPerEu();
|
||||
}
|
||||
|
||||
@Override
|
|
@ -104,8 +104,8 @@ industrialwires.tooltip.instantaneous=Turns off after half a second
|
|||
industrialwires.tooltip.length=Length: %1s
|
||||
industrialwires.tooltip.power_tier=Power Tier: %s
|
||||
industrialwires.tooltip.eu_per_tick=%s EU/t
|
||||
industrialwires.tooltip.transfer_rate=Burns at %s EU/t
|
||||
industrialwires.tooltip.input_rate=%s EU/t per connector
|
||||
industrialwires.tooltip.transfer_rate=Burns at %s EU/t (%s IF/t)
|
||||
industrialwires.tooltip.input_rate=%s EU/t (%s IF/t) per connector
|
||||
|
||||
|
||||
industrialwires.chat.tooLong=This coil does not contain enough wire for this connection
|
||||
|
|
Loading…
Reference in a new issue