-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathNuclearHelper.java
More file actions
94 lines (81 loc) · 2.87 KB
/
Copy pathNuclearHelper.java
File metadata and controls
94 lines (81 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
package shedar.mods.ic2.nuclearcontrol.utils;
import cpw.mods.fml.common.Loader;
import ic2.api.reactor.IReactor;
import ic2.api.reactor.IReactorChamber;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
import shedar.mods.ic2.nuclearcontrol.IC2NuclearControl;
import shedar.mods.ic2.nuclearcontrol.crossmod.ic2.IC2Cross;
public class NuclearHelper {
private static final double STEAM_PER_EU = 3.2D;
public static IReactor getReactorAt(World world, int x, int y, int z) {
if (world == null)
return null;
TileEntity entity = world.getTileEntity(x, y, z);
if (entity instanceof IReactor)
return (IReactor) entity;
return null;
}
public static boolean isSteam(IReactor reactor) {
return IC2NuclearControl.instance.crossIc2.isSteamReactor((TileEntity) reactor);
}
public static int euToSteam(int eu) {
return (int) Math.floor((eu) * STEAM_PER_EU);
}
public static IReactorChamber getReactorChamberAt(World world, int x, int y, int z) {
if (world == null)
return null;
TileEntity entity = world.getTileEntity(x, y, z);
if (entity instanceof IReactorChamber) {
return (IReactorChamber) entity;
}
return null;
}
public static IReactor getReactorAroundCoord(World world, int x, int y, int z) {
if (world == null)
return null;
IReactor reactor = null;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
reactor = getReactorAt(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if(reactor != null)
{
break;
}
}
return reactor;
}
public static IReactorChamber getReactorChamberAroundCoord(World world, int x, int y, int z) {
if (world == null)
return null;
IReactorChamber chamber = null;
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
chamber = getReactorChamberAt(world, x + dir.offsetX, y + dir.offsetY, z + dir.offsetZ);
if(chamber != null)
{
break;
}
}
return chamber;
}
public static boolean isProducing(IReactor reactor) {
ChunkCoordinates position = reactor.getPosition();
return reactor.getWorld().isBlockIndirectlyGettingPowered(position.posX, position.posY, position.posZ);
}
public static int getNuclearCellTimeLeft(ItemStack rStack) {
int val;
if (IC2NuclearControl.instance.crossGT.isApiAvailable()) {
val = IC2NuclearControl.instance.crossGT.getNuclearCellTimeLeft(rStack);
if (val == -1)
{
val = IC2NuclearControl.instance.crossIc2.getNuclearCellTimeLeft(rStack);
}
} else {
val = IC2NuclearControl.instance.crossIc2.getNuclearCellTimeLeft(rStack);
}
return val;
}
}