mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 12:19:55 +00:00
Insulated Redstone Conduits can now be toggled between emitting a strong and weak signal via the GUI
Default output has been reverted to a weak signal.
This commit is contained in:
1 parent
d871d1112f
commit
18ed8cc402
9 files changed
+181
-33
No files matched your search
@@ -24,6 +24,8 @@ import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IRedNetOmniNode;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.connectivity.RedNetConnectionType;
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
@@ -47,6 +49,7 @@ import crazypants.enderio.conduit.liquid.PacketFluidLevel;
|
||||
import crazypants.enderio.conduit.packet.PacketConnectionMode;
|
||||
import crazypants.enderio.conduit.packet.PacketExtractMode;
|
||||
import crazypants.enderio.conduit.packet.PacketItemConduitFilter;
|
||||
import crazypants.enderio.conduit.packet.PacketRedstoneConduitOutputStrength;
|
||||
import crazypants.enderio.conduit.packet.PacketRedstoneConduitSignalColor;
|
||||
import crazypants.enderio.conduit.redstone.IRedstoneConduit;
|
||||
import crazypants.enderio.item.ItemConduitProbe;
|
||||
@@ -54,8 +57,6 @@ import crazypants.enderio.machine.painter.PainterUtil;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.render.BoundingBox;
|
||||
import crazypants.util.Util;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IRedNetOmniNode;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.connectivity.RedNetConnectionType;
|
||||
|
||||
@Optional.Interface(iface = "powercrystals.minefactoryreloaded.api.rednet.IRedNetOmniNode", modid = "MineFactoryReloaded")
|
||||
public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade, IRedNetOmniNode {
|
||||
@@ -75,6 +76,8 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
PacketHandler.INSTANCE.registerMessage(PacketModItemFilter.class, PacketModItemFilter.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketFluidFilter.class, PacketFluidFilter.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketRedstoneConduitSignalColor.class, PacketRedstoneConduitSignalColor.class, PacketHandler.nextID(), Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketRedstoneConduitOutputStrength.class, PacketRedstoneConduitOutputStrength.class, PacketHandler.nextID(),
|
||||
Side.SERVER);
|
||||
PacketHandler.INSTANCE.registerMessage(PacketOpenConduitUI.class, PacketOpenConduitUI.class, PacketHandler.nextID(), Side.SERVER);
|
||||
|
||||
BlockConduitBundle result = new BlockConduitBundle();
|
||||
@@ -137,7 +140,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
double d0 = x + (j1 + 0.5D) / b0;
|
||||
double d1 = y + (k1 + 0.5D) / b0;
|
||||
double d2 = z + (l1 + 0.5D) / b0;
|
||||
int i2 = this.rand.nextInt(6);
|
||||
int i2 = rand.nextInt(6);
|
||||
EntityDiggingFX fx = new EntityDiggingFX(world, d0, d1, d2, d0 - x - 0.5D,
|
||||
d1 - y - 0.5D, d2 - z - 0.5D, this, i2, 0).applyColourMultiplier(x, y, z);
|
||||
fx.setParticleIcon(tex);
|
||||
@@ -419,6 +422,7 @@ public class BlockConduitBundle extends BlockEio implements IGuiHandler, IFacade
|
||||
world.removeTileEntity(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
|
||||
ItemStack equipped = player.getCurrentEquippedItem();
|
||||
if(!player.isSneaking() || equipped == null || equipped.getItem() != EnderIO.itemYetaWench) {
|
||||
|
||||
@@ -4,8 +4,10 @@ import java.awt.Color;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import crazypants.enderio.conduit.IConduit;
|
||||
import crazypants.enderio.conduit.packet.PacketRedstoneConduitOutputStrength;
|
||||
import crazypants.enderio.conduit.packet.PacketRedstoneConduitSignalColor;
|
||||
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
|
||||
import crazypants.enderio.gui.CheckBoxEIO;
|
||||
import crazypants.enderio.gui.ColorButton;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
@@ -16,25 +18,41 @@ import crazypants.util.Lang;
|
||||
public class RedstoneSettings extends BaseSettingsPanel {
|
||||
|
||||
private static final int ID_COLOR_BUTTON = GuiExternalConnection.nextButtonId();
|
||||
private static final int ID_STRONG_BUTTON = GuiExternalConnection.nextButtonId();
|
||||
private ColorButton cb;
|
||||
|
||||
private CheckBoxEIO strongCB;
|
||||
|
||||
private String signalColorStr = Lang.localize("gui.conduit.redstone.color");
|
||||
private String signalStringthStr = Lang.localize("gui.conduit.redstone.signalStrengh");
|
||||
private IInsulatedRedstoneConduit insCon;
|
||||
|
||||
private int stongLabelX;
|
||||
|
||||
public RedstoneSettings(GuiExternalConnection gui, IConduit con) {
|
||||
super(IconEIO.WRENCH_OVERLAY_REDSTONE, Lang.localize("itemRedstoneConduitInsulated.name"), gui, con);
|
||||
|
||||
if(!(con instanceof IInsulatedRedstoneConduit
|
||||
&& ((IInsulatedRedstoneConduit) con).isSpecialConnection(gui.getDir()))) {
|
||||
int x = gap + gui.getFontRenderer().getStringWidth(signalColorStr) + gap + 2;
|
||||
int y = customTop;
|
||||
cb = new ColorButton(gui, ID_COLOR_BUTTON, x, y);
|
||||
cb.setToolTipHeading(Lang.localize("gui.conduit.redstone.signalColor"));
|
||||
if(con instanceof IInsulatedRedstoneConduit) {
|
||||
insCon = (IInsulatedRedstoneConduit) con;
|
||||
int x = 0;
|
||||
int y = customTop;
|
||||
|
||||
if(con instanceof IInsulatedRedstoneConduit) {
|
||||
insCon = (IInsulatedRedstoneConduit) con;
|
||||
}
|
||||
|
||||
if(insCon != null) {
|
||||
if(!insCon.isSpecialConnection(gui.getDir())) {
|
||||
x += gap + gap + 2 + gui.getFontRenderer().getStringWidth(signalColorStr);
|
||||
cb = new ColorButton(gui, ID_COLOR_BUTTON, x, y);
|
||||
cb.setToolTipHeading(Lang.localize("gui.conduit.redstone.signalColor"));
|
||||
DyeColor sigCol = insCon.getSignalColor(gui.getDir());
|
||||
cb.setColorIndex(sigCol.ordinal());
|
||||
x += cb.getButtonWidth();
|
||||
|
||||
}
|
||||
stongLabelX = x;
|
||||
x += gap + gui.getFontRenderer().getStringWidth(signalStringthStr) + gap + 3;
|
||||
strongCB = new CheckBoxEIO(gui, ID_STRONG_BUTTON, x, y);
|
||||
strongCB.setToolTip(Lang.localize("gui.conduit.redstone.signalStrengh.tooltip"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,14 +62,21 @@ public class RedstoneSettings extends BaseSettingsPanel {
|
||||
if(guiButton.id == ID_COLOR_BUTTON && cb != null) {
|
||||
insCon.setSignalColor(gui.getDir(), DyeColor.values()[cb.getColorIndex()]);
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketRedstoneConduitSignalColor(insCon, gui.getDir()));
|
||||
} else if(guiButton.id == ID_STRONG_BUTTON && strongCB != null) {
|
||||
insCon.setOutputStrength(gui.getDir(), strongCB.isSelected());
|
||||
PacketHandler.INSTANCE.sendToServer(new PacketRedstoneConduitOutputStrength(insCon, gui.getDir()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initCustomOptions() {
|
||||
if(insCon != null && cb != null) {
|
||||
cb.setColorIndex(cb.getColorIndex());
|
||||
cb.onGuiInit();
|
||||
if(insCon != null) {
|
||||
if(cb != null) {
|
||||
cb.setColorIndex(cb.getColorIndex());
|
||||
cb.onGuiInit();
|
||||
}
|
||||
strongCB.onGuiInit();
|
||||
strongCB.setSelected(insCon.isOutputStrong(gui.getDir()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,14 +84,22 @@ public class RedstoneSettings extends BaseSettingsPanel {
|
||||
public void deactivate() {
|
||||
super.deactivate();
|
||||
if(cb != null) {
|
||||
cb.setToolTip((String[]) null);
|
||||
cb.detach();
|
||||
}
|
||||
if(strongCB != null) {
|
||||
strongCB.detach();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderCustomOptions(int top, float par1, int par2, int par3) {
|
||||
if(insCon != null) {
|
||||
gui.getFontRenderer().drawString(signalColorStr, left, top, ColorUtil.getRGB(Color.darkGray));
|
||||
if(cb != null) {
|
||||
gui.getFontRenderer().drawString(signalColorStr, left, top, ColorUtil.getRGB(Color.darkGray));
|
||||
}
|
||||
if(strongCB != null) {
|
||||
gui.getFontRenderer().drawString(signalStringthStr, left + stongLabelX, top, ColorUtil.getRGB(Color.darkGray));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package crazypants.enderio.conduit.packet;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
||||
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
||||
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
||||
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
|
||||
|
||||
public class PacketRedstoneConduitOutputStrength extends AbstractConduitPacket<IInsulatedRedstoneConduit> implements
|
||||
IMessageHandler<PacketRedstoneConduitOutputStrength, IMessage> {
|
||||
|
||||
private ForgeDirection dir;
|
||||
private boolean isStrong;
|
||||
|
||||
public PacketRedstoneConduitOutputStrength() {
|
||||
}
|
||||
|
||||
public PacketRedstoneConduitOutputStrength(IInsulatedRedstoneConduit con, ForgeDirection dir) {
|
||||
super(con.getBundle().getEntity(), ConTypeEnum.REDSTONE);
|
||||
this.dir = dir;
|
||||
isStrong = con.isOutputStrong(dir);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toBytes(ByteBuf buf) {
|
||||
super.toBytes(buf);
|
||||
buf.writeShort(dir.ordinal());
|
||||
buf.writeBoolean(isStrong);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fromBytes(ByteBuf buf) {
|
||||
super.fromBytes(buf);
|
||||
dir = ForgeDirection.values()[buf.readShort()];
|
||||
isStrong = buf.readBoolean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IMessage onMessage(PacketRedstoneConduitOutputStrength message, MessageContext ctx) {
|
||||
IInsulatedRedstoneConduit tile = message.getTileCasted(ctx);
|
||||
if(tile != null) {
|
||||
tile.setOutputStrength(message.dir, message.isStrong);
|
||||
//message.getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -12,13 +12,18 @@ public interface IInsulatedRedstoneConduit extends IRedstoneConduit {
|
||||
|
||||
public static final String COLOR_CONTROLLER_ID = "ColorController";
|
||||
|
||||
public void onInputsChanged(ForgeDirection side, int[] inputValues);
|
||||
void onInputsChanged(ForgeDirection side, int[] inputValues);
|
||||
|
||||
public void onInputChanged(ForgeDirection side, int inputValue);
|
||||
void onInputChanged(ForgeDirection side, int inputValue);
|
||||
|
||||
public void forceConnectionMode(ForgeDirection dir, ConnectionMode mode);
|
||||
void forceConnectionMode(ForgeDirection dir, ConnectionMode mode);
|
||||
|
||||
void setSignalColor(ForgeDirection dir, DyeColor col);
|
||||
|
||||
public boolean isSpecialConnection(ForgeDirection dir);
|
||||
boolean isSpecialConnection(ForgeDirection dir);
|
||||
|
||||
boolean isOutputStrong(ForgeDirection dir);
|
||||
|
||||
void setOutputStrength(ForgeDirection dir, boolean isStrong);
|
||||
|
||||
}
|
||||
@@ -71,6 +71,7 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
|
||||
private Map<ForgeDirection, DyeColor> signalColors = new HashMap<ForgeDirection, DyeColor>();
|
||||
|
||||
private Map<ForgeDirection, Boolean> signalStrengths = new HashMap<ForgeDirection, Boolean>();
|
||||
|
||||
@Override
|
||||
public boolean onBlockActivated(EntityPlayer player, RaytraceResult res, List<RaytraceResult> all) {
|
||||
@@ -151,12 +152,14 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
|
||||
@Override
|
||||
protected void readTypeSettings(ForgeDirection dir, NBTTagCompound dataRoot) {
|
||||
setSignalColor(dir, DyeColor.values()[dataRoot.getShort("signalColor")]);
|
||||
setSignalColor(dir, DyeColor.values()[dataRoot.getShort("signalColor")]);
|
||||
setOutputStrength(dir, dataRoot.getBoolean("signalStrong"));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void writeTypeSettingsToNbt(ForgeDirection dir, NBTTagCompound dataRoot) {
|
||||
dataRoot.setShort("signalColor", (short)getSignalColor(dir).ordinal());
|
||||
dataRoot.setShort("signalColor", (short) getSignalColor(dir).ordinal());
|
||||
dataRoot.setBoolean("signalStrong", isOutputStrong(dir));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -214,12 +217,10 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
|
||||
@Override
|
||||
public void onInputsChanged(ForgeDirection side, int[] inputValues) {
|
||||
//System.out.println("InsulatedRedstoneConduit.onInputsChanged: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onInputChanged(ForgeDirection side, int inputValue) {
|
||||
//System.out.println("InsulatedRedstoneConduit.onInputChanged: ");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -244,6 +245,28 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
setClientStateDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOutputStrong(ForgeDirection dir) {
|
||||
if(signalStrengths.containsKey(dir)) {
|
||||
return signalStrengths.get(dir);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setOutputStrength(ForgeDirection dir, boolean isStrong) {
|
||||
if(isOutputStrong(dir) != isStrong) {
|
||||
if(isStrong) {
|
||||
signalStrengths.put(dir, isStrong);
|
||||
} else {
|
||||
signalStrengths.remove(dir);
|
||||
}
|
||||
if(network != null) {
|
||||
network.notifyNeigborsOfSignals();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canConnectToExternal(ForgeDirection direction, boolean ignoreConnectionState) {
|
||||
if(ignoreConnectionState) { //you can always force an external connection
|
||||
@@ -336,12 +359,14 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
}
|
||||
return super.isProvidingWeakPower(toDirection);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(ForgeDirection toDirection) {
|
||||
return isProvidingWeakPower(toDirection);
|
||||
if(isOutputStrong(toDirection.getOpposite())) {
|
||||
return isProvidingWeakPower(toDirection);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -467,6 +492,22 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
}
|
||||
nbtRoot.setByteArray("signalColors", modes);
|
||||
}
|
||||
|
||||
if(signalStrengths.size() >= 0) {
|
||||
byte[] modes = new byte[6];
|
||||
int i = 0;
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
boolean isStrong = isOutputStrong(dir);
|
||||
if(isStrong) {
|
||||
modes[i] = 1;
|
||||
} else {
|
||||
modes[i] = 0;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
nbtRoot.setByteArray("signalStrengths", modes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -496,6 +537,19 @@ public class InsulatedRedstoneConduit extends RedstoneConduit implements IInsula
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
signalStrengths.clear();
|
||||
byte[] strengths = nbtRoot.getByteArray("signalStrengths");
|
||||
if(strengths != null && strengths.length == 6) {
|
||||
int i = 0;
|
||||
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
if(strengths[i] > 0) {
|
||||
signalStrengths.put(dir, true);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -8,8 +8,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.init.Blocks;
|
||||
@@ -18,7 +16,9 @@ import net.minecraft.util.IIcon;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IRedNetOutputNode;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.Optional.Method;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import crazypants.enderio.EnderIO;
|
||||
@@ -30,7 +30,7 @@ import crazypants.enderio.conduit.geom.CollidableComponent;
|
||||
import crazypants.render.IconUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.DyeColor;
|
||||
import powercrystals.minefactoryreloaded.api.rednet.IRedNetOutputNode;
|
||||
import dan200.computercraft.api.ComputerCraftAPI;
|
||||
|
||||
public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit {
|
||||
|
||||
@@ -246,7 +246,7 @@ public class RedstoneConduit extends AbstractConduit implements IRedstoneConduit
|
||||
|
||||
@Override
|
||||
public int isProvidingStrongPower(ForgeDirection toDirection) {
|
||||
return isProvidingWeakPower(toDirection);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,7 +34,7 @@ public enum RedstoneControlMode {
|
||||
}
|
||||
|
||||
public static boolean isConditionMet(RedstoneControlMode redstoneControlMode, TileEntity te) {
|
||||
return isConditionMet(redstoneControlMode, te.getWorldObj().getBlockPowerInput(te.xCoord, te.yCoord, te.zCoord));
|
||||
return isConditionMet(redstoneControlMode, te.getWorldObj().getStrongestIndirectPower(te.xCoord, te.yCoord, te.zCoord));
|
||||
}
|
||||
|
||||
public RedstoneControlMode next() {
|
||||
|
||||
Reference in new issue
Block a user