Some filter and wire IC2 compatibility fixes
This commit is contained in:
parent
4a9c97f3b0
commit
500eca7ea6
6 changed files with 98 additions and 17 deletions
|
@ -27,6 +27,7 @@ import calclavia.lib.render.EnumColor;
|
||||||
import calclavia.lib.utility.LanguageUtility;
|
import calclavia.lib.utility.LanguageUtility;
|
||||||
import codechicken.lib.vec.BlockCoord;
|
import codechicken.lib.vec.BlockCoord;
|
||||||
import codechicken.lib.vec.Vector3;
|
import codechicken.lib.vec.Vector3;
|
||||||
|
import codechicken.multipart.ControlKeyModifer;
|
||||||
import codechicken.multipart.JItemMultiPart;
|
import codechicken.multipart.JItemMultiPart;
|
||||||
import codechicken.multipart.MultiPartRegistry;
|
import codechicken.multipart.MultiPartRegistry;
|
||||||
import codechicken.multipart.TMultiPart;
|
import codechicken.multipart.TMultiPart;
|
||||||
|
@ -55,7 +56,7 @@ public class ItemWire extends JItemMultiPart
|
||||||
{
|
{
|
||||||
BlockCoord onPos = pos.copy().offset(side ^ 1);
|
BlockCoord onPos = pos.copy().offset(side ^ 1);
|
||||||
|
|
||||||
if (player.isSneaking())
|
if (player.isSneaking() && !ControlKeyModifer.isControlDown(player))
|
||||||
{
|
{
|
||||||
PartFramedWire wire = (PartFramedWire) MultiPartRegistry.createPart("resonant_induction_wire", false);
|
PartFramedWire wire = (PartFramedWire) MultiPartRegistry.createPart("resonant_induction_wire", false);
|
||||||
|
|
||||||
|
|
|
@ -124,7 +124,7 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
||||||
{
|
{
|
||||||
TMultiPart part = tile().partMap(i);
|
TMultiPart part = tile().partMap(i);
|
||||||
|
|
||||||
if (part instanceof IEnergyTile)
|
if (part instanceof IEnergyTile && part != this)
|
||||||
{
|
{
|
||||||
foundAnotherPart = true;
|
foundAnotherPart = true;
|
||||||
break;
|
break;
|
||||||
|
@ -154,7 +154,7 @@ public abstract class PartConductor extends PartAdvanced implements IConductor
|
||||||
{
|
{
|
||||||
TMultiPart part = tile().partMap(i);
|
TMultiPart part = tile().partMap(i);
|
||||||
|
|
||||||
if (part instanceof IEnergyTile)
|
if (part instanceof IEnergyTile && part != this)
|
||||||
{
|
{
|
||||||
foundAnotherPart = true;
|
foundAnotherPart = true;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
package resonantinduction.electrical.wire.framed;
|
package resonantinduction.electrical.wire.framed;
|
||||||
|
|
||||||
|
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||||
|
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||||
|
import ic2.api.energy.tile.IEnergyTile;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -13,11 +17,13 @@ import net.minecraft.util.Icon;
|
||||||
import net.minecraft.util.MovingObjectPosition;
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import resonantinduction.core.prefab.part.PartFramedConnection;
|
import resonantinduction.core.prefab.part.PartFramedConnection;
|
||||||
import resonantinduction.electrical.Electrical;
|
import resonantinduction.electrical.Electrical;
|
||||||
import resonantinduction.electrical.wire.EnumWireMaterial;
|
import resonantinduction.electrical.wire.EnumWireMaterial;
|
||||||
import resonantinduction.electrical.wire.PartAdvancedWire;
|
import resonantinduction.electrical.wire.PartAdvancedWire;
|
||||||
import universalelectricity.api.CompatibilityModule;
|
import universalelectricity.api.CompatibilityModule;
|
||||||
|
import universalelectricity.api.UniversalClass;
|
||||||
import universalelectricity.api.energy.EnergyNetworkLoader;
|
import universalelectricity.api.energy.EnergyNetworkLoader;
|
||||||
import universalelectricity.api.energy.IConductor;
|
import universalelectricity.api.energy.IConductor;
|
||||||
import universalelectricity.api.energy.IEnergyNetwork;
|
import universalelectricity.api.energy.IEnergyNetwork;
|
||||||
|
@ -34,12 +40,14 @@ import codechicken.multipart.JIconHitEffects;
|
||||||
import codechicken.multipart.JNormalOcclusion;
|
import codechicken.multipart.JNormalOcclusion;
|
||||||
import codechicken.multipart.MultiPartRegistry;
|
import codechicken.multipart.MultiPartRegistry;
|
||||||
import codechicken.multipart.PartMap;
|
import codechicken.multipart.PartMap;
|
||||||
|
import codechicken.multipart.TMultiPart;
|
||||||
import codechicken.multipart.TSlottedPart;
|
import codechicken.multipart.TSlottedPart;
|
||||||
import codechicken.multipart.TileMultipart;
|
import codechicken.multipart.TileMultipart;
|
||||||
import cpw.mods.fml.common.FMLCommonHandler;
|
import cpw.mods.fml.common.FMLCommonHandler;
|
||||||
import cpw.mods.fml.relauncher.Side;
|
import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
|
||||||
|
@UniversalClass
|
||||||
public class PartFramedWire extends PartFramedConnection<EnumWireMaterial, IConductor, IEnergyNetwork> implements IConductor, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
|
public class PartFramedWire extends PartFramedConnection<EnumWireMaterial, IConductor, IEnergyNetwork> implements IConductor, TSlottedPart, JNormalOcclusion, IHollowConnect, JIconHitEffects
|
||||||
{
|
{
|
||||||
public PartFramedWire()
|
public PartFramedWire()
|
||||||
|
@ -66,6 +74,68 @@ public class PartFramedWire extends PartFramedConnection<EnumWireMaterial, ICond
|
||||||
return "resonant_induction_wire";
|
return "resonant_induction_wire";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IC2 Functions
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onWorldJoin()
|
||||||
|
{
|
||||||
|
if (tile() instanceof IEnergyTile && !world().isRemote)
|
||||||
|
{
|
||||||
|
// Check if there's another part that's an IEnergyTile
|
||||||
|
boolean foundAnotherPart = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < tile().partList().size(); i++)
|
||||||
|
{
|
||||||
|
TMultiPart part = tile().partMap(i);
|
||||||
|
|
||||||
|
if (part instanceof IEnergyTile && part != this)
|
||||||
|
{
|
||||||
|
foundAnotherPart = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundAnotherPart)
|
||||||
|
{
|
||||||
|
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent((IEnergyTile) tile()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void preRemove()
|
||||||
|
{
|
||||||
|
if (!world().isRemote)
|
||||||
|
{
|
||||||
|
this.getNetwork().split(this);
|
||||||
|
|
||||||
|
if (tile() instanceof IEnergyTile)
|
||||||
|
{
|
||||||
|
// Check if there's another part that's an IEnergyTile
|
||||||
|
boolean foundAnotherPart = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < tile().partList().size(); i++)
|
||||||
|
{
|
||||||
|
TMultiPart part = tile().partMap(i);
|
||||||
|
|
||||||
|
if (part instanceof IEnergyTile && part != this)
|
||||||
|
{
|
||||||
|
foundAnotherPart = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundAnotherPart)
|
||||||
|
{
|
||||||
|
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile) tile()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.preRemove();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doesTick()
|
public boolean doesTick()
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraftforge.common.ForgeDirection;
|
import net.minecraftforge.common.ForgeDirection;
|
||||||
|
import codechicken.multipart.PartMap;
|
||||||
import codechicken.multipart.TMultiPart;
|
import codechicken.multipart.TMultiPart;
|
||||||
import codechicken.multipart.TileMultipart;
|
import codechicken.multipart.TileMultipart;
|
||||||
|
|
||||||
|
@ -85,9 +86,9 @@ public class TraitEnergySink extends TileMultipart implements IEnergySink
|
||||||
{
|
{
|
||||||
TMultiPart part = this.partMap(dir.ordinal());
|
TMultiPart part = this.partMap(dir.ordinal());
|
||||||
|
|
||||||
if (this.icInterfaces.contains(part))
|
if (part instanceof IEnergySink)
|
||||||
{
|
{
|
||||||
return ((IEnergySink) part).demandedEnergyUnits();
|
demanded += ((IEnergySink) part).demandedEnergyUnits();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,22 +98,32 @@ public class TraitEnergySink extends TileMultipart implements IEnergySink
|
||||||
@Override
|
@Override
|
||||||
public double injectEnergyUnits(ForgeDirection from, double amount)
|
public double injectEnergyUnits(ForgeDirection from, double amount)
|
||||||
{
|
{
|
||||||
if (this.partMap(from.ordinal()) == null)
|
/**
|
||||||
|
* Try out different sides to try to inject energy into.
|
||||||
|
*/
|
||||||
|
if (partMap(from.ordinal()) instanceof IEnergySink)
|
||||||
{
|
{
|
||||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
return ((IEnergySink) partMap(from.ordinal())).injectEnergyUnits(from, amount);
|
||||||
{
|
}
|
||||||
if (dir != from.getOpposite())
|
|
||||||
{
|
|
||||||
TMultiPart part = this.partMap(dir.ordinal());
|
|
||||||
|
|
||||||
if (this.icInterfaces.contains(part))
|
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
||||||
{
|
{
|
||||||
return ((IEnergySink) part).injectEnergyUnits(from, amount);
|
if (dir != from.getOpposite())
|
||||||
}
|
{
|
||||||
|
TMultiPart part = this.partMap(dir.ordinal());
|
||||||
|
|
||||||
|
if (part instanceof IEnergySink)
|
||||||
|
{
|
||||||
|
return ((IEnergySink) part).injectEnergyUnits(from, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (partMap(PartMap.CENTER.ordinal()) instanceof IEnergySink)
|
||||||
|
{
|
||||||
|
return ((IEnergySink) partMap(PartMap.CENTER.ordinal())).injectEnergyUnits(from, amount);
|
||||||
|
}
|
||||||
|
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,5 +132,4 @@ public class TraitEnergySink extends TileMultipart implements IEnergySink
|
||||||
{
|
{
|
||||||
return Integer.MAX_VALUE;
|
return Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class BlockFilter extends BlockTile
|
||||||
/**
|
/**
|
||||||
* Add liquid to bottom.
|
* Add liquid to bottom.
|
||||||
*/
|
*/
|
||||||
checkBelow.setBlock(world, Block.waterStill.blockID, 0, 3);
|
checkBelow.setBlock(world, Block.waterMoving.blockID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 957 B |
Loading…
Reference in a new issue