use of net.blay09.mods.waystones.util.WaystoneEntry in project Waystones by blay09.
the class ItemReturnScroll method addInformation.
@Override
@SideOnly(Side.CLIENT)
public void addInformation(ItemStack stack, @Nullable World world, List<String> tooltip, ITooltipFlag flag) {
EntityPlayer player = Minecraft.getMinecraft().player;
if (player == null) {
return;
}
WaystoneEntry lastEntry = PlayerWaystoneHelper.getLastWaystone(player);
if (lastEntry != null) {
tooltip.add(TextFormatting.GRAY + I18n.format("tooltip.waystones:boundTo", TextFormatting.DARK_AQUA + lastEntry.getName()));
} else {
tooltip.add(TextFormatting.GRAY + I18n.format("tooltip.waystones:boundTo", I18n.format("tooltip.waystones:none")));
}
}
use of net.blay09.mods.waystones.util.WaystoneEntry in project Waystones by blay09.
the class MessageWaystones method toBytes.
@Override
public void toBytes(ByteBuf buf) {
buf.writeByte(entries.length);
for (WaystoneEntry entry : entries) {
entry.write(buf);
}
buf.writeLong(lastFreeWarp);
buf.writeLong(Math.max(0, WaystoneConfig.general.warpStoneCooldown * 1000 - (System.currentTimeMillis() - lastWarpStoneUse)));
}
use of net.blay09.mods.waystones.util.WaystoneEntry in project Waystones by blay09.
the class CommonProxy method onPlayerLoggedIn.
@SubscribeEvent
public void onPlayerLoggedIn(PlayerEvent.PlayerLoggedInEvent event) {
GlobalWaystones globalWaystones = GlobalWaystones.get(event.player.world);
PlayerWaystoneData waystoneData = PlayerWaystoneData.fromPlayer(event.player);
List<WaystoneEntry> validWaystones = Lists.newArrayList();
for (WaystoneEntry waystone : waystoneData.getWaystones()) {
if (waystone.isGlobal()) {
if (globalWaystones.getGlobalWaystone(waystone.getName()) == null) {
continue;
}
}
validWaystones.add(waystone);
}
for (WaystoneEntry waystone : globalWaystones.getGlobalWaystones()) {
if (!validWaystones.contains(waystone)) {
validWaystones.add(waystone);
}
}
PlayerWaystoneHelper.store(event.player, validWaystones.toArray(new WaystoneEntry[validWaystones.size()]), waystoneData.getLastFreeWarp(), waystoneData.getLastWarpStoneUse());
NetworkHandler.channel.sendTo(new MessageConfig(), (EntityPlayerMP) event.player);
WaystoneManager.sendPlayerWaystones(event.player);
}
use of net.blay09.mods.waystones.util.WaystoneEntry in project Waystones by blay09.
the class GlobalWaystones method readFromNBT.
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
NBTTagList tagList = tagCompound.getTagList(TAG_LIST_NAME, Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < tagList.tagCount(); i++) {
WaystoneEntry entry = WaystoneEntry.read((NBTTagCompound) tagList.get(i));
globalWaystones.put(entry.getName(), entry);
}
}
use of net.blay09.mods.waystones.util.WaystoneEntry in project Waystones by blay09.
the class WaystoneManager method getWaystoneInWorld.
@Nullable
public static TileWaystone getWaystoneInWorld(WaystoneEntry waystone) {
World targetWorld = DimensionManager.getWorld(waystone.getDimensionId());
if (targetWorld == null) {
DimensionManager.initDimension(waystone.getDimensionId());
targetWorld = DimensionManager.getWorld(waystone.getDimensionId());
}
if (targetWorld != null) {
TileEntity tileEntity = targetWorld.getTileEntity(waystone.getPos());
if (tileEntity instanceof TileWaystone) {
return ((TileWaystone) tileEntity).getParent();
}
}
return null;
}
Aggregations