use of crazypants.enderio.machines.machine.teleport.telepad.packet.PacketSetTarget in project EnderIO by SleepyTrousers.
the class TileTelePad method processTasks.
@Override
protected boolean processTasks(boolean redstoneCheck) {
if (!isMaster()) {
return false;
}
if (target.getDimension() == Integer.MIN_VALUE) {
target.setDimension(world.provider.getDimension());
}
if (!getInventory().getSlot("INPUT").isEmpty() && getInventory().getSlot("OUTPUT").isEmpty()) {
ItemStack stack = getInventory().getSlot("INPUT").get();
setTarget(TelepadTarget.readFromNBT(stack));
getInventory().getSlot("INPUT").clear();
getInventory().getSlot("OUTPUT").set(stack);
}
if (tankDirty && shouldDoWorkThisTick(10)) {
PacketHandler.sendToAllAround(new PacketTelePadFluidLevel(this), this);
tankDirty = false;
}
if (active()) {
if (powerUsed >= requiredPower) {
teleport(toTeleport.poll());
powerUsed = 0;
} else {
int usable = Math.min(Math.min(getUsage(), requiredPower), getEnergy().getEnergyStored());
getEnergy().setEnergyStored(getEnergy().getEnergyStored() - usable);
powerUsed += usable;
}
if (shouldDoWorkThisTick(5)) {
updateQueuedEntities();
}
// we have a very smooth block animation, so all clients need very detailed progress data
// TODO: check if this is really needed for the TelePad
PacketHandler.INSTANCE.sendToAllAround(getProgressPacket(), this);
}
if (coordsChanged) {
coordsChanged = false;
PacketHandler.sendToAllAround(new PacketSetTarget(this, target), this);
}
return false;
}
use of crazypants.enderio.machines.machine.teleport.telepad.packet.PacketSetTarget in project EnderIO by SleepyTrousers.
the class GuiTelePad method updateCoords.
private void updateCoords() {
BlockPos pos = new BlockPos(getIntFromTextBox(xTF), getIntFromTextBox(yTF), getIntFromTextBox(zTF));
int targetDim = getIntFromTextBox(dimTF);
if (!pos.equals(te.getTarget().getLocation()) || targetDim != te.getTargetDim()) {
te.setCoords(pos);
te.setTargetDim(targetDim);
PacketHandler.INSTANCE.sendToServer(new PacketSetTarget(te, te.getTarget()));
}
}
use of crazypants.enderio.machines.machine.teleport.telepad.packet.PacketSetTarget in project EnderIO by SleepyTrousers.
the class ContainerDialingDevice method doTeleport.
@Override
public IMessage doTeleport(@Nonnull BlockPos telepad, int targetID, boolean initiateTeleport) {
final TileDialingDevice dialer = getTileEntity();
if (dialer != null && dialer.getEnergy().canUseEnergy(CapacitorKey.DIALING_DEVICE_POWER_USE_TELEPORT)) {
TileTelePad tp = BlockEnder.getAnyTileEntitySafe(dialer.getWorld(), telepad, TileTelePad.class);
if (tp != null) {
ArrayList<TelepadTarget> targets = dialer.getTargets();
if (targetID >= 0 && targetID < targets.size()) {
tp.setTarget(targets.get(targetID));
if (initiateTeleport) {
tp.teleportAll();
dialer.getEnergy().useEnergy(CapacitorKey.DIALING_DEVICE_POWER_USE_TELEPORT);
}
}
return new PacketSetTarget(tp, tp.getTarget());
}
}
return null;
}
Aggregations