Implemented 'color coded' redstone signals.

This commit is contained in:
CrazyPants committed 2013-10-18 16:37:00 +08:00
1 parent ef4261e703
commit 838be49b18
16 files changed
+320 -38

No files matched your search

@@ -21,6 +21,7 @@ import crazypants.enderio.conduit.power.PowerConduit;
import crazypants.enderio.conduit.power.PowerConduitRenderer;
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduit;
import crazypants.enderio.conduit.redstone.RedstoneConduit;
import crazypants.enderio.conduit.redstone.InsulatedRedstoneConduitRenderer;
import crazypants.enderio.conduit.redstone.RedstoneSwitch;
import crazypants.enderio.conduit.redstone.RedstoneSwitchRenderer;
import crazypants.enderio.conduit.render.ConduitBundleRenderer;
@@ -129,6 +130,7 @@ public class ClientProxy extends CommonProxy {
conduitRenderers.add(RedstoneSwitchRenderer.getInstance());
conduitRenderers.add(new LiquidConduitRenderer());
conduitRenderers.add(new PowerConduitRenderer());
conduitRenderers.add(new InsulatedRedstoneConduitRenderer());
EnderIoRenderer eior = new EnderIoRenderer();
ClientRegistry.bindTileEntitySpecialRenderer(TileEnderIO.class, eior);
@@ -262,7 +262,7 @@ public abstract class AbstractConduit implements IConduit {
}
@Override
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res) {
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
return false;
}
@@ -451,15 +451,20 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider {
}
// Check conduit defined actions
RaytraceResult res = doRayTrace(world, x, y, z, player);
RaytraceResult closest = doRayTrace(world, x, y, z, player);
List<RaytraceResult> all = null;
if(closest != null) {
all = doRayTraceAll(world, x, y, z, player);
}
if(res != null && res.component != null && res.component.data instanceof
if(closest != null && closest.component != null && closest.component.data instanceof
ConduitConnectorType) {
System.out.println("BlockConduitBundle.onBlockActivated: Connector hit");
boolean result = false;
// if its a connector pass the event on to all conduits
for (IConduit con : bundle.getConduits()) {
if(con.onBlockActivated(player, res)) {
if(con.onBlockActivated(player, closest, all)) {
bundle.getEntity().onInventoryChanged();
result = true;
}
@@ -468,15 +473,15 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider {
return result;
}
if(res == null || res.component == null || res.component.conduitType ==
if(closest == null || closest.component == null || closest.component.conduitType ==
null) {
// Nothing of interest hit
return false;
}
// Conduit specific actions
if(bundle.getConduit(res.component.conduitType) != null && bundle.getConduit(res.component.conduitType).onBlockActivated(player,
res)) {
if(bundle.getConduit(closest.component.conduitType) != null && bundle.getConduit(closest.component.conduitType).onBlockActivated(player,
closest, all)) {
bundle.getEntity().onInventoryChanged();
return true;
}
@@ -577,6 +582,21 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider {
public RaytraceResult doRayTrace(World world, int x, int y, int z,
EntityPlayer entityPlayer) {
List<RaytraceResult> allHits = doRayTraceAll(world, x, y, z, entityPlayer);
if(allHits == null) {
return null;
}
double posY = entityPlayer.posY + 1.62 - entityPlayer.yOffset;
if(!world.isRemote && entityPlayer.isSneaking()) {
posY -= 0.08;
}
Vec3 origin = Vec3.fakePool.getVecFromPool(entityPlayer.posX, posY,
entityPlayer.posZ);
return RaytraceResult.getClosestHit(origin, allHits);
}
public List<RaytraceResult> doRayTraceAll(World world, int x, int y, int z,
EntityPlayer entityPlayer) {
double pitch = Math.toRadians(entityPlayer.rotationPitch);
double yaw = Math.toRadians(entityPlayer.rotationYaw);
@@ -594,12 +614,19 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider {
entityPlayer.posZ);
Vec3 direction = origin.addVector(dirX * reachDistance, dirY *
reachDistance, dirZ * reachDistance);
RaytraceResult res = doRayTrace(world, x, y, z, origin, direction,
return doRayTraceAll(world, x, y, z, origin, direction,
entityPlayer);
return res;
}
protected RaytraceResult doRayTrace(World world, int x, int y, int z, Vec3
private RaytraceResult doRayTrace(World world, int x, int y, int z, Vec3 origin, Vec3 direction, EntityPlayer entityPlayer) {
List<RaytraceResult> allHits = doRayTraceAll(world, x, y, z, origin, direction, entityPlayer);
if(allHits == null) {
return null;
}
return RaytraceResult.getClosestHit(origin, allHits);
}
protected List<RaytraceResult> doRayTraceAll(World world, int x, int y, int z, Vec3
origin, Vec3 direction, EntityPlayer player) {
TileEntity te = world.getBlockTileEntity(x, y, z);
@@ -646,7 +673,7 @@ public class BlockConduitBundle extends Block implements ITileEntityProvider {
setBlockBounds(0, 0, 0, 1, 1, 1);
return RaytraceResult.getClosestHit(origin, hits);
return hits;
}
}
@@ -1,6 +1,7 @@
package crazypants.enderio.conduit;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import net.minecraft.entity.player.EntityPlayer;
@@ -98,7 +99,7 @@ public interface IConduit {
// Actions
boolean onBlockActivated(EntityPlayer player, RaytraceResult res);
boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all);
void onChunkUnload(World worldObj);
@@ -7,6 +7,7 @@ import java.util.Map;
import net.minecraftforge.common.ForgeDirection;
import crazypants.enderio.conduit.IConduit;
import crazypants.render.BoundingBox;
import crazypants.util.ForgeDirectionOffsets;
import crazypants.vecmath.VecmathUtil;
import crazypants.vecmath.Vector3d;
@@ -95,6 +96,28 @@ public class ConduitGeometryUtil {
return result;
}
public BoundingBox createBoundsForConnectionController(ForgeDirection dir, Offset offset) {
Vector3d nonUniformScale = ForgeDirectionOffsets.forDirCopy(dir);
nonUniformScale.scale(0.5);
nonUniformScale.x = 0.8 * (1 - Math.abs(nonUniformScale.x));
nonUniformScale.y = 0.8 * (1 - Math.abs(nonUniformScale.y));
nonUniformScale.z = 0.8 * (1 - Math.abs(nonUniformScale.z));
BoundingBox bb = CORE_BOUNDS;
//bb = bb.scale(0.8f, 0.8f, 0.8f);
bb = bb.scale(nonUniformScale.x, nonUniformScale.y, nonUniformScale.z);
double transMag = 0.5 - bb.sizeX() * 2;
Vector3d trans = ForgeDirectionOffsets.forDirCopy(dir);
trans.scale(transMag);
bb = bb.translate(trans);
bb = bb.translate(getTranslation(dir, offset));
return bb;
}
private BoundingBox createConduitBounds(Class<? extends IConduit> type, GeometryKey key) {
return createConduitBounds(type, key.dir, key.isStub, key.offset);
}
@@ -2,6 +2,7 @@ package crazypants.enderio.conduit.liquid;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -87,7 +88,7 @@ public class LiquidConduit extends AbstractConduit implements ILiquidConduit {
private final Set<BlockCoord> filledFromThisTick = new HashSet<BlockCoord>();
@Override
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res) {
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
if(player.getCurrentEquippedItem() == null) {
return false;
}
@@ -1,6 +1,7 @@
package crazypants.enderio.conduit.power;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.client.renderer.texture.IconRegister;
@@ -97,7 +98,7 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
}
@Override
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res) {
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
if(ConduitUtil.isToolEquipped(player)) {
if(!getBundle().getEntity().worldObj.isRemote) {
if(res.component != null) {
@@ -138,8 +138,10 @@ public class PowerConduitRenderer extends DefaultConduitRenderer {
return;
}
double xOffset = offset.xOffset * ConduitGeometryUtil.WIDTH;
double yOffset = offset.yOffset * ConduitGeometryUtil.HEIGHT;
Vector3d trans = ConduitGeometryUtil.instance.getTranslation(dir, offset);
// double xOffset = offset.xOffset * ConduitGeometryUtil.WIDTH;
// double yOffset = offset.yOffset * ConduitGeometryUtil.HEIGHT;
float uWidth = tex.getMaxU() - tex.getMinU();
float uScale = uWidth * 0.64f;
@@ -149,7 +151,7 @@ public class PowerConduitRenderer extends DefaultConduitRenderer {
Tessellator tes = Tessellator.instance;
for (Vertex v : verts) {
tes.setNormal(v.nx(), v.ny(), v.nz());
tes.addVertexWithUV(v.x() + xOffset, v.y() + yOffset, v.z(), minU + (v.u() * uScale), tex.getMinV() + (v.v() * vScale));
tes.addVertexWithUV(v.x() + trans.x, v.y() + trans.y, v.z() + trans.z, minU + (v.u() * uScale), tex.getMinV() + (v.v() * vScale));
}
}
@@ -1,10 +1,14 @@
package crazypants.enderio.conduit.redstone;
public interface IInsulatedRedstoneConduit extends IRedstoneConduit {
public static final String KEY_INS_CONDUIT_ICON = "enderio:redstoneInsulatedConduit";
public static final String KEY_INS_TRANSMISSION_ICON = "enderio:redstoneInsulatedConduitTransmission";
public static final String KEY_INS_CORE_OFF_ICON = "enderio:redstoneInsulatedConduitCoreOff";
public static final String KEY_INS_CORE_ON_ICON = "enderio:redstoneInsulatedConduitCoreOn";
static final String KEY_INS_CONDUIT_ICON = "enderio:redstoneInsulatedConduit";
static final String KEY_INS_TRANSMISSION_ICON = "enderio:redstoneInsulatedConduitTransmission";
static final String KEY_INS_CORE_OFF_ICON = "enderio:redstoneInsulatedConduitCoreOff";
static final String KEY_INS_CORE_ON_ICON = "enderio:redstoneInsulatedConduitCoreOn";
static final String KEY_COLOR_CONTROLLER = "enderio:white";
static final String COLOR_CONTROLLER_ID = "ColorController";
}
@@ -2,6 +2,7 @@ package crazypants.enderio.conduit.redstone;
import java.util.Set;
import net.minecraft.item.ItemDye;
import net.minecraftforge.common.ForgeDirection;
import crazypants.enderio.conduit.IConduit;
@@ -12,8 +13,58 @@ public interface IRedstoneConduit extends IConduit {
public static final String KEY_CORE_OFF_ICON = "enderio:redstoneConduitCoreOff";
public static final String KEY_CORE_ON_ICON = "enderio:redstoneConduitCoreOn";
public static final String[] DYE_ORE_NAMES = {
"dyeBlack",
"dyeRed",
"dyeGreen",
"dyeBrown",
"dyeBlue",
"dyePurple",
"dyeCyan",
"dyeLightGray",
"dyeGray",
"dyePink",
"dyeLime",
"dyeYellow",
"dyeLightBlue",
"dyeMagenta",
"dyeOrange",
"dyeWhite"
};
enum SignalColor {
RED
BLACK,
RED,
GREEN,
BROWN,
BLUE,
PURPLE,
CYAN,
SILVER,
GRAY,
PINK,
LIME,
YELLOW,
LIGHT_BLUE,
MAGENTA,
ORANGE,
WHITE;
public static SignalColor getNext(SignalColor mode) {
int ord = mode.ordinal() + 1;
if(ord >= SignalColor.values().length) {
ord = 0;
}
return SignalColor.values()[ord];
}
private SignalColor() {
}
int getColor() {
return ItemDye.dyeColors[ordinal()];
}
}
// External redstone interface
@@ -28,6 +79,8 @@ public interface IRedstoneConduit extends IConduit {
Set<Signal> getNetworkOutputs(ForgeDirection side);
SignalColor getSignalColor(ForgeDirection dir);
void updateNetwork();
}
@@ -1,8 +1,11 @@
package crazypants.enderio.conduit.redstone;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -10,10 +13,12 @@ import java.util.Set;
import net.minecraft.block.Block;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.Icon;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.oredict.OreDictionary;
import powercrystals.minefactoryreloaded.api.rednet.IConnectableRedNet;
import powercrystals.minefactoryreloaded.api.rednet.IRedNetNoConnection;
import powercrystals.minefactoryreloaded.api.rednet.RedNetConnectionType;
@@ -24,7 +29,10 @@ import crazypants.enderio.ModObject;
import crazypants.enderio.conduit.ConduitUtil;
import crazypants.enderio.conduit.ConnectionMode;
import crazypants.enderio.conduit.RaytraceResult;
import crazypants.enderio.conduit.geom.CollidableCache.CacheKey;
import crazypants.enderio.conduit.geom.CollidableComponent;
import crazypants.enderio.conduit.geom.ConduitGeometryUtil;
import crazypants.render.BoundingBox;
import crazypants.render.IconUtil;
import crazypants.util.BlockCoord;
@@ -42,6 +50,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
ICONS.put(KEY_INS_CORE_ON_ICON, register.registerIcon(KEY_INS_CORE_ON_ICON));
ICONS.put(KEY_INS_CONDUIT_ICON, register.registerIcon(KEY_INS_CONDUIT_ICON));
ICONS.put(KEY_INS_TRANSMISSION_ICON, register.registerIcon(KEY_INS_TRANSMISSION_ICON));
ICONS.put(KEY_COLOR_CONTROLLER, register.registerIcon(KEY_COLOR_CONTROLLER));
}
@Override
@@ -58,17 +67,37 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
private Map<ForgeDirection, ConnectionMode> forcedConnections = new HashMap<ForgeDirection, ConnectionMode>();
@Override
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res) {
private Map<ForgeDirection, SignalColor> signalColors = new HashMap<ForgeDirection, SignalColor>();
@Override
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
World world = getBundle().getEntity().worldObj;
if(!world.isRemote) {
SignalColor col = getSignalColorFromEquippedItem(player.getCurrentEquippedItem());
if(col != null && res.component != null) {
setSignalColor(res.component.dir, col);
} else if(ConduitUtil.isToolEquipped(player)) {
if(ConduitUtil.isToolEquipped(player)) {
World world = getBundle().getEntity().worldObj;
if(!world.isRemote) {
if(res.component != null) {
ForgeDirection connDir = res.component.dir;
ForgeDirection faceHit = ForgeDirection.getOrientation(res.movingObjectPosition.sideHit);
if(connDir == ForgeDirection.UNKNOWN || connDir == faceHit) {
boolean colorHit = false;
if(all != null && containsExternalConnection(connDir)) {
for (RaytraceResult rtr : all) {
if(rtr != null && rtr.component != null && COLOR_CONTROLLER_ID.equals(rtr.component.data)) {
colorHit = true;
}
}
}
if(colorHit) {
setSignalColor(connDir, SignalColor.getNext(getSignalColor(connDir)));
} else if(connDir == ForgeDirection.UNKNOWN || connDir == faceHit) {
// Attempt to join networks
BlockCoord loc = getLocation().getLocation(faceHit);
IRedstoneConduit neighbour = ConduitUtil.getConduit(getBundle().getEntity().worldObj, loc.x, loc.y, loc.z, IRedstoneConduit.class);
@@ -125,6 +154,46 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
return false;
}
private SignalColor getSignalColorFromEquippedItem(ItemStack currentEquippedItem) {
if(currentEquippedItem == null) {
return null;
}
int oreId = OreDictionary.getOreID(currentEquippedItem);
if(oreId < 0) {
return null;
}
for (int i = 0; i < DYE_ORE_NAMES.length; i++) {
String dyeName = DYE_ORE_NAMES[i];
if(OreDictionary.getOreID(dyeName) == oreId) {
return SignalColor.values()[i];
}
}
return null;
}
@Override
public SignalColor getSignalColor(ForgeDirection dir) {
SignalColor res = signalColors.get(dir);
if(res == null) {
return SignalColor.RED;
}
return res;
}
public void setSignalColor(ForgeDirection dir, SignalColor col) {
System.out.println("InsulatedRedstoneConduit.setSignalColor: " + col);
Set<Signal> toRemove = getNetworkInputs(dir);
signalColors.put(dir, col);
Set<Signal> toAdd = getNetworkInputs(dir);
if(network != null) {
network.removeSignals(toRemove);
network.addSignals(toAdd);
network.notifyNeigborsOfSignals();
}
setClientStateDirty();
}
@Override
public boolean canConnectToExternal(ForgeDirection direction) {
if(forcedConnections.get(direction) == ConnectionMode.DISABLED) {
@@ -210,7 +279,20 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
if(network == null || mode != ConnectionMode.IN_OUT) {
return Collections.emptySet();
}
return network.getSignals();
Set<Signal> allSigs = network.getSignals();
if(allSigs.isEmpty()) {
return allSigs;
}
SignalColor col = getSignalColor(side);
Set<Signal> result = new HashSet<Signal>();
for (Signal signal : allSigs) {
if(signal.color == col) {
result.add(signal);
}
}
return result;
}
@Override
@@ -227,11 +309,31 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
return getConectionMode(dir) == ConnectionMode.IN_OUT && super.acceptSignalsForDir(dir);
}
@Override
public Collection<CollidableComponent> createCollidables(CacheKey key) {
Collection<CollidableComponent> baseCollidables = super.createCollidables(key);
if(key.dir == ForgeDirection.UNKNOWN) {
return baseCollidables;
}
BoundingBox bb = ConduitGeometryUtil.instance.createBoundsForConnectionController(key.dir, key.offset);
CollidableComponent cc = new CollidableComponent(IRedstoneConduit.class, bb, key.dir, COLOR_CONTROLLER_ID);
List<CollidableComponent> result = new ArrayList<CollidableComponent>();
result.addAll(baseCollidables);
result.add(cc);
return result;
}
@Override
public Icon getTextureForState(CollidableComponent component) {
if(component.dir == ForgeDirection.UNKNOWN) {
return isActive() ? ICONS.get(KEY_INS_CORE_ON_ICON) : ICONS.get(KEY_INS_CORE_OFF_ICON);
}
if(COLOR_CONTROLLER_ID.equals(component.data)) {
return ICONS.get(KEY_COLOR_CONTROLLER);
}
return isActive() ? ICONS.get(KEY_INS_TRANSMISSION_ICON) : ICONS.get(KEY_INS_CONDUIT_ICON);
}
@@ -244,7 +346,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
public void writeToNBT(NBTTagCompound nbtRoot) {
super.writeToNBT(nbtRoot);
if(forcedConnections.size() > 0) {
if(forcedConnections.size() >= 0) {
byte[] modes = new byte[6];
int i = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
@@ -256,7 +358,22 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
}
i++;
}
nbtRoot.setByteArray("forcedCons", modes);
nbtRoot.setByteArray("forcedConnections", modes);
}
if(signalColors.size() >= 0) {
byte[] modes = new byte[6];
int i = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
SignalColor col = signalColors.get(dir);
if(col != null) {
modes[i] = (byte) col.ordinal();
} else {
modes[i] = -1;
}
i++;
}
nbtRoot.setByteArray("signalColors", modes);
}
}
@@ -265,16 +382,28 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
super.readFromNBT(nbtRoot);
forcedConnections.clear();
byte[] modes = nbtRoot.getByteArray("forcedCons");
byte[] modes = nbtRoot.getByteArray("forcedConnections");
if(modes != null && modes.length == 6) {
int i = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if(modes[i] > 0) {
if(modes[i] >= 0) {
forcedConnections.put(dir, ConnectionMode.values()[modes[i]]);
}
i++;
}
}
signalColors.clear();
byte[] cols = nbtRoot.getByteArray("signalColors");
if(cols != null && cols.length == 6) {
int i = 0;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
if(cols[i] >= 0) {
signalColors.put(dir, SignalColor.values()[cols[i]]);
}
i++;
}
}
}
}
@@ -0,0 +1,32 @@
package crazypants.enderio.conduit.redstone;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.Icon;
import crazypants.enderio.conduit.IConduit;
import crazypants.enderio.conduit.geom.CollidableComponent;
import crazypants.enderio.conduit.render.DefaultConduitRenderer;
import crazypants.render.CubeRenderer;
public class InsulatedRedstoneConduitRenderer extends DefaultConduitRenderer {
@Override
public boolean isRendererForConduit(IConduit conduit) {
return conduit instanceof IInsulatedRedstoneConduit;
}
@Override
protected void renderConduit(Icon tex, IConduit conduit, CollidableComponent component, float selfIllum) {
if(IInsulatedRedstoneConduit.COLOR_CONTROLLER_ID.equals(component.data)) {
if(conduit.containsExternalConnection(component.dir)) {
int c = ((IInsulatedRedstoneConduit) conduit).getSignalColor(component.dir).getColor();
Tessellator tessellator = Tessellator.instance;
tessellator.setColorOpaque_I(c);
CubeRenderer.render(component.bound, tex);
tessellator.setColorOpaque(255, 255, 255);
}
} else {
super.renderConduit(tex, conduit, component, selfIllum);
}
}
}
@@ -112,7 +112,7 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
if(input > 1) { // need to degrade external signals by one as they
// enter
BlockCoord loc = getLocation().getLocation(dir);
Signal signal = new Signal(loc.x, loc.y, loc.z, dir, input - 1, SignalColor.RED);
Signal signal = new Signal(loc.x, loc.y, loc.z, dir, input - 1, getSignalColor(dir));
res.add(signal);
}
}
@@ -125,6 +125,11 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
return res;
}
@Override
public SignalColor getSignalColor(ForgeDirection dir) {
return SignalColor.RED;
}
@Override
public Set<Signal> getNetworkOutputs(ForgeDirection side) {
if(network == null) {
@@ -160,8 +165,6 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
protected int getExternalPowerLevel(ForgeDirection dir) {
World world = getBundle().getEntity().worldObj;
BlockCoord loc = getLocation();
//return world.getStrongestIndirectPower(loc.x, loc.y, loc.z);
loc = loc.getLocation(dir);
return world.getIndirectPowerLevelTo(loc.x, loc.y, loc.z, dir.getOpposite().ordinal());
}
@@ -177,7 +180,7 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
return 0;
}
int result = 0;
for (Signal signal : network.getSignals()) {
for (Signal signal : getNetworkOutputs(toDirection.getOpposite())) {
result = Math.max(result, signal.strength);
}
return result;
@@ -102,7 +102,7 @@ public class RedstoneSwitch extends RedstoneConduit {
}
@Override
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res) {
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
if(res.component.data != null && res.component.data.equals(SWITCH_TAG)) {
toggleSwitch();
return true;
@@ -61,6 +61,10 @@ public final class BoundingBox {
return minX < maxX && minY < maxY && minZ < maxZ;
}
public BoundingBox scale(double x, double y, double z) {
return scale((float) x, (float) y, (float) z);
}
public BoundingBox scale(float x, float y, float z) {
x = 1 - x;
y = 1 - y;
Binary file not shown.

After

Width:  |  Height:  |  Size: 157 B