mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-15 17:44:46 +00:00
add wireless fluid pattern terminal
This commit is contained in:
1 parent
a22814940b
commit
7f53e01184
25 files changed
+708
-91
No files matched your search
@@ -37,6 +37,7 @@ public class NameConst {
|
||||
public static final String ITEM_FLUID_STORAGE = "fluid_storage";
|
||||
public static final String ITEM_FLUID_PORTABLE_CELL = "portable_fluid_cell";
|
||||
public static final String ITEM_WIRELESS_FLUID_TERMINAL = "wireless_fluid_terminal";
|
||||
public static final String ITEM_WIRELESS_FLUID_PATTERN_TERMINAL = "wireless_fluid_pattern_terminal";
|
||||
public static final String ITEM_FLUID_PART = "fluid_part";
|
||||
|
||||
public static final String TT_KEY = FluidCraft.MODID + ".tooltip.";
|
||||
|
||||
@@ -27,13 +27,13 @@ import appeng.api.storage.StorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.WorldCoord;
|
||||
import appeng.items.tools.powered.ToolWirelessTerminal;
|
||||
import appeng.tile.networking.TileCableBus;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.item.AEFluidStack;
|
||||
|
||||
import com.glodblock.github.common.item.ItemFluidDrop;
|
||||
import com.glodblock.github.common.item.ItemFluidPacket;
|
||||
import com.glodblock.github.common.item.ItemWirelessFluidTerminal;
|
||||
import com.glodblock.github.inventory.IAEFluidTank;
|
||||
|
||||
import cpw.mods.fml.common.ModContainer;
|
||||
@@ -42,24 +42,28 @@ import io.netty.buffer.ByteBuf;
|
||||
|
||||
public final class Util {
|
||||
|
||||
public static IGridNode getWirelessGrid(ItemStack is, BlockPos pos, StorageChannel channel) {
|
||||
String key = ((ItemWirelessFluidTerminal) is.getItem()).getEncryptionKey(is);
|
||||
IGridHost securityTerminal = (IGridHost) AEApi.instance().registries().locatable()
|
||||
.getLocatableBy(Long.parseLong(key));
|
||||
if (securityTerminal == null) return null;
|
||||
return securityTerminal.getGridNode(ForgeDirection.UNKNOWN);
|
||||
public static IGridNode getWirelessGrid(ItemStack is) {
|
||||
if (is.getItem() instanceof ToolWirelessTerminal) {
|
||||
String key = ((ToolWirelessTerminal) is.getItem()).getEncryptionKey(is);
|
||||
IGridHost securityTerminal = (IGridHost) AEApi.instance().registries().locatable()
|
||||
.getLocatableBy(Long.parseLong(key));
|
||||
if (securityTerminal == null) return null;
|
||||
return securityTerminal.getGridNode(ForgeDirection.UNKNOWN);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static IBaseMonitor<? extends IAEStack<? extends IAEStack<?>>> getWirelessInv(ItemStack is, BlockPos pos,
|
||||
StorageChannel channel) {
|
||||
IGridNode gridNode = getWirelessGrid(is, pos, channel);
|
||||
public static IBaseMonitor<? extends IAEStack<? extends IAEStack<?>>> getWirelessInv(ItemStack is,
|
||||
EntityPlayer player, StorageChannel channel) {
|
||||
IGridNode gridNode = getWirelessGrid(is);
|
||||
if (gridNode == null) return null;
|
||||
IGrid grid = gridNode.getGrid();
|
||||
if (grid == null) return null;
|
||||
for (IGridNode node : grid.getMachines(TileWireless.class)) {
|
||||
IWirelessAccessPoint accessPoint = (IWirelessAccessPoint) node.getMachine();
|
||||
WorldCoord distance = accessPoint.getLocation().subtract(pos.getX(), pos.getY(), pos.getZ());
|
||||
WorldCoord distance = accessPoint.getLocation()
|
||||
.subtract((int) player.posX, (int) player.posY, (int) player.posZ);
|
||||
int squaredDistance = distance.x * distance.x + distance.y * distance.y + distance.z * distance.z;
|
||||
if (squaredDistance <= accessPoint.getRange() * accessPoint.getRange()) {
|
||||
IStorageGrid gridCache = grid.getCache(IStorageGrid.class);
|
||||
@@ -269,14 +273,14 @@ public final class Util {
|
||||
private static final int value = 1 << 30;
|
||||
|
||||
public static int encodeType(int y, GuiType type) {
|
||||
if (y > (1 << 28)) {
|
||||
if (Math.abs(y) > (1 << 28)) {
|
||||
throw new IllegalArgumentException("out of range");
|
||||
}
|
||||
return value | (type.ordinal() << 29) | y;
|
||||
}
|
||||
|
||||
public static MutablePair<GuiType, Integer> decodeType(int y) {
|
||||
if (y > (1 << 28)) {
|
||||
if (Math.abs(y) > (1 << 28)) {
|
||||
return new MutablePair<>(GuiType.values()[y >> 29 & 1], y - (3 << 29 & y));
|
||||
} else {
|
||||
return new MutablePair<>(GuiType.TILE, y);
|
||||
|
||||
Reference in new issue
Block a user