Search in sources :

Example 11 with WaystoneEntry

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")));
    }
}
Also used : WaystoneEntry(net.blay09.mods.waystones.util.WaystoneEntry) EntityPlayer(net.minecraft.entity.player.EntityPlayer) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 12 with WaystoneEntry

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)));
}
Also used : WaystoneEntry(net.blay09.mods.waystones.util.WaystoneEntry)

Example 13 with WaystoneEntry

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);
}
Also used : MessageConfig(net.blay09.mods.waystones.network.message.MessageConfig) WaystoneEntry(net.blay09.mods.waystones.util.WaystoneEntry) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 14 with WaystoneEntry

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);
    }
}
Also used : NBTTagList(net.minecraft.nbt.NBTTagList) WaystoneEntry(net.blay09.mods.waystones.util.WaystoneEntry)

Example 15 with WaystoneEntry

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) World(net.minecraft.world.World) TileWaystone(net.blay09.mods.waystones.block.TileWaystone) Nullable(javax.annotation.Nullable)

Aggregations

WaystoneEntry (net.blay09.mods.waystones.util.WaystoneEntry)17 Nullable (javax.annotation.Nullable)6 EntityPlayer (net.minecraft.entity.player.EntityPlayer)5 NBTTagList (net.minecraft.nbt.NBTTagList)5 TileWaystone (net.blay09.mods.waystones.block.TileWaystone)3 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 PlayerWaystoneData (net.blay09.mods.waystones.PlayerWaystoneData)2 TileEntity (net.minecraft.tileentity.TileEntity)2 BlockPos (net.minecraft.util.math.BlockPos)2 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 World (net.minecraft.world.World)2 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)2 GlobalWaystones (net.blay09.mods.waystones.GlobalWaystones)1 GuiWaystoneList (net.blay09.mods.waystones.client.gui.GuiWaystoneList)1 MessageConfig (net.blay09.mods.waystones.network.message.MessageConfig)1 MessageRemoveWaystone (net.blay09.mods.waystones.network.message.MessageRemoveWaystone)1 MessageSortWaystone (net.blay09.mods.waystones.network.message.MessageSortWaystone)1 MessageTeleportToWaystone (net.blay09.mods.waystones.network.message.MessageTeleportToWaystone)1 GuiInventory (net.minecraft.client.gui.inventory.GuiInventory)1 ItemStack (net.minecraft.item.ItemStack)1