use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class PorterTools method returnTargets.
public static void returnTargets(EntityPlayer player) {
ItemStack heldItem = player.getHeldItem(EnumHand.MAIN_HAND);
if (heldItem.isEmpty()) {
return;
}
NBTTagCompound tagCompound = heldItem.getTagCompound();
int target = -1;
int[] targets = new int[AdvancedChargedPorterItem.MAXTARGETS];
String[] names = new String[AdvancedChargedPorterItem.MAXTARGETS];
TeleportDestinations destinations = TeleportDestinations.getDestinations(player.getEntityWorld());
if (tagCompound != null) {
if (tagCompound.hasKey("target")) {
target = tagCompound.getInteger("target");
} else {
target = -1;
}
for (int i = 0; i < AdvancedChargedPorterItem.MAXTARGETS; i++) {
names[i] = "";
if (tagCompound.hasKey("target" + i)) {
targets[i] = tagCompound.getInteger("target" + i);
GlobalCoordinate gc = destinations.getCoordinateForId(targets[i]);
if (gc != null) {
TeleportDestination destination = destinations.getDestination(gc);
if (destination != null) {
names[i] = destination.getName() + " (dimension " + destination.getDimension() + ")";
}
}
} else {
targets[i] = -1;
}
}
} else {
for (int i = 0; i < AdvancedChargedPorterItem.MAXTARGETS; i++) {
targets[i] = -1;
names[i] = "";
}
}
PacketTargetsReady msg = new PacketTargetsReady(target, targets, names);
RFToolsMessages.INSTANCE.sendTo(msg, (EntityPlayerMP) player);
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class PorterTools method checkTarget.
private static int checkTarget(EntityPlayer playerEntity, NBTTagCompound tagCompound, TeleportDestinations destinations, int curtarget, int donext, int tgt) {
if (tagCompound.hasKey("target" + tgt)) {
int target = tagCompound.getInteger("target" + tgt);
GlobalCoordinate gc = destinations.getCoordinateForId(target);
if (gc != null) {
TeleportDestination destination = destinations.getDestination(gc);
if (destination != null) {
if (donext == 1) {
String name = destination.getName() + " (dimension " + destination.getDimension() + ")";
tagCompound.setInteger("target", target);
ITextComponent component = new TextComponentString(TextFormatting.GREEN + "Target: " + TextFormatting.WHITE + name);
if (playerEntity != null) {
playerEntity.sendStatusMessage(component, false);
}
donext = 2;
} else if (target == curtarget) {
donext = 1;
}
}
}
}
return donext;
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class PacketGetScreenData method fromBytes.
@Override
public void fromBytes(ByteBuf buf) {
modid = NetworkTools.readString(buf);
pos = new GlobalCoordinate(NetworkTools.readPos(buf), buf.readInt());
millis = buf.readLong();
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class SmartWrenchItem method onItemUse.
@Override
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float sx, float sy, float sz) {
if (!world.isRemote) {
SmartWrenchMode mode = getCurrentMode(stack);
if (mode == SmartWrenchMode.MODE_SELECT) {
GlobalCoordinate b = getCurrentBlock(stack);
if (b != null) {
if (b.getDimension() != world.provider.dimensionId) {
Logging.message(player, EnumChatFormatting.RED + "The selected block is in another dimension!");
return true;
}
TileEntity te = world.getTileEntity(b.getCoordinate().getX(), b.getCoordinate().getY(), b.getCoordinate().getZ());
if (te instanceof SmartWrenchSelector) {
SmartWrenchSelector smartWrenchSelector = (SmartWrenchSelector) te;
smartWrenchSelector.selectBlock(player, x, y, z);
}
}
}
}
return true;
}
use of mcjty.lib.varia.GlobalCoordinate in project RFTools by McJty.
the class PacketGetTargets method onMessage.
@Override
public PacketTargetsReady onMessage(PacketGetTargets message, MessageContext ctx) {
EntityPlayer player = ctx.getServerHandler().playerEntity;
ItemStack heldItem = player.getHeldItem();
if (heldItem == null) {
return null;
}
NBTTagCompound tagCompound = heldItem.getTagCompound();
int target = -1;
int[] targets = new int[AdvancedChargedPorterItem.MAXTARGETS];
String[] names = new String[AdvancedChargedPorterItem.MAXTARGETS];
TeleportDestinations destinations = TeleportDestinations.getDestinations(player.worldObj);
if (tagCompound != null) {
if (tagCompound.hasKey("target")) {
target = tagCompound.getInteger("target");
} else {
target = -1;
}
for (int i = 0; i < AdvancedChargedPorterItem.MAXTARGETS; i++) {
names[i] = "";
if (tagCompound.hasKey("target" + i)) {
targets[i] = tagCompound.getInteger("target" + i);
GlobalCoordinate gc = destinations.getCoordinateForId(targets[i]);
if (gc != null) {
TeleportDestination destination = destinations.getDestination(gc);
if (destination != null) {
names[i] = destination.getName() + " (dimension " + destination.getDimension() + ")";
}
}
} else {
targets[i] = -1;
}
}
} else {
for (int i = 0; i < AdvancedChargedPorterItem.MAXTARGETS; i++) {
targets[i] = -1;
names[i] = "";
}
}
return new PacketTargetsReady(target, targets, names);
}
Aggregations