mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
NEITHER SNOW NOR RAIN NOR THE GLOOM OF NIGHT
This commit is contained in:
parent
c16818c15d
commit
e5dffd3d2a
@ -79,13 +79,8 @@ public class Nodespace {
|
||||
|
||||
if(conNode.hasValidNet() && conNode.net == node.net) continue; // if the net is valid and both nodes have the same net, skip
|
||||
|
||||
for(DirPos revCon : conNode.connections) { // check if neighbor node also has a valid reverse connection
|
||||
|
||||
// god i hope i didn't fuck this up my brain is hurting already
|
||||
if(revCon.getX() - revCon.getDir().offsetX == con.getX() && revCon.getY() - revCon.getDir().offsetY == con.getY() && revCon.getZ() - revCon.getDir().offsetZ == con.getZ() && revCon.getDir() == con.getDir().getOpposite()) {
|
||||
connectToNode(node, conNode);
|
||||
break;
|
||||
}
|
||||
if(checkConnection(conNode, con, false)) {
|
||||
connectToNode(node, conNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -93,6 +88,18 @@ public class Nodespace {
|
||||
if(node.net == null || !node.net.isValid()) new PowerNetMK2().joinLink(node);
|
||||
}
|
||||
|
||||
public static boolean checkConnection(PowerNode connectsTo, DirPos connectFrom, boolean skipSideCheck) {
|
||||
|
||||
for(DirPos revCon : connectsTo.connections) {
|
||||
|
||||
if(revCon.getX() - revCon.getDir().offsetX == connectFrom.getX() && revCon.getY() - revCon.getDir().offsetY == connectFrom.getY() && revCon.getZ() - revCon.getDir().offsetZ == connectFrom.getZ() && (revCon.getDir() == connectFrom.getDir().getOpposite() || skipSideCheck)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Links two nodes with different or potentially no networks */
|
||||
private static void connectToNode(PowerNode origin, PowerNode connection) {
|
||||
|
||||
@ -166,6 +173,14 @@ public class Nodespace {
|
||||
return this;
|
||||
}
|
||||
|
||||
public PowerNode addConnection(DirPos connection) {
|
||||
DirPos[] newCons = new DirPos[this.connections.length + 1];
|
||||
for(int i = 0; i < this.connections.length; i++) newCons[i] = this.connections[i];
|
||||
newCons[newCons.length - 1] = connection;
|
||||
this.connections = newCons;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean hasValidNet() {
|
||||
return this.net != null && this.net.isValid();
|
||||
}
|
||||
|
||||
@ -177,6 +177,10 @@ public class PowerNetMK2 {
|
||||
}
|
||||
}
|
||||
|
||||
public long sendPowerDiode(long power) {
|
||||
return power;
|
||||
}
|
||||
|
||||
public static final ReceiverComparator COMP = new ReceiverComparator();
|
||||
|
||||
public static class ReceiverComparator implements Comparator<IEnergyReceiverMK2> {
|
||||
|
||||
@ -8,9 +8,14 @@ import com.hbm.blocks.ITooltipProvider;
|
||||
import com.hbm.tileentity.TileEntityLoadedBase;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
import com.hbm.util.I18nUtil;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.block.IToolable;
|
||||
import api.hbm.energymk2.IEnergyConnectorBlock;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2;
|
||||
import api.hbm.energymk2.Nodespace;
|
||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||
import api.hbm.energymk2.IEnergyReceiverMK2.ConnectionPriority;
|
||||
import cpw.mods.fml.client.registry.RenderingRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
@ -136,7 +141,7 @@ public class CableDiode extends BlockContainer implements IEnergyConnectorBlock,
|
||||
return new TileEntityDiode();
|
||||
}
|
||||
|
||||
public static class TileEntityDiode extends TileEntityLoadedBase implements IEnergyUser {
|
||||
public static class TileEntityDiode extends TileEntityLoadedBase implements IEnergyReceiverMK2 {
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
@ -189,9 +194,9 @@ public class CableDiode extends BlockContainer implements IEnergyConnectorBlock,
|
||||
return dir != getDir();
|
||||
}
|
||||
|
||||
/** Used as an intra-tick tracker for how much energy has been transmitted, resets to 0 each tick and maxes out based on transfer */
|
||||
private long power;
|
||||
private boolean recursionBrake = false;
|
||||
private long subBuffer;
|
||||
private long contingent = 0;
|
||||
private long lastTransfer = 0;
|
||||
private int pulses = 0;
|
||||
public ConnectionPriority priority = ConnectionPriority.NORMAL;
|
||||
@ -206,31 +211,25 @@ public class CableDiode extends BlockContainer implements IEnergyConnectorBlock,
|
||||
|
||||
if(lastTransfer != worldObj.getTotalWorldTime()) {
|
||||
lastTransfer = worldObj.getTotalWorldTime();
|
||||
contingent = getMaxPower();
|
||||
pulses = 0;
|
||||
this.setPower(0); //tick is over, reset our allowed transfe
|
||||
}
|
||||
|
||||
if(contingent <= 0 || pulses > 10)
|
||||
return power;
|
||||
|
||||
//this part turns "maxPower" from a glorified transfer weight into an actual transfer cap
|
||||
long overShoot = Math.max(0, power - contingent);
|
||||
power = Math.min(power, contingent);
|
||||
if(this.getPower() >= this.getMaxPower() || pulses > 10) return power; //if we have already maxed out transfer or max pulses, abort
|
||||
|
||||
recursionBrake = true;
|
||||
this.subBuffer = power;
|
||||
|
||||
ForgeDirection dir = getDir();
|
||||
this.sendPower(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir);
|
||||
long ret = this.subBuffer;
|
||||
PowerNode node = Nodespace.getNode(worldObj, xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
|
||||
long sent = power - ret;
|
||||
contingent -= sent;
|
||||
if(node.hasValidNet() && Nodespace.checkConnection(node, new DirPos(xCoord, yCoord, zCoord, dir), false)) {
|
||||
long prevPower = power;
|
||||
power = node.net.sendPowerDiode(power);
|
||||
this.power += (prevPower - power);
|
||||
}
|
||||
|
||||
this.subBuffer = 0;
|
||||
recursionBrake = false;
|
||||
|
||||
return ret + overShoot;
|
||||
return power;
|
||||
}
|
||||
|
||||
|
||||
@ -241,12 +240,12 @@ public class CableDiode extends BlockContainer implements IEnergyConnectorBlock,
|
||||
|
||||
@Override
|
||||
public long getPower() {
|
||||
return subBuffer;
|
||||
return Math.min(power, this.getMaxPower());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPower(long power) {
|
||||
this.subBuffer = power;
|
||||
this.power = power;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,20 +1,14 @@
|
||||
package com.hbm.inventory.gui;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import com.hbm.inventory.container.ContainerMachineSelenium;
|
||||
import com.hbm.inventory.fluid.FluidType;
|
||||
import com.hbm.inventory.fluid.Fluids;
|
||||
import com.hbm.lib.RefStrings;
|
||||
import com.hbm.tileentity.machine.TileEntityMachineSeleniumEngine;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.I18n;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
public class GUIMachineSelenium extends GuiInfoContainer {
|
||||
@ -36,22 +30,6 @@ public class GUIMachineSelenium extends GuiInfoContainer {
|
||||
|
||||
selenium.tank.renderTankInfo(this, mouseX, mouseY, guiLeft + 116, guiTop + 18, 16, 52);
|
||||
this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 8, guiTop + 108, 160, 16, selenium.power, selenium.powerCap);
|
||||
|
||||
List<String> text = new ArrayList();
|
||||
text.add(EnumChatFormatting.YELLOW + "Accepted Fuels:");
|
||||
|
||||
for(FluidType type : Fluids.getInNiceOrder()) {
|
||||
long energy = selenium.getHEFromFuel(type);
|
||||
|
||||
if(energy > 0)
|
||||
text.add(" " + type.getLocalizedName() + " (" + BobMathUtil.getShortNumber(energy) + "HE/t)");
|
||||
}
|
||||
|
||||
text.add(EnumChatFormatting.ITALIC + "(These numbers are base values,");
|
||||
text.add(EnumChatFormatting.ITALIC + "actual output is based");
|
||||
text.add(EnumChatFormatting.ITALIC + "on piston count)");
|
||||
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 36, 16, 16, guiLeft - 8, guiTop + 36 + 16, text.toArray(new String[0]));
|
||||
|
||||
String[] text1 = new String[] { "Fuel consumption rate:",
|
||||
" 1 mB/t",
|
||||
@ -65,13 +43,6 @@ public class GUIMachineSelenium extends GuiInfoContainer {
|
||||
"required to operate this radial engine!" };
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 36 + 32, 16, 16, guiLeft - 8, guiTop + 36 + 16 + 32, text2);
|
||||
}
|
||||
|
||||
if(!selenium.hasAcceptableFuel()) {
|
||||
|
||||
String[] text2 = new String[] { "Error: The currently set fuel type",
|
||||
"is not supported by this engine!" };
|
||||
this.drawCustomInfoStat(mouseX, mouseY, guiLeft - 16, guiTop + 36 + 48, 16, 16, guiLeft - 8, guiTop + 36 + 16 + 32, text2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,19 +59,6 @@ public class GUIMachineSelenium extends GuiInfoContainer {
|
||||
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
|
||||
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
|
||||
|
||||
if(selenium.power > 0) {
|
||||
int i = (int)selenium.getPowerScaled(160);
|
||||
|
||||
i = (int) Math.min(i, 160);
|
||||
|
||||
drawTexturedModalRect(guiLeft + 8, guiTop + 108, 0, 222, i, 16);
|
||||
}
|
||||
|
||||
if(selenium.tank.getFill() > 0 && selenium.hasAcceptableFuel() && selenium.pistonCount > 2)
|
||||
{
|
||||
drawTexturedModalRect(guiLeft + 115, guiTop + 71, 192, 0, 18, 18);
|
||||
}
|
||||
|
||||
if(selenium.pistonCount > 0)
|
||||
{
|
||||
int k = selenium.pistonCount;
|
||||
@ -110,9 +68,6 @@ public class GUIMachineSelenium extends GuiInfoContainer {
|
||||
if(selenium.pistonCount < 3)
|
||||
this.drawInfoPanel(guiLeft - 16, guiTop + 36 + 32, 16, 16, 6);
|
||||
|
||||
if(!selenium.hasAcceptableFuel())
|
||||
this.drawInfoPanel(guiLeft - 16, guiTop + 36 + 48, 16, 16, 7);
|
||||
|
||||
this.drawInfoPanel(guiLeft - 16, guiTop + 36, 16, 16, 2);
|
||||
this.drawInfoPanel(guiLeft - 16, guiTop + 36 + 16, 16, 16, 3);
|
||||
|
||||
|
||||
@ -6,11 +6,12 @@ import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.packet.AuxParticlePacketNT;
|
||||
import com.hbm.packet.PacketDispatcher;
|
||||
import com.hbm.util.ChatBuilder;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
|
||||
import api.hbm.energy.IEnergyConductor;
|
||||
import api.hbm.energy.IEnergyConnector;
|
||||
import api.hbm.energy.IPowerNet;
|
||||
import api.hbm.energy.PowerNet;
|
||||
import api.hbm.energymk2.IEnergyConductorMK2;
|
||||
import api.hbm.energymk2.Nodespace;
|
||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||
import api.hbm.energymk2.PowerNetMK2;
|
||||
import cpw.mods.fml.common.network.NetworkRegistry.TargetPoint;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
@ -19,7 +20,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ItemPowerNetTool extends Item {
|
||||
@ -44,51 +44,33 @@ public class ItemPowerNetTool extends Item {
|
||||
if(world.isRemote)
|
||||
return true;
|
||||
|
||||
if((te instanceof IEnergyConductor)) {
|
||||
if((te instanceof IEnergyConductorMK2)) {
|
||||
PowerNode node = Nodespace.getNode(world, x, y, z);
|
||||
|
||||
IEnergyConductor con = (IEnergyConductor) te;
|
||||
IPowerNet net = con.getPowerNet();
|
||||
|
||||
if(net == null) {
|
||||
player.addChatComponentMessage(ChatBuilder.start("Error: No network found! This should be impossible!").color(EnumChatFormatting.RED).flush());
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!(net instanceof PowerNet)) {
|
||||
player.addChatComponentMessage(ChatBuilder.start("Error: Cannot print diagnostic for non-standard power net implementation!").color(EnumChatFormatting.RED).flush());
|
||||
}
|
||||
|
||||
PowerNet network = (PowerNet) net;
|
||||
String id = Integer.toHexString(net.hashCode());
|
||||
|
||||
player.addChatComponentMessage(ChatBuilder.start("Start of diagnostic for network " + id).color(EnumChatFormatting.GOLD).flush());
|
||||
player.addChatComponentMessage(ChatBuilder.start("Links: " + network.getLinks().size()).color(EnumChatFormatting.YELLOW).flush());
|
||||
player.addChatComponentMessage(ChatBuilder.start("Proxies: " + network.getProxies().size()).color(EnumChatFormatting.YELLOW).flush());
|
||||
player.addChatComponentMessage(ChatBuilder.start("Subscribers: " + network.getSubscribers().size()).color(EnumChatFormatting.YELLOW).flush());
|
||||
player.addChatComponentMessage(ChatBuilder.start("End of diagnostic for network " + id).color(EnumChatFormatting.GOLD).flush());
|
||||
|
||||
for(IEnergyConductor link : network.getLinks()) {
|
||||
Vec3 pos = link.getDebugParticlePos();
|
||||
if(node != null && node.hasValidNet()) {
|
||||
|
||||
boolean errored = link.getPowerNet() != net;
|
||||
PowerNetMK2 net = node.net;
|
||||
String id = Integer.toHexString(net.hashCode());
|
||||
player.addChatComponentMessage(ChatBuilder.start("Start of diagnostic for network " + id).color(EnumChatFormatting.GOLD).flush());
|
||||
player.addChatComponentMessage(ChatBuilder.start("Links: " + net.links.size()).color(EnumChatFormatting.YELLOW).flush());
|
||||
player.addChatComponentMessage(ChatBuilder.start("Providers: " + net.providerEntries.size()).color(EnumChatFormatting.YELLOW).flush());
|
||||
player.addChatComponentMessage(ChatBuilder.start("Receivers: " + net.receiverEntries.size()).color(EnumChatFormatting.YELLOW).flush());
|
||||
player.addChatComponentMessage(ChatBuilder.start("End of diagnostic for network " + id).color(EnumChatFormatting.GOLD).flush());
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "debug");
|
||||
data.setInteger("color", errored ? 0xff0000 : 0xffff00);
|
||||
data.setFloat("scale", 0.5F);
|
||||
data.setString("text", id);
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, pos.xCoord, pos.yCoord, pos.zCoord), new TargetPoint(world.provider.dimensionId, pos.xCoord, pos.yCoord, pos.zCoord, radius));
|
||||
}
|
||||
|
||||
for(IEnergyConnector subscriber : network.getSubscribers()) {
|
||||
Vec3 pos = subscriber.getDebugParticlePos();
|
||||
for(PowerNode link : net.links) {
|
||||
|
||||
for(BlockPos pos : link.positions) {
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "debug");
|
||||
data.setInteger("color", 0xffff00);
|
||||
data.setFloat("scale", 0.5F);
|
||||
data.setString("text", id);
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, pos.getX() + 0.5, pos.getY() + 1.5, pos.getZ() + 0.5), new TargetPoint(world.provider.dimensionId, pos.getX(), pos.getY(), pos.getZ(), radius));
|
||||
}
|
||||
}
|
||||
|
||||
NBTTagCompound data = new NBTTagCompound();
|
||||
data.setString("type", "debug");
|
||||
data.setInteger("color", 0x0000ff);
|
||||
data.setFloat("scale", 1.5F);
|
||||
data.setString("text", id);
|
||||
PacketDispatcher.wrapper.sendToAllAround(new AuxParticlePacketNT(data, pos.xCoord, pos.yCoord, pos.zCoord), new TargetPoint(world.provider.dimensionId, pos.xCoord, pos.yCoord, pos.zCoord, radius));
|
||||
} else {
|
||||
player.addChatComponentMessage(ChatBuilder.start("Error: No network found!").color(EnumChatFormatting.RED).flush());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -46,9 +46,6 @@ public class RenderSelenium extends TileEntitySpecialRenderer {
|
||||
ResourceManager.selenium_piston.renderAll();
|
||||
GL11.glRotatef(rot, 0, 0, 1);
|
||||
}
|
||||
|
||||
if(count > 2 && ((TileEntityMachineSeleniumEngine)tileEntity).hasAcceptableFuel() && ((TileEntityMachineSeleniumEngine)tileEntity).tank.getFill() > 0)
|
||||
GL11.glRotatef((System.currentTimeMillis() / 2) % 360, 0F, 0F, -1F);
|
||||
|
||||
bindTexture(ResourceManager.selenium_rotor_tex);
|
||||
ResourceManager.selenium_rotor.renderAll();
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.energy.IEnergyConductor;
|
||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
@ -24,33 +24,14 @@ public class TileEntityConnector extends TileEntityPylonBase {
|
||||
public double getMaxWireLength() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<int[]> getConnectionPoints() {
|
||||
List<int[]> pos = new ArrayList(connected);
|
||||
|
||||
public PowerNode createNode() {
|
||||
TileEntity tile = (TileEntity) this;
|
||||
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite();
|
||||
//pos.add(new int[] {xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ});
|
||||
|
||||
TileEntity te = worldObj.getTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
|
||||
IEnergyConductor conductor = (IEnergyConductor) te;
|
||||
|
||||
if(conductor.canConnect(dir.getOpposite())) {
|
||||
|
||||
if(this.getPowerNet() == null && conductor.getPowerNet() != null) {
|
||||
conductor.getPowerNet().joinLink(this);
|
||||
}
|
||||
|
||||
if(this.getPowerNet() != null && conductor.getPowerNet() != null && this.getPowerNet() != conductor.getPowerNet()) {
|
||||
conductor.getPowerNet().joinNetworks(this.getPowerNet());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
PowerNode node = new PowerNode(new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord)).setConnections(new DirPos(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ, dir));
|
||||
for(int[] pos : this.connected) node.addConnection(new DirPos(pos[0], pos[1], pos[2], ForgeDirection.UNKNOWN));
|
||||
return node;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -1,8 +1,11 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
@ -22,14 +25,19 @@ public class TileEntityPylon extends TileEntityPylonBase {
|
||||
public double getMaxWireLength() {
|
||||
return 25D;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<int[]> getConnectionPoints() {
|
||||
List<int[]> pos = new ArrayList(connected);
|
||||
|
||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||
pos.add(new int[] {xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ});
|
||||
}
|
||||
return pos;
|
||||
public PowerNode createNode() {
|
||||
TileEntity tile = (TileEntity) this;
|
||||
PowerNode node = new PowerNode(new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord)).setConnections(
|
||||
new DirPos(xCoord + 1, yCoord, zCoord, Library.POS_X),
|
||||
new DirPos(xCoord - 1, yCoord, zCoord, Library.NEG_X),
|
||||
new DirPos(xCoord, yCoord + 1, zCoord, Library.POS_Y),
|
||||
new DirPos(xCoord, yCoord - 1, zCoord, Library.NEG_Y),
|
||||
new DirPos(xCoord, yCoord, zCoord + 1, Library.POS_Z),
|
||||
new DirPos(xCoord, yCoord, zCoord - 1, Library.NEG_Z)
|
||||
);
|
||||
for(int[] pos : this.connected) node.addConnection(new DirPos(pos[0], pos[1], pos[2], ForgeDirection.UNKNOWN));
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,11 @@ package com.hbm.tileentity.network;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import api.hbm.energy.IEnergyConductor;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.energymk2.Nodespace;
|
||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@ -14,6 +18,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
|
||||
|
||||
@ -40,15 +45,22 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
|
||||
|
||||
return len >= delta.lengthVector() ? 0 : 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PowerNode createNode() {
|
||||
TileEntity tile = (TileEntity) this;
|
||||
PowerNode node = new PowerNode(new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord));
|
||||
for(int[] pos : this.connected) node.addConnection(new DirPos(pos[0], pos[1], pos[2], ForgeDirection.UNKNOWN));
|
||||
return node;
|
||||
}
|
||||
|
||||
public void addConnection(int x, int y, int z) {
|
||||
|
||||
connected.add(new int[] {x, y, z});
|
||||
|
||||
if(this.getPowerNet() != null) {
|
||||
this.getPowerNet().reevaluate();
|
||||
this.network = null;
|
||||
}
|
||||
PowerNode node = Nodespace.getNode(worldObj, xCoord, yCoord, zCoord);
|
||||
node.recentlyChanged = true;
|
||||
node.addConnection(new DirPos(x, y, z, ForgeDirection.UNKNOWN));
|
||||
|
||||
this.markDirty();
|
||||
|
||||
@ -87,33 +99,8 @@ public abstract class TileEntityPylonBase extends TileEntityCableBaseNT {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void connect() {
|
||||
|
||||
for(int[] pos : getConnectionPoints()) {
|
||||
|
||||
TileEntity te = worldObj.getTileEntity(pos[0], pos[1], pos[2]);
|
||||
|
||||
if(te instanceof IEnergyConductor) {
|
||||
|
||||
IEnergyConductor conductor = (IEnergyConductor) te;
|
||||
|
||||
if(this.getPowerNet() == null && conductor.getPowerNet() != null) {
|
||||
conductor.getPowerNet().joinLink(this);
|
||||
}
|
||||
|
||||
if(this.getPowerNet() != null && conductor.getPowerNet() != null && this.getPowerNet() != conductor.getPowerNet()) {
|
||||
conductor.getPowerNet().joinNetworks(this.getPowerNet());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<int[]> getConnectionPoints() {
|
||||
return new ArrayList(connected);
|
||||
Nodespace.destroyNode(worldObj, xCoord, yCoord, zCoord);
|
||||
}
|
||||
|
||||
public abstract ConnectionType getConnectionType();
|
||||
|
||||
@ -1,12 +1,14 @@
|
||||
package com.hbm.tileentity.network;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.blocks.BlockDummyable;
|
||||
import com.hbm.lib.Library;
|
||||
import com.hbm.util.fauxpointtwelve.BlockPos;
|
||||
import com.hbm.util.fauxpointtwelve.DirPos;
|
||||
|
||||
import api.hbm.energy.IEnergyConductor;
|
||||
import api.hbm.energymk2.Nodespace.PowerNode;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.Vec3;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
|
||||
public class TileEntitySubstation extends TileEntityPylonBase {
|
||||
|
||||
@ -45,33 +47,21 @@ public class TileEntitySubstation extends TileEntityPylonBase {
|
||||
public double getMaxWireLength() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<int[]> getConnectionPoints() {
|
||||
List<int[]> pos = new ArrayList(connected);
|
||||
pos.add(new int[] {xCoord + 2, yCoord, zCoord - 1});
|
||||
pos.add(new int[] {xCoord + 2, yCoord, zCoord + 1});
|
||||
pos.add(new int[] {xCoord - 2, yCoord, zCoord - 1});
|
||||
pos.add(new int[] {xCoord - 2, yCoord, zCoord + 1});
|
||||
pos.add(new int[] {xCoord - 1, yCoord, zCoord + 2});
|
||||
pos.add(new int[] {xCoord + 1, yCoord, zCoord + 2});
|
||||
pos.add(new int[] {xCoord - 1, yCoord, zCoord - 2});
|
||||
pos.add(new int[] {xCoord + 1, yCoord, zCoord - 2});
|
||||
return pos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasProxies() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getProxies() {
|
||||
List<Integer> proxies = new ArrayList();
|
||||
proxies.add(IEnergyConductor.getIdentityFromPos(xCoord + 1, yCoord, zCoord + 1));
|
||||
proxies.add(IEnergyConductor.getIdentityFromPos(xCoord + 1, yCoord, zCoord - 1));
|
||||
proxies.add(IEnergyConductor.getIdentityFromPos(xCoord - 1, yCoord, zCoord + 1));
|
||||
proxies.add(IEnergyConductor.getIdentityFromPos(xCoord - 1, yCoord, zCoord - 1));
|
||||
return proxies;
|
||||
public PowerNode createNode() {
|
||||
TileEntity tile = (TileEntity) this;
|
||||
PowerNode node = new PowerNode(new BlockPos(tile.xCoord, tile.yCoord, tile.zCoord)).setConnections(
|
||||
new DirPos(xCoord + 2, yCoord, zCoord - 1, Library.POS_X),
|
||||
new DirPos(xCoord + 2, yCoord, zCoord + 1, Library.POS_X),
|
||||
new DirPos(xCoord - 2, yCoord, zCoord - 1, Library.NEG_X),
|
||||
new DirPos(xCoord - 2, yCoord, zCoord + 1, Library.NEG_X),
|
||||
new DirPos(xCoord - 1, yCoord, zCoord + 2, Library.POS_Z),
|
||||
new DirPos(xCoord + 1, yCoord, zCoord + 2, Library.POS_Z),
|
||||
new DirPos(xCoord - 1, yCoord, zCoord - 2, Library.NEG_Z),
|
||||
new DirPos(xCoord + 1, yCoord, zCoord - 2, Library.NEG_Z)
|
||||
);
|
||||
for(int[] pos : this.connected) node.addConnection(new DirPos(pos[0], pos[1], pos[2], ForgeDirection.UNKNOWN));
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user