Prevent HV wires from connecting to manual breaker switches
The wire changes are on Maven now!
This commit is contained in:
parent
129d8f732a
commit
8190a4c80e
|
@ -70,7 +70,7 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
deobfCompile 'net.industrial-craft:industrialcraft-2:2.8.+'
|
||||
//TODO readd when the wirechanges are on master deobfCompile "blusunrize:ImmersiveEngineering:0.12-+:deobf"
|
||||
deobfCompile "blusunrize:ImmersiveEngineering:0.12-+:deobf"
|
||||
compileOnly "TechReborn:TechReborn-1.12:2.6.+:dev"
|
||||
compileOnly "RebornCore:RebornCore-1.12:3.2.+:dev"
|
||||
deobfCompile 'com.elytradev:mirage:2.0.1-SNAPSHOT'
|
||||
|
|
|
@ -17,12 +17,20 @@
|
|||
*/
|
||||
package malte0811.industrialWires;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import net.minecraft.entity.Entity;
|
||||
|
||||
public interface IIC2Connector {
|
||||
public interface IIC2Connector extends IImmersiveConnectable {
|
||||
/**
|
||||
* @return leftover energy.
|
||||
*/
|
||||
double insertEnergy(double eu, boolean simulate);
|
||||
void addAvailableEnergy(double amount, Consumer<Double> consume);
|
||||
|
||||
@Override
|
||||
default float getDamageAmount(Entity e, ImmersiveNetHandler.Connection c)
|
||||
{
|
||||
return (float) Math.ceil(IImmersiveConnectable.super.getDamageAmount(e, c));//Same as IC2 uses
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ import java.util.List;
|
|||
import static malte0811.industrialWires.blocks.wire.BlockTypes_IC2_Connector.*;
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.*;
|
||||
|
||||
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies = "required-after:immersiveengineering@[0.12-72,);after:ic2",
|
||||
@Mod(modid = IndustrialWires.MODID, version = IndustrialWires.VERSION, dependencies = "required-after:immersiveengineering@[0.12-77,);after:ic2",
|
||||
certificateFingerprint = "7e11c175d1e24007afec7498a1616bef0000027d")
|
||||
@Mod.EventBusSubscriber
|
||||
public class IndustrialWires {
|
||||
|
|
|
@ -71,7 +71,6 @@ import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
|
|||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static blusunrize.immersiveengineering.api.energy.wires.WireType.REDSTONE_CATEGORY;
|
||||
import static malte0811.industrialWires.blocks.hv.TileEntityMarx.FiringState.FIRE;
|
||||
|
@ -549,11 +548,6 @@ public class TileEntityMarx extends TileEntityIWMultiblock implements ITickable,
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
//TODO
|
||||
@Override
|
||||
public void addAvailableEnergy(double amount, Consumer<Double> consume) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getConnectionMaster(@Nullable WireType cableType, TargetingInfo target) {
|
||||
|
|
|
@ -32,7 +32,6 @@ import ic2.api.energy.tile.IEnergySource;
|
|||
import malte0811.industrialWires.IIC2Connector;
|
||||
import malte0811.industrialWires.IndustrialWires;
|
||||
import malte0811.industrialWires.blocks.IBlockBoundsIW;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
@ -47,7 +46,10 @@ import org.apache.commons.lang3.tuple.Pair;
|
|||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static malte0811.industrialWires.wires.IC2Wiretype.IC2_TIN_CAT;
|
||||
|
@ -135,12 +137,9 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
}
|
||||
}
|
||||
if (inBuffer>0) {
|
||||
conns.stream().map((ac)->ApiUtils.toIIC(ac.end, world)).forEach((iic)-> {
|
||||
if (iic instanceof IIC2Connector) {
|
||||
((IIC2Connector) iic).addAvailableEnergy(inBuffer, (d)->inBuffer-=d);
|
||||
}
|
||||
});
|
||||
addAvailableEnergy(0D, null);
|
||||
conns.stream().map((ac)->ApiUtils.toIIC(ac.end, world))
|
||||
.forEach((iic)-> iic.addAvailableEnergy((float) inBuffer, (d)->inBuffer-=d));
|
||||
addAvailableEnergy(0, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -268,48 +267,16 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
markDirty();
|
||||
}
|
||||
|
||||
|
||||
private List<Pair<Double, Consumer<Double>>> sources = new ArrayList<>();
|
||||
private long lastSourceUpdate = 0;
|
||||
@Override
|
||||
public void addAvailableEnergy(double amount, Consumer<Double> consume) {
|
||||
long currentTime = world.getTotalWorldTime();
|
||||
if (lastSourceUpdate!=currentTime)
|
||||
{
|
||||
sources.clear();
|
||||
Pair<Double, Consumer<Double>> own = getOwnEnergyIC2();
|
||||
if (own!=null)
|
||||
sources.add(own);
|
||||
lastSourceUpdate = currentTime;
|
||||
}
|
||||
if (amount>0&&consume!=null)
|
||||
sources.add(new ImmutablePair<>(amount, consume));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected Pair<Double,Consumer<Double>> getOwnEnergyIC2()
|
||||
protected Pair<Float,Consumer<Float>> getOwnEnergy()
|
||||
{
|
||||
if (isRelay())
|
||||
return null;
|
||||
return new ImmutablePair<>(inBuffer, (d)->inBuffer -= d);
|
||||
return new ImmutablePair<>((float)inBuffer, (d)->inBuffer -= d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getDamageAmount(Entity e, Connection c)
|
||||
{
|
||||
float max = getMaxDamage(c);
|
||||
if (max==0||world.getTotalWorldTime()-lastSourceUpdate>1)
|
||||
return 0;
|
||||
float energy = 0;
|
||||
for (int i = 0;i<sources.size()&&energy<max;i++) {
|
||||
energy += Math.min(sources.get(i).getLeft(), max-energy);
|
||||
}
|
||||
return (float) Math.ceil(energy/64);//Same as IC2 uses
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getMaxDamage(Connection c) {
|
||||
return c.cableType.getTransferRate()/8;
|
||||
protected float getBaseDamage(ImmersiveNetHandler.Connection c) {
|
||||
return 1/64F;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -414,6 +381,8 @@ public class TileEntityIC2ConnectorTin extends TileEntityImmersiveConnectable im
|
|||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (world==null)
|
||||
return 0;
|
||||
int ret = world.provider.getDimension();
|
||||
ret = 31 * ret + pos.hashCode();
|
||||
return ret;
|
||||
|
|
|
@ -24,8 +24,9 @@ import blusunrize.immersiveengineering.api.energy.wires.IImmersiveConnectable;
|
|||
import blusunrize.immersiveengineering.api.energy.wires.IWireCoil;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.ImmersiveNetHandler.Connection;
|
||||
import blusunrize.immersiveengineering.api.energy.wires.WireType;
|
||||
import blusunrize.immersiveengineering.common.IESaveData;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.TileEntityBreakerSwitch;
|
||||
import blusunrize.immersiveengineering.common.blocks.metal.TileEntityRedstoneBreaker;
|
||||
import blusunrize.immersiveengineering.common.util.ItemNBTHelper;
|
||||
import blusunrize.immersiveengineering.common.util.Utils;
|
||||
import malte0811.industrialWires.IWConfig;
|
||||
|
@ -89,7 +90,7 @@ public class ItemIC2Coil extends Item implements IWireCoil {
|
|||
}
|
||||
|
||||
@Override
|
||||
public WireType getWireType(ItemStack stack) {
|
||||
public IC2Wiretype getWireType(ItemStack stack) {
|
||||
return IC2Wiretype.ALL[stack.getMetadata()];
|
||||
}
|
||||
|
||||
|
@ -124,14 +125,18 @@ 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);
|
||||
WireType wire = getWireType(stack);
|
||||
IC2Wiretype wire = getWireType(stack);
|
||||
BlockPos masterPos = ((IImmersiveConnectable) tileEntity).getConnectionMaster(wire, target);
|
||||
Vec3i offset = pos.subtract(masterPos);
|
||||
tileEntity = world.getTileEntity(masterPos);
|
||||
if (!(tileEntity instanceof IImmersiveConnectable) || !((IImmersiveConnectable) tileEntity).canConnect())
|
||||
return EnumActionResult.PASS;
|
||||
|
||||
if (!((IImmersiveConnectable) tileEntity).canConnectCable(wire, target, offset)) {
|
||||
boolean canConnect = ((IImmersiveConnectable) tileEntity).canConnectCable(wire, target, offset);
|
||||
if (canConnect&&tileEntity instanceof TileEntityBreakerSwitch) {
|
||||
canConnect = !wire.isHV()||tileEntity instanceof TileEntityRedstoneBreaker;
|
||||
}
|
||||
if (!canConnect) {
|
||||
if (!world.isRemote)
|
||||
player.sendMessage(new TextComponentTranslation(Lib.CHAT_WARN + "wrongCable"));
|
||||
return EnumActionResult.FAIL;
|
||||
|
|
|
@ -161,4 +161,8 @@ public class IC2Wiretype extends WireType {
|
|||
public int getFactor() {
|
||||
return type<5?8:4;
|
||||
}
|
||||
|
||||
public boolean isHV() {
|
||||
return this==HV||this==GLASS;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,7 +64,7 @@ industrialwires.desc.output=Main Output
|
|||
industrialwires.desc.alt=Replacement
|
||||
industrialwires.desc.ideal_e=Ideal Energy
|
||||
|
||||
industrialwires.desc.wireLength=Wire length: %1s block(s)
|
||||
industrialwires.desc.wireLength=Wire length: %s block(s)
|
||||
industrialwires.desc.recipe=Please check the Engineer's manual for recipe details
|
||||
industrialwires.desc.remove_all=Remove all components from this panel
|
||||
industrialwires.desc.create_panel=Create a new control panel
|
||||
|
@ -111,7 +111,6 @@ industrialwires.chat.marxEnergy=Last discharge was %s kJ per block
|
|||
death.attack.industrialwires.jacobs_ladder=%1$s was electrocuted by a Jacob's Ladder
|
||||
death.attack.industrialwires.marx=%1$s was struck by lightning produced by a Marx generator
|
||||
|
||||
|
||||
itemGroup.industrialwires=Industrial Wires
|
||||
|
||||
ie.manual.category.industrialwires.name=Industrial Wires
|
||||
|
|
Loading…
Reference in a new issue