Skip to content

Commit

Permalink
Missing file (egit, one day I will kill you for that)
Browse files Browse the repository at this point in the history
  • Loading branch information
Victorious3 committed Mar 20, 2015
1 parent ebcfdf4 commit e4defc7
Showing 1 changed file with 130 additions and 0 deletions.
130 changes: 130 additions & 0 deletions src/main/java/vic/mod/integratedcircuits/gate/BPDevice.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package vic.mod.integratedcircuits.gate;

import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;

import com.bluepowermod.api.BPApi;
import com.bluepowermod.api.misc.MinecraftColor;
import com.bluepowermod.api.wire.ConnectionType;
import com.bluepowermod.api.wire.IConnectionCache;
import com.bluepowermod.api.wire.redstone.IBundledDevice;
import com.bluepowermod.api.wire.redstone.IRedstoneDevice;

public class BPDevice implements IBundledDevice, IRedstoneDevice
{
private final PartGate gate;

private final IConnectionCache<IBundledDevice> cacheBundled;
private final IConnectionCache<IRedstoneDevice> cacheSimple;

public BPDevice(PartGate gate)
{
this.gate = gate;
this.cacheBundled = BPApi.getInstance().getRedstoneApi().createBundledConnectionCache(this);
this.cacheSimple = BPApi.getInstance().getRedstoneApi().createRedstoneConnectionCache(this);
}

@Override
public int getX()
{
return gate.getProvider().getPos().x;
}

@Override
public int getY()
{
return gate.getProvider().getPos().y;
}

@Override
public int getZ()
{
return gate.getProvider().getPos().z;
}

@Override
public World getWorld()
{
return gate.getProvider().getWorld();
}

@Override
public boolean canConnect(ForgeDirection side, IBundledDevice dev, ConnectionType type)
{
return gate.canConnectBundledImpl(gate.getSideRel(side.ordinal()));
}

@Override
public IConnectionCache<? extends IBundledDevice> getBundledConnectionCache()
{
return cacheBundled;
}

@Override
public byte[] getBundledOutput(ForgeDirection side)
{
return gate.getBundledOutput(gate.getSideRel(side.ordinal()));
}

@Override
public void setBundledPower(ForgeDirection side, byte[] power)
{
gate.updateInputPre();
gate.setInput(gate.getSideRel(side.ordinal()), power);
}

@Override
public byte[] getBundledPower(ForgeDirection side)
{
return gate.getBundledInput(gate.getSideRel(side.ordinal()));
}

@Override
public void onBundledUpdate()
{
gate.updateInputPost();
}

@Override
public MinecraftColor getBundledColor(ForgeDirection side)
{
return MinecraftColor.ANY;
}

@Override
public boolean isNormalFace(ForgeDirection side)
{
return true;
}

@Override
public boolean canConnect(ForgeDirection side, IRedstoneDevice dev, ConnectionType type)
{
return gate.canConnectRedstoneImpl(gate.getSideRel(side.ordinal()));
}

@Override
public IConnectionCache<? extends IRedstoneDevice> getRedstoneConnectionCache()
{
return cacheSimple;
}

@Override
public byte getRedstonePower(ForgeDirection side)
{
return (byte) (gate.getRedstoneOutput(gate.getSideRel(side.ordinal())) != 0 ? -1 : 0);
}

@Override
public void setRedstonePower(ForgeDirection side, byte power)
{
gate.updateInputPre();
gate.setInput(gate.getSideRel(side.ordinal()), 0, power);
}

@Override
public void onRedstoneUpdate()
{
gate.updateInputPost();
}
}

0 comments on commit e4defc7

Please sign in to comment.