mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
fixed diodes voiding energy, fixed side restriction confusion
This commit is contained in:
parent
0e334262ac
commit
3ce962018d
@ -26,6 +26,7 @@ public interface IEnergyConnector extends ILoadedTile {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the given side can be connected to
|
* Whether the given side can be connected to
|
||||||
|
* dir refers to the side of this block, not the connecting block doing the check
|
||||||
* @param dir
|
* @param dir
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -58,7 +58,7 @@ public interface IEnergyUser extends IEnergyConnector {
|
|||||||
if(te instanceof IEnergyConductor) {
|
if(te instanceof IEnergyConductor) {
|
||||||
IEnergyConductor con = (IEnergyConductor) te;
|
IEnergyConductor con = (IEnergyConductor) te;
|
||||||
|
|
||||||
if(con.getPowerNet() != null && con.getPowerNet().isSubscribed(this)) {
|
if(con.canConnect(dir.getOpposite()) && con.getPowerNet() != null && con.getPowerNet().isSubscribed(this)) {
|
||||||
con.getPowerNet().unsubscribe(this);
|
con.getPowerNet().unsubscribe(this);
|
||||||
wasSubscribed = true;
|
wasSubscribed = true;
|
||||||
}
|
}
|
||||||
@ -105,7 +105,8 @@ public interface IEnergyUser extends IEnergyConnector {
|
|||||||
|
|
||||||
public default void updateStandardConnections(World world, int x, int y, int z) {
|
public default void updateStandardConnections(World world, int x, int y, int z) {
|
||||||
|
|
||||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
|
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
||||||
this.trySubscribe(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir);
|
this.trySubscribe(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ, dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,8 +18,8 @@ public class RBMKLoader extends BlockGeneric implements IFluidConnectorBlock {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(FluidType type, IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
|
public boolean canConnect(FluidType type, IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
|
||||||
if(type.hasTrait(FT_Heatable.class)) return dir == ForgeDirection.DOWN;
|
if(dir == ForgeDirection.UP) return type.hasTrait(FT_Heatable.class);
|
||||||
return type.hasTrait(FT_Coolable.class) && dir != ForgeDirection.DOWN;
|
return type.hasTrait(FT_Coolable.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -107,25 +107,26 @@ public class Library {
|
|||||||
/*
|
/*
|
||||||
* Is putting this into this trash can a good idea? No. Do I have a better idea? Not currently.
|
* Is putting this into this trash can a good idea? No. Do I have a better idea? Not currently.
|
||||||
*/
|
*/
|
||||||
public static boolean canConnect(IBlockAccess world, int x, int y, int z, ForgeDirection dir) {
|
public static boolean canConnect(IBlockAccess world, int x, int y, int z, ForgeDirection dir /* cable's connecting side */) {
|
||||||
|
|
||||||
if(y > 255 || y < 0)
|
if(y > 255 || y < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Block b = world.getBlock(x, y, z);
|
Block b = world.getBlock(x, y, z);
|
||||||
TileEntity te = world.getTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if(b instanceof IEnergyConnectorBlock) {
|
if(b instanceof IEnergyConnectorBlock) {
|
||||||
IEnergyConnectorBlock con = (IEnergyConnectorBlock) b;
|
IEnergyConnectorBlock con = (IEnergyConnectorBlock) b;
|
||||||
|
|
||||||
if(con.canConnect(world, x, y, z, dir))
|
if(con.canConnect(world, x, y, z, dir.getOpposite() /* machine's connecting side */))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TileEntity te = world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
if(te instanceof IEnergyConnector) {
|
if(te instanceof IEnergyConnector) {
|
||||||
IEnergyConnector con = (IEnergyConnector) te;
|
IEnergyConnector con = (IEnergyConnector) te;
|
||||||
|
|
||||||
if(con.canConnect(dir))
|
if(con.canConnect(dir.getOpposite() /* machine's connecting side */))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,25 +134,26 @@ public class Library {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** dir is the direction along the fluid duct entering the block */
|
/** dir is the direction along the fluid duct entering the block */
|
||||||
public static boolean canConnectFluid(IBlockAccess world, int x, int y, int z, ForgeDirection dir, FluidType type) {
|
public static boolean canConnectFluid(IBlockAccess world, int x, int y, int z, ForgeDirection dir /* duct's connecting side */, FluidType type) {
|
||||||
|
|
||||||
if(y > 255 || y < 0)
|
if(y > 255 || y < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Block b = world.getBlock(x, y, z);
|
Block b = world.getBlock(x, y, z);
|
||||||
TileEntity te = world.getTileEntity(x, y, z);
|
|
||||||
|
|
||||||
if(b instanceof IFluidConnectorBlock) {
|
if(b instanceof IFluidConnectorBlock) {
|
||||||
IFluidConnectorBlock con = (IFluidConnectorBlock) b;
|
IFluidConnectorBlock con = (IFluidConnectorBlock) b;
|
||||||
|
|
||||||
if(con.canConnect(type, world, x, y, z, dir.getOpposite()))
|
if(con.canConnect(type, world, x, y, z, dir.getOpposite() /* machine's connecting side */))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TileEntity te = world.getTileEntity(x, y, z);
|
||||||
|
|
||||||
if(te instanceof IFluidConnector) {
|
if(te instanceof IFluidConnector) {
|
||||||
IFluidConnector con = (IFluidConnector) te;
|
IFluidConnector con = (IFluidConnector) te;
|
||||||
|
|
||||||
if(con.canConnect(type, dir.getOpposite()))
|
if(con.canConnect(type, dir.getOpposite() /* machine's connecting side */))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -56,12 +56,12 @@ public class RenderCable implements ISimpleBlockRenderingHandler {
|
|||||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||||
tessellator.setColorOpaque_F(1, 1, 1);
|
tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
|
||||||
boolean pX = Library.canConnect(world, x + 1, y, z, Library.NEG_X);
|
boolean pX = Library.canConnect(world, x + 1, y, z, Library.POS_X);
|
||||||
boolean nX = Library.canConnect(world, x - 1, y, z, Library.POS_X);
|
boolean nX = Library.canConnect(world, x - 1, y, z, Library.NEG_X);
|
||||||
boolean pY = Library.canConnect(world, x, y + 1, z, Library.NEG_Y);
|
boolean pY = Library.canConnect(world, x, y + 1, z, Library.POS_Y);
|
||||||
boolean nY = Library.canConnect(world, x, y - 1, z, Library.POS_Y);
|
boolean nY = Library.canConnect(world, x, y - 1, z, Library.NEG_Y);
|
||||||
boolean pZ = Library.canConnect(world, x, y, z + 1, Library.NEG_Z);
|
boolean pZ = Library.canConnect(world, x, y, z + 1, Library.POS_Z);
|
||||||
boolean nZ = Library.canConnect(world, x, y, z - 1, Library.POS_Z);
|
boolean nZ = Library.canConnect(world, x, y, z - 1, Library.NEG_Z);
|
||||||
|
|
||||||
tessellator.addTranslation(x + 0.5F, y + 0.5F, z + 0.5F);
|
tessellator.addTranslation(x + 0.5F, y + 0.5F, z + 0.5F);
|
||||||
|
|
||||||
|
|||||||
@ -81,12 +81,12 @@ public class RenderTestPipe implements ISimpleBlockRenderingHandler {
|
|||||||
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
tessellator.setBrightness(block.getMixedBrightnessForBlock(world, x, y, z));
|
||||||
tessellator.setColorOpaque_F(1, 1, 1);
|
tessellator.setColorOpaque_F(1, 1, 1);
|
||||||
|
|
||||||
boolean pX = Library.canConnectFluid(world, x + 1, y, z, Library.NEG_X, type);
|
boolean pX = Library.canConnectFluid(world, x + 1, y, z, Library.POS_X, type);
|
||||||
boolean nX = Library.canConnectFluid(world, x - 1, y, z, Library.POS_X, type);
|
boolean nX = Library.canConnectFluid(world, x - 1, y, z, Library.NEG_X, type);
|
||||||
boolean pY = Library.canConnectFluid(world, x, y + 1, z, Library.NEG_Y, type);
|
boolean pY = Library.canConnectFluid(world, x, y + 1, z, Library.POS_Y, type);
|
||||||
boolean nY = Library.canConnectFluid(world, x, y - 1, z, Library.POS_Y, type);
|
boolean nY = Library.canConnectFluid(world, x, y - 1, z, Library.NEG_Y, type);
|
||||||
boolean pZ = Library.canConnectFluid(world, x, y, z + 1, Library.NEG_Z, type);
|
boolean pZ = Library.canConnectFluid(world, x, y, z + 1, Library.POS_Z, type);
|
||||||
boolean nZ = Library.canConnectFluid(world, x, y, z - 1, Library.POS_Z, type);
|
boolean nZ = Library.canConnectFluid(world, x, y, z - 1, Library.NEG_Z, type);
|
||||||
|
|
||||||
int mask = 0 + (pX ? 32 : 0) + (nX ? 16 : 0) + (pY ? 8 : 0) + (nY ? 4 : 0) + (pZ ? 2 : 0) + (nZ ? 1 : 0);
|
int mask = 0 + (pX ? 32 : 0) + (nX ? 16 : 0) + (pY ? 8 : 0) + (nY ? 4 : 0) + (pZ ? 2 : 0) + (nZ ? 1 : 0);
|
||||||
|
|
||||||
|
|||||||
@ -206,7 +206,7 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
|
|||||||
//if it's a cable, buffer both the network and all subscribers of the net
|
//if it's a cable, buffer both the network and all subscribers of the net
|
||||||
if(te instanceof IEnergyConductor) {
|
if(te instanceof IEnergyConductor) {
|
||||||
IEnergyConductor con = (IEnergyConductor) te;
|
IEnergyConductor con = (IEnergyConductor) te;
|
||||||
if(con.getPowerNet() != null) {
|
if(con.canConnect(dir.getOpposite()) && con.getPowerNet() != null) {
|
||||||
nets.add(con.getPowerNet());
|
nets.add(con.getPowerNet());
|
||||||
con.getPowerNet().unsubscribe(this);
|
con.getPowerNet().unsubscribe(this);
|
||||||
consumers.addAll(con.getPowerNet().getSubscribers());
|
consumers.addAll(con.getPowerNet().getSubscribers());
|
||||||
|
|||||||
@ -72,7 +72,7 @@ public class TileEntityCableBaseNT extends TileEntity implements IEnergyConducto
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection dir) {
|
public boolean canConnect(ForgeDirection dir) {
|
||||||
return true;
|
return dir != ForgeDirection.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -3,6 +3,8 @@ package com.hbm.tileentity.network;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import api.hbm.energy.IEnergyConductor;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
import net.minecraft.util.Vec3;
|
import net.minecraft.util.Vec3;
|
||||||
import net.minecraftforge.common.util.ForgeDirection;
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
@ -27,14 +29,32 @@ public class TileEntityConnector extends TileEntityPylonBase {
|
|||||||
public List<int[]> getConnectionPoints() {
|
public List<int[]> getConnectionPoints() {
|
||||||
List<int[]> pos = new ArrayList(connected);
|
List<int[]> pos = new ArrayList(connected);
|
||||||
|
|
||||||
for(ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
|
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite();
|
||||||
pos.add(new int[] {xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ});
|
//pos.add(new int[] {xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ});
|
||||||
|
|
||||||
|
TileEntity te = worldObj.getTileEntity(xCoord, yCoord, zCoord);
|
||||||
|
|
||||||
|
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;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canConnect(ForgeDirection dir) { //i've about had it with your fucking bullshit
|
public boolean canConnect(ForgeDirection dir) { //i've about had it with your fucking bullshit
|
||||||
return true;
|
return ForgeDirection.getOrientation(this.getBlockMetadata()).getOpposite() == dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 295 B |
Binary file not shown.
|
After Width: | Height: | Size: 232 B |
Loading…
x
Reference in New Issue
Block a user