use of crazypants.enderio.base.item.coordselector.TelepadTarget in project EnderIO by SleepyTrousers.
the class TileTelePad method setTarget.
public void setTarget(@Nullable TelepadTarget newTarget) {
if (inNetwork() && !isMaster()) {
getMaster().setTarget(newTarget);
return;
}
if (newTarget == null) {
newTarget = new TelepadTarget();
}
target = new TelepadTarget(newTarget);
coordsChanged = true;
markDirty();
}
use of crazypants.enderio.base.item.coordselector.TelepadTarget in project EnderIO by SleepyTrousers.
the class GuiTargetList method elementClicked.
@Override
protected boolean elementClicked(int elementIndex, boolean doubleClick, int elX, int elY) {
TelepadTarget target = getSelectedElement();
Rectangle iconBounds = getIconBounds(0);
if (iconBounds.contains(elX, elY)) {
PacketHandler.INSTANCE.sendToServer(new PacketTargetList(te, target, false));
if (selectedIndex >= getNumElements()) {
setSelection(getNumElements() - 1);
}
return false;
}
return true;
}
use of crazypants.enderio.base.item.coordselector.TelepadTarget in project EnderIO by SleepyTrousers.
the class GuiTargetList method drawElement.
@Override
protected void drawElement(int elementIndex, int x, int y, int heightIn, @Nonnull BufferBuilder renderer) {
TelepadTarget targ = getElementAt(elementIndex);
String name = targ.getName();
if (name.trim().length() == 0) {
name = Lang.GUI_TELEPAD_UNNAMED_LOCATION.get();
}
FontRenderer fr = Minecraft.getMinecraft().fontRenderer;
fr.drawString(name, x + 4, y + 2, 0xffffff, true);
if (getSelectedElement() == targ) {
Rectangle iconBounds = getIconBounds(y);
EnderWidget icon = EnderWidget.X_BUT;
// TODO no access to these vars anymore
// if(iconBounds.contains(mouseX, mouseY)) {
// icon = EnderWidget.X_BUT_HOVER;
// }
EnderWidget.map.render(icon, iconBounds.x, iconBounds.y, iconBounds.width, iconBounds.height, 0, true);
}
}
use of crazypants.enderio.base.item.coordselector.TelepadTarget in project EnderIO by SleepyTrousers.
the class ItemRodOfReturn method onItemUseFinish.
@Override
@Nonnull
public ItemStack onItemUseFinish(@Nonnull ItemStack stack, @Nonnull World worldIn, @Nonnull EntityLivingBase entityLiving) {
boolean hasPower = true;
boolean hasFluid = true;
if (!(entityLiving instanceof EntityPlayer) || !((EntityPlayer) entityLiving).capabilities.isCreativeMode) {
hasPower = updateStackNBT(stack, worldIn, 0);
// don't use fluid if we didn't have enough power
hasFluid = hasPower ? useFluid(stack) : true;
}
if (hasPower && hasFluid) {
TelepadTarget target = TelepadTarget.readFromNBT(stack);
if (target == null) {
if (worldIn.isRemote) {
stopPlayingSound();
entityLiving.sendMessage(Lang.RETURN_ROD_NO_TARGET.toChat(TextFormatting.RED));
}
return stack;
}
TeleportUtil.doTeleport(entityLiving, target.getLocation(), target.getDimension(), false, TravelSource.TELEPAD);
} else if (worldIn.isRemote) {
if (!hasPower) {
entityLiving.sendMessage(Lang.RETURN_ROD_NO_POWER.toChat(TextFormatting.RED));
} else {
entityLiving.sendMessage(Lang.RETURN_ROD_NO_FLUID.toChat(TextFormatting.RED));
}
}
if (worldIn.isRemote) {
stopPlayingSound();
}
return stack;
}
use of crazypants.enderio.base.item.coordselector.TelepadTarget in project EnderIO by SleepyTrousers.
the class TileDialingDevice method processTasks.
@Override
public boolean processTasks(boolean redstoneCheck) {
getEnergy().useEnergy();
if (!getInventory().getSlot("INPUT").isEmpty() && getInventory().getSlot("OUTPUT").isEmpty() && getEnergy().useEnergy(CapacitorKey.DIALING_DEVICE_POWER_USE_PAPER)) {
ItemStack stack = getInventory().getSlot("INPUT").get();
TelepadTarget newTarg = TelepadTarget.readFromNBT(stack);
if (newTarg != null && !targets.contains(newTarg)) {
addTarget(newTarg);
PacketHandler.sendToAllAround(new PacketTargetList(this, newTarg, true), this);
}
getInventory().getSlot("INPUT").clear();
getInventory().getSlot("OUTPUT").set(stack);
}
return false;
}
Aggregations